/*-------------------------------------------------------------------------------- * 2017/9/30 14:21:51 *-------------------------------------------------------------------------------- * PLANT : * MODULE : * * SHORT DESCRIPTION : iHyperDBÉúÃ÷Îļþ * FILE : IhyperDBTransform.h * AUTHOR : AUTO GENERATION *-------------------------------------------------------------------------------- * Copyright (c) rmbai@baosight.com 2012 *--------------------------------------------------------------------------------*/ #ifndef _H_IHYPERDB_COMMON_H_ #define _H_IHYPERDB_COMMON_H_ #ifdef _WIN32 //#include #else #include #endif #include #include #include #include #include #include #include #include #include #include #include //#include using namespace log4cplus; using namespace baosight; #define TAGNAME_MAXLEN 256 namespace ihdcommon { inline int getNowDurationSecFromGreen() { time_t startTimeL, ti1970; time(&startTimeL); ti1970 = time(NULL); int sec = startTimeL; // printf("NowDurationSecFromGreen:%d\n", sec); return sec; } inline int getNowMSec() { struct timeb tb; ftime(&tb); int msec = tb.millitm; // printf("NowMSec:%d\n", msec); return msec; } inline void IHDValue(HD3Record snapshotsSaved[], int index, bool value) { // LOG d("IHDValue"); // d.Debug() << "Index:" << index << " Value:" << value << endl; snapshotsSaved[index].nTagType = HD3_TAG_TYPE_INT8; snapshotsSaved[index].value.nInt8 = value; snapshotsSaved[index].nSec = getNowDurationSecFromGreen(); snapshotsSaved[index].nMsec = getNowMSec(); snapshotsSaved[index].nQuality = 192; } inline void IHDValue(HD3Record snapshotsSaved[], int index, int value) { snapshotsSaved[index].nTagType = HD3_TAG_TYPE_INT32; snapshotsSaved[index].value.nInt32 = value; snapshotsSaved[index].nSec = getNowDurationSecFromGreen(); snapshotsSaved[index].nMsec = getNowMSec(); snapshotsSaved[index].nQuality = 192; } inline void IHDValue(HD3Record snapshotsSaved[], int index, float value) { snapshotsSaved[index].nTagType = HD3_TAG_TYPE_FLOAT32; snapshotsSaved[index].value.fFloat32 = value; snapshotsSaved[index].nSec = getNowDurationSecFromGreen(); snapshotsSaved[index].nMsec = getNowMSec(); snapshotsSaved[index].nQuality = 192; } inline void IHDValue(HD3Record snapshotsSaved[], int index, const char *value, int length) { snapshotsSaved[index].nTagType = HD3_TAG_TYPE_STRING; snapshotsSaved[index].value.strBlob.pBuf = new char[length + 1]; strcpy(snapshotsSaved[index].value.strBlob.pBuf, value); snapshotsSaved[index].value.strBlob.nLenBuf = length + 1; snapshotsSaved[index].nSec = getNowDurationSecFromGreen(); snapshotsSaved[index].nMsec = getNowMSec(); snapshotsSaved[index].nQuality = 192; } }; // namespace ihdcommon #endif