NetSim Source Code Help
Loading...
Searching...
No Matches
NodeJoin.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "Mobility.h"
16#include "Animation.h"
17static unsigned int nCallBackCount=0;
19
20#define MOBILITY_JOIN_AT_DEFAULT _strdup("0,")
21#define MOBILITY_LEAVE_AT_DEFAULT _strdup("")
22
24{
25 char* szValJoin;
26 char* szValLeave;
27 char* t;
28 char* s;
30 getXmlVar(&szValJoin,JOIN_AT,xmlNode,1,_STRING,MOBILITY);
31 getXmlVar(&szValLeave,LEAVE_AT,xmlNode,0,_STRING,MOBILITY);
32 s=szValJoin;
33 t=strtok(szValJoin,",");
34 while(t && *t)
35 {
37 njp->action = JOIN;
38 njp->time=atof(t)*SECOND;
39 njp->NodeId=nDeviceId;
40 JOIN_PROFILE_ADD(joinprofile,njp);
41 if(atoi(t) == 0)
43 t=strtok(NULL,",");
44 }
45 free(s);
46 s=szValLeave;
47 t=strtok(szValLeave,",");
48 while(t && *t)
49 {
51 njp->action = LEAVE;
52 njp->time=atof(t)*SECOND;
53 njp->NodeId=nDeviceId;
54 JOIN_PROFILE_ADD(joinprofile,njp);
55 if(atoi(t) == 0)
57 t=strtok(NULL,",");
58 }
59 free(s);
60 return 0;
61}
62
64{
67 memset(&pevent,0,sizeof pevent);
68 pevent.nDeviceId=nDevIndex+1;
69 pevent.nDeviceType=DEVICE_TYPE(nDevIndex+1);
72 while(join)
73 {
74 pevent.dEventTime = join->time;
75 if(join->action==JOIN)
77 else if(join->action==LEAVE)
79 fnpAddEvent(&pevent);
81 }
82 return 0;
83}
84
86{
88 unsigned int nLoop;
91
92 //Call animation
94 devid,
96
97 //call all the callback function
98 for(nLoop=0;nLoop<nCallBackCount;nLoop++)
99 {
101 }
102 return 0;
103}
104
106{
107 extern ANIM_HANDLE animHandle;
108 unsigned int nLoop;
111
112 //Call animation
114 devid,
116
117 //call all the callback function
118 for(nLoop=0;nLoop<nCallBackCount;nLoop++)
119 {
121 }
122 return 0;
123}
124
126{
127 if(!nCallBackCount)
128 {
130 }
131 else
132 {
134 }
137 return 0;
138}
void animation_add_new_entry(ANIM_HANDLE animHandle, ANIM_TYPE type, void *format,...)
@ ANIM_NODELEAVE
Definition: Animation.h:77
@ ANIM_NODEJOIN
Definition: Animation.h:76
void * ANIM_HANDLE
Definition: Animation.h:52
unsigned int NETSIM_ID
Definition: Animation.h:45
#define _declspec(dllexport)
This function is used to trigger the update.
Definition: Linux.h:41
#define realloc(p, s)
Definition: Memory.h:32
#define free(p)
Definition: Memory.h:31
#define calloc(c, s)
Definition: Memory.h:29
ANIM_HANDLE animHandle
Definition: Mobility.c:26
@ NODE_JOIN
Definition: Mobility.h:40
@ NODE_LEAVE
Definition: Mobility.h:41
int fn_NetSim_Mobility_NodeLeaved()
Definition: NodeJoin.c:105
int fn_NetSim_Mobility_NodeJoined()
Definition: NodeJoin.c:85
int fn_NetSim_Mobility_configure_NodeJoinProfile(void *xmlNode, NETSIM_ID nDeviceId)
Definition: NodeJoin.c:23
int fnNodeJoinRegisterCallBackFunction(_fnNodeJoinCallBack fnCallBack)
Definition: NodeJoin.c:125
int fn_NetSim_Mobility_NodeJoinInit(NETSIM_ID nDevIndex)
Definition: NodeJoin.c:63
static _fnNodeJoinCallBack * fnNodeJoinCallBack
Definition: NodeJoin.c:18
static unsigned int nCallBackCount
Definition: NodeJoin.c:17
int(* _fnNodeJoinCallBack)(NETSIM_ID nDeviceId, double time, NODE_ACTION)
Definition: Stack.h:1024
#define JOIN_PROFILE_ALLOC()
Definition: Stack.h:603
#define getXmlVar(var, name, xmlNode, flag, type, protocol)
Definition: Stack.h:1046
#define DEVICE_TYPE(DeviceId)
Definition: Stack.h:773
@ JOIN
Definition: Stack.h:381
@ CONNECTED
Definition: Stack.h:380
@ NOT_CONNECTED
Definition: Stack.h:379
@ LEAVE
Definition: Stack.h:382
@ _STRING
Definition: Stack.h:1033
EXPORTED struct stru_NetSim_Network * NETWORK
Definition: Stack.h:742
#define SECOND
Definition: Stack.h:60
@ TIMER_EVENT
Definition: Stack.h:114
#define JOIN_PROFILE_ADD(lprofile, profile)
Definition: Stack.h:605
#define JOIN_PROFILE_NEXT(profile)
Definition: Stack.h:604
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
#define PROTOCOL_MOBILITY
Definition: Stack.h:142
#define fnpAddEvent(pstruEvent)
Definition: main.h:191
PNODE_JOIN_PROFILE node_join_profile
Definition: Stack.h:725
NODE_ACTION node_status
Definition: Stack.h:726
EVENT_TYPE nEventType
Definition: Stack.h:747
NETSIM_ID nProtocolId
Definition: Stack.h:748
NETSIM_ID nSubEventType
Definition: Stack.h:757
NETSIM_ID nDeviceId
Definition: Stack.h:750
netsimDEVICE_TYPE nDeviceType
Definition: Stack.h:749
struct stru_NetSim_Device ** ppstruDeviceList
Definition: Stack.h:737
NETSIM_ID NodeId
Definition: Stack.h:598
NODE_ACTION action
Definition: Stack.h:600