FC_GetTimeOfDay - General Information
Type: |
Function |
Available as of: |
SystemInterface_1.32.6.0 |
Versions: |
Current version |
Read the time of the system in millisecond resolution without the date.
A time stamp with date specification in milliseconds is required in the program. The time of the system is read without the date in millisecond resolution. The time is returned in the TimeOfDay format.
Data type |
Description |
---|---|
TOD |
GetTimeOfDay: Time in TimeOfDay format (range from 00h00m00s000ms to 23h59min59s999ms) |
You want to integrate a logging function in the program. The log is to record diagnostic messages of the system and customer-specific messages. Every recorded message is to be given a time stamp in milliseconds similar to that in the message logger. The time stamp must be in the YYYY-MM-DD-hh:mm:ss.000 format. The subsequent function saves the date and time in two variables. These two variables are converted to strings and combined.
VAR
dtActualDate : DATE;
todActualTimeOfDay: TOD;
sActualDate : STRING;
sActualTimeOfDay : STRING;
sTimestamp : STRING;
END_VAR
dtActualDate:= DT_TO_DATE(PacDriveM.Realtimeclock);
todActualTimeOfDay:= FC_GetTimeOfDay();
sActualDate := DATE_TO_STRING(dtActualDate);
sActualDate := DELETE(sActualDate,2,1);
sActualTimeOfDay := TOD_TO_STRING(todActualTimeOfDay);
sActualTimeOfDay := DELETE(sActualTimeOfDay,4,1);
sTimestamp := CONCAT(sActualDate,'-');
sTimestamp := CONCAT(sTimestamp,sActualTimeOfDay);
This function shows how to get the time in millisecond resolution and the date from the parameter RealTimeClock and the method FC_GetTimeOfDay(). You can now save or display the time as a string with a message.