📄 realdb.cpp
字号:
if (SymNo==4) return (BYTE)dbGetCharField(Record,"符号5");
if (SymNo==5) return (BYTE)dbGetCharField(Record,"符号6");
if (SymNo==6) return (BYTE)dbGetCharField(Record,"符号7");
if (SymNo==7) return (BYTE)dbGetCharField(Record,"符号8");
if (SymNo==8) return (BYTE)dbGetCharField(Record,"符号9");
if (SymNo==9) return (BYTE)dbGetCharField(Record,"符号10");
return 0;
}
int CALC::GetSOrder(WORD Record,BYTE SymNo)
{
/*
char COUNT[5]={"遥测1"};
COUNT[4]=(char)(SymNo+0x30);
return dbGetIntField(Record,COUNT);
*/
if (SymNo==0) return dbGetIntField(Record,"遥测1");
if (SymNo==1) return dbGetIntField(Record,"遥测2");
if (SymNo==2) return dbGetIntField(Record,"遥测3");
if (SymNo==3) return dbGetIntField(Record,"遥测4");
if (SymNo==4) return dbGetIntField(Record,"遥测5");
if (SymNo==5) return dbGetIntField(Record,"遥测6");
if (SymNo==6) return dbGetIntField(Record,"遥测7");
if (SymNo==7) return dbGetIntField(Record,"遥测8");
if (SymNo==8) return dbGetIntField(Record,"遥测9");
if (SymNo==9) return dbGetIntField(Record,"遥测10");
return 0;
}
int CALC::GetDOrder(WORD Record,BYTE SymNo)
{
return dbGetIntField(Record,"遥测");
}
ZFDB::ZFDB(): TRealDB((int)ZFRTUDB)
{
zflpRtuInx = (RTUINDEX huge *)GlobalLock(zfhRtuInxMem);
}
ZFDB::~ZFDB()
{
GlobalUnlock(zfhRtuInxMem);
}
WORD ZFDB::GetStation(WORD stano)
{
return dbGetIntField(stano, "目的");
}
int ZFDB::GetStaYxNum(WORD stano)
{
return (dbGetIntField(stano, "遥信数"));
}
int ZFDB::GetStaYcNum(WORD stano)
{
return (dbGetIntField(stano, "遥测数"));
}
int ZFDB::GetStaKwhNum(WORD stano)
{
return (dbGetIntField(stano, "电度数"));
}
int ZFDB::GetStaYxStart(WORD stano)
{
if ((stano<dbGetRcdNum()) && zflpRtuInx)
return (zflpRtuInx+stano)->YxStart;
return 0;
}
int ZFDB::GetStaYcStart(WORD stano)
{
if ((stano<dbGetRcdNum()) && zflpRtuInx)
return (zflpRtuInx+stano)->YcStart;
return 0;
}
int ZFDB::GetStaKwhStart(WORD stano)
{
if ((stano<dbGetRcdNum()) && zflpRtuInx)
return (zflpRtuInx+stano)->KwhStart;
return 0;
}
int ZFYxDB::GetStation(WORD stano, WORD yxno)
{
ZFDB zf;
if ( yxno >= zf.GetStaYxNum(stano)) return 0;
int iv = (WORD)dbGetIntField(zf.GetStaYxStart(stano)+yxno, "厂站号");
return iv;
}
int ZFYxDB::GetOrder(WORD stano, WORD yxno)
{
ZFDB zf;
if ( yxno >= zf.GetStaYxNum(stano)) return 0;
int iv = (WORD)dbGetIntField(zf.GetStaYxStart(stano)+yxno, "遥信号");
return iv;
}
int ZFYcDB::GetStation(WORD stano, WORD ycno)
{
ZFDB zf;
if ( ycno >= zf.GetStaYcNum(stano)) return 0;
int iv = (WORD)dbGetIntField(zf.GetStaYcStart(stano)+ycno, "厂站号");
return iv;
}
int ZFYcDB::GetOrder(WORD stano, WORD ycno)
{
ZFDB zf;
if ( ycno >= zf.GetStaYcNum(stano)) return 0;
int iv = (WORD)dbGetIntField(zf.GetStaYcStart(stano)+ycno, "遥测号");
return iv;
}
int ZFKwhDB::GetStation(WORD stano, WORD kwhno)
{
ZFDB zf;
if ( kwhno >= zf.GetStaKwhNum(stano)) return 0;
int iv = (WORD)dbGetIntField(zf.GetStaKwhStart(stano)+kwhno, "厂站号");
return iv;
}
int ZFKwhDB::GetOrder(WORD stano, WORD kwhno)
{
ZFDB zf;
if ( kwhno >= zf.GetStaKwhNum(stano)) return 0;
int iv = (WORD)dbGetIntField(zf.GetStaKwhStart(stano)+kwhno, "电度号");
return iv;
}
ZFYxDB::ZFYxDB() : TRealDB((int)ZFYX)
{
}
ZFYxDB::~ZFYxDB()
{
}
ZFYcDB::ZFYcDB() : TRealDB((int)ZFYC)
{
}
ZFYcDB::~ZFYcDB()
{
}
ZFKwhDB::ZFKwhDB() : TRealDB((int)ZFDD)
{
}
ZFKwhDB::~ZFKwhDB()
{
}
//--------------------------------------------------------------------------------//
TRtuDB::TRtuDB() : TRealDB((int)RTUDB)
{
lpRtuInx = (RTUINDEX huge *)GlobalLock(hRtuInxMem);
}
TRtuDB::~TRtuDB()
{
GlobalUnlock(hRtuInxMem);
}
void TRtuDB::GetStaName(WORD stano, char *staname)
{
dbGetStrField(stano, "厂站名", staname);
}
int TRtuDB::GetStaYxNum(WORD stano)
{
return (dbGetIntField(stano, "遥信数"));
}
int TRtuDB::GetStaYcNum(WORD stano)
{
return (dbGetIntField(stano, "遥测数"));
}
int TRtuDB::GetStaKwhNum(WORD stano)
{
return (dbGetIntField(stano, "电度数"));
}
int TRtuDB::GetStaYxStart(WORD stano)
{
if ((stano<dbGetRcdNum()) && lpRtuInx)
return (lpRtuInx+stano)->YxStart;
return 0;
}
int TRtuDB::GetStaYcStart(WORD stano)
{
if ((stano<dbGetRcdNum()) && lpRtuInx)
return (lpRtuInx+stano)->YcStart;
return 0;
}
int TRtuDB::GetStaKwhStart(WORD stano)
{
if ((stano<dbGetRcdNum()) && lpRtuInx)
return (lpRtuInx+stano)->KwhStart;
return 0;
}
void TRtuDB::SetEvidentTimer(WORD stano, int SecondNum)
{
if ((stano<dbGetRcdNum()) && lpRtuInx)
(lpRtuInx+stano)->EvidentNum = SecondNum;
}
int TRtuDB::GetEvidentTimer(WORD stano)
{
if ((stano<dbGetRcdNum()) && lpRtuInx)
return (lpRtuInx+stano)->EvidentNum;
else return 0;
}
void TRtuDB::DecEvidentTimer(WORD stano)
{
if ((stano<dbGetRcdNum()) && lpRtuInx)
if ((lpRtuInx+stano)->EvidentNum>0) (lpRtuInx+stano)->EvidentNum -= 1;
}
//--------------------------------------------------------------------------------//
TYxDB::TYxDB() : TRealDB((int)YXDB)
{
}
TYxDB::~TYxDB()
{
}
void TYxDB::GetYxName(WORD stano, WORD yxno, char *yxname)
{
TRtuDB rtu;
if ( yxno >= rtu.GetStaYxNum(stano)) *yxname=0;
else
dbGetStrField(rtu.GetStaYxStart(stano)+yxno, "遥信名", yxname);
}
DWORD TYxDB::GetYxAttr(WORD stano, WORD yxno)
{
TRtuDB rtu;
if ( yxno >= rtu.GetStaYxNum(stano)) return 0;
DWORD attr = (DWORD)dbGetLongField(rtu.GetStaYxStart(stano)+yxno, "属性");
return attr;
}
BYTE TYxDB::GetYxType(WORD stano, WORD yxno)
{
TRtuDB rtu;
if ( yxno >= rtu.GetStaYxNum(stano)) return 0;
BYTE yxtype = (BYTE)dbGetCharField(rtu.GetStaYxStart(stano)+yxno, "遥信类型");
return (yxtype&0x7);
}
BYTE TYxDB::GetYxValue(WORD stano, WORD yxno)
{
TRtuDB rtu;
if ( yxno >= rtu.GetStaYxNum(stano)) return 0;
BYTE yxv = (BYTE)dbGetCharField(rtu.GetStaYxStart(stano)+yxno, "实时值");
return yxv;
}
void TYxDB::SetYxAttr(WORD stano, WORD yxno, DWORD attr)
{
TRtuDB rtu;
if ( yxno >= rtu.GetStaYxNum(stano)) return;
dbSetLongField(rtu.GetStaYxStart(stano)+yxno, "属性", attr);
}
void TYxDB::SetYxValue(WORD stano, WORD yxno, BYTE yxvalue)
{
TRtuDB rtu;
BYTE oldyxv;
WORD yxnum = rtu.GetStaYxNum(stano);
if (yxno >= yxnum) return;
BYTE yxtype = GetYxType(stano, yxno);
yxtype &=7;
DWORD yxattr = GetYxAttr(stano, yxno);
if (yxattr & YXREFRESH) //允许刷新
{
if (yxattr & YXXOR) yxvalue ^= 1;
oldyxv = GetYxValue(stano, yxno);
if ((yxtype==YXEVIDENT) && (yxvalue & bit0))
rtu.SetEvidentTimer(stano, 5);
dbSetCharField(rtu.GetStaYxStart(stano)+yxno, "实时值", yxvalue&bit0);
if (yxattr &YXREADY)
{
if ((yxvalue & bit0) != (oldyxv & bit0))
{
DWORD attrtemp = GetYxAttr(0,0);
SetYxAttr(0,0,attrtemp |=YXCHANGE);
attrtemp = GetYxAttr(stano,yxno);
SetYxAttr(stano,yxno,attrtemp |=YXCHANGE);
}
if (((yxvalue & bit0) != (oldyxv & bit0)) && (yxattr & YXCREATESOE) && !(yxattr &RECRTUSOE))
{
CreateSoe(stano, yxno, yxtype, yxvalue&bit0);
}//TZC
}
else SetYxAttr(stano,yxno,yxattr |=YXREADY);
}
}
void TYxDB::SetYxValue(WORD stano, WORD startyx, BYTE yxvalue, BYTE yxmask)
{
TRtuDB rtu;
DWORD yxattr;
BYTE yxtype, oldyxv;
WORD yxnum;
yxnum = rtu.GetStaYxNum(stano);
for (int i=0; i<8; i++)
{
if ((startyx+i)>=yxnum) break;
yxattr = GetYxAttr(stano, startyx+i);
yxtype = GetYxType(stano, startyx+i);
if (yxmask & bit0)
{
if (yxattr & YXREFRESH) //允许刷新
{
yxattr |= YXREADY;
if (yxattr & YXXOR) yxvalue ^= 1;
if ((yxtype==YXEVIDENT) && (yxvalue & bit0))
rtu.SetEvidentTimer(stano, 5);
oldyxv = GetYxValue(stano, startyx+i);
if (yxvalue & bit0)
dbSetCharField(rtu.GetStaYxStart(stano)+startyx+i, "实时值", oldyxv|bit0);
else
dbSetCharField(rtu.GetStaYxStart(stano)+startyx+i, "实时值", oldyxv&(~bit0));
oldyxv &= bit0;
// if (((yxvalue & bit0) != oldyxv) && (yxattr & YXCREATESOE))
// CreateSoe(stano, startyx+i, yxtype, yxvalue&bit0);
}
}
yxmask >>= 1;
yxvalue >>= 1;
}
}
void TYxDB::CreateSoe(WORD stano, WORD yxno, BYTE yxtype, BYTE yxv)
{
EVENT evercd;
struct dosdate_t d;
struct dostime_t t;
TYxDB yx;
TRtuDB rtu;
TEventDB eve;
DWORD yxattr =yx.GetYxAttr(stano, yxno);
if (yxtype==YXSWITCH) evercd.EventType = KGEVENT;
else evercd.EventType = DZEVENT;
evercd.Station = stano;
evercd.Order = yxno;
evercd.Status =0x33;
if (yxv&bit0)
evercd.Status =0xcc;
//if (yxattr&YXXOR) evercd.Status ^= 0xff;//jgx 98.8
if (rtu.GetEvidentTimer(stano))
{
if (evercd.Status==0x33)
{
if ((yxtype==YXSWITCH) || (yxtype==YXLINKER))
// evercd.EventAttr |= SGFLAG;
evercd.EventType |= SGFLAG;
else if (yxtype==YXPROTECT) evercd.EventType |=SGFLAG;
}
}
_dos_getdate(&d);
_dos_gettime(&t);
evercd.Hour = t.hour;
evercd.Min = t.minute;
evercd.Sec = t.second;
evercd.Ms = 0;
evercd.data[0]=evercd.Status;
evercd.EventAttr=0x88;
eve.WriteAEvent(&evercd);
}
//--------------------------------------------------------------------------------//
TYcDB::TYcDB() : TRealDB((int)YCDB)
{
}
TYcDB::~TYcDB()
{
}
void TYcDB::GetYcName(WORD stano, WORD ycno, char *ycname)
{
TRtuDB rtu;
if ( ycno >= rtu.GetStaYcNum(stano)) *ycname=0;
else
dbGetStrField(rtu.GetStaYcStart(stano)+ycno, "遥测名", ycname);
}
DWORD TYcDB::GetYcAttr(WORD stano, WORD ycno)
{
TRtuDB rtu;
if ( ycno >= rtu.GetStaYcNum(stano)) return 0;
DWORD attr = (DWORD)dbGetLongField(rtu.GetStaYcStart(stano)+ycno, "属性");
return attr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -