/*@!Encoding:1252*/
includes
{
  #include "SimCar.cin"
}

variables
{
  msTimer sendTimer;
  int counterSeconds = 0;
}

/****************************************************************/
// SimCar includes the SimCar.cin in which the behaviour
// is implemented. This CAPL programm configures the behaviour
// of the included CAPL programm.
/****************************************************************/
void VehicleSetup()
{
  char stationId[4] = {0, 0, 0, 2};
  
  strncpy(gGps.name, ".\\TRACKS\\GPS_Log_RoadHazardConditionAhead.log", elcount(gGps.name)) ; // direction of car
    
  // Start Pos
  gVehicle.latitude = 42.439064;
  gVehicle.longitude = -83.438833;
  
  gVehicle.obDist = 100;
  gVehicle.obDir = 0;
  
  gVehicle.mobileOrStationaryFlag = 128; // 0 = RSU, 128 = Vehicle

  memcpy(gVehicle.stationId, stationId, elcount(stationId));
  
  counterSeconds = 0;
  setTimer(sendTimer, 100);
}

on timer sendTimer
{ 
  counterSeconds++;
  
  if(counterSeconds == 80)
  {
    API_StartReadingPositions(gGps.handle); // activate GPS position
    
    C2xEnableMsg("BasicSafetyMessage");
  }
   
  if(counterSeconds == 233)
  {
    API_StopReadingPositions(gGps.handle); // deactivate GPS position
    API_GPS_FileReset(gGps.handle);
    UpdatePosition();
            
    C2xDisableMsg("BasicSafetyMessage");
  }
  else
  {
    setTimer(sendTimer, 100);
  }
}