📄 server3.cpp
字号:
rtinfo.st[i].alarm=alarm;
rtinfo.st[i].state=state;
rtinfo.st[i].stno=stno;
rtinfo.st[i].dirc=dirc-1;
rtinfo.st[i].reflg=ref;
for(j=0;j<16;j++)
rtinfo.st[i].name[j]=name[j];
Server2::setEventRecord(14,stno,dirc);
for(j=0;j<255;j++)
if(File4.flag[j]==4) File4.flag[j]=0xff;
for(j=0;j<rtinfo.count;j++)
File4.flag[rtinfo.st[j].stno]=4;
*rb=0;
}
return S_OK;
}
STDMETHODIMP Crjinteface::addrTab_add(short addr, LPSTR name, short addtyp, short *ent,short personNum,short *rb)
{
// TODO: Add your implementation code here
int i,j;
i=0;
*rb=1;
while((i<adlst.count)&&(adlst.addr[i].addrno!=addr))
i++;
if((i>=adlst.count)&&(i<50))
{
adlst.addr[i].addrno=addr;
adlst.addr[i].addtyp=addtyp;
adlst.addr[i].AlarmPersonNum=personNum;
for(j=0;j<8;j++)
adlst.addr[i].ent[j]=ent[j];
for(j=0;j<16;j++)
adlst.addr[i].name[j]=name[j];
adlst.count++;
*rb=0;
}
return S_OK;
}
STDMETHODIMP Crjinteface::addrTab_del(short addr, short *rb)
{
// TODO: Add your implementation code here
int i,j;
i=0;
*rb=1;
while((i<adlst.count)&&(adlst.addr[i].addrno!=addr))
i++;
if(i<adlst.count)
{
for(j=i;j<adlst.count;j++)
adlst.addr[j]=adlst.addr[j+1];
adlst.count--;
Server2::setEventRecord(13,addr,0);
*rb=0;
}
return S_OK;
}
STDMETHODIMP Crjinteface::addrTab_mod(short addr, LPSTR name, short addtyp, short *ent,short personNum,short *rb)
{
// TODO: Add your implementation code here
int i,j;
i=0;
*rb=1;
while((i<adlst.count)&&(adlst.addr[i].addrno!=addr))
i++;
if(i<adlst.count)
{
adlst.addr[i].addtyp=addtyp;
adlst.addr[i].AlarmPersonNum=personNum;
for(j=0;j<8;j++)
adlst.addr[i].ent[j]=ent[j];
for(j=0;j<16;j++)
adlst.addr[i].name[j]=name[j];
Server2::setEventRecord(12,addr,0);
*rb=0;
}
return S_OK;
}
STDMETHODIMP Crjinteface::removTab_add(short rfid, int lampno, short *rb)
{
// TODO: Add your implementation code here
int i;
i=0;
*rb=1;
while((i<manager.count)&&(manager.m[i].rfid!=rfid))
i++;
if((i>=manager.count)&&(i<500))
{
manager.m[i].rfid=rfid;
manager.m[i].lampno=lampno;
manager.count++;
*rb=0;
}
return S_OK;
}
STDMETHODIMP Crjinteface::removTab_del(short rfid, short *rb)
{
// TODO: Add your implementation code here
int i,j;
i=0;
*rb=1;
while((i<manager.count)&&(manager.m[i].rfid!=rfid))
i++;
if(i<manager.count)
{
for(j=i;j<manager.count;j++)
manager.m[j]=manager.m[j+1];
*rb=0;
}
return S_OK;
}
STDMETHODIMP Crjinteface::removTab_mod(short rfid, int lampno,short *rb)
{
// TODO: Add your implementation code here
int i;
i=0;
*rb=1;
while((i<manager.count)&&(manager.m[i].rfid!=rfid))
i++;
if(i<manager.count)
{
//manager.m[i].rfid=rfid;
manager.m[i].lampno=lampno;
manager.count--;
*rb=0;
}
return S_OK;
}
STDMETHODIMP Crjinteface::getrfidlamp(short wno, short *id, short *lamp, short *rb)
{
// TODO: Add your implementation code here
int i;
*rb=1;
for(i=0;i<prst.count;i++)
{
if(wno==prst.pl[i].workno)
{
*id=prst.pl[i].rfid;
*lamp=prst.pl[i].lampno;
*rb=0;
break;
}
}
return S_OK;
}
STDMETHODIMP Crjinteface::getRenoState(short *count, short *st)
{
// TODO: Add your implementation code here
int i;
int j;
short rno[400]={0};
short idx[400]={0};
for(i=0;i<rtinfo.count;i++)
{
rno[i]=rtinfo.st[i].reno;
idx[i]=i;
}
for(i=0;i<rtinfo.count-1;i++)
{
for(j=i+1;j<rtinfo.count;j++)
{
short tmp=0;
if(rno[i]>rno[j])
{
tmp=rno[i];
rno[i]=rno[j];
rno[j]=tmp;
tmp=idx[i];
idx[i]=idx[j];
idx[j]=tmp;
}
}
}
for(i=0;i<rtinfo.count;i++)
{
//st[i]=rtinfo.st[i].state;
//rtinfo.st[i].state=0;
st[i]=rtinfo.st[idx[i]].state;
rtinfo.st[idx[i]].state=0;
}
*count=rtinfo.count;
return S_OK;
}
STDMETHODIMP Crjinteface::checkup(short count, short *idno)
{
// TODO: Add your implementation code here
for(int i=0;i<count,i<200;i++)
chkup[i]=idno[i];
if(count>0) setRemotechkup(count);
chkct=count;
return S_OK;
}
LPWSTR Crjinteface::wszFromSTR(LPCTSTR szSTR)
{
#ifdef _UNICODE
return (LPWSTR)szSTR;
#else
gwszTemp[0] = '\0';
if(szSTR == NULL) return gwszTemp;
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
szSTR, -1,
gwszTemp, MAX_PATH);
return gwszTemp;
#endif
}
void Crjinteface::AnsiToUnicode(LPCSTR pszA, LPOLESTR* ppszW)
{
ULONG cCharacters;
DWORD dwError;
if (NULL == pszA)
{
*ppszW = NULL;
return ;
}
//分配ANSI stringByte 数量 2Byte
cCharacters = strlen(pszA)+1;
//申请内存
*ppszW = (LPOLESTR) CoTaskMemAlloc(cCharacters*2);
if ( *ppszW == NULL)
{
MessageBox(NULL,"内存溢出!","错误!",MB_OK);
return;
}
// 转换 to Unicode.
if (0 == MultiByteToWideChar(CP_ACP, 0, pszA, cCharacters,
*ppszW, cCharacters))
{
dwError = GetLastError();
CoTaskMemFree(*ppszW);
*ppszW = NULL;
}
}
void Crjinteface::setRemotechkup(short count)
{
DWORD dwR;
char clsidString[_MAX_PATH];
char path[_MAX_PATH];
UUID clsid;
HRESULT hr;
HKEY hCLSID;
// short rb;
Irjremote *gpIrmt;
Server1::unsigned_To_signed(otherpcname,path);
HKEY hk = HKEY_CLASSES_ROOT;
dwR = RegConnectRegistry (path, HKEY_CLASSES_ROOT, &hk);
//dwR = RegConnectRegistry ("\\\\cari_soft", HKEY_CLASSES_ROOT, &hk);
dwR = RegOpenKey(hk, "comserver.rjremote.1", &hCLSID );
RegCloseKey(hk);
if( dwR != ERROR_SUCCESS )
return ;
LONG size=260;
dwR = RegQueryValue(hCLSID, "CLSID", clsidString, &size );
if( dwR != ERROR_SUCCESS )
return ;
hr = CLSIDFromString( wszFromSTR(clsidString), &clsid );
if( FAILED(hr))
return ;
COSERVERINFO si;
MULTI_QI qi;
/* Caution COSERVERINFO struct is different in VC++ 4.0 and VC++ 5.0*/
si.pAuthInfo = NULL;
LPOLESTR swName;
AnsiToUnicode(path,&swName);
si.pwszName = swName;
si.dwReserved1 = 0;
si.dwReserved2 = 0;
qi.pIID = &IID_Irjremote;
qi.pItf = NULL;
qi.hr = 0;
hr = CoCreateInstanceEx(clsid, NULL, CLSCTX_REMOTE_SERVER, &si, 1, &qi);
switch(hr)
{
case CO_S_NOTALLINTERFACES:
break;
case E_NOINTERFACE:
break;
case S_OK:
break;
case E_INVALIDARG:
break;
}
if (FAILED(hr))
{
//szMsg.Format(_T("CoCreateInstanceEx for %s : \n"),
// szServerName);
//CCrack::ShowErrorMessage(szMsg, hr);
return ;
}
if (FAILED(qi.hr))
{
//szMsg.Format(_T("Failed to connect to server %s : \n"),
// szServerName);
//CCrack::ShowErrorMessage(szMsg, hr);
return ;
}
gpIrmt = (Irjremote*) qi.pItf;
gpIrmt->setchkUpPl(count,chkup);
gpIrmt->Release();
gpIrmt=NULL;
}
STDMETHODIMP Crjinteface::getDeptdown(LPSTR dept, short *count)
{
// TODO: Add your implementation code here
unsigned char dep[16];
//unsigned char ddep[10];
int i,j=0;
for(i=0;i<16;i++)
dep[i]=dept[i];
for(i=0;i<prst.count;i++)
{
//Server1::signed_To_unsigned(prst.pl[i].depart,ddep);
if(compname(dep,prst.pl[i].depart))
{
if(perstmb[prst.pl[i].rfid].entrytm!=0)
j++;
}
}
*count =j;
return S_OK;
}
bool Crjinteface::compname(unsigned char sdep[16], unsigned char ddep[16])
{
int i=0;
bool bl=0;
while((i<15)&&(sdep[i]==ddep[i]))
i++;
if(i<15)
return 0;
else
return 1;
}
STDMETHODIMP Crjinteface::getDepttrace(LPSTR dept, short *count, short *wno, short *idno, short *rno, DATE *dt, short *addrn)
{
// TODO: Add your implementation code here
unsigned char dep[16];
// unsigned char ddep[10];
int i,j=0;
for(i=0;i<16;i++)
dep[i]=dept[i];
for(i=0;i<rj_ct;i++)
{
//Server1::unsigned_To_signed(trclst[i].depart,ddep);
if(compname(dep,trclst[i].depart))
{
wno[j]=trclst[i].workno;
idno[j]=trclst[i].personID;
rno[j]=trclst[i].reno;
dt[j]=trclst[i].dt;
addrn[j]=trclst[i].addrno;
j++;
}
}
*count=j;
return S_OK;
}
STDMETHODIMP Crjinteface::getDeptuptj(LPSTR name, short *count, short *wno, short *idno, DATE *downdt, DATE *updt,short *dw_rno, short *up_rno,short *tag)
{
// TODO: Add your implementation code here
unsigned char dep[16];
//unsigned char ddep[10];
int i,j=0;
for(i=0;i<16;i++)
dep[i]=name[i];
for(i=0;i<upct;i++)
{
//Server1::unsigned_To_signed(uptjb[i].depart,ddep);
if(compname(dep,uptjb[i].depart))
{
wno[j]=uptjb[i].workno;
idno[j]=uptjb[i].personID;
downdt[j]=uptjb[i].downdtm;
updt[j]=uptjb[i].updtm;
dw_rno[j]=uptjb[i].dw_rno;
up_rno[j]=uptjb[i].up_rno;
tag[j]=uptjb[i].tag;
j++;
}
}
*count=j;
return S_OK;
}
STDMETHODIMP Crjinteface::getDeptRenotrace(LPSTR dept, short reno, short *count, short *wno, short *idno, DATE *dt)
{
// TODO: Add your implementation code here
unsigned char dep[16];
//unsigned char ddep[10];
int i,j=0;
for(i=0;i<16;i++)
dep[i]=dept[i];
for(i=0;i<rj_ct;i++)
{
// Server1::unsigned_To_signed(trclst[i].depart,ddep);
if((compname(dep,trclst[i].depart))&&(trclst[i].reno==reno))
{
wno[j]=trclst[i].workno;
idno[j]=trclst[i].personID;
dt[j]=trclst[i].dt;
j++;
}
}
*count=j;
return S_OK;
}
STDMETHODIMP Crjinteface::getDeptField(LPSTR dept, short addr, short *count, short *wno, short *idno, short *rno,DATE *dt)
{
// TODO: Add your implementation code here
unsigned char dep[16];
//unsigned char ddep[10];
int i,j=0;
for(i=0;i<16;i++)
dep[i]=dept[i];
for(i=0;i<prst.count;i++)
{
//Server1::unsigned_To_signed(prst.pl[i].depart,ddep);
if((compname(dep,prst.pl[i].depart))&&(perstmb[prst.pl[i].rfid].addrno==addr))
{
wno[j]=prst.pl[i].workno;
idno[j]=prst.pl[i].rfid;
dt[j]=perstmb[prst.pl[i].rfid].localtm;
rno[j]=perstmb[prst.pl[i].rfid].lastreno;
j++;
}
}
*count=j;
return S_OK;
}
STDMETHODIMP Server3::loadrjfile()
{
// TODO: Add your implementation code here
Server2::setEventRecord(11,0,0);
Server2::remote_read_File();
return S_OK;
}
STDMETHODIMP Server3::set_devPT(BYTE sensor, short pos, BYTE xing, LPSTR exp, short *rb)
{
// TODO: Add your implementation code here
int j,i=0;
*rb=0;
while((i<devpoint.count)&&(((devpoint.dv[i].sensor==sensor)&&(devpoint.dv[i].position!=pos))||devpoint.dv[i].sensor!=sensor))
i++;
devpoint.dv[i].sensor=sensor;
devpoint.dv[i].position=pos;
devpoint.dv[i].xing=xing;
for(j=0;j<80;j++)
devpoint.dv[i].exp[j]=exp[j];
if(i>=devpoint.count)
{
devpoint.count++;
*rb=1;
}
return S_OK;
}
STDMETHODIMP Server3::del_devPT(BYTE sensor, short pos, short *rb)
{
// TODO: Add your implementation code here
int j,i=0;
*rb=0;
while((i<devpoint.count)&&(!((devpoint.dv[i].sensor==sensor)&&(devpoint.dv[i].position==pos))))
i++;
if(i<devpoint.count)
{
for(j=i;j<devpoint.count;j++)
devpoint.dv[j]=devpoint.dv[j+1];
if(devpoint.count>0) devpoint.count--;
*rb=1;
}
return S_OK;
}
STDMETHODIMP Server3::procdrive()
{
// TODO: Add your implementation code here
int i,k,n,j;
float vl;
CEval exp;
CPrvString sexp;
char chexp[80];
for(i=0;i<devpoint.count;i++)
{
Server1::unsigned_To_signed(devpoint.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -