eis/inc/glob/BinaryTele.h

118 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*********************************************
*
* Binary message organization and parsing
*
* copyright Shanghai Baosight Software Co., Ltd.
*
* create zoufuzhou 20201001
*
************************************************/
#pragma once
#ifdef _WIN32
//#include <Winsock2.h>
#else
#include <netinet/in.h>
#endif
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <dao/TeleDAO.h>
#include <base/ByteTool.h>
#include <base/TypeCheck.h>
#include <common/BasicStruct.h>
#include <dao/LimitsMag.h>
#include <glob/GlobDefine.h>
using namespace std;
using namespace baosight;
typedef vector<TeleItem* > TVectItem;
class BinaryTele
{
public:
BinaryTele(int eventNo=9999,const string& table = "T_LOV_TELEITEM");
virtual ~BinaryTele();
int ReBuild(int eventNo,const char* buff);
int ReBuild(int eventNo);
//读取最近一次电文结构及数据
int Read(int eventNo);
/*按索引获取电文项内容或给当前电文项赋值*/
TeleItem& operator[]( int elem );
/*按电文项名称获取电文项内容或给当前电文项赋值*/
TeleItem& operator[]( const string& itemName);
// get index NO. of tele columns ,start No. is :0
int GetItemIndex(const string &itemName);
/*输出组织的电文数据,输出时是否高低字节转换*/
char* GetTeleData(bool htol_byte = true);
/*取电文处理相关表*/
vector<string>& GetTables();
/*通过读相关表填充
参数const string& dbtable 出口相关MUCODE
const string dbwhere 可以自己为定义的表组织where条件*/
int Fill(const string& dbtable, const string& dbwhere);
/*输出电文详细*/
void Print(void);
//获取当前电文项数
const int size(void) const;
//组织电文完成后取电文长度
const int TeleLen() const;
public:
//获取电文通信配置
static int GetTeleConf(int eventNo,TeleConf& conf);
protected:
/*拆分电文串*/
int SplitTele(const char* buffer);
//组织电文 ,否高低字节转换
int OrganizeTele(bool htol_byte = true);
//zero item value
void InitValue(void);
private:
void reverse_string(char *left, char *right);
TeleItem& IsNuLL();
private:
vector<string> mv_table;
TVectItem *mp_itemvect; //存放当前电文定义
int m_teleLen; //store current bufferlen;
static map<int, TVectItem* > *mp_telemap; //电文结构池,存储已扩展的电文定义
static map<int,TeleConf> mm_teleconf; //电文通信配置
TeleItem itemnull; //空电文项
static TeleDAO* mp_teledao;
std::string m_table;
char m_buff[102400];
};