chenluhua1980
2026-01-08 3e91a18f75a75fbe8f646d73e4e68ba107b6750b
1.增加状态是否远程禁等逻辑;
已修改2个文件
53 ■■■■■ 文件已修改
SourceCode/Bond/Servo/HsmsPassive.cpp 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -12,6 +12,9 @@
#include <set>
#include <regex>
// ControlState values (keep in sync with Model::ControlState / VariableList.txt)
static constexpr uint8_t kControlStateOnlineRemote = 5;
const char ACK[2] = {0, 1};
const char* ACK0 = &ACK[0];
@@ -442,6 +445,21 @@
    }
    return nullptr;
}
int CHsmsPassive::getCurrentControlState()
{
    auto v = getVariable("CurrentControlState");
    if (v != nullptr) {
        return static_cast<int>(v->getIntValue());
    }
    return 0;
}
bool CHsmsPassive::isHostCommandAllowed()
{
    // Only allow host control commands in OnlineRemote.
    return getCurrentControlState() == kControlStateOnlineRemote;
}
void CHsmsPassive::clearAllVariabel()
@@ -2221,6 +2239,13 @@
        goto MYREPLY;
    }
    if (!isHostCommandAllowed()) {
        CAACK = CAACK_5;
        ERRCODE = CAACK_5;
        strError = "rejected - ControlState not OnlineRemote";
        goto MYREPLY;
    }
    ISECS2Item* pBody = pRecv->getBody();
    if (pBody == nullptr || pBody->getType() != SITYPE::L) ER_PARAM_ERROR;
@@ -2424,6 +2449,13 @@
    ISECS2Item* pReplyItemAck = pReplyItemAcks->addU1Item(0, "OBJACK");
    ISECS2Item* pReplyItemErrs = pReplyItemAcks->addItem();
    if (!isHostCommandAllowed()) {
        ISECS2Item* pItemError = pReplyItemErrs->addItem();
        pItemError->addU4Item(2001, "ERRCODE");
        pItemError->addItem("rejected - ControlState not OnlineRemote", "ERRTEXT");
        goto MYREPLY;
    }
    // 当前只处理类各为ControlJob
    if (_strcmpi(pszObjType, "ControlJob") == 0) {
@@ -2538,6 +2570,25 @@
    ISECS2Item* pBody = pRecv->getBody();
    if (pBody == nullptr || pBody->getType() != SITYPE::L) ER_PARAM_ERROR;
    if (!isHostCommandAllowed()) {
        IMessage* pMessage = NULL;
        HSMS_Create1Message(pMessage, m_nSessionId, 16, 16, ++m_nSystemByte);
        ASSERT(pMessage);
        ISECS2Item* pItemPrjobIds = pMessage->getBody()->addItem();
        ISECS2Item* pItemErrors = pMessage->getBody()->addItem();
        pItemErrors->addBoolItem(false, "ACKA");
        ISECS2Item* pItemErrors2 = pItemErrors->addItem();
        auto err = pItemErrors2->addItem();
        err->addU4Item(2001, "ERRCODE");
        err->addItem("rejected - ControlState not OnlineRemote", "ERRTEXT");
        m_pPassive->sendMessage(pMessage);
        LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
            pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
        LOGI("<HSMS>[SEND]%s", pMessage->toString());
        HSMS_Destroy1Message(pMessage);
        return 0;
    }
    // 解释数据,得到CProcessJob
    ISECS2Item* pItemPjs, * pItemPj,* pItemCarriers, * pItemCarrier, *pItemSlots, *pItemRecipes;
SourceCode/Bond/Servo/HsmsPassive.h
@@ -150,6 +150,8 @@
    // 取得指定Variable
    SERVO::CVariable* getVariable(int variableId);
    SERVO::CVariable* getVariable(const char* pszName);
    int getCurrentControlState();
    bool isHostCommandAllowed();
    int deleteVariable(int variableId);
    int addVariable(const char* pszName, const char* pszFormat, const char* pszRemark, int& outId);
    int updateVariable(int variableId, const char* pszName, const char* pszFormat, const char* pszRemark);