62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
#include "mainwindow.h"
|
||
#include "cmdwrd.h"
|
||
|
||
extern unsigned char HexBinFlag;
|
||
|
||
CommandWord::CommandWord()
|
||
{
|
||
DeviceAddress = 0;
|
||
K = 0;
|
||
SubAdd_CtrlMode = 0;
|
||
NumData_CmdCode = 0;
|
||
}
|
||
|
||
unsigned char CommandWord::AddressFind(int cmdw)
|
||
{
|
||
return (cmdw & 0x0000F800) >> 11;
|
||
}
|
||
|
||
unsigned char CommandWord::ResTranFind(int cmdw)
|
||
{
|
||
return (cmdw >> 10) & 1;
|
||
}
|
||
|
||
unsigned char CommandWord::SubadContrlModeFind(int cmdw)
|
||
{
|
||
return (cmdw & 0x000003E0) >> 5;
|
||
}
|
||
|
||
unsigned char CommandWord::NumDataWCodeCCFind(int cmdw)
|
||
{
|
||
return (cmdw & 0x0000001F) >> 0;
|
||
}
|
||
|
||
void CommandWord::description(QString CmdW)
|
||
{
|
||
int cmdw;
|
||
bool result;
|
||
|
||
if(HexBinFlag)
|
||
cmdw = CmdW.toInt(&result, 16);
|
||
else
|
||
cmdw = CmdW.toInt(&result, 2);
|
||
|
||
if(result == false)
|
||
QMessageBox::warning(0, "Ошибка", "Недопустимое значение КС");
|
||
else if((HexBinFlag == 0) && (CmdW.length() != 16))
|
||
QMessageBox::warning(0, "Ошибка", "Недопустимое значение КС");
|
||
else if((HexBinFlag == 1) && (CmdW.length() != 4))
|
||
QMessageBox::warning(0, "Ошибка", "Недопустимое значение КС");
|
||
else
|
||
{
|
||
DeviceAddress = AddressFind(cmdw);
|
||
K = ResTranFind(cmdw);
|
||
SubAdd_CtrlMode = SubadContrlModeFind(cmdw);
|
||
NumData_CmdCode = NumDataWCodeCCFind(cmdw);
|
||
}
|
||
}
|
||
|
||
CommandWord::~CommandWord()
|
||
{
|
||
}
|