2 * $Id: events.c,v 0.0.0.1 2003/09/19
4 * DEBUG: section 10 Event system based on htimerNtp
5 * AUTHOR: Petr Smolik petr.smolik@wo.cz
7 * ORTE - OCERA Real-Time Ethernet http://www.ocera.org/
8 * --------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundtion; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
25 * ORTEEventAdd - add a event into event system (root and application)
26 * @d: pointer to Domain
27 * @otAID: pointer to objectTreeAID or NULL for multicast event
28 * @fncNode: pointer on structure fncNode or NULL
29 * @where: in which timer queue is the event added
30 * 0-UnicastCommon,1-UnicastSendMetatraffic,2-UnicastSendUserdata
31 * @name: name called function
32 * @lock: pointer on lock or NULL for unprotected agruments
33 * @func: pointer to called function
34 * @arg1: first function argument
35 * @when: time when is needed call the function
39 eventAdd(ORTEDomain *d,
40 ObjectEntryAID *objectEntryAID,
41 HTimFncUserNode *fncNode,
45 pthread_rwlock_t *lock,
48 NtpTime whenExpire,actualTime;
50 debug(10,10) ("eventAdd: AID 0x%x %s\n",objectEntryAID->aid,name);
51 actualTime=getActualNtpTime();
53 NtpTimeAdd(whenExpire,actualTime,*when);
55 whenExpire=actualTime;
58 fncNode=(HTimFncUserNode*)MALLOC(sizeof(HTimFncUserNode));
59 htimerUnicastCommon_init_detached(fncNode);
67 htimerUnicastCommon_set_expire(fncNode,whenExpire);
68 htimerUnicastCommon_add(objectEntryAID,fncNode);
69 htimerUnicastCommon_update_root_timer(&d->objectEntry,objectEntryAID);
72 htimerUnicastSendMetatraffic_set_expire(fncNode,whenExpire);
73 htimerUnicastSendMetatraffic_add(objectEntryAID,fncNode);
74 htimerUnicastSendMetatraffic_update_root_timer(&d->objectEntry,objectEntryAID);
77 htimerUnicastSendUserData_set_expire(fncNode,whenExpire);
78 htimerUnicastSendUserData_add(objectEntryAID,fncNode);
79 htimerUnicastSendUserData_update_root_timer(&d->objectEntry,objectEntryAID);
86 debug(10,10) ("eventAdd: finished\n");
91 * ORTEEventDetach - detach a event from event system (root and application)
92 * @d: pointer to Domain
93 * @otAID: pointer to objectTreeAID
94 * @fncNode: pointer on structure fncNode or NULL
95 * @where: from which timer queue is the event detached
96 * 0-UnicastCommon,1-UnicastSendMetatraffic,2-UnicastSendUserdata
100 eventDetach(ORTEDomain *d,
101 ObjectEntryAID *objectEntryAID,
102 HTimFncUserNode *fncNode,
104 debug(10,10) ("eventDetach: AID 0x%x\n",objectEntryAID->aid);
107 htimerUnicastCommon_detach(objectEntryAID,fncNode);
108 htimerUnicastCommon_update_root_timer(&d->objectEntry,objectEntryAID);
111 htimerUnicastSendMetatraffic_detach(objectEntryAID,fncNode);
112 htimerUnicastSendMetatraffic_update_root_timer(&d->objectEntry,objectEntryAID);
115 htimerUnicastSendUserData_detach(objectEntryAID,fncNode);
116 htimerUnicastSendUserData_update_root_timer(&d->objectEntry,objectEntryAID);
122 debug(10,10) ("eventDetach: finished\n");