|
@@ -61,8 +61,19 @@ static std::list <tFrameMapping> arFrame;
|
|
|
|
|
|
static bool DecodeFrame(const char* strFrame, int length)
|
|
static bool DecodeFrame(const char* strFrame, int length)
|
|
{
|
|
{
|
|
|
|
+ // 添加安全检查
|
|
|
|
+ if (!strFrame || length <= 0) {
|
|
|
|
+ FERROR("DecodeFrame: Invalid parameters - strFrame={$}, length={$}", (void*)strFrame, length);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
auto pr = [strFrame, length](const tFrameMapping& Item)
|
|
auto pr = [strFrame, length](const tFrameMapping& Item)
|
|
{
|
|
{
|
|
|
|
+ // 边界检查:确保不会越界访问
|
|
|
|
+ if (Item.NbOfCharOfHead > length) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
for (int i = 0; i < Item.NbOfCharOfHead; i++)
|
|
for (int i = 0; i < Item.NbOfCharOfHead; i++)
|
|
{
|
|
{
|
|
if (strFrame[i] != Item.strHead[i])
|
|
if (strFrame[i] != Item.strHead[i])
|
|
@@ -129,15 +140,12 @@ nsGEN::PSGHRDevice::PSGHRDevice(std::shared_ptr <IOEventCenter> center, std::sha
|
|
: super(center)
|
|
: super(center)
|
|
, superGen()
|
|
, superGen()
|
|
, m_SCF(SCF)
|
|
, m_SCF(SCF)
|
|
- , m_bConnectFlag(false)
|
|
|
|
, HeartBeatFlag(false)
|
|
, HeartBeatFlag(false)
|
|
{
|
|
{
|
|
assert(EventCenter);
|
|
assert(EventCenter);
|
|
m_bExtraFlag = true;
|
|
m_bExtraFlag = true;
|
|
|
|
|
|
- //��ʼ��
|
|
|
|
m_bExpEnable = false;
|
|
m_bExpEnable = false;
|
|
- m_bConnectFlag = true;
|
|
|
|
m_iLoopTime.store(PSGHR_LoopDefHBTime);
|
|
m_iLoopTime.store(PSGHR_LoopDefHBTime);
|
|
for (int i = 0; i < 18; i++)
|
|
for (int i = 0; i < 18; i++)
|
|
{
|
|
{
|
|
@@ -151,7 +159,6 @@ nsGEN::PSGHRDevice::PSGHRDevice(std::shared_ptr <IOEventCenter> center, std::sha
|
|
FINFO("\n===============log begin : version:{$} ===================\n", version.c_str());
|
|
FINFO("\n===============log begin : version:{$} ===================\n", version.c_str());
|
|
//else
|
|
//else
|
|
FINFO("\n===============log begin : version:0.0.0.0 ===================\n");
|
|
FINFO("\n===============log begin : version:0.0.0.0 ===================\n");
|
|
- //���÷��������Լ��ϸ���ֵ�ķ�Χ������
|
|
|
|
m_DoseUnit.m_KV.reset(new KVMould(0.0, 39.0, 151.0, 1.0));
|
|
m_DoseUnit.m_KV.reset(new KVMould(0.0, 39.0, 151.0, 1.0));
|
|
m_DoseUnit.m_MA.reset(new MAMould(0.0, PSGHR_MIN_MA, PSGHR_MAX_MA, 0.1));
|
|
m_DoseUnit.m_MA.reset(new MAMould(0.0, PSGHR_MIN_MA, PSGHR_MAX_MA, 0.1));
|
|
m_DoseUnit.m_MS.reset(new MSMould(0.0, PSGHR_MIN_MS, PSGHR_MAX_MS, 0.01));
|
|
m_DoseUnit.m_MS.reset(new MSMould(0.0, PSGHR_MIN_MS, PSGHR_MAX_MS, 0.01));
|
|
@@ -193,19 +200,15 @@ nsGEN::PSGHRDevice::PSGHRDevice(std::shared_ptr <IOEventCenter> center, std::sha
|
|
m_DoseUnit.m_PostMA.reset(new POSTMAMould(0.0, 1.0, 1000.0, 0.1));
|
|
m_DoseUnit.m_PostMA.reset(new POSTMAMould(0.0, 1.0, 1000.0, 0.1));
|
|
m_DoseUnit.m_PostMS.reset(new POSTMSMould(0.0, 1.0, 10000.0, 0.01));
|
|
m_DoseUnit.m_PostMS.reset(new POSTMSMould(0.0, 1.0, 10000.0, 0.01));
|
|
m_DoseUnit.m_PostMAS.reset(new POSTMASMould(0.0, 0.5, 1000.0, 0.01));
|
|
m_DoseUnit.m_PostMAS.reset(new POSTMASMould(0.0, 0.5, 1000.0, 0.01));
|
|
- //�������澯��������Ϣ
|
|
|
|
m_MSGUnit.reset(new nsDetail::MSGUnit(center, nsGEN::GeneratorUnitType));
|
|
m_MSGUnit.reset(new nsDetail::MSGUnit(center, nsGEN::GeneratorUnitType));
|
|
|
|
|
|
m_hGenPostEvent = LinuxEvent::CreateEvent(LinuxEvent::MANUAL_RESET, false);
|
|
m_hGenPostEvent = LinuxEvent::CreateEvent(LinuxEvent::MANUAL_RESET, false);
|
|
|
|
|
|
- //������Ӧ�������ձ� ���������ش������ݴ�����Ӧ�IJ���
|
|
|
|
OnCallBack();
|
|
OnCallBack();
|
|
|
|
|
|
- //�����������Զ����ṩ��ָ��ע�Ἧ���в���
|
|
|
|
Register();
|
|
Register();
|
|
LoadConfig(configfile);
|
|
LoadConfig(configfile);
|
|
|
|
|
|
- //����Ӳ��״̬��ѯ����
|
|
|
|
StartHardwareStatusThread();
|
|
StartHardwareStatusThread();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -999,13 +1002,26 @@ void nsGEN::PSGHRDevice::ProcessClientData(const char* pData, unsigned long nDat
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHRDevice::HWSend(const char* strCommand,int lengh, bool reSend, int nTimeOut)
|
|
RET_STATUS nsGEN::PSGHRDevice::HWSend(const char* strCommand,int lengh, bool reSend, int nTimeOut)
|
|
{
|
|
{
|
|
- if (!m_bConnectFlag)
|
|
|
|
- {
|
|
|
|
- FERROR("==OUT==: not Connect, send failed \n");
|
|
|
|
|
|
+ if (!m_SCF) {
|
|
|
|
+ FINFO("Failed - Serial communication interface not initialized");
|
|
|
|
+ if (m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_SHUTDOWN))
|
|
|
|
+ {
|
|
|
|
+ FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
|
|
|
|
+ FINFO("Generator status updated to {$}", static_cast<int>(nsGEN::AttrKey::GENERATOR_STATUS_SHUTDOWN));
|
|
|
|
+ }
|
|
return RET_STATUS::RET_FAILED;
|
|
return RET_STATUS::RET_FAILED;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!m_SCF) return RET_STATUS::RET_FAILED;
|
|
|
|
|
|
+ if (!m_SCF->IsConnected())
|
|
|
|
+ {
|
|
|
|
+ FERROR("Failed - Device not connected");
|
|
|
|
+ if (m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_SHUTDOWN))
|
|
|
|
+ {
|
|
|
|
+ FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
|
|
|
|
+ FINFO("Generator status updated to {$}", static_cast<int>(nsGEN::AttrKey::GENERATOR_STATUS_SHUTDOWN));
|
|
|
|
+ }
|
|
|
|
+ return RET_STATUS::RET_FAILED;
|
|
|
|
+ }
|
|
|
|
|
|
// 使用传入的lengh参数,如果为0则用strlen计算
|
|
// 使用传入的lengh参数,如果为0则用strlen计算
|
|
int cmdLen = (lengh > 0) ? lengh : strlen(strCommand);
|
|
int cmdLen = (lengh > 0) ? lengh : strlen(strCommand);
|
|
@@ -1034,9 +1050,12 @@ RET_STATUS nsGEN::PSGHRDevice::HWSend(const char* strCommand,int lengh, bool reS
|
|
strSendCommand[cmdLen + 1] = checkSum;
|
|
strSendCommand[cmdLen + 1] = checkSum;
|
|
int totalLen = cmdLen + 2; // 实际发送的总长度
|
|
int totalLen = cmdLen + 2; // 实际发送的总长度
|
|
|
|
|
|
- // 打印完整数据包的十六进制(含ETX和CheckSum)便于调试
|
|
|
|
|
|
+ // 打印完整数据包的十六进制和ASCII(含ETX和CheckSum)便于调试
|
|
std::string hexStr;
|
|
std::string hexStr;
|
|
|
|
+ std::string asciiStr;
|
|
hexStr.reserve(totalLen * 3);
|
|
hexStr.reserve(totalLen * 3);
|
|
|
|
+ asciiStr.reserve(cmdLen + 10);
|
|
|
|
+
|
|
int printLen = std::min(totalLen, 32); // 最多打印前32字节
|
|
int printLen = std::min(totalLen, 32); // 最多打印前32字节
|
|
for (int i = 0; i < printLen; i++) {
|
|
for (int i = 0; i < printLen; i++) {
|
|
char buf[4];
|
|
char buf[4];
|
|
@@ -1044,7 +1063,19 @@ RET_STATUS nsGEN::PSGHRDevice::HWSend(const char* strCommand,int lengh, bool reS
|
|
hexStr += buf;
|
|
hexStr += buf;
|
|
}
|
|
}
|
|
if (totalLen > 32) hexStr += "...";
|
|
if (totalLen > 32) hexStr += "...";
|
|
- FINFO("==OUT== Packet[{$}]: {$}\n", totalLen, hexStr.c_str());
|
|
|
|
|
|
+
|
|
|
|
+ // 提取可打印的ASCII字符串(命令部分,不包括ETX和CheckSum)
|
|
|
|
+ for (int i = 0; i < cmdLen; i++) {
|
|
|
|
+ char ch = strCommand[i];
|
|
|
|
+ if (ch >= 32 && ch <= 126) { // 可打印字符
|
|
|
|
+ asciiStr += ch;
|
|
|
|
+ } else {
|
|
|
|
+ asciiStr += '.'; // 不可打印字符用'.'表示
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ asciiStr += " + ETX + CKS"; // 标注后面的控制字符
|
|
|
|
+
|
|
|
|
+ FINFO("==OUT== Packet[{$}]: HEX=[{$}] ASCII=[{$}]\n", totalLen, hexStr.c_str(), asciiStr.c_str());
|
|
|
|
|
|
// 发送数据包,支持重发机制
|
|
// 发送数据包,支持重发机制
|
|
int maxRetry = reSend ? 2 : 1; // 如果reSend为true,最多重试2次
|
|
int maxRetry = reSend ? 2 : 1; // 如果reSend为true,最多重试2次
|
|
@@ -1144,9 +1175,11 @@ void nsGEN::PSGHRDevice::FireWarnMessage(const bool Act, const int Code, const c
|
|
|
|
|
|
void nsGEN::PSGHRDevice::OnCallBack()
|
|
void nsGEN::PSGHRDevice::OnCallBack()
|
|
{
|
|
{
|
|
|
|
+ FINFO("=== OnCallBack: Start parsing device commands ===");
|
|
|
|
+
|
|
auto HWNotProcess = [](const char* value, int length) -> void
|
|
auto HWNotProcess = [](const char* value, int length) -> void
|
|
{
|
|
{
|
|
- FINFO("This commands[{$}] didn't need to process", value);
|
|
|
|
|
|
+ FINFO("Command [{$}] - No processing needed", value);
|
|
};
|
|
};
|
|
|
|
|
|
auto extractValue = [](const char* src, int start, int len, bool isInt = false) -> double {
|
|
auto extractValue = [](const char* src, int start, int len, bool isInt = false) -> double {
|
|
@@ -1157,8 +1190,8 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
|
|
|
|
auto HWKV = [this, extractValue](const char* value, int length) {
|
|
auto HWKV = [this, extractValue](const char* value, int length) {
|
|
assert(value);
|
|
assert(value);
|
|
- if (length > 20) {
|
|
|
|
- FINFO("value:{$}", value);
|
|
|
|
|
|
+ if (length > 20) {
|
|
|
|
+ FINFO("KV: Parsing combined exposure params: {$}", value);
|
|
|
|
|
|
int tmpkv = static_cast<int>(extractValue(value, 0, 3, true));
|
|
int tmpkv = static_cast<int>(extractValue(value, 0, 3, true));
|
|
float tmpma = static_cast<float>(extractValue(value, 6, 5)) / 10.0f;
|
|
float tmpma = static_cast<float>(extractValue(value, 6, 5)) / 10.0f;
|
|
@@ -1177,11 +1210,12 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
m_DoseUnit.m_MAS->Update(tmpmx);
|
|
m_DoseUnit.m_MAS->Update(tmpmx);
|
|
FireNotify(AttrKey::MAS, m_DoseUnit.m_MAS->JSGet());
|
|
FireNotify(AttrKey::MAS, m_DoseUnit.m_MAS->JSGet());
|
|
|
|
|
|
- FINFO("tmpkv={$}, tmpma={$}, tmpms={$}, tmpmx={$};", tmpkv, tmpma, tmpms, tmpmx);
|
|
|
|
|
|
+ FINFO("KV: Parsed - KV={$}, MA={$}, MS={$}, MAS={$}", tmpkv, tmpma, tmpms, tmpmx);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
if (m_DoseUnit.m_KV->Update(atof(value))) {
|
|
if (m_DoseUnit.m_KV->Update(atof(value))) {
|
|
FireNotify(AttrKey::KV, m_DoseUnit.m_KV->JSGet());
|
|
FireNotify(AttrKey::KV, m_DoseUnit.m_KV->JSGet());
|
|
|
|
+ FINFO("KV: Updated to {$}", value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -1192,6 +1226,7 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
float fmas = atof(value) / 100.0;
|
|
float fmas = atof(value) / 100.0;
|
|
m_DoseUnit.m_MAS->Update(fmas);
|
|
m_DoseUnit.m_MAS->Update(fmas);
|
|
FireNotify(AttrKey::MAS, m_DoseUnit.m_MAS->JSGet());
|
|
FireNotify(AttrKey::MAS, m_DoseUnit.m_MAS->JSGet());
|
|
|
|
+ FINFO("MAS: Updated to {$} mAs", fmas);
|
|
};
|
|
};
|
|
|
|
|
|
auto HWMA = [this](const char* value, int length)
|
|
auto HWMA = [this](const char* value, int length)
|
|
@@ -1200,6 +1235,7 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
float fma = atof(value) / 10.0;
|
|
float fma = atof(value) / 10.0;
|
|
m_DoseUnit.m_MA->Update(fma);
|
|
m_DoseUnit.m_MA->Update(fma);
|
|
FireNotify(AttrKey::MA, m_DoseUnit.m_MA->JSGet());
|
|
FireNotify(AttrKey::MA, m_DoseUnit.m_MA->JSGet());
|
|
|
|
+ FINFO("MA: Updated to {$} mA", fma);
|
|
};
|
|
};
|
|
|
|
|
|
auto HWMS = [this](const char* value, int length)
|
|
auto HWMS = [this](const char* value, int length)
|
|
@@ -1208,6 +1244,7 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
float fms = atof(value) / 100.0;
|
|
float fms = atof(value) / 100.0;
|
|
m_DoseUnit.m_MS->Update(fms);
|
|
m_DoseUnit.m_MS->Update(fms);
|
|
FireNotify(AttrKey::MS, m_DoseUnit.m_MS->JSGet());
|
|
FireNotify(AttrKey::MS, m_DoseUnit.m_MS->JSGet());
|
|
|
|
+ FINFO("MS: Updated to {$} ms", fms);
|
|
};
|
|
};
|
|
|
|
|
|
auto HWVP = [this](const char* value, int length)
|
|
auto HWVP = [this](const char* value, int length)
|
|
@@ -1311,18 +1348,18 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
int nValue = atoi(value);
|
|
int nValue = atoi(value);
|
|
if (nValue == 2)
|
|
if (nValue == 2)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ FINFO("PR: Received value 2 - No action");
|
|
}
|
|
}
|
|
else if (nValue == 1)
|
|
else if (nValue == 1)
|
|
{
|
|
{
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_PREPARE);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_PREPARE);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("PR: Radiography prepare state - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
else if (nValue == 0)
|
|
else if (nValue == 0)
|
|
{
|
|
{
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_OFF);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_OFF);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("PR: Radiography off state - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
m_bGenBusy = false;
|
|
m_bGenBusy = false;
|
|
RefreshData();
|
|
RefreshData();
|
|
@@ -1336,21 +1373,21 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
if (nValue == 2)
|
|
if (nValue == 2)
|
|
{
|
|
{
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_XRAYON);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_XRAYON);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("XR: X-Ray ON - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
else if (nValue == 1)
|
|
else if (nValue == 1)
|
|
{
|
|
{
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_READY);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_READY);
|
|
m_hGenPostEvent->ResetEvent();
|
|
m_hGenPostEvent->ResetEvent();
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("XR: Radiography ready - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
else if (nValue == 0)
|
|
else if (nValue == 0)
|
|
{
|
|
{
|
|
m_bGenBusy = false;
|
|
m_bGenBusy = false;
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_XRAYOFF);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_XRAYOFF);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("XR: X-Ray OFF - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -1399,28 +1436,24 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
auto HWFLK = [this](const char* value, int length) {
|
|
auto HWFLK = [this](const char* value, int length) {
|
|
assert(value);
|
|
assert(value);
|
|
|
|
|
|
- if (length > 20) { // ��������ʽ�ַ���: "040 FLM00010 FLI000 FLT000 FLF1 FLA0 FLS060 FLD0 FLO0 FLC1 FLW00400"
|
|
|
|
|
|
+ if (length > 20) { // "040 FLM00010 FLI000 FLT000 FLF1 FLA0 FLS060 FLD0 FLO0 FLC1 FLW00400"
|
|
FINFO("value:{$}", value);
|
|
FINFO("value:{$}", value);
|
|
|
|
|
|
int tmpflk, tmpflf, tmpfla, tmpfld, tmpflo;
|
|
int tmpflk, tmpflf, tmpfla, tmpfld, tmpflo;
|
|
float tmpflm, tmpfli, tmpflt, tmpfls, tmpflw;
|
|
float tmpflm, tmpfli, tmpflt, tmpfls, tmpflw;
|
|
|
|
|
|
- // ����ʽֱ����ȡ�����ֶΣ�%n��ȡ�Ѷ��ֽ���������У���ʽ��
|
|
|
|
int bytesRead;
|
|
int bytesRead;
|
|
const char* fmt = "%3d FLM%5f FLI%3f FLT%3f FLF%d FLA%d FLS%3f FLD%d FLO%d FLC%d FLW%5f%n";
|
|
const char* fmt = "%3d FLM%5f FLI%3f FLT%3f FLF%d FLA%d FLS%3f FLD%d FLO%d FLC%d FLW%5f%n";
|
|
int ret = sscanf(value, fmt,
|
|
int ret = sscanf(value, fmt,
|
|
- &tmpflk, &tmpflm, &tmpfli, &tmpflt, &tmpflf, &tmpfla, &tmpfls, &tmpfld, &tmpflo, /*FLCδʹ��*/nullptr, & tmpflw, & bytesRead);
|
|
|
|
|
|
+ &tmpflk, &tmpflm, &tmpfli, &tmpflt, &tmpflf, &tmpfla, &tmpfls, &tmpfld, &tmpflo, /*FLC*/nullptr, & tmpflw, & bytesRead);
|
|
|
|
|
|
- // У������Ƿ�ɹ�����ƥ��11���ֶ��Ҷ��������ַ�����
|
|
|
|
if (ret == 11 && bytesRead == length) {
|
|
if (ret == 11 && bytesRead == length) {
|
|
- // ͳһ������ֵת����ԭ���еij�����
|
|
|
|
tmpflm /= 10.0f;
|
|
tmpflm /= 10.0f;
|
|
tmpfli /= 10.0f;
|
|
tmpfli /= 10.0f;
|
|
tmpflt /= 10.0f;
|
|
tmpflt /= 10.0f;
|
|
tmpfls /= 10.0f;
|
|
tmpfls /= 10.0f;
|
|
tmpflw /= 100.0f;
|
|
tmpflw /= 100.0f;
|
|
|
|
|
|
- // ���²�֪ͨ������������
|
|
|
|
if (m_DoseUnit.m_FLKV->Update(tmpflk))
|
|
if (m_DoseUnit.m_FLKV->Update(tmpflk))
|
|
FireNotify(AttrKey::FLUKV, m_DoseUnit.m_FLKV->JSGet());
|
|
FireNotify(AttrKey::FLUKV, m_DoseUnit.m_FLKV->JSGet());
|
|
if (m_DoseUnit.m_FLMA->Update(tmpflm))
|
|
if (m_DoseUnit.m_FLMA->Update(tmpflm))
|
|
@@ -1450,7 +1483,6 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- // �̸�ʽ����
|
|
|
|
int tmpflkv = atoi(value);
|
|
int tmpflkv = atoi(value);
|
|
m_DoseUnit.m_FLKV->Update(tmpflkv);
|
|
m_DoseUnit.m_FLKV->Update(tmpflkv);
|
|
FireNotify(AttrKey::FLUKV, m_DoseUnit.m_FLKV->JSGet());
|
|
FireNotify(AttrKey::FLUKV, m_DoseUnit.m_FLKV->JSGet());
|
|
@@ -1513,18 +1545,18 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
if (nValue == 2)
|
|
if (nValue == 2)
|
|
{
|
|
{
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_XRAYON);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_XRAYON);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("FLX: Fluoroscopy X-Ray ON - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
else if (nValue == 1)
|
|
else if (nValue == 1)
|
|
{
|
|
{
|
|
- FINFO("Recv FLX1, do nothing");
|
|
|
|
|
|
+ FINFO("FLX: Received value 1 - No action");
|
|
}
|
|
}
|
|
else if (nValue == 0)
|
|
else if (nValue == 0)
|
|
{
|
|
{
|
|
m_bGenBusy = false;
|
|
m_bGenBusy = false;
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_XRAYOFF);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_XRAYOFF);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("FLX: Fluoroscopy X-Ray OFF - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -1536,25 +1568,25 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
if (nValue == 2)
|
|
if (nValue == 2)
|
|
{
|
|
{
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_READY);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_READY);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("FLP: Fluoroscopy ready - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
else if (nValue == 1)
|
|
else if (nValue == 1)
|
|
{
|
|
{
|
|
- FINFO("Recv FLP1, do nothing\n");
|
|
|
|
|
|
+ FINFO("FLP: Received value 1 - No action");
|
|
}
|
|
}
|
|
else if (nValue == 0)
|
|
else if (nValue == 0)
|
|
{
|
|
{
|
|
int nFlFMode = atoi(m_DoseUnit.m_FLMode->JSGet().c_str());
|
|
int nFlFMode = atoi(m_DoseUnit.m_FLMode->JSGet().c_str());
|
|
- FINFO("m_DoseUnit.m_FLMode={$}- number ={$};", m_DoseUnit.m_FLMode->JSGet().c_str(), nFlFMode);
|
|
|
|
|
|
+ FINFO("FLP: Fluoroscopy mode={$} (value={$})", m_DoseUnit.m_FLMode->JSGet().c_str(), nFlFMode);
|
|
if (nFlFMode == 2)
|
|
if (nFlFMode == 2)
|
|
{
|
|
{
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_XRAYOFF);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_XRAYOFF);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("FLP: Fluoroscopy X-Ray OFF - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
}
|
|
}
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_OFF);
|
|
m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_FLU_OFF);
|
|
- FINFO("m_DoseUnit.m_GenSynState={$};", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
|
|
|
+ FINFO("FLP: Fluoroscopy OFF - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
m_bGenBusy = false;
|
|
m_bGenBusy = false;
|
|
RefreshData();
|
|
RefreshData();
|
|
@@ -1600,6 +1632,7 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
tmpbuf[0] = value[0];
|
|
tmpbuf[0] = value[0];
|
|
tmpbuf[1] = value[1];
|
|
tmpbuf[1] = value[1];
|
|
tmpbuf[2] = value[2];
|
|
tmpbuf[2] = value[2];
|
|
|
|
+ FINFO("ER: Received error code {$}", tmpbuf);
|
|
if (nValue != 0)
|
|
if (nValue != 0)
|
|
{
|
|
{
|
|
std::unordered_map<std::string, std::string> errorMessages = {
|
|
std::unordered_map<std::string, std::string> errorMessages = {
|
|
@@ -1692,13 +1725,19 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
auto it = errorMessages.find(tmpbuf);
|
|
auto it = errorMessages.find(tmpbuf);
|
|
if (it != errorMessages.end())
|
|
if (it != errorMessages.end())
|
|
{
|
|
{
|
|
|
|
+ FINFO("ER: Warning - {$}: {$}", tmpbuf, it->second.c_str());
|
|
m_MSGUnit->AddWarnMessage(ErrorCode, level, it->second.c_str());
|
|
m_MSGUnit->AddWarnMessage(ErrorCode, level, it->second.c_str());
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ FINFO("ER: Unknown error code {$}", tmpbuf);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
int level = 1;
|
|
int level = 1;
|
|
- char ErrorCode[20];
|
|
|
|
|
|
+ char ErrorCode[20];
|
|
|
|
+ FINFO("ER: Error cleared");
|
|
m_MSGUnit->DelWarnMessage(ErrorCode, level, "");
|
|
m_MSGUnit->DelWarnMessage(ErrorCode, level, "");
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -1711,6 +1750,7 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
tmpbuf[0] = value[0];
|
|
tmpbuf[0] = value[0];
|
|
tmpbuf[1] = value[1];
|
|
tmpbuf[1] = value[1];
|
|
tmpbuf[2] = value[2];
|
|
tmpbuf[2] = value[2];
|
|
|
|
+ FINFO("EL: Received error level code {$}", tmpbuf);
|
|
if (nValue != 0)
|
|
if (nValue != 0)
|
|
{
|
|
{
|
|
std::unordered_map<std::string, std::string> errorMessages = {
|
|
std::unordered_map<std::string, std::string> errorMessages = {
|
|
@@ -1746,15 +1786,21 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
auto it = errorMessages.find(tmpbuf);
|
|
auto it = errorMessages.find(tmpbuf);
|
|
if (it != errorMessages.end())
|
|
if (it != errorMessages.end())
|
|
{
|
|
{
|
|
|
|
+ FINFO("EL: Critical error - {$}: {$}", tmpbuf, it->second.c_str());
|
|
m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_ERROR);
|
|
m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_ERROR);
|
|
FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
|
|
FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
|
|
m_MSGUnit->AddErrorMessage(ErrorCode, level, it->second.c_str());
|
|
m_MSGUnit->AddErrorMessage(ErrorCode, level, it->second.c_str());
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ FINFO("EL: Unknown error level code {$}", tmpbuf);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
int level = 1;
|
|
int level = 1;
|
|
char ErrorCode[20];
|
|
char ErrorCode[20];
|
|
|
|
+ FINFO("EL: Error level cleared");
|
|
m_MSGUnit->DelErrorMessage(ErrorCode, level, "");
|
|
m_MSGUnit->DelErrorMessage(ErrorCode, level, "");
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -2154,8 +2200,8 @@ void nsGEN::PSGHRDevice::OnCallBack()
|
|
arFrame.push_back(tFrameMapping("DS", 2, HWDS));
|
|
arFrame.push_back(tFrameMapping("DS", 2, HWDS));
|
|
arFrame.push_back(tFrameMapping("ST", 2, HWST));
|
|
arFrame.push_back(tFrameMapping("ST", 2, HWST));
|
|
arFrame.push_back(tFrameMapping("SR", 2, HWSR));
|
|
arFrame.push_back(tFrameMapping("SR", 2, HWSR));
|
|
- arFrame.push_back(tFrameMapping("P", 1, HWPR));
|
|
|
|
|
|
|
|
|
|
+ FINFO("=== OnCallBack: Command mapping initialized ({$} commands) ===", arFrame.size());
|
|
}
|
|
}
|
|
|
|
|
|
bool nsGEN::PSGHRDevice::ReConnect()
|
|
bool nsGEN::PSGHRDevice::ReConnect()
|
|
@@ -2168,7 +2214,6 @@ bool nsGEN::PSGHRDevice::ReConnect()
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- // ��Ҫ�� pIODriver ת��Ϊ PSGHRDriver*
|
|
|
|
PSGHRDriver* driver = dynamic_cast<PSGHRDriver*>(pIODriver.get());
|
|
PSGHRDriver* driver = dynamic_cast<PSGHRDriver*>(pIODriver.get());
|
|
if (driver && driver->ReConnection())
|
|
if (driver && driver->ReConnection())
|
|
{
|
|
{
|
|
@@ -2607,7 +2652,7 @@ bool nsGEN::PSGHRDriver::isConnected() const
|
|
|
|
|
|
// 1. 连接中/实际已连接:返回true(无需重连)
|
|
// 1. 连接中/实际已连接:返回true(无需重连)
|
|
if (state == ConnectionState::Connecting || (m_scfWrapper && m_scfWrapper->IsConnected())) {
|
|
if (state == ConnectionState::Connecting || (m_scfWrapper && m_scfWrapper->IsConnected())) {
|
|
- FINFO(state == ConnectionState::Connecting ? "Connecting in progress" : "Already connected");
|
|
|
|
|
|
+ //FINFO(state == ConnectionState::Connecting ? "Connecting in progress" : "Already connected");
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2886,7 +2931,7 @@ PACKET_RET nsGEN::PSGHRDriver::callbackPackageProcess(const char* RecData, uint3
|
|
char strtemp[100] = { 0 };
|
|
char strtemp[100] = { 0 };
|
|
memcpy(strtemp, RecData, i);
|
|
memcpy(strtemp, RecData, i);
|
|
strtemp[PacketLength + 1] = 0;
|
|
strtemp[PacketLength + 1] = 0;
|
|
- FINFO("==IN==:{$}\n", strtemp);
|
|
|
|
|
|
+ //FINFO("==IN==:{$}\n", strtemp);
|
|
return PACKET_ISPACKET;
|
|
return PACKET_ISPACKET;
|
|
}
|
|
}
|
|
}
|
|
}
|