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

105 lines
2.2 KiB
C++
Raw 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 "reswrd.h"
extern unsigned char HexBinFlag;
ResponseWord::ResponseWord()
{
DeviceAddressR = 0;
ErrorInMsg = 0;
TransResW = 0;
SerReq = 0;
Reserve = 0;
GroupCmd = 0;
SubBusy = 0;
SubFailure = 0;
IntCtrlAccepted = 0;
DeviceFailure = 0;
}
unsigned char ResponseWord::DeviceAddressRFind(int resw)
{
return (resw & 0x0000F800) >> 11;
}
unsigned char ResponseWord::ErrorInMsgFind(int resw)
{
return (resw >> 10) & 1;
}
unsigned char ResponseWord::TransResWFind(int resw)
{
return (resw >> 9) & 1;
}
unsigned char ResponseWord::SerReqFind(int resw)
{
return (resw >> 8) & 1;
}
unsigned char ResponseWord::ReserveFind(int resw)
{
return (resw & 0x000000E0) >> 5;
}
unsigned char ResponseWord::GroupCmdFind(int resw)
{
return (resw >> 4) & 1;
}
unsigned char ResponseWord::SubBusyFind(int resw)
{
return (resw >> 3) & 1;
}
unsigned char ResponseWord::SubFailureFind(int resw)
{
return (resw >> 2) & 1;
}
unsigned char ResponseWord::IntCtrlAcceptedFind(int resw)
{
return (resw >> 1) & 1;
}
unsigned char ResponseWord::DeviceFailureFind(int resw)
{
return (resw >> 0) & 1;
}
void ResponseWord::description(QString ResW)
{
int resw;
bool result;
if(HexBinFlag)
resw = ResW.toInt(&result, 16);
else
resw = ResW.toInt(&result, 2);
if(result == false)
QMessageBox::warning(0, "Ошибка", "Недопустимое значение ОС");
else if((HexBinFlag == 0) && (ResW.length() != 16))
QMessageBox::warning(0, "Ошибка", "Недопустимое значение ОС");
else if((HexBinFlag == 1) && (ResW.length() != 4))
QMessageBox::warning(0, "Ошибка", "Недопустимое значение ОС");
else
{
DeviceAddressR = DeviceAddressRFind(resw);
ErrorInMsg = ErrorInMsgFind(resw);
TransResW = TransResWFind(resw);
SerReq = SerReqFind(resw);
Reserve = ReserveFind(resw);
GroupCmd = GroupCmdFind(resw);
SubBusy = SubBusyFind(resw);
SubFailure = SubFailureFind(resw);
IntCtrlAccepted = IntCtrlAcceptedFind(resw);
DeviceFailure = DeviceFailureFind(resw);
}
}
ResponseWord::~ResponseWord()
{
}