chenluhua1980
2026-01-07 7e0e199c4adc819b5784f689de98b8569025ed53
1.实现 CJobSpace的管理的维护;
已修改5个文件
32 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CMaster.cpp 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.cpp 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
    }
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
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -1784,9 +1784,11 @@
        goto MYREPLY;
    }
    if (!pBody->getSubItemU2(0, SVID)) {
        if (!pBody->getSubItemI2(0, (short&)SVID)) {
        pMessage->getBody()->addU1Item(SVU1, "SV");
        goto MYREPLY;
    }
    }
    SERVO::CVariable* pVariable = getVariable((int)SVID);
    if (pVariable == nullptr) {
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"));
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);