📄 ybcommdevice.cpp
字号:
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetSyncEvents(bool b)
{
_bSyncEvents = b;
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::fGetInBufSize(void)
{
return _CommPort->InBufSize;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetInBufSize(long ibs)
{
_CommPort->InBufSize = ibs;
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::fGetOutBufSize(void)
{
return _CommPort->OutBufSize;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetOutBufSize(long obs)
{
_CommPort->OutBufSize = obs;
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::fGetHwInSize(void)
{
return _CommPort->HwInSize;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetHwInSize(long his)
{
_CommPort->HwInSize = his;
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::fGetHwOutSize(void)
{
return _CommPort->HwOutSize;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetHwOutSize(long hos)
{
_CommPort->HwOutSize = hos;
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::fGetDTR(void) //Computer status, read/write
{
return _CommPort->DTR;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetDTR(bool b) //Computer status, read/write
{
_CommPort->DTR = b;
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::fGetRTS(void) //Computer status, read/write
{
return _CommPort->RTS;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetRTS(bool b) //Computer status, read/write
{
_CommPort->RTS = b;
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::fGetCTS(void) //Modem status, read-only
{
return _CommPort->CTS;
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::fGetDSR(void) //Modem status, read-only
{
return _CommPort->DSR;
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::fGetRING(void) //Modem status, read-only
{
return _CommPort->RING;
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::fGetRLSD(void) //Modem status, read-only
{
return _CommPort->RLSD;
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::fGetQSize(void)
{
return _CommPackage->QueueSize;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetQSize(long qs)
{
_CommPackage->QueueSize = qs;
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::fGetPkgSz(void)
{
return _CommPackage->PackageSize;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetPkgSz(long ps)
{
_CommPackage->PackageSize = ps;
}
//---------------------------------------------------------------------------
TCommPackageType __fastcall TYbCustomCommDevice::fGetPkgType(void)
{
return _CommPackage->PackageType;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetPkgType(TCommPackageType pt)
{
_CommPackage->PackageType = pt;
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::fGetPkgInterval(void)
{
return _CommPackage->PackageInterval;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::fSetPkgInterval(long i)
{
_CommPackage->PackageInterval = i;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::_EvNotifyProc(Messages::TMessage &Message)
{
switch(Message.Msg)
{
case nmtCommMsg: EvCommNotify((TObject*)Message.WParam, Message.LParam); break;
case nmtPackage: EvPackageNotify((TObject*)Message.WParam, Message.LParam); break;
}
Message.Result = DefWindowProc(_hNotifyWindow, Message.Msg, Message.WParam, Message.LParam);
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::_EvComm(TObject *Sender, int NotifyType)
{
if(_bSyncEvents)
PostMessage(_hNotifyWindow, nmtCommMsg, (WPARAM)Sender, (LPARAM)NotifyType);
else
EvCommNotify(Sender, NotifyType);
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::_EvPackage(TObject *Sender, int NotifyType)
{
if(_bSyncEvents)
PostMessage(_hNotifyWindow, nmtPackage, (WPARAM)Sender, (LPARAM)NotifyType);
else
EvPackageNotify(Sender, NotifyType);
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::_EvAfterOpen(TObject *Sender)
{
EvAfterOpen(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::_EvBeforeClose(TObject *Sender)
{
EvBeforeClose(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::EvCommNotify(TObject *Sender, int NotifyType)
{
if(_lpfnCommNotify)
{
_lpfnCommNotify(this, NotifyType);
}
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::EvPackageNotify(TObject *Sender, int NotifyType)
{
if(_lpfnPackageNotify)
{
_lpfnPackageNotify(this, NotifyType);
}
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::EvAfterOpen(TObject *Sender)
{
if(_lpfnAfterOpen)
{
_lpfnAfterOpen(this);
}
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::EvBeforeClose(TObject *Sender)
{
if(_lpfnBeforeClose)
{
_lpfnBeforeClose(this);
}
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::Read(void far *s, long n)
{
if(_bUsePackage)
return _CommPackage->ReadPackage(s,n);
return _CommPort->Read(s,n);
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::Write(const void far *s, long n)
{
if(_bUsePackage)
return _CommPackage->WritePackage(s,n);
return _CommPort->Write(s,n);
}
//---------------------------------------------------------------------------
long __fastcall TYbCustomCommDevice::Command(const char far *s)
{
return _CommPort->Command(s);
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::ReadPackage(void *lpPkg)
{
return _CommPackage->ReadPackage(lpPkg,0)!=0;
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::WritePackage(const void *lpPkg)
{
return _CommPackage->WritePackage(lpPkg,0)!=0;
}
//---------------------------------------------------------------------------
unsigned long __fastcall TYbCustomCommDevice::ReadPackage(void *lpPkg, unsigned long BufSize)
{
return _CommPackage->ReadPackage(lpPkg, BufSize);
}
//---------------------------------------------------------------------------
unsigned long __fastcall TYbCustomCommDevice::WritePackage(const void *lpPkg, unsigned long nBytes)
{
return _CommPackage->WritePackage(lpPkg, nBytes);
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::PurgeRead(bool bAbort)
{
if(_bUsePackage)
_CommPackage->PurgeRead();
else
_CommPort->PurgeRead(bAbort);
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::PurgeWrite(bool bAbort)
{
if(_bUsePackage)
_CommPackage->PurgeWrite();
else
_CommPort->PurgeWrite(bAbort);
}
//---------------------------------------------------------------------------
bool __fastcall TYbCustomCommDevice::SettingsDialog(TComponent* AOwner, bool FActive)
{
TForm_YbCommDevice_Settings *FormSettings = new TForm_YbCommDevice_Settings(AOwner,this,FActive);
bool bOK = FormSettings->ShowModal() == IDOK;
delete FormSettings;
return bOK;
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::ResetModem(void)
{
_CommPort->ResetModem();
}
//---------------------------------------------------------------------------
void __fastcall TYbCustomCommDevice::InitModem(void)
{
_CommPort->InitModem();
}
//---------------------------------------------------------------------------
BOOL __fastcall TYbCustomCommDevice::EscapeCommFunction(DWORD dwFunc)
{
return _CommPort->EscapeCommFunction(dwFunc);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -