98 lines
3.1 KiB
C++
98 lines
3.1 KiB
C++
|
|
/*--------------------------------------------------------------------------------
|
|||
|
|
* 2017/9/30 14:21:51
|
|||
|
|
*--------------------------------------------------------------------------------
|
|||
|
|
* PLANT :
|
|||
|
|
* MODULE :
|
|||
|
|
*
|
|||
|
|
* SHORT DESCRIPTION : iHyperDB<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
|
* 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 <Winsock2.h>
|
|||
|
|
#else
|
|||
|
|
#include <netinet/in.h>
|
|||
|
|
#endif
|
|||
|
|
#include <common/L2Event.h>
|
|||
|
|
#include <common/typedefL1.h>
|
|||
|
|
#include <log4cplus/LOG.h>
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <string.h>
|
|||
|
|
#include <sys/timeb.h>
|
|||
|
|
#include <utility/IniProperty.h>
|
|||
|
|
#include <zhd/data_types.h>
|
|||
|
|
#include <zhd/error_code.h>
|
|||
|
|
#include <zhd/hd3Enum.h>
|
|||
|
|
#include <zhd/hd3Struct.h>
|
|||
|
|
//#include <zhd/ihyperdb.h>
|
|||
|
|
|
|||
|
|
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
|