RTDatOpr.h
资源名称:PasRTDat.rar [点击查看]
上传用户:shtiemo
上传日期:2017-12-29
资源大小:163k
文件大小:6k
源码类别:
能源行业(电力石油煤炭)
开发平台:
Visual C++
- //#include "MSDB.h"
- #include "eventdll.h"
- #include "Commdef.h"
- #define INVALID_SHEET -1
- #define NO_SHEET 10
- #define MEM_ERROR 20
- #define DBSERVER_ERROR 30
- #define SBCOM_ERROR 40
- #define WAIT_SHEET_TIMEOUT 50
- #define WAIT_SHEET_ABANDONED 60
- #define WAIT_SHEET_FAILED 70
- #define GET_DATA_OK 1
- #define MAX_ID_NUM 140 //定单最大数为:100
- #define KWHWTYPE unsigned long
- typedef union _m_DeviceInfo
- {
- BYTE BuYong;
- RETYCV m_RetYcv; //1--遥测(包括属性);
- YCTYPE m_Ycv; //2--仅遥测值;
- MAXMIN m_MaxMin; //3--最大最小值及发生时间
- RECTIME m_RecTime; //4--发生时间(时,分,秒)(越限时累)
- SMALLINT m_AQT; //5--安全天
- RECCNT m_RecCnt; //6--越限次数累计(计数器)
- REAL m_RealRate; //7--合格率 4 bytes
- TINYINT m_TinyInt; //8--单字节
- SMALLINT m_SmallInt; //9--双字节
- RETYXV m_RetYxv; //10--遥信(包括属性)
- DBYXV m_DbYxv; //11--保护或虚拟量
- RETJDV m_RetJdv; //12--遥信接地返回标志 //1998.3.16
- KWHTYPE m_RetKwhv; //13--电度值(差值)
- KWHWTYPE m_RetwKwhv; //14--电度窗口值
- DWORD m_wBYQFJT; //15 变压器分接头
- BYTE m_byBYQFJT; //16 变压器分接头
- BYTE m_byJDType; //17 接地状态牌
- BYTE m_byJXType; //18 检修状态牌
- BYTE m_byBYType; //19 备用牌
- TIMESTAMP_STRUCT m_HisTime; //20 历史时间
- } DEVICEVALUE, *PDEVICEVALUE;
- //电网部件YC数据结构
- typedef struct _tagPartRTData
- {
- BYTE wPartTypeID; // 部件类型
- WORD wPartID; // 部件ID
- BYTE wPartParaID; // 部件参数ID
- float fYCData; // YC数据
- DWORD dwTap; // LTC Tap Position
- DWORD dwKWH; // KWH数据*100(电度数据的100倍,保留2位小数)
- BYTE byYXVal; // 遥信值(开关,刀闸,保护,虚拟状态)
- }PartRTData, LPPartRTData;
- //电网部件YC数据结构菜单
- typedef struct _tagRTMenuData
- {
- WORD wIDNum; //部件数
- PartRTData PartsRtData[MAX_ID_NUM];
- }RTMenuData, *LPRTMenuData;
- typedef struct _tagPWRNETPARA
- {
- char szName[64]; //部件类型
- float fPCoef;
- float fQCoef;
- float fFCoef;
- }PWRNETPARA, *LPPWRNETPARA;
- typedef struct _tagSTATIONPARA
- {
- char szName[64]; //部件类型
- int ID;
- float fPCoef;
- float fQCoef;
- float fFCoef;
- }STATIONPARA, *LPSTATIONPARA;
- typedef struct _tagCTPARA
- {
- char szName[64]; //部件类型
- int ID;
- float fPCoef;
- float fQCoef;
- float fPOffSet;
- float fQOffSet;
- float fICoef;
- float fIOffSet;
- float fIACoef;
- float fIBCoef;
- float fICCoef;
- float fIAOffSet;
- float fIBOffSet;
- float fICOffSet;
- }CTPARA, *LPCTPARA;
- typedef struct _tagPTPARA
- {
- char szName[64]; //部件类型
- int ID;
- float fVACoef;
- float fVBCoef;
- float fVCCoef;
- float fVAOffSet;
- float fVBOffSet;
- float fVCOffSet;
- float fVXCoef;
- float fVXOffSet;
- float fVABCoef;
- float fVABOffSet;
- float fVACCoef;
- float fVACOffSet;
- float fVBCCoef;
- float fVBCOffSet;
- }PTPARA, *LPPTPARA;
- typedef struct _tagVAMEAPARA
- {
- char szName[64]; // 部件类型
- int ID;
- float fCoef;
- float fOffSet;
- }VAMEAPARA, *LPVAMEAPARA;
- typedef struct _tagCBPARA
- {
- char szName[64]; // 部件类型
- int ID;
- BYTE bNot; // 取反标志
- BYTE bTwoBit; // 双位标志
- }CBPARA, *LPCBPARA;
- typedef struct _tagDISPARA
- {
- char szName[64]; // 部件类型
- int ID;
- BYTE bNot; // 取反标志
- }DISPARA, *LPDISPARA;
- typedef struct _tagTRANPARA
- {
- char szName[64]; // 部件类型
- int ID;
- BYTE bLTC; // 有栽调压标志
- float fTapCoef;
- }TRANPARA, *LPTRANPARA;
- typedef struct TAG_RTU
- {
- char szName[64];
- int nRtuID;
- int nYCNum; // 3段ID
- int nYXNum;
- }RTU, *PRTU;
- typedef struct TAG_RTUYC
- {
- char szName[64];
- int nRTUID;
- DBID DBID; // 3段ID
- float fVal; // YC值
- float fPreVal; // 上次YC值
- BYTE bChanged; // 变化标志
- }RTUYC, *PRTUYC;
- typedef struct TAG_RTUYX
- {
- char szName[64];
- int nRTUID;
- DBID DBID; // 3段ID
- BYTE bVal; // YX状态
- BYTE bPreVal; // 上次YX状态
- BYTE bChanged; // 变化标志
- }RTUYX, *PRTUYX;
- extern CTime DatStartTime; // 数据断面开始时间
- extern CTime StartTime; // 仿真开始时间
- extern int nSecond;
- extern int nSeconds;
- extern BOOL bAutoRead;
- extern BOOL bAutoSave;
- extern int gRtuID;
- extern CArray<PRTU, PRTU> RtuAry; // RTU数组
- extern CArray<PRTUYX, PRTUYX> YXInfoAry1; // RTU-YX数组
- extern CArray<PRTUYC, PRTUYC> YCInfoAry1; // RTU-YC数组
- extern CArray<PRTUYX, PRTUYX> YXInfoAry2; // 数据文件读入-YX数组
- extern CArray<PRTUYC, PRTUYC> YCInfoAry2; // 数据文件读入-YC数组
- extern BOOL bYXYCAryBusy;
- extern BOOL bRTUMea; // 默认由RTU信息表获取实时数据
- //Regiset the Module
- BOOL ModuleRegist();
- //UnRegist the Module
- BOOL ModuleUnRegist();
- //Connect to DB Server
- BOOL ConnectServ();
- //Disconnect from DB Server
- BOOL DisConnectServ();
- //CallBack function For SB Communication
- void GetRealDataCallBack(WORD wOpType, LPVOID pPara, LPVOID* pRecBuf, PDWORD pDataLength);
- //遥测数据,单精度数据(单精度), 积分电量数据(双精度)
- BOOL GetRealData(RTMenuData &RtMenuData);
- BOOL SetModuleStatus();
- BOOL GetModuleStatus();
- BOOL ReadRTUYCYXInfo();
- BOOL ReadMeaCoefInfo();
- BOOL ReadRTUInfo();
- BOOL SendAllDataToADM();
- BOOL saveAllRTDataToFile();
- BOOL GetAllRTData();
- BOOL LoadRTDataFromFile(LPCSTR lpFName);
- void FreeRTUInfo();
- void FreeRTUYXYCInfo();
- void FreeFileYXYCInfo();
- void FreeMeaCoefInfo();
- void GetRtuName(PDBID pDBID, CString& Name, int kind);
- void Ary2ToAry1();
- int GetRTUYXYCStartIdx(int nRTUID, int nYCYX);
- int GetRTUYCYXNum(int nRTUID, int nYC, int nStartIdx);
- BOOL BeSCADAEventProcess();
- BOOL GetMeaCoef(PDBID pDBID, float* pCoef, float* pOffSet, CString& strInfo);