Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual
Page 124
CHAPTER 11 • CLICK SUPERVISOR SUPPORT 123
unsigned long tmp_sec;
int timeOffset;
long tmp_long;
unsigned long tmp_ulong;
struct tm NewTime;
char timestampStr[22];
char eventStr[64];
// Generate UTC timestamp and convert to local time
tmp_sec = SEC_TIMER;
timeOffset
= ((int)((ClickSupervisorOemConfig0.hourOffsetMSB << 8)
+ ClickSupervisorOemConfig0.hourOffsetLSB))-12;
tmp_long = (long)3600*(long)timeOffset;
tmp_ulong = (unsigned long)labs(tmp_long);
if (tmp_long < 0)
{
tmp_sec = tmp_sec - tmp_ulong;
}
else
{
tmp_sec = tmp_sec + tmp_ulong;
}
mktm(&NewTime,tmp_sec);
sprintf(timestampStr,”%04d:%02d:%02d,%02d:%02d:%02d.%03d”,
NewTime.tm_year + 1900, NewTime.tm_mon,
NewTime.tm_mday, NewTime.tm_hour,
NewTime.tm_min, NewTime.tm_sec,50);
sprintf(eventStr,”%s,%06.1f\r\n”,timestampStr,VirtualSpeed);
ClickSerialPortTransmit(V2,32,eventStr);
}