|
@@ -3,11 +3,15 @@
|
|
|
#include <assert.h>
|
|
|
#include <functional>
|
|
|
#include <unordered_map>
|
|
|
-#include <fstream>
|
|
|
+#include <fstream>
|
|
|
+#include <sstream>
|
|
|
+#include <iomanip>
|
|
|
#include <cmath>
|
|
|
+#include <cfloat>
|
|
|
#include <climits>
|
|
|
#include <unordered_set>
|
|
|
#include <algorithm>
|
|
|
+#include <vector>
|
|
|
#include "LogicDevice.h"
|
|
|
using namespace std::placeholders;
|
|
|
#include "LogLocalHelper.h"
|
|
@@ -81,7 +85,7 @@ static std::list <tFrameMapping> arFrame;
|
|
|
|
|
|
static bool DecodeFrame(const char* data, int len) {
|
|
|
if (!data || len < 8) {
|
|
|
- FINFO("DecodeFrame: Invalid input");
|
|
|
+ FINFO("Invalid input");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -91,7 +95,7 @@ static bool DecodeFrame(const char* data, int len) {
|
|
|
while (pos < len) {
|
|
|
while (pos < len && (uint8_t)data[pos] != STX) pos++;
|
|
|
if (pos >= len) {
|
|
|
- FINFO("DecodeFrame: No STX found");
|
|
|
+ FINFO("No STX found");
|
|
|
break;
|
|
|
}
|
|
|
int start = pos;
|
|
@@ -104,7 +108,16 @@ static bool DecodeFrame(const char* data, int len) {
|
|
|
}
|
|
|
}
|
|
|
if (end == -1) {
|
|
|
- FINFO("DecodeFrame: Incomplete cmd (no CRLF)");
|
|
|
+ // 打印不完整的命令内容
|
|
|
+ int incompleteLen = len - start;
|
|
|
+ std::string incompleteCmd(data + start, incompleteLen);
|
|
|
+ std::stringstream hexStr;
|
|
|
+ hexStr << "Incomplete cmd (hex): ";
|
|
|
+ for (int i = 0; i < incompleteLen; i++) {
|
|
|
+ hexStr << std::hex << std::setw(2) << std::setfill('0')
|
|
|
+ << (int)(uint8_t)data[start + i] << " ";
|
|
|
+ }
|
|
|
+ FINFO("Incomplete cmd (no CRLF), content: [{$}], {$}", incompleteCmd, hexStr.str());
|
|
|
break;
|
|
|
}
|
|
|
int cmdLen = end - start + 1;
|
|
@@ -130,12 +143,23 @@ static bool DecodeFrame(const char* data, int len) {
|
|
|
}
|
|
|
if (argEnd > argStart) {
|
|
|
it->fun(data + argStart, argEnd - argStart);
|
|
|
- FINFO("DecodeFrame: Parsed cmd: [{$}], ARG len: {$}", it->strHead, argEnd - argStart);
|
|
|
+ FINFO("Parsed cmd: [{$}], ARG len: {$}", it->strHead, argEnd - argStart);
|
|
|
hasValid = true;
|
|
|
}
|
|
|
- else FINFO("DecodeFrame: Cmd missing ';'");
|
|
|
+ else FINFO("Cmd missing ';'");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 打印不符合协议的字段内容
|
|
|
+ std::string unknownCmd(data + start, cmdLen);
|
|
|
+ // 将不可打印字符转换为十六进制显示
|
|
|
+ std::stringstream hexStr;
|
|
|
+ hexStr << "Unknown field (hex): ";
|
|
|
+ for (int i = 0; i < cmdLen; i++) {
|
|
|
+ hexStr << std::hex << std::setw(2) << std::setfill('0')
|
|
|
+ << (int)(uint8_t)data[start + i] << " ";
|
|
|
+ }
|
|
|
+ FINFO("No matching header, content: [{$}], {$}", unknownCmd, hexStr.str());
|
|
|
}
|
|
|
- else FINFO("DecodeFrame: No matching header");
|
|
|
|
|
|
pos = end + 1; // Next cmd start
|
|
|
}
|
|
@@ -273,21 +297,25 @@ void nsGEN::PSGHDDevice::Register()
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::IncKV()
|
|
|
{
|
|
|
- FINFO("Enter PSGHDDevice::IncKV()\n");
|
|
|
+ FINFO("IncKV called, current value: {$}", m_DoseUnit.m_KV->Get());
|
|
|
if (!m_DoseUnit.m_KV->CanInc()) return RET_STATUS::RET_SUCCEED;
|
|
|
m_DoseUnit.m_KV->Inc();
|
|
|
+ FINFO("IncKV: new value: {$}", m_DoseUnit.m_KV->Get());
|
|
|
return SetKV(m_DoseUnit.m_KV->Get());
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::DecKV()
|
|
|
{
|
|
|
+ FINFO("DecKV called, current value: {$}", m_DoseUnit.m_KV->Get());
|
|
|
if (!m_DoseUnit.m_KV->CanDec()) return RET_STATUS::RET_SUCCEED;
|
|
|
m_DoseUnit.m_KV->Dec();
|
|
|
+ FINFO("DecKV: new value: {$}", m_DoseUnit.m_KV->Get());
|
|
|
return SetKV(m_DoseUnit.m_KV->Get());
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetKV(float value)
|
|
|
{
|
|
|
+ FINFO("SetKV called with value: {$}", value);
|
|
|
if (!m_DoseUnit.m_KV->Verify(value)) return RET_STATUS::RET_SUCCEED;
|
|
|
|
|
|
char temp[50] = { 0 };
|
|
@@ -300,6 +328,7 @@ RET_STATUS nsGEN::PSGHDDevice::SetKV(float value)
|
|
|
RET_STATUS nsGEN::PSGHDDevice::IncMA()
|
|
|
{
|
|
|
float currentMA = m_DoseUnit.m_MA->Get();
|
|
|
+ FINFO("IncMA called, current value: {$}", currentMA);
|
|
|
|
|
|
// 查找当前值在档位中的位置
|
|
|
size_t currentIndex = maStepCount;
|
|
@@ -311,15 +340,18 @@ RET_STATUS nsGEN::PSGHDDevice::IncMA()
|
|
|
}
|
|
|
|
|
|
if (currentIndex >= maStepCount - 1) {
|
|
|
+ FINFO("IncMA: already at maximum");
|
|
|
return RET_STATUS::RET_SUCCEED; // 已经是最大值
|
|
|
}
|
|
|
|
|
|
+ FINFO("IncMA: new value: {$}", maSteps[currentIndex + 1]);
|
|
|
return SetMA(maSteps[currentIndex + 1]);
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::DecMA()
|
|
|
{
|
|
|
float currentMA = m_DoseUnit.m_MA->Get();
|
|
|
+ FINFO("DecMA called, current value: {$}", currentMA);
|
|
|
|
|
|
// 查找当前值在档位中的位置
|
|
|
size_t currentIndex = maStepCount;
|
|
@@ -331,14 +363,17 @@ RET_STATUS nsGEN::PSGHDDevice::DecMA()
|
|
|
}
|
|
|
|
|
|
if (currentIndex == 0 || currentIndex >= maStepCount) {
|
|
|
+ FINFO("DecMA: already at minimum or invalid");
|
|
|
return RET_STATUS::RET_SUCCEED; // 已经是最小值或无效值
|
|
|
}
|
|
|
|
|
|
+ FINFO("DecMA: new value: {$}", maSteps[currentIndex - 1]);
|
|
|
return SetMA(maSteps[currentIndex - 1]);
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetMA(float value)
|
|
|
{
|
|
|
+ FINFO("SetMA called with value: {$}", value);
|
|
|
// 找到最接近的合法档位值
|
|
|
size_t closestIndex = 0;
|
|
|
float minDiff = fabsf(maSteps[0] - value);
|
|
@@ -354,12 +389,14 @@ RET_STATUS nsGEN::PSGHDDevice::SetMA(float value)
|
|
|
// 转换为协议单位并发送命令
|
|
|
char command[50] = { 0 };
|
|
|
snprintf(command, sizeof(command), "IREF %04d", (int)(maSteps[closestIndex] * 100));
|
|
|
+ FINFO("SetMA: closest valid value: {$}", maSteps[closestIndex]);
|
|
|
return HWSend(command, strlen(command));
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::IncMS()
|
|
|
{
|
|
|
float currentMS = m_DoseUnit.m_MS->Get();
|
|
|
+ FINFO("IncMS called, current value: {$}", currentMS);
|
|
|
|
|
|
// 查找当前值在档位中的位置
|
|
|
size_t currentIndex = msStepCount;
|
|
@@ -371,15 +408,18 @@ RET_STATUS nsGEN::PSGHDDevice::IncMS()
|
|
|
}
|
|
|
|
|
|
if (currentIndex >= msStepCount - 1) {
|
|
|
+ FINFO("IncMS: already at maximum");
|
|
|
return RET_STATUS::RET_SUCCEED; // 已经是最大值
|
|
|
}
|
|
|
|
|
|
+ FINFO("IncMS: new value: {$}", msSteps[currentIndex + 1]);
|
|
|
return SetMS(msSteps[currentIndex + 1]);
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::DecMS()
|
|
|
{
|
|
|
float currentMS = m_DoseUnit.m_MS->Get();
|
|
|
+ FINFO("DecMS called, current value: {$}", currentMS);
|
|
|
|
|
|
// 查找当前值在档位中的位置
|
|
|
size_t currentIndex = msStepCount;
|
|
@@ -391,14 +431,17 @@ RET_STATUS nsGEN::PSGHDDevice::DecMS()
|
|
|
}
|
|
|
|
|
|
if (currentIndex == 0 || currentIndex >= msStepCount) {
|
|
|
+ FINFO("DecMS: already at minimum or invalid");
|
|
|
return RET_STATUS::RET_SUCCEED; // 已经是最小值或无效值
|
|
|
}
|
|
|
|
|
|
+ FINFO("DecMS: new value: {$}", msSteps[currentIndex - 1]);
|
|
|
return SetMS(msSteps[currentIndex - 1]);
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetMS(float value)
|
|
|
{
|
|
|
+ FINFO("SetMS called with value: {$}", value);
|
|
|
// 找到最接近的合法档位值
|
|
|
size_t closestIndex = 0;
|
|
|
float minDiff = fabsf(msSteps[0] - value);
|
|
@@ -414,31 +457,170 @@ RET_STATUS nsGEN::PSGHDDevice::SetMS(float value)
|
|
|
// 发送命令
|
|
|
char command[50] = { 0 };
|
|
|
snprintf(command, sizeof(command), "SMS %07d", static_cast<int>(msSteps[closestIndex] * 100));
|
|
|
+ FINFO("SetMS: closest valid value: {$}", msSteps[closestIndex]);
|
|
|
return HWSend(command, strlen(command));
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::IncMAS()
|
|
|
{
|
|
|
- return RET_STATUS::RET_SUCCEED;
|
|
|
+ // 获取当前MA和MS值,计算当前MAS
|
|
|
+ float currentMA = m_DoseUnit.m_MA->Get();
|
|
|
+ float currentMS = m_DoseUnit.m_MS->Get();
|
|
|
+ float currentMAS = currentMA * currentMS / 1000.0f;
|
|
|
+ FINFO("IncMAS called, current MAS: {$} (MA={$}, MS={$})", currentMAS, currentMA, currentMS);
|
|
|
+
|
|
|
+ // 生成所有可能的MAS值并排序
|
|
|
+ std::vector<float> possibleMAS;
|
|
|
+ for (size_t i = 0; i < maStepCount; ++i) {
|
|
|
+ for (size_t j = 0; j < msStepCount; ++j) {
|
|
|
+ float mas = maSteps[i] * msSteps[j] / 1000.0f;
|
|
|
+ possibleMAS.push_back(mas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 排序并去重
|
|
|
+ std::sort(possibleMAS.begin(), possibleMAS.end());
|
|
|
+ possibleMAS.erase(std::unique(possibleMAS.begin(), possibleMAS.end(),
|
|
|
+ [](float a, float b) { return fabsf(a - b) < 1e-6f; }), possibleMAS.end());
|
|
|
+
|
|
|
+ // 找到比当前值大的最小MAS值
|
|
|
+ for (size_t i = 0; i < possibleMAS.size(); ++i) {
|
|
|
+ if (possibleMAS[i] > currentMAS + 1e-6f) {
|
|
|
+ FINFO("IncMAS: new MAS: {$}", possibleMAS[i]);
|
|
|
+ return SetMAS(possibleMAS[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FINFO("IncMAS: already at maximum");
|
|
|
+ return RET_STATUS::RET_SUCCEED; // 已经是最大值
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::DecMAS()
|
|
|
{
|
|
|
- return RET_STATUS::RET_SUCCEED;
|
|
|
+ // 获取当前MA和MS值,计算当前MAS
|
|
|
+ float currentMA = m_DoseUnit.m_MA->Get();
|
|
|
+ float currentMS = m_DoseUnit.m_MS->Get();
|
|
|
+ float currentMAS = currentMA * currentMS / 1000.0f;
|
|
|
+ FINFO("DecMAS called, current MAS: {$} (MA={$}, MS={$})", currentMAS, currentMA, currentMS);
|
|
|
+
|
|
|
+ // 生成所有可能的MAS值并排序
|
|
|
+ std::vector<float> possibleMAS;
|
|
|
+ for (size_t i = 0; i < maStepCount; ++i) {
|
|
|
+ for (size_t j = 0; j < msStepCount; ++j) {
|
|
|
+ float mas = maSteps[i] * msSteps[j] / 1000.0f;
|
|
|
+ possibleMAS.push_back(mas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 排序并去重
|
|
|
+ std::sort(possibleMAS.begin(), possibleMAS.end());
|
|
|
+ possibleMAS.erase(std::unique(possibleMAS.begin(), possibleMAS.end(),
|
|
|
+ [](float a, float b) { return fabsf(a - b) < 1e-6f; }), possibleMAS.end());
|
|
|
+
|
|
|
+ // 找到比当前值小的最大MAS值(从后往前找)
|
|
|
+ for (int i = possibleMAS.size() - 1; i >= 0; --i) {
|
|
|
+ if (possibleMAS[i] < currentMAS - 1e-6f) {
|
|
|
+ FINFO("DecMAS: new MAS: {$}", possibleMAS[i]);
|
|
|
+ return SetMAS(possibleMAS[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FINFO("DecMAS: already at minimum");
|
|
|
+ return RET_STATUS::RET_SUCCEED; // 已经是最小值
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetMAS(float value)
|
|
|
{
|
|
|
+ FINFO("SetMAS called with value: {$}", value);
|
|
|
+ // MAS = MA * MS / 1000.0
|
|
|
+ // 需要找到最合适的MA和MS组合来达到目标MAS值
|
|
|
+ if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
|
|
|
+ m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
|
|
|
+ {
|
|
|
+ FINFO("Techmode is 3Point, Cannot set MAS \n");
|
|
|
+ return RET_STATUS::RET_FAILED;
|
|
|
+ }
|
|
|
+ float targetMAS = value;
|
|
|
+ float bestMA = maSteps[0];
|
|
|
+ float bestMS = msSteps[0];
|
|
|
+ float minError = FLT_MAX;
|
|
|
+
|
|
|
+ // 遍历所有可能的MA和MS组合,找到最接近目标MAS的组合
|
|
|
+ for (size_t i = 0; i < maStepCount; ++i) {
|
|
|
+ for (size_t j = 0; j < msStepCount; ++j) {
|
|
|
+ float calculatedMAS = maSteps[i] * msSteps[j] / 1000.0f;
|
|
|
+ float error = fabsf(calculatedMAS - targetMAS);
|
|
|
+
|
|
|
+ if (error < minError) {
|
|
|
+ minError = error;
|
|
|
+ bestMA = maSteps[i];
|
|
|
+ bestMS = msSteps[j];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FINFO("SetMAS: calculated best MA={$}, MS={$}, actual MAS={$}", bestMA, bestMS, bestMA * bestMS / 1000.0f);
|
|
|
+
|
|
|
+ // 依次设置MA和MS
|
|
|
+ RET_STATUS ret = SetMA(bestMA);
|
|
|
+ if (ret != RET_STATUS::RET_SUCCEED) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = SetMS(bestMS);
|
|
|
+ if (ret != RET_STATUS::RET_SUCCEED) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ //// 更新MAS值
|
|
|
+ //float actualMAS = bestMA * bestMS / 1000.0f;
|
|
|
+ //m_DoseUnit.m_MAS->Update(actualMAS);
|
|
|
+
|
|
|
return RET_STATUS::RET_SUCCEED;
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetTechmode(int value)
|
|
|
{
|
|
|
+ FINFO("SetTechmode called with value: {$}", value);
|
|
|
+ if (!m_DoseUnit.m_Techmode->Verify(value)) return RET_STATUS::RET_SUCCEED;
|
|
|
+ m_DoseUnit.m_Techmode->Update(value);
|
|
|
+ FireNotify(m_DoseUnit.m_Techmode->GetKey(), m_DoseUnit.m_Techmode->JSGet());
|
|
|
+ switch (value)
|
|
|
+ {
|
|
|
+ case AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P:
|
|
|
+ {
|
|
|
+ FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
|
|
|
+ FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P:
|
|
|
+ {
|
|
|
+ FireNotify(m_DoseUnit.m_MA->GetKey(), "0");
|
|
|
+ FireNotify(m_DoseUnit.m_MS->GetKey(), "0");
|
|
|
+ FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P:
|
|
|
+ {
|
|
|
+ FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
|
|
|
+ FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P:
|
|
|
+ {
|
|
|
+ FireNotify(m_DoseUnit.m_MA->GetKey(), "0");
|
|
|
+ FireNotify(m_DoseUnit.m_MS->GetKey(), "0");
|
|
|
+ FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
return RET_STATUS::RET_SUCCEED;
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetEXAMMode(std::string value)
|
|
|
{
|
|
|
+ FINFO("SetEXAMMode called with value: {$}", value);
|
|
|
return RET_STATUS::RET_SUCCEED;
|
|
|
}
|
|
|
|
|
@@ -449,9 +631,44 @@ RET_STATUS nsGEN::PSGHDDevice::SetAPR(const _tAPRArgs& t)
|
|
|
|
|
|
SetKV(t.fKV);
|
|
|
Sleep(50);
|
|
|
- SetMA(t.fMA);
|
|
|
- Sleep(80);
|
|
|
- SetMS(t.fMS);
|
|
|
+ if (t.nTechmode == AttrKey::TECHMODE_V2TYPE::ET_AEC)
|
|
|
+ {
|
|
|
+ // aec
|
|
|
+ m_DoseUnit.m_Techmode->Update(t.nTechmode);
|
|
|
+ FireNotify(m_DoseUnit.m_Techmode->GetKey(), m_DoseUnit.m_Techmode->JSGet());
|
|
|
+ Sleep(50);
|
|
|
+ SetMA(t.fMA);
|
|
|
+ Sleep(50);
|
|
|
+ SetMS(t.fMS);
|
|
|
+ }
|
|
|
+ else if (t.nTechmode == AttrKey::TECHMODE_V2TYPE::ET_MAS)
|
|
|
+ {
|
|
|
+ // mas
|
|
|
+ m_DoseUnit.m_Techmode->Update(t.nTechmode);
|
|
|
+ FireNotify(m_DoseUnit.m_Techmode->GetKey(), m_DoseUnit.m_Techmode->JSGet());
|
|
|
+ Sleep(50);
|
|
|
+
|
|
|
+ const float EPSINON = 0.000001;
|
|
|
+
|
|
|
+ if ((t.fMAS >= -EPSINON) && (t.fMAS <= EPSINON))
|
|
|
+ {
|
|
|
+ SetMAS(t.fMA * t.fMS / 1000);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SetMAS(t.fMAS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (t.nTechmode == AttrKey::TECHMODE_V2TYPE::ET_TIME)
|
|
|
+ {
|
|
|
+ // time
|
|
|
+ m_DoseUnit.m_Techmode->Update(t.nTechmode);
|
|
|
+ FireNotify(m_DoseUnit.m_Techmode->GetKey(), m_DoseUnit.m_Techmode->JSGet());
|
|
|
+ Sleep(50);
|
|
|
+ SetMA(t.fMA);
|
|
|
+ Sleep(80);
|
|
|
+ SetMS(t.fMS);
|
|
|
+ }
|
|
|
|
|
|
m_bGenBusy = false;
|
|
|
return RET_STATUS::RET_SUCCEED;
|
|
@@ -467,6 +684,7 @@ RET_STATUS nsGEN::PSGHDDevice::RefreshData()
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetFocus(int value)
|
|
|
{
|
|
|
+ FINFO("SetFocus called with value: {$}", value);
|
|
|
if (!m_DoseUnit.m_Focus->Verify(value)) return RET_STATUS::RET_SUCCEED;
|
|
|
|
|
|
return RET_STATUS::RET_SUCCEED;
|
|
@@ -501,6 +719,7 @@ RET_STATUS nsGEN::PSGHDDevice::SetCollimatorLight(unsigned short value)
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetDeviceSleepState(const int value)
|
|
|
{
|
|
|
+ FINFO("SetDeviceSleepState called with value: {$}", value);
|
|
|
m_bSleepState = (bool)value;
|
|
|
FINFO("Attempting to set device sleep state: {$}({$})",
|
|
|
value, m_bSleepState ? "sleeping" : "awake");
|
|
@@ -518,8 +737,9 @@ void nsGEN::PSGHDDevice::SubscribeSelf(ccos_mqtt_connection* conn)
|
|
|
//SubscribeTopic(conn, "CCOS/DEVICE/Generator/Action/#"); Moduld层默认订阅了这个Action,如果这边也订阅的话就会执行两遍Action,可能会出问题
|
|
|
}
|
|
|
|
|
|
-RET_STATUS nsGEN::PSGHDDevice::SetAECDensity(int value)
|
|
|
+RET_STATUS nsGEN::PSGHDDevice::SetAECDensity(int value)
|
|
|
{
|
|
|
+ FINFO("SetAECDensity called with value: {$}", value);
|
|
|
if (!m_DoseUnit.m_AECDensity->Verify(value)) return RET_STATUS::RET_SUCCEED;
|
|
|
if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_V2TYPE::ET_AEC) return RET_STATUS::RET_FAILED;
|
|
|
|
|
@@ -561,8 +781,9 @@ RET_STATUS nsGEN::PSGHDDevice::SetAECDensity(int value)
|
|
|
|
|
|
return HWSend(temp, strlen(temp));
|
|
|
}
|
|
|
-RET_STATUS nsGEN::PSGHDDevice::SetAECField(int value)
|
|
|
+RET_STATUS nsGEN::PSGHDDevice::SetAECField(int value)
|
|
|
{
|
|
|
+ FINFO("SetAECField called with value: {$}", value);
|
|
|
if (!m_DoseUnit.m_AECField->Verify(value)) return RET_STATUS::RET_SUCCEED;
|
|
|
if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_V2TYPE::ET_MAS) return RET_STATUS::RET_FAILED;
|
|
|
m_DoseUnit.m_AECField->Update(value);
|
|
@@ -572,6 +793,7 @@ RET_STATUS nsGEN::PSGHDDevice::SetAECField(int value)
|
|
|
}
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetAECFilm(int value)
|
|
|
{
|
|
|
+ FINFO("SetAECFilm called with value: {$}", value);
|
|
|
if (!m_DoseUnit.m_AECFilm->Verify(value)) return RET_STATUS::RET_SUCCEED;
|
|
|
|
|
|
if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_V2TYPE::ET_MAS) return RET_STATUS::RET_FAILED;
|
|
@@ -581,7 +803,7 @@ RET_STATUS nsGEN::PSGHDDevice::SetAECFilm(int value)
|
|
|
|
|
|
return HWSend(temp, strlen(temp));
|
|
|
}
|
|
|
-RET_STATUS nsGEN::PSGHDDevice::SetWS(const string value)
|
|
|
+RET_STATUS nsGEN::PSGHDDevice::SetWS(const string value)
|
|
|
{
|
|
|
FINFO("Enter SetWS {$}", value);
|
|
|
int tempws = 0;
|
|
@@ -652,17 +874,18 @@ RET_STATUS nsGEN::PSGHDDevice::SetExpMode(std::string value)
|
|
|
}
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetFrameRate(float frameRate)
|
|
|
{
|
|
|
+ FINFO("SetFrameRate called with value: {$}", frameRate);
|
|
|
return RET_STATUS::RET_SUCCEED;
|
|
|
}
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetExpEnable()
|
|
|
{
|
|
|
FINFO("SetExpEnable in\n");
|
|
|
- return HWSend("DSW 1", 5);
|
|
|
+ return HWSend("DSW 0", 5);
|
|
|
}
|
|
|
RET_STATUS nsGEN::PSGHDDevice::SetExpDisable()
|
|
|
{
|
|
|
FINFO("SetExpDisable in\n");
|
|
|
- return HWSend("DSW 0", 5);
|
|
|
+ return HWSend("DSW 1", 5);
|
|
|
}
|
|
|
|
|
|
RET_STATUS nsGEN::PSGHDDevice::PrepareAcquisition()
|
|
@@ -685,12 +908,22 @@ RET_STATUS nsGEN::PSGHDDevice::HWSend(const char* strCommand, int length, bool r
|
|
|
{
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
if (!m_SCF->IsConnected())
|
|
|
{
|
|
|
- FINFO("Failed - Device not connected");
|
|
|
+ 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;
|
|
|
}
|
|
|
// 构造协议格式:<STX>CMD<SP>ARG;<CS><CR><LF>
|
|
@@ -855,6 +1088,16 @@ void nsGEN::PSGHDDevice::OnCallBack()
|
|
|
|
|
|
m_DoseUnit.m_MA->Update(actualMA);
|
|
|
FireNotify(AttrKey::MA, m_DoseUnit.m_MA->JSGet());
|
|
|
+
|
|
|
+ float tempMa = m_DoseUnit.m_MA->Get();
|
|
|
+ float tempMs = m_DoseUnit.m_MS->Get();
|
|
|
+ float tempMAS = tempMa * tempMs / 1000.0f;
|
|
|
+ if (tempMAS > 0)
|
|
|
+ {
|
|
|
+ m_DoseUnit.m_MAS->Update(tempMAS);
|
|
|
+ FireNotify(AttrKey::MAS, m_DoseUnit.m_MAS->JSGet());
|
|
|
+ }
|
|
|
+
|
|
|
FINFO("HWIREF: Parsed actual MA = {$} mA", actualMA);
|
|
|
};
|
|
|
|
|
@@ -921,6 +1164,15 @@ void nsGEN::PSGHDDevice::OnCallBack()
|
|
|
|
|
|
m_DoseUnit.m_MS->Update(exposureTime);
|
|
|
FireNotify(AttrKey::MS, m_DoseUnit.m_MS->JSGet());
|
|
|
+ float tempMa = m_DoseUnit.m_MA->Get();
|
|
|
+ float tempMs = m_DoseUnit.m_MS->Get();
|
|
|
+ float tempMAS = tempMa * tempMs / 1000.0f;
|
|
|
+ if (tempMAS > 0)
|
|
|
+ {
|
|
|
+ m_DoseUnit.m_MAS->Update(tempMAS);
|
|
|
+ FireNotify(AttrKey::MAS, m_DoseUnit.m_MAS->JSGet());
|
|
|
+ }
|
|
|
+
|
|
|
FINFO("HWSMS: Parsed exposure time = {$} ms", exposureTime);
|
|
|
};
|
|
|
|
|
@@ -1191,6 +1443,37 @@ void nsGEN::PSGHDDevice::OnCallBack()
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ auto HWFLP = [this](const char* data, int length) -> void
|
|
|
+ {
|
|
|
+ if (length < 1) { // 需1字节(X)
|
|
|
+ FINFO("HWFLP: Invalid data length ({$} < 1), skip", length);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ char flxStr[2] = { 0 };
|
|
|
+ strncpy(flxStr, data, 1);
|
|
|
+ int nValue = atoi(flxStr);
|
|
|
+ FINFO("HWFLP: Fluorescence mode detected = {$}", nValue);
|
|
|
+
|
|
|
+ if (nValue == 2)
|
|
|
+ {
|
|
|
+ FINFO("HWFLP: Received value 2 - No action");
|
|
|
+ }
|
|
|
+ else if (nValue == 1)
|
|
|
+ {
|
|
|
+ m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_PREPARE);
|
|
|
+ FINFO("HWFLP: Radiography prepare state - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
+ FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
|
+ }
|
|
|
+ else if (nValue == 0)
|
|
|
+ {
|
|
|
+ m_DoseUnit.m_GenSynState->Update(AttrKey::GENERATOR_RAD_OFF);
|
|
|
+ FINFO("HWFLP: Radiography off state - {$}", m_DoseUnit.m_GenSynState->JSGet().c_str());
|
|
|
+ FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
|
|
|
+ m_bGenBusy = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
auto HWVER = [this](const char* data, int length) -> void
|
|
|
{
|
|
|
if (length < 6) { // 需6字节(XXXXXX)
|
|
@@ -1703,7 +1986,8 @@ bool nsGEN::PSGHDDriver::isConnected() const
|
|
|
|
|
|
// 1. 连接中/实际已连接:返回true(无需重连)
|
|
|
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" : "Al
|
|
|
+ // ready connected");
|
|
|
return true;
|
|
|
}
|
|
|
|