/**************************************************************************** ** File name : HTDataStruct.h ** Description : define data struct ** 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_DATA_STRUCT_H #define __HT_DATA_STRUCT_H #pragma pack (push ,1) #define DEF_EQM_CODE_SIZE 32+1 // 设备编码eqm_code最大长度 //#define _SITE_ID_TYPE_INT // 站点ID数据类型定义 #ifdef _SITE_ID_TYPE_INT typedef unsigned int htype; #else typedef unsigned char* htype; #endif typedef struct { unsigned char status; // 链接状态 0:非正常 1:正常 int udp_fd; // 与MEC的上行通道套接字fd tint64 online_time; // 登陆时间 tint64 last_time; // 离线/退出时间 struct sockaddr_in staddr; // 对方地址 }ST_UDP_CONN; // 链路管理数据结构 typedef struct { bool isConnect; // true: connected false: not connected int listenid; // listen handle int sockid; // socket connect handle time_t last_time; // last send/recv time bool is_yk_ack ; // 是否收到遥控信号 bool b_Signal; // 遥信量变化 false: 无变化 true:有变化,则需记录一条记录 time_t stime; // 遥信信号变化时间,否则为0 time_t etime; // 结束时间 time_t lastTime; // 最近一次入库时间 time_t last_yx_time; time_t last_yc_time; unsigned long m_gis_fault_count; // gis故障次数 //unsigned long m_gis_count; // gis开合次数 bool m_gis_change; // 断路器断开时,记录入库 char m_iec_warn_time[24]; // IEC子站异常时间 unsigned short usSendNo; // 发送序号 unsigned short usRecvNo; // 接收序号 int TxCounter; int RxCounter; int LastAckTx; int LastAckRx; int t0; // time-out of connection establishment (reconnection) TCP连接建立的超时时间 int t1; // time-out of send or test APDUs (wait ack). RTU(服务器)端启动U格式测试过程后等待U格式测试应答的超时时间 int t2; // time-out for ack in case of no data messages (T2 < T1). S格式的超时时间 int t3; // time-out for sending TESFR in case of long idle state. 没有实际的数据交换时,任何一端启动U格式测试过程的最大间隔时间 int k; // maximum difference N(R) and N(S) int w; // lastest ack after receiving W I-Format message. unsigned short usISUType; // 0,2=I ; 1=S ; 3=U //int timer_Connect; int timer_t0; // T0 param int timer_Confirm; // associated of T1 param int timer_t1; // T1 param int timer_S_Ack; // associated of T2 param time_t timer_t2; // T2 param bool timer_S_Ackflag; time_t timer_t3; // T3 param bool timer_U_Testflag; time_t time_action; // 总召间隔请求时间 }ST_IEC104_CTRL; typedef struct { unsigned char start; // 起始字节 unsigned char len; // 帧长度 unsigned char cntl1; // 控制域1-4 unsigned char cntl2; unsigned char cntl3; unsigned char cntl4; }ST_APCI; typedef struct { // 数据单元标识 unsigned char type; // 类型标识 unsigned char qual; // 可变结构限定词 unsigned char tx_cause1; // 传送原因(2字节)根据主站配置 unsigned char tx_cause2; unsigned char commom_asdu1; // 公共地址(2字节)根据主站配置 unsigned char commom_asdu2; }ST_ASDU_HEADER; typedef struct { ST_ASDU_HEADER header; // 数据单元标识 unsigned char data[243]; // 信息体 }ST_ASDU; typedef struct { ST_APCI apci; ST_ASDU asdu; }ST_IEC_APDU; typedef struct { int iLength ; // 接收长度 unsigned short usISUType; // 0,2=I ; 1=S ; 3=U unsigned short usSendNo; // 发送序号 unsigned short usRecvNo; // 接收序号 unsigned char *pszBuff; // 接收数据 }ST_RECVPKG ; /* typedef struct { unsigned short usISUType ; // 0,2=I ; 1=S ; 3=U unsigned short usLen ; // data length unsigned short usSendNo; // 发送序号 unsigned short usRecvNo; // 接收序号 unsigned int LastAckSendNo; // last send number unsigned int LastAckRecvNo; // last recv number ST_ASDU_HEADER stAsduHead; // ASDU Header unsigned int uiInfoAddr; // info body addr,3(byte) unsigned int uiLastAckTx; // last respone send number }ST_IEC104_INFO; */ // single point information w/quality struct SIQ104{ unsigned char spi : 1, // off=0 / on=1 rs1 : 1, // reserve rs2 : 1, // reserve rs3 : 1, // reserve bl : 1, // not blocked=0 / blocked=1 sb : 1, // not substituted=0 / substituted=1 nt : 1, // topical=0 / not topical=1 iv : 1; // valid=0 / not valid=1 }; // quality descriptor struct QDS104{ unsigned char ov : 1, // no overflow=0 / overflow=1 rs1 : 1, // reserve rs2 : 1, // reserve rs3 : 1, // reserve bl : 1, // not blocked=0 / blocked=1 sb : 1, // not substituted=0 / substituted=1 nt : 1, // topical=0 / not topical=1 iv : 1; // valid=0 / not valid=1 }; // single point value struct SP104{ unsigned char addr0; unsigned char addr1; unsigned char addr2; struct SIQ104 siq; }; // single point value w/time tag CP56Time2a struct SP104_T{ unsigned char addr0; unsigned char addr1; unsigned char addr2; struct SIQ104 siq; unsigned char time[7]; }; // short floating point value struct SFP104{ unsigned char addr0; unsigned char addr1; unsigned char addr2; //float value; unsigned char val[4]; struct QDS104 qds; }; // short floating point value struct SFP104V{ unsigned char val[4]; struct QDS104 qds; }; // short point value struct SH104{ unsigned char addr0; unsigned char addr1; unsigned char addr2; unsigned char val[2]; struct QDS104 qds; }; // short point value struct SHP104{ unsigned char val[2]; struct QDS104 qds; }; // short floating point value w/time tag CP56Time2a struct SFP104_T{ unsigned char addr0; unsigned char addr1; unsigned char addr2; unsigned char val[4]; struct QDS104 qds; unsigned char time[7]; }; // GIS负荷计算表结构定义iec_break_param typedef struct { unsigned char site_id[DEF_EQM_CODE_SIZE]; // 站点ID unsigned char eqm_code[DEF_EQM_CODE_SIZE]; // 设备编码 unsigned char system_code[DEF_EQM_CODE_SIZE]; // 设备编码 unsigned char wstate; // 工作状态 1:发电 2:抽水 3:空闲 unsigned char is_close; // 断开状态 0:分 1:合 unsigned char is_fault; // 是否故障 1:故障 0:正常 float faild_rate; // 发生故障率% time_t d_time; // 发生时间 double abort_current; // 断开电流(A) double abort_voltage; // 断开电压(V) }ST_IEC_GISBREAK_TABLE; // 变压器负荷计算表结构定义iec_bydwork_param typedef struct { unsigned char site_id[DEF_EQM_CODE_SIZE]; // 站点ID unsigned char eqm_code[DEF_EQM_CODE_SIZE]; // 设备编码 unsigned char system_code[DEF_EQM_CODE_SIZE]; // 设备编码 unsigned char state; // 状态类型: 1-发电状态 2:抽水状态 3:空闲状态 unsigned char is_fault; // 主变是否故障 1:故障 0:正常 time_t start_time; // 发电/抽水开始时间 time_t stop_time; // 发电/抽水结束时间 time_t real_time; // 发生时间 double voltage; // 高/低压出口电压(kV) double current; // 高/低压出口电流(A) }ST_IEC_BYQWORK_TABLE; // 变压器运行工况表结构定义transformer_read_table typedef struct { unsigned char site_id[DEF_EQM_CODE_SIZE]; // 站点ID unsigned char eqm_code[DEF_EQM_CODE_SIZE]; // 设备编码 unsigned char system_code[DEF_EQM_CODE_SIZE]; // 设备编码 unsigned char wstate; // 工作状态:1-发电状态 2:抽水状态 3:空闲状态 time_t chkTime; // 监测时间 #if 0 double dcurJkyl; // 冷却水进口压力值 double dcurCkyl; // 冷却水出口压力值 double dCoolWaterTempEntry; // 冷却水进口温度 double dCoolWaterTempOuter; // 冷却水出口温度 //2020-05-23 add double dOilPressEntry; // 变压器油进口油压力(MPa) double dOilPressOuter; // 变压器油出口油压力(MPa) double dOilTempEntry; // 变压器油进口温度 double dOilTempOuter; // 变压器油出口温度 double dOilTemperature; //主变本体油温点位 double dOilPosition; //主变本体油位点位 double dOilTopTemp; //主变顶层油温点位 double dOilPillowLevel; //主变油枕油位点位 double dWindingTemp; //主变绕组温度点位 #else char dcurJkyl[16]; // 冷却水进口压力值 char dcurCkyl[16]; // 冷却水出口压力值 char dCoolWaterTempEntry[16]; // 冷却水进口温度 char dCoolWaterTempOuter[16]; // 冷却水出口温度 char dOilPressEntry[16]; // 变压器油进口油压力(MPa) char dOilPressOuter[16]; // 变压器油出口油压力(MPa) char dOilTempEntry[16]; // 变压器油进口温度 char dOilTempOuter[16]; // 变压器油出口温度 char dOilTemperature[16]; //主变本体油温点位 char dOilPosition[16]; //主变本体油位点位 char dOilTopTemp[16]; //主变顶层油温点位 char dOilPillowLevel[16]; //主变油枕油位点位 char dWindingTemp[16]; //主变绕组温度点位 #endif }ST_IEC_BYQREAD_TABLE; // 入库队列 typedef struct { unsigned char ctype; // 类型:1-运行工况 2:断路器数据 3:变压器数据 unsigned int iLength; // 数据长度 unsigned char *pData; // 数据ST_MASRTE_PARAM |ST_BREAKER_PARAM|ST_WORK_PARAM }ST_DB_DATA; // 变压器工作数据,通过104获取。 typedef struct { unsigned char stype; // 状态类型: 1-发电状态 2:抽水状态 3:空闲状态 time_t start_time; // 发电/抽水开始时间 time_t stop_time; // 发电/抽水结束时间 double voltage; // 高/低压出口电压(v) double current; // 高/低压出口电流(A) double dcurYWei; // 最近油位值 double dcurYWen; // 最近油温值 double dcurJkyl; // 最近冷却水进口压力值 double dcurCkyl; // 最近冷却水出口压力值 }ST_IEC104_BYQ_DATA; // 变压器设备对应关系、阈值缓存记录 //typedef struct { //#ifdef _SITE_ID_TYPE_INT // unsigned int SiteID; // 站点ID //#else // unsigned char SiteID[DEF_EQM_CODE_SIZE]; // 站点ID //#endif // unsigned char szSiteCode[DEF_EQM_CODE_SIZE]; // 物理站点唯一编码 // unsigned char szEqmCode[DEF_EQM_CODE_SIZE]; // 系统设备唯一编码 // unsigned char szSersorID[20]; // sersorid唯一编码 // double dYWei; // 油位阈值 // double dYWen; // 油温阈值 // double dJkyl; // 冷却水进口压力阈值 // double dCkyl; // 冷却水出口压力阈值 // ST_IEC104_BYQ_DATA stLastData; // 变压器最近一次104上传的数据 //}ST_BYQ_CACHE; // 断路器104数据结构 //typedef struct { // unsigned char is_fault; // 是否故障 1:否 2:是 // time_t record_date; // 发生时间 // double voltage; // 断开电压(V) // double current; // 断开电流(A) // double failed_rate; // %电流故障百分比% //}ST_IEC104_GIS_DATA; // GIS设备对应关系、阈值缓存记录 //typedef struct { //#ifdef _SITE_ID_TYPE_INT // unsigned int SiteID; // 站点ID //#else // unsigned char SiteID[DEF_EQM_CODE_SIZE]; // 站点ID //#endif // unsigned char szEqmCode[DEF_EQM_CODE_SIZE]; // 设备唯一编码 // ST_IEC104_GIS_DATA stLastData; // 断路器最近一次104上传的数据 //}ST_GIS_IEC104_DATA; // GIS设备外挂对应关系、阈值缓存记录 //typedef struct { //#ifdef _SITE_ID_TYPE_INT // unsigned int SiteID; // 站点ID //#else // unsigned char SiteID[DEF_EQM_CODE_SIZE]; // 站点ID //#endif // unsigned char szSersorID[20]; // sersorid唯一编码 // unsigned char szEqmCodeID[18]; // 设备唯一编码 // unsigned char name_des[128]; // 设备名称,描述 // double dNum ; // GIS放电电流(mA) //}ST_GIS_CACHE; // BLQ设备对应关系、阈值缓存记录 //typedef struct { //#ifdef _SITE_ID_TYPE_INT // unsigned int SiteID; // 站点ID //#else // unsigned char SiteID[DEF_EQM_CODE_SIZE]; // 站点ID //#endif // unsigned char szSersorID[20]; // sersorid唯一编码 // unsigned char szEqmCodeID[18]; // 设备唯一编码 // unsigned char name_des[128]; // 设备名称,描述 // double dMaxDL; // 避雷器放电电流图片识别阈值 //}ST_BLQ_CACHE; #pragma pack (pop) #endif // end