/**************************************************************************** ** File name : HTCP56Time2a.h ** Description : define data type ** Create date : 2018.09.01 ** Auther by : Liuyx ** Version info : V1.0.01 ** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd ** Update record: ** DATE AUTHER DESC ** ------------------------------------------------------------------------- ** 2018.09.01 Liuyx first build ****************************************************************************/ #ifndef __HT_CP56TIME2A_H #define __HT_CP56TIME2A_H // // CP56Time2a IEC 60870-5-104 time data type implementation // #pragma pack (push ,1) #include #ifndef _WIN32 typedef struct _SYSTEMTIME { unsigned short wYear; unsigned short wMonth; unsigned short wDayOfWeek; unsigned short wDay; unsigned short wHour; unsigned short wMinute; unsigned short wSecond; unsigned short wMilliseconds; } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; typedef struct _FILETIME { unsigned long dwLowDateTime; unsigned long dwHighDateTime; } FILETIME, *PFILETIME, *LPFILETIME; #endif typedef struct cp56time2a { u_short msec; u_char min :6; u_char res1 :1; u_char iv :1; u_char hour :5; u_char res2 :2; u_char su :1; u_char mday :5; u_char wday :3; u_char month :4; u_char res3 :4; u_char year :7; u_char res4 :1; } cp56time2a ; class CP56Time2a { private: SYSTEMTIME stime; bool valid; bool genuine; bool summer; public: CP56Time2a(unsigned char *data); ~CP56Time2a(void); void GetTimeString(char *buf, size_t size); FILETIME _GetFileTime(void); SYSTEMTIME _GetSystemTime(void); void ActualTimeToCP56Time(unsigned char *data); void TimeToCP56Time2a(FILETIME *ft, unsigned char *data); void TimeToCP56Time2a(SYSTEMTIME *st, unsigned char *data); void CP56Time2aToTime(unsigned char *data, FILETIME *ft); void CP56Time2aToTime(unsigned char *data, SYSTEMTIME *st); }; #pragma pack (pop) #endif // end __HT_TYPE_H