29double *corr(
char*
id);
38 char command_to_python[BUFSIZ];
39 sprintf(command_to_python,
"start vanet.exe -main \"%s\\ConfigSupport\\%s\" ",pszIOPath,sumoname);
40 fprintf(stderr,
"Executing command for opening Sumo - %s",command_to_python);
41 system(command_to_python);
42 fprintf(stderr,
"....done.\n");
43 printf(
"Init sumo pipe\n");
52 MOBILITY_VAR* pstruMobilityVar=(MOBILITY_VAR*)NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDeviceMobility->pstruMobVar;
53 double dPresentTime = pstruMobilityVar->dLastTime;
55 memcpy(NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDeviceMobility->pstruCurrentPosition,
56 NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDeviceMobility->pstruNextPosition,
57 sizeof* NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDeviceMobility->pstruCurrentPosition);
59 if(pstruMobilityVar->dLastTime+pstruMobilityVar->dPauseTime*1000000<pstruEventDetails->dEventTime+1000000)
62 coordinates = corr(DEVICE_NAME(pstruEventDetails->nDeviceId));
63 if (coordinates!=NULL)
65 NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDeviceMobility->pstruNextPosition->X = coordinates[0];
66 NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDeviceMobility->pstruNextPosition->Y = coordinates[1];
67 NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId - 1]->pstruDeviceMobility->pstruNextPosition->Z = coordinates[2];
72 pstruMobilityVar->dLastTime = pstruEventDetails->dEventTime+1000000*step_size;
75 memcpy(NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDevicePosition,
76 NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDeviceMobility->pstruCurrentPosition,
77 sizeof* NETWORK->ppstruDeviceList[pstruEventDetails->nDeviceId-1]->pstruDevicePosition);
79 mobility_pass_position_to_animation(pstruEventDetails->nDeviceId,
80 pstruEventDetails->dEventTime,
81 DEVICE_POSITION(pstruEventDetails->nDeviceId));
84 pstruEventDetails->dEventTime+=1000000*step_size;
85 fnpAddEvent(pstruEventDetails);
86 pstruEventDetails->dEventTime-=1000000*step_size;
95 DWORD cbToWrite, cbWritten;
97 char message_to_be_sent[2];
99 LPCSTR lpszPipename =
"\\\\.\\pipe\\netsim_sumo_pipe";
103 fprintf(stderr,
"Creating Sumo pipe\n");
119 if (hPipe != INVALID_HANDLE_VALUE)
124 fprintf(stderr,
"Connecting Sumo and NetSim in real time\n");
125 dwMode = PIPE_READMODE_MESSAGE;
126 fSuccess = SetNamedPipeHandleState
135 fnSystemError(
"Error in connection netsim sump pipe.\n");
137 fprintf(stderr,
"Connection done\n");
139 if(anim_get_anim_flag() == ANIMFLAG_ONLINE)
145 message_to_be_sent[0]=gui;
146 message_to_be_sent[1]=0;
148 cbToWrite=(DWORD)strlen(message_to_be_sent);
163double *corr(
char*
id)
166 DWORD cbRead, cbToWrite, cbWritten;
169 double xcor1,ycor1,zcor1;
185 if ( ! fSuccess && GetLastError() != ERROR_MORE_DATA )
193 cbToWrite=(DWORD)strlen(
id)+1;
217 if ( ! fSuccess && GetLastError() != ERROR_MORE_DATA )
240 if ( ! fSuccess && GetLastError() != ERROR_MORE_DATA )
260 if ( ! fSuccess && GetLastError() != ERROR_MORE_DATA )
276 BUFSIZ *
sizeof(CHAR),
281 if (!fSuccess && GetLastError() != ERROR_MORE_DATA)
288 coordinates = (
double*)malloc(3*
sizeof* coordinates);
289 coordinates[0]=xcor1;
290 coordinates[1]=ycor1;
291 coordinates[2] = zcor1;
292 return (coordinates);