You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iec104/include/HTCP56Time.h

87 lines
2.1 KiB
C++

/****************************************************************************
** File name : HTCP56Time.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_CP56TIME_H
#define __HT_CP56TIME_H
//
// CP56Time IEC 60870-5-104 time data type implementation
//
#pragma pack (push ,1)
#include <time.h>
#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 cp56time {
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;
} cp56time ;
class CP56Time
{
private:
SYSTEMTIME stime;
bool valid;
bool genuine;
bool summer;
public:
CP56Time(unsigned char *data);
~CP56Time(void);
void GetTimeString(char *buf, size_t size);
FILETIME _GetFileTime(void);
SYSTEMTIME _GetSystemTime(void);
time_t GetTime(void);
void ActualTimeToCP56Time(unsigned char *data);
void TimeToCP56Time(FILETIME *ft, unsigned char *data);
void TimeToCP56Time(SYSTEMTIME *st, unsigned char *data);
void CP56TimeToTime(unsigned char *data, FILETIME *ft);
void CP56TimeToTime(unsigned char *data, SYSTEMTIME *st);
};
#pragma pack (pop)
#endif // end __HT_CP56TIME_H