📄 dblink.h
字号:
#ifndef _DBLINK_HEAD
#define _DBLINK_HEAD
#include "\nsa2000\dev\env\inc\FjrLibDef.h"
#define RELAY_INIT_FILE "\\nsa2000\\init\\rlydef.ini"
#define DATA_TYPE_YX 0 //数据类型
#define DATA_TYPE_YC 1 //数据类型
#define DATA_TYPE_BH 2 //数据类型
#define DATA_TYPE_YT 3 //数据类型
#define DATA_TYPE_YXDEV 4 //数据类型
#define ID_TYPE_YX 0 //状态遥信类型
#define ID_TYPE_ADEV 1 //状态遥信类型
#define ID_TYPE_RTU 2
#define ID_TYPE_WORKSTATION 3
#define DBT_FJNT 0
#define DBT_DISA 1
#define DBT_EC2000 2
#define DBT_NSA2000 3
class DATAYC_DEF{
public:
int rtu;
int dot;
float GetValue();
void GetName(char *name);
BOOL CheckParam(){
return TRUE;
if ((rtu >255)||(rtu<0)) return FALSE;
if ((dot <0)||(dot>2048)) return FALSE;
return true;
};
};
class DATAYX_DEF{
public:
int rtu;
int dot;
int idType;
short GetYkObjNo();
BOOL DoYkProc(BOOL bClose);
WORD GetStatusWord();
BOOL GetStatus();
void GetName(char *name);
void SetWfStatus(BOOL status);
BOOL CheckParam(){
if ((rtu >255)||(rtu<0)) return FALSE;
if (idType == ID_TYPE_RTU) return TRUE;
if (idType == ID_TYPE_WORKSTATION) return TRUE;
if ((dot <0)||(dot>6000)) return FALSE;
return true;
};
};
class DATABH_DEF{
public:
int rtu;
int dot;
BOOL actStat;
void SetActStatus(int rtuNo, int dotNo);
BOOL GetActStatus();
void GetName(char *name);
void ClearActStatus();
BOOL CheckParam(){
if ((rtu >255)||(rtu<0)) return FALSE;
if ((dot <0)||(dot>2048)) return FALSE;
return true;
};
};
class DATAYT_DEF{
public:
int rtu;
int dot;
short GetYtObjNo(BOOL bUp);//取遥调的遥控对象号
short GetYtJTObjNo();
void GetName(char *name);
BOOL DoYtProc(BOOL bUp);
BOOL DoYtStopProc();
float GetYtValue();
BOOL CheckParam(){
if ((rtu >255)||(rtu<0)) return FALSE;
if ((dot <0)||(dot>2048)) return FALSE;
return true;
};
};
class DATAYC_DEF;
class DATAYX_DEF;
class DATABH_DEF;
class FJNT_DBLINK{
public:
union {
DATAYC_DEF yc;
DATAYX_DEF yx;
DATABH_DEF bh;
DATAYT_DEF yt;
};
};
class DBLINK{
public:
UINT ClassSize;
BYTE dataType;
class FJNT_DBLINK fjntDef;
void ReInitDataProc(int dt){
dataType = dt;
if (dt==DATA_TYPE_YC){
fjntDef.yc.rtu = -1;
fjntDef.yc.dot = -1;
}
else if (dt==DATA_TYPE_BH){
fjntDef.bh.rtu = -1;
fjntDef.bh.dot = -1;
}
else if (dt==DATA_TYPE_YT){
fjntDef.yt.rtu = -1;
fjntDef.yt.dot = -1;
}
else {
dt = DATA_TYPE_YX;
fjntDef.yx.rtu = -1;
fjntDef.yx.dot = -1;
fjntDef.yx.idType = ID_TYPE_YX;
}
dataType = dt;
};
DBLINK(){
ClassSize = sizeof(DBLINK);
dataType = DATA_TYPE_YX;
fjntDef.yx.rtu = -1;
fjntDef.yx.dot = -1;
}
BOOL CheckEqualDefineProc(DBLINK * p){
if (dataType != p->dataType) return FALSE;
if (GetRtuNo() != p->GetRtuNo()) return FALSE;
if (GetDotNo() != p->GetDotNo()) return FALSE;
if (p->dataType != DATA_TYPE_YX) return TRUE;
if (fjntDef.yx.idType != p->fjntDef.yx.idType) return FALSE;
return TRUE;
};
void SetBhStatus(int rtuNo, int dotNo){
if (dataType == DATA_TYPE_BH) fjntDef.bh.SetActStatus(rtuNo, dotNo);
};
BOOL GetBhStatus(){
if (dataType == DATA_TYPE_BH) return (fjntDef.bh.GetActStatus());
return 0;
};
void ClearBhStatus(){
if (dataType == DATA_TYPE_BH) fjntDef.bh.ClearActStatus();
};
float GetYcValue(){
if (dataType == DATA_TYPE_YC) return fjntDef.yc.GetValue();
return 0.0;
};
BOOL DoYtStopProc(){
if (dataType == DATA_TYPE_YT) return(fjntDef.yt.DoYtStopProc());
return FALSE;
};
float GetYtValue(){
if (dataType == DATA_TYPE_YT) return(fjntDef.yt.GetYtValue());
return 0.0;
};
BOOL DoYtProc(BOOL bUp){
if (dataType == DATA_TYPE_YT) return(fjntDef.yt.DoYtProc(bUp));
return FALSE;
};
int GetYtObjNo(BOOL bUp){
if (dataType == DATA_TYPE_YT) return fjntDef.yt.GetYtObjNo(bUp);
return -1;
};
BOOL DoYkProc(BOOL bClose){
if (dataType == DATA_TYPE_YX) return(fjntDef.yx.DoYkProc(bClose));
return FALSE;
};
void SetWfStatus(BOOL status){
if (dataType == DATA_TYPE_YX) fjntDef.yx.SetWfStatus(status);
};
WORD GetStatusWord(){
if (dataType == DATA_TYPE_YX) return fjntDef.yx.GetStatusWord();
return FALSE;
};
BOOL GetStatus(){
if (dataType == DATA_TYPE_YX) return fjntDef.yx.GetStatus();
return FALSE;
};
int GetYkObjNo(){
if (dataType == DATA_TYPE_YX) return fjntDef.yx.GetYkObjNo();
return -1;
};
BOOL CheckYcParam(){
if (dataType == DATA_TYPE_YC) return fjntDef.yc.CheckParam();
return FALSE;
}
BOOL CheckYxParam(){
if (dataType == DATA_TYPE_YX) return fjntDef.yx.CheckParam();
return FALSE;
}
BOOL CheckBhParam(){
if (dataType == DATA_TYPE_BH) return fjntDef.bh.CheckParam();
return FALSE;
}
BOOL CheckYtParam(){
if (dataType == DATA_TYPE_YT) return fjntDef.yt.CheckParam();
return FALSE;
}
void GetName(char *name){
wsprintf(name, "无定义");
if (dataType == DATA_TYPE_BH) fjntDef.bh.GetName(name);
else if (dataType == DATA_TYPE_YX) fjntDef.yx.GetName(name);
else if (dataType == DATA_TYPE_YC) fjntDef.yc.GetName(name);
else if (dataType == DATA_TYPE_YT) fjntDef.yt.GetName(name);
}
int GetRtuNo(){
if (dataType == DATA_TYPE_BH) return(fjntDef.bh.rtu);
if (dataType == DATA_TYPE_YC) return(fjntDef.yc.rtu);
if (dataType == DATA_TYPE_YT) return(fjntDef.yt.rtu);
if (dataType == DATA_TYPE_YX) return(fjntDef.yx.rtu);
return(-1);
};
int GetDotNo(){
if (dataType == DATA_TYPE_BH) return(fjntDef.bh.dot);
if (dataType == DATA_TYPE_YC) return(fjntDef.yc.dot);
if (dataType == DATA_TYPE_YX) return(fjntDef.yx.dot);
if (dataType == DATA_TYPE_YT) return(fjntDef.yt.dot);
return(-1);
};
void SetRtuNo(int no){
if (dataType == DATA_TYPE_BH) fjntDef.bh.rtu = no;
else if (dataType == DATA_TYPE_YC) fjntDef.yc.rtu = no;
else if (dataType == DATA_TYPE_YX) fjntDef.yx.rtu = no;
else if (dataType == DATA_TYPE_YT) fjntDef.yt.rtu = no;
else {
dataType = DATA_TYPE_YX;
fjntDef.yx.rtu = no;
fjntDef.yx.idType = ID_TYPE_YX;
}
};
void SetDotNo(int no){
if (dataType == DATA_TYPE_BH) fjntDef.bh.dot = no;
else if (dataType == DATA_TYPE_YC) fjntDef.yc.dot = no;
else if (dataType == DATA_TYPE_YX) fjntDef.yx.dot = no;
else if (dataType == DATA_TYPE_YT) fjntDef.yt.dot = no;
else {
dataType = DATA_TYPE_YX;
fjntDef.yx.dot = no;
fjntDef.yx.idType = ID_TYPE_YX;
};
};
void SetYxIdType(int idType){
dataType = DATA_TYPE_YX;
fjntDef.yx.idType = idType;
}
BYTE GetYxIdType(){
if (dataType != DATA_TYPE_YX) return ID_TYPE_YX;
return (fjntDef.yx.idType);
}
};
#define MAX_EXIST_YK_NUM 40
class YKTRANSDEFINE{
UINT needTransYkNum;
UINT times;
struct {
WORD RtuNO;
WORD CmdCode;
WORD FunCode;
short Obj;
}transBuf[MAX_EXIST_YK_NUM];
public:
YKTRANSDEFINE(){
needTransYkNum=0;
times=0;
};
BOOL AppendOneYkProc(WORD RtuNO, WORD CmdCode,WORD FunCode, short Obj)
{
if (needTransYkNum>=MAX_EXIST_YK_NUM) return FALSE;
if (needTransYkNum==0) times=20;
transBuf[needTransYkNum].RtuNO = RtuNO;
transBuf[needTransYkNum].CmdCode = CmdCode;
transBuf[needTransYkNum].FunCode = FunCode;
transBuf[needTransYkNum].Obj = Obj;
needTransYkNum++;
return TRUE;
};
void DeleteOneYkProc()
{
if (needTransYkNum==0) return;
for (UINT i=1;i<needTransYkNum;i++){
transBuf[i-1].RtuNO = transBuf[i].RtuNO;
transBuf[i-1].CmdCode = transBuf[i].CmdCode;
transBuf[i-1].FunCode = transBuf[i].FunCode;
transBuf[i-1].Obj = transBuf[i].Obj;
}
needTransYkNum--;
};
void DoYkProc();
};
extern int GetBhUintNumProc(int rtuNo);
extern void GetBhNameProc(int rtu,int dot,char *name);
extern void VqcPutMsgProc(int rtu, char *pMsg);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -