first version.

This commit is contained in:
2025-07-23 12:34:16 +03:00
commit 1c10abd24b
10 changed files with 697 additions and 0 deletions

61
cmdwrd.cpp Normal file
View File

@@ -0,0 +1,61 @@
#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()
{
}