2 * $Id: events.c,v 0.0.0.1 2003/09/19
4 * DEBUG: section 10 Event system based on htimerNtp
6 * -------------------------------------------------------------------
8 * Open Real-Time Ethernet
10 * Copyright (C) 2001-2006
11 * Department of Control Engineering FEE CTU Prague, Czech Republic
12 * http://dce.felk.cvut.cz
13 * http://www.ocera.org
15 * Author: Petr Smolik petr@smoliku.cz
17 * Project Responsible: Zdenek Hanzalek
18 * --------------------------------------------------------------------
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundtion; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
35 * ORTEEventAdd - add a event into event system (root and application)
36 * @d: pointer to Domain
37 * @otAID: pointer to objectTreeAID or NULL for multicast event
38 * @fncNode: pointer on structure fncNode or NULL
39 * @where: in which timer queue is the event added
40 * 0-UnicastCommon,1-UnicastSendMetatraffic,2-UnicastSendUserdata
41 * @name: name called function
42 * @lock: pointer on lock or NULL for unprotected agruments
43 * @func: pointer to called function
44 * @arg1: first function argument
45 * @when: time when is needed call the function
49 eventAdd(ORTEDomain *d,
50 ObjectEntryAID *objectEntryAID,
51 HTimFncUserNode *fncNode,
55 pthread_rwlock_t *lock,
58 NtpTime whenExpire,actualTime;
60 debug(10,10) ("eventAdd: AID 0x%x %s\n",objectEntryAID->aid,name);
61 actualTime=getActualNtpTime();
63 NtpTimeAdd(whenExpire,actualTime,*when);
65 whenExpire=actualTime;
68 fncNode=(HTimFncUserNode*)MALLOC(sizeof(HTimFncUserNode));
69 htimerUnicastCommon_init_detached(fncNode);
77 htimerUnicastCommon_set_expire(fncNode,whenExpire);
78 htimerUnicastCommon_add(objectEntryAID,fncNode);
79 htimerUnicastCommon_update_root_timer(&d->objectEntry,objectEntryAID);
82 htimerUnicastSendMetatraffic_set_expire(fncNode,whenExpire);
83 htimerUnicastSendMetatraffic_add(objectEntryAID,fncNode);
84 htimerUnicastSendMetatraffic_update_root_timer(&d->objectEntry,objectEntryAID);
87 htimerUnicastSendUserData_set_expire(fncNode,whenExpire);
88 htimerUnicastSendUserData_add(objectEntryAID,fncNode);
89 htimerUnicastSendUserData_update_root_timer(&d->objectEntry,objectEntryAID);
96 debug(10,10) ("eventAdd: finished\n");
101 * ORTEEventDetach - detach a event from event system (root and application)
102 * @d: pointer to Domain
103 * @otAID: pointer to objectTreeAID
104 * @fncNode: pointer on structure fncNode or NULL
105 * @where: from which timer queue is the event detached
106 * 0-UnicastCommon,1-UnicastSendMetatraffic,2-UnicastSendUserdata
110 eventDetach(ORTEDomain *d,
111 ObjectEntryAID *objectEntryAID,
112 HTimFncUserNode *fncNode,
114 debug(10,10) ("eventDetach: AID 0x%x\n",objectEntryAID->aid);
117 htimerUnicastCommon_detach(objectEntryAID,fncNode);
118 htimerUnicastCommon_update_root_timer(&d->objectEntry,objectEntryAID);
121 htimerUnicastSendMetatraffic_detach(objectEntryAID,fncNode);
122 htimerUnicastSendMetatraffic_update_root_timer(&d->objectEntry,objectEntryAID);
125 htimerUnicastSendUserData_detach(objectEntryAID,fncNode);
126 htimerUnicastSendUserData_update_root_timer(&d->objectEntry,objectEntryAID);
132 debug(10,10) ("eventDetach: finished\n");