Files
novikova/cmdwrd.cpp
2025-07-23 12:34:16 +03:00

62 lines
1.4 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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()
{
}