1.SECS通讯,实现S1F41,接收EAP的Command,解释出参数列表,并回复。具体指令(Stop, Abort,  Pause,  Resume等)需要和机器端确认相关逻辑。
已修改3个文件
76 ■■■■■ 文件已修改
SourceCode/Bond/Servo/HsmsPassive.cpp 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.h 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.cpp 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -38,7 +38,11 @@
    m_bCimWorking = FALSE;
    m_hCimWorkEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
    m_nSessionId = 1;
    m_listener.onEQOffLine = nullptr;
    m_listener.onEQOnLine = nullptr;
    m_listener.onCommand = nullptr;
    m_listener.onEQConstantRequest = nullptr;
    m_listener.onEQConstantSend = nullptr;
    InitializeCriticalSection(&m_criticalSection);
}
@@ -66,6 +70,7 @@
{
    m_listener.onEQOffLine = listener.onEQOffLine;
    m_listener.onEQOnLine = listener.onEQOnLine;
    m_listener.onCommand = listener.onCommand;
    m_listener.onEQConstantRequest = listener.onEQConstantRequest;
    m_listener.onEQConstantSend = listener.onEQConstantSend;
}
@@ -208,6 +213,9 @@
        }
        else if (nStream == 2 && pHeader->function == 37) {
            replyEanbleDisableEventReport(pMessage);
        }
        else if (nStream == 2 && pHeader->function == 41) {
            replyCommand(pMessage);
        }
        else if (nStream == 5 && pHeader->function == 3) {
            replyEanbleDisableAlarmReport(pMessage);
@@ -598,6 +606,55 @@
    return 0;
}
// S2F41
int CHsmsPassive::replyCommand(IMessage* pRecv)
{
    if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
        return ER_NOTSELECT;
    }
    ISECS2Item* pBody = pRecv->getBody();
    if (pBody == nullptr || pBody->getType() != SITYPE::A) ER_PARAM_ERROR;
    BOOL bCheckData = FALSE;
    const char* pszCmdName;
    std::vector<CommandParameter> params;
    {
        ISECS2Item* pItemParams, *pItemParam;
        ISECS2Item* pItem = pRecv->getBody();
        if (pItem->getSubItemSize() < 2) goto MYREPLY;
        if (!pItem->getSubItemString(0, pszCmdName)) goto MYREPLY;
        pItemParams = pItem->getSubItem(1);
        if (pItemParams == nullptr || pItemParams->getType() != SITYPE::L) goto MYREPLY;
        for (int i = 0; i < pItemParams->getSubItemSize(); i++) {
            const char* pszParamName, * pszParamValue;
            pItemParam = pItemParams->getSubItem(i);
            if (pItemParam != nullptr
                && pItemParam->getSubItemString(0, pszParamName)
                && pItemParam->getSubItemString(1, pszParamValue)) {
                CommandParameter cp;
                strcpy_s(cp.szName, 256, pszParamName);
                strcpy_s(cp.szValue, 256, pszParamValue);
                params.push_back(cp);
            }
        }
        bCheckData = TRUE;
    }
    // 回调到应用层
    if (bCheckData) {
        if (m_listener.onCommand != nullptr) {
            m_listener.onCommand(this, pszCmdName, params);
        }
    }
MYREPLY:
    replyAck(2, 42, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK");
    return 0;
}
// S5F3
int CHsmsPassive::replyEanbleDisableAlarmReport(IMessage* pRecv)
{
SourceCode/Bond/Servo/HsmsPassive.h
@@ -21,15 +21,25 @@
    char szValue[256];
} EQConstant;
/*
 * Command 数据结构
 */
typedef struct _CommandParameter
{
    char szName[256];
    char szValue[256];
} CommandParameter;
typedef std::function<void(void* pFrom, std::vector<EQConstant>&)> SECSEQCONSTANTREQUEST;
typedef std::function<void(void* pFrom)> SECSEQOFFLINE;
typedef std::function<void(void* pFrom, std::vector<EQConstant>&)> SECSEQCONSTANTREQUEST;
typedef std::function<void(void* pFrom, const char*, std::vector<CommandParameter>&)> SECSCommand;
typedef struct _SECSListener
{
    SECSEQOFFLINE                onEQOffLine;
    SECSEQOFFLINE                onEQOnLine;
    SECSEQCONSTANTREQUEST        onEQConstantRequest;
    SECSEQCONSTANTREQUEST        onEQConstantSend;
    SECSCommand                    onCommand;
} SECSListener;
@@ -71,6 +81,7 @@
    int replyEquipmentConstantSend(IMessage* pRecv);
    int replyDatetime(IMessage* pRecv);
    int replyEanbleDisableEventReport(IMessage* pRecv);
    int replyCommand(IMessage* pRecv);
    int replyEanbleDisableAlarmReport(IMessage* pRecv);
    int replyQueryPPIDList(IMessage* pRecv);
    int replyTerminalDisplay(IMessage* pRecv);
SourceCode/Bond/Servo/Model.cpp
@@ -64,6 +64,12 @@
    listener.onEQOnLine = [&](void* pFrom) -> void {
        LOGI("远程请求OnLine");
    };
    listener.onCommand = [&](void* pFrom, const char* pszName, std::vector<CommandParameter>& params) -> void {
        LOGI("onCommand:%s", pszName);
        for (auto& item : params) {
            LOGI("param:%s,%s", item.szName, item.szValue);
        }
    };
    listener.onEQConstantRequest = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
        // 在此填充常量值,目前仅是加1后返回
        for (auto& item : eqcs) {