From 7e0e199c4adc819b5784f689de98b8569025ed53 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期三, 07 一月 2026 16:05:30 +0800
Subject: [PATCH] 1.实现 CJobSpace的管理的维护;
---
SourceCode/Bond/Servo/HsmsPassive.cpp | 6 ++++--
SourceCode/Bond/Servo/Model.h | 3 +++
SourceCode/Bond/Servo/CMaster.cpp | 12 ++++++++++++
SourceCode/Bond/Servo/CMaster.h | 2 ++
SourceCode/Bond/Servo/Model.cpp | 13 ++++++++++++-
5 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 1ef96c5..f27a523 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -222,6 +222,9 @@
// 璇荤紦瀛樻暟鎹�
readCache();
loadState();
+ if (m_listener.onControlJobChanged) {
+ m_listener.onControlJobChanged(this);
+ }
// 瀹氭椂鍣�
@@ -2868,6 +2871,9 @@
}
m_pControlJob->setPJs(temps);
this->saveState();
+ if (m_listener.onControlJobChanged) {
+ m_listener.onControlJobChanged(this);
+ }
return 0;
@@ -3210,6 +3216,9 @@
saveState();
+ if (m_listener.onControlJobChanged) {
+ m_listener.onControlJobChanged(this);
+ }
return true;
}
@@ -3244,6 +3253,9 @@
saveState();
+ if (m_listener.onControlJobChanged) {
+ m_listener.onControlJobChanged(this);
+ }
return true;
}
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index be5c434..1d983e2 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -61,6 +61,7 @@
typedef std::function<void(void* pMaster, CEquipment* pEquipment, int slotNo, PROCESS_STATE state)> ONPROCESSSTATECHANGED;
typedef std::function<void(void* pMaster, int round)> ONCTROUNDEND;
typedef std::function<void(void* pMaster, void* pj)> ONPJSTART;
+ typedef std::function<void(void* pMaster)> ONCONTROLJOBCHANGED;
typedef struct _MasterListener
{
ONMASTERSTATECHANGED onMasterStateChanged;
@@ -79,6 +80,7 @@
ONPJSTART onPjEnd;
ONPJSTART onPanelStart;
ONPJSTART onPanelEnd;
+ ONCONTROLJOBCHANGED onControlJobChanged;
} MasterListener;
class CMaster : public IResourceView
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index ed605ae..cd16e19 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -1784,8 +1784,10 @@
goto MYREPLY;
}
if (!pBody->getSubItemU2(0, SVID)) {
- pMessage->getBody()->addU1Item(SVU1, "SV");
- goto MYREPLY;
+ if (!pBody->getSubItemI2(0, (short&)SVID)) {
+ pMessage->getBody()->addU1Item(SVU1, "SV");
+ goto MYREPLY;
+ }
}
SERVO::CVariable* pVariable = getVariable((int)SVID);
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 9918b56..5857dca 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -22,6 +22,12 @@
{
}
+void CModel::refreshDerivedSVs()
+{
+ // CJobSpace: how many ControlJobs can be created (current implementation supports 0/1).
+ m_hsmsPassive.setVariableValue("CJobSpace", (__int64)(m_master.canCreateControlJob() ? 1 : 0));
+}
+
IObservable* CModel::getObservable()
{
if (m_pObservable == nullptr) {
@@ -123,7 +129,7 @@
listener.onEQConstantRequest = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
// 鍦ㄦ濉厖甯搁噺鍊硷紝鐩墠浠呮槸鍔�1鍚庤繑鍥�
for (auto& item : eqcs) {
- sprintf_s(item.szValue, 256, "Test%d", item.id + 1);
+ sprintf_s(item.szValue, EQCONSTANT_VALUE_MAX, "Test%d", item.id + 1);
}
};
listener.onEQConstantSend = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
@@ -241,6 +247,7 @@
CString strVarialbleFile;
strVarialbleFile.Format(_T("%s\\VariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
m_hsmsPassive.loadVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile);
+ refreshDerivedSVs();
m_hsmsPassive.init(this, "APP", 7000);
strVarialbleFile.Format(_T("%s\\ReportList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
m_hsmsPassive.loadReports((LPTSTR)(LPCTSTR)strVarialbleFile);
@@ -255,6 +262,10 @@
LOGI("<CModel>Master state changed(%d)", (int)state);
notify(RX_CODE_MASTER_STATE_CHANGED);
};
+ masterListener.onControlJobChanged = [this](void* pMaster) {
+ (void)pMaster;
+ this->refreshDerivedSVs();
+ };
masterListener.onEqAlive = [&](void* pMaster, SERVO::CEquipment* pEquipment, BOOL bAlive) -> void {
LOGI("<CModel>Equipment onAlive:%s(%s).", pEquipment->getName().c_str(),
bAlive ? _T("ON") : _T("OFF"));
diff --git a/SourceCode/Bond/Servo/Model.h b/SourceCode/Bond/Servo/Model.h
index e1b1563..8cf90a8 100644
--- a/SourceCode/Bond/Servo/Model.h
+++ b/SourceCode/Bond/Servo/Model.h
@@ -21,6 +21,9 @@
int init();
int term();
+private:
+ void refreshDerivedSVs();
+
public:
int notify(int code);
int notifyPtr(int code, void* ptr = NULL);
--
Gitblit v1.9.3