eis/inc/glob/AutoTele.h

169 lines
4.2 KiB
C++
Raw Permalink 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.

/*********************************************
*
* Text message organization and analysis
*
* copyright Shanghai Baosight Software Co., Ltd.
*
* create zoufuzhou 20101001
*
************************************************/
#pragma once
#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>
const int MAX_SQL_LENGTH = 102400; //max sql length
using namespace std;
using namespace baosight;
typedef vector<TeleItem* > TVectItem;
class AutoTele
{
public:
AutoTele(int eventNo,const string& buff);
AutoTele(int eventNo=9999);
virtual ~AutoTele();
int ReBuild(int eventNo,const string& 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);
/*输出组织的电文到字符串*/
void operator>>(string& buff);
const string GetTeleData();
/*字符串电文拆分*/
void operator<<(const string& buff);
/*取电文处理相关表*/
vector<string>& GetTables();
/*通过读相关表填充
参数const MAT_STRUCTURE materialExt 出口相关MUCODE
const MAT_STRUCTURE materialEnt 入口相关MUCODE
const SELECT_PARAMS selectParams 入出口有效的MUCODE索引
const string dbwhere 查询不是内部定义MUCODE相关表可以自己为定义的表组织where条件*/
int Fill(const MAT_STRUCTURE materialExt,
const MAT_STRUCTURE materialEnt,
const SELECT_PARAMS selectParams,
const string& dbwhere = "");
/*输出电文详细*/
void Print(void);
/* check vlaue of teleitem enable*/
/* rmbai 2012-03-26 */
/**********************************************************************
* 概述: 检查AutoTele中数据项的极限值
* 函数名: CheckValueLimit
* 返回值: int 返回极限值超限报警等级最高的值正常返回0
* 参数列表: 参数类型 取值范围 描述
*
*
* 版本历史
* 1.0 2010-09-02 echo_li 增加注释
*
**********************************************************************/
int CheckValueLimit(void);
//rmbai 2012-03-26 check enum item by destColumn of the destTable
/**********************************************************************
* 概述: 按枚举检查AutoTele中数据项
* 函数名: CheckEnumValue
* 返回值: int 返回极限值报警等级最高的值
* 参数列表: 参数类型 取值范围 描述
*
*
* 版本历史
* 1.0 2010-09-02 echo_li 增加注释
*
**********************************************************************/
int CheckEnumValue( const string &value,const string &destTable, const string &destColumnName);
/*保存电文串到数据表如果发送的电文没有组织则组织并写入表T_TEL_SEND
参数flag = 'recv' 保存到 T_TEL_RECV表
参数flag = 'send' 保存到 T_TEL_SEND表
参数coilId 为当前电文的钢卷号*/
int SaveToDB(const string flag = "send",const string coilId = "UNKNOW");
//获取当前电文项数
const int size(void) const;
string TeleValueToString() const {return m_buff;}
public:
//获取电文通信配置
static int GetTeleConf(int eventNo,TeleConf& conf);
protected:
/*拆分电文串*/
int SplitTele(const string& buff);
//组织电文
int OrganizeTele(void);
//rmbai 2012-03-26
short GetCommonIndex(void);
//zero item value
void InitValue(void);
//add 2012-5-21
void InitOkAll(void);
private:
TeleItem& IsNuLL();
private:
vector<string> mv_table;
TVectItem *mp_itemvect; //存放当前电文定义
static map<int, TVectItem* > *mp_telemap; //电文结构池,存储已扩展的电文定义
static map<int,TeleConf> mm_teleconf; //电文通信配置
TeleItem itemnull; //空电文项
static TeleDAO* mp_teledao;
string m_buff;
char m_seq[MAX_SQL_LENGTH];
LimitsMag mp_limitMag; //rmbai 2012-03-26
int indexOkAll; //rmbai 2012-03-26
int indexNextProcssCode;
int indexPhOk;
int indexLoOk ;
int indexOrOk_1;
int indexOrOk_2 ;
int indexOrOk_3;
};