LAPTOP-SNT8I5JK\Boounion
2024-11-14 e321862aa976acc151da3e3b983b34288800d975
1.删简;
已修改5个文件
115 ■■■■ 文件已修改
SourceCode/Bond/BondEq/BondEqDlg.cpp 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/CProjectPageRemoteEqs.cpp 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/Common.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/Model.cpp 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/Model.h 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -212,7 +212,6 @@
    // Homeҳ
    m_pHomeDialog = CreateHomeDlg();
    ShowWindow(SW_SHOWMAXIMIZED);
    SetTimer(2, 1000, nullptr);
    InitRxWindows();
@@ -578,10 +577,7 @@
            }
        }
    }
    else if (2 == nIDEvent) {
        KillTimer(2);
        theApp.m_model.createRemoteEqs();
    }
    CDialogEx::OnTimer(nIDEvent);
}
SourceCode/Bond/BondEq/CProjectPageRemoteEqs.cpp
@@ -55,7 +55,7 @@
            // onNext
            pAny->addRef();
            int code = pAny->getCode();
            if (RX_CODE_REMOTEEQ_STATE_CHANGED == code) {
            if (RX_CODE_EQ_STATE_CHANGED == code) {
                BEQ::IRemoteEquipment* pRemoteEq;
                if (pAny->getPtrValue("ptr", (void*&)pRemoteEq)) {
                    HTREEITEM hItem = getTreeItem(pRemoteEq);
@@ -195,16 +195,6 @@
    if (1 == nIDEvent) {
        KillTimer(1);
        InitRxWindows();
        // 远程设备列表
        char szEqName[256];
        BEQ::IRemoteEquipment* pRemoteEq = theApp.m_model.getBond1();
        ASSERT(pRemoteEq);
        pRemoteEq->getName(szEqName, 256);
        HTREEITEM hItemEq = m_treeRemoteEqs.InsertItem(szEqName);
        m_treeRemoteEqs.SetItemIcon(hItemEq, pRemoteEq->isConnected() ? m_hIconRemoteEqLight : m_hIconRemoteEqDark);
        m_treeRemoteEqs.SetItemData(hItemEq, (DWORD_PTR)pRemoteEq);
    }
    CDialogEx::OnTimer(nIDEvent);
SourceCode/Bond/BondEq/Common.h
@@ -28,7 +28,7 @@
#define RX_CODE_ALARM_EVENT                1012
#define RX_CODE_EQSTATE_EVENT            1013
#define RX_CODE_EFEM_STATUS_CHANGED        1014
#define RX_CODE_REMOTEEQ_STATE_CHANGED    1015
#define RX_CODE_EQ_STATE_CHANGED    1015
/* 广播代码 */
#define BC_CODE_DATA1_MATERIAL_RECEIVED    5000
SourceCode/Bond/BondEq/Model.cpp
@@ -19,8 +19,7 @@
{
    m_pObservableEmitter = nullptr;
    m_pObservable = nullptr;
    m_pServo = nullptr;
    m_pEqBond1 = nullptr;
    m_pEquipment = nullptr;
    m_nTimerID = 0;
}
@@ -76,54 +75,19 @@
    // 创建Servo
    BEQ_CreateServo(m_pServo, "BLServo");
    ASSERT(m_pServo);
    BEQ::ServoListener listener;
    listener.onRemoteEqConnecting = [&](void* pServo, void* pRemoteEiuipment) -> void {
        BEQ::IRemoteEquipment* p = (BEQ::IRemoteEquipment*)pRemoteEiuipment;
        char szBuffer[256];
        p->getName(szBuffer, 256);
        LOGI("<ServoListener>正在连接远程设备(%s)...", szBuffer);
    BEQ_CreateEquipment(m_pEquipment, "BLBonder");
    ASSERT(m_pEquipment);
    BEQ::EquipmentListener listener;
    listener.onConnected = [&](void* pEiuipment, const char* pszAddr, int port) -> void {
        LOGI("<EquipmentListener>连接进入(%s:%d).", pszAddr, port);
        notifyPtr(RX_CODE_EQ_STATE_CHANGED, pEiuipment);
    };
    listener.onRemoteEqConnected = [&](void* pServo, void* pRemoteEiuipment) -> void {
        BEQ::IRemoteEquipment* p = (BEQ::IRemoteEquipment*)pRemoteEiuipment;
        char szBuffer[256];
        p->getName(szBuffer, 256);
        LOGI("<ServoListener>连接远程设备(%s)成功.", szBuffer);
        notifyPtr(RX_CODE_REMOTEEQ_STATE_CHANGED, pRemoteEiuipment);
    listener.onDisconnected = [&](void* pEiuipment, const char* pszAddr, int port) -> void {
        LOGI("<EquipmentListener>连接断开(%s:%d).", pszAddr, port);
        notifyPtr(RX_CODE_EQ_STATE_CHANGED, pEiuipment);
    };
    listener.onRemoteEqConnectFailed = [&](void* pServo, void* pRemoteEiuipment, int errorCode) -> void {
        BEQ::IRemoteEquipment* p = (BEQ::IRemoteEquipment*)pRemoteEiuipment;
        char szBuffer[256];
        p->getName(szBuffer, 256);
        LOGW("<ServoListener>连接远程设备(%s)失败.", szBuffer);
    };
    listener.onRemoteEqDisconnecting = [&](void* pServo, void* pRemoteEiuipment) -> void {
        BEQ::IRemoteEquipment* p = (BEQ::IRemoteEquipment*)pRemoteEiuipment;
        char szBuffer[256];
        p->getName(szBuffer, 256);
        LOGI("<ServoListener>正在断开远程设备(%s).", szBuffer);
    };
    listener.onRemoteEqDisconnected = [&](void* pServo, void* pRemoteEiuipment) -> void {
        BEQ::IRemoteEquipment* p = (BEQ::IRemoteEquipment*)pRemoteEiuipment;
        char szBuffer[256];
        p->getName(szBuffer, 256);
        LOGW("<ServoListener>远程设备(%s)连接断开.", szBuffer);
        notifyPtr(RX_CODE_REMOTEEQ_STATE_CHANGED, pRemoteEiuipment);
    };
    listener.onRemoteEqReadRawdata = [&](void* pServo, void* pRemoteEiuipment, const char* pszData, int len) -> void {
        BEQ::IRemoteEquipment* p = (BEQ::IRemoteEquipment*)pRemoteEiuipment;
        char szBuffer[256];
        p->getName(szBuffer, 256);
        LOGD("<ServoListener>收到远程设备(%s)原始数据(%s).", szBuffer, std::string(pszData, len).c_str());
    };
    listener.onRemoteEqEventUpdate = [&](void* pServo, void* pRemoteEiuipment, void* pUnit, BEQ::REMOTE_EQ_EVENT eventCode) -> void {
        BEQ::IRemoteEquipment* p = (BEQ::IRemoteEquipment*)pRemoteEiuipment;
        char szBuffer[256];
        p->getName(szBuffer, 256);
        LOGD("<ServoListener>远程设备(%s)onRemoteEqEventUpdate.", szBuffer);
    };
    m_pServo->setListener(listener);
    // 注意此处还有几个回调函数未处理
    m_pEquipment->setEquipmentListener(listener);
    m_pObservable = RX_AllocaObservable([&](IObservableEmitter* e) -> void {
@@ -134,22 +98,6 @@
    m_nTimerID = (int)SetTimer(NULL, 1, 1000, (TIMERPROC)ModerTimerProc);
    g_pModel = this;
    return 0;
}
int CModel::createRemoteEqs()
{
    // 从配置中读取远程机器配置
    CString strIp, strIniFile;
    UINT nPort, nDoorCount;
    strIniFile.Format(_T("%s\\Configuration.ini"), (LPTSTR)(LPCTSTR)m_strWorkDir);
    CConfiguration configuration((LPTSTR)(LPCTSTR)strIniFile);
    configuration.getBond1(strIp, nPort, nDoorCount);
    m_pServo->createRemoteEquipment(m_pEqBond1, (LPTSTR)(LPCTSTR)strIp, nPort);
    ASSERT(m_pEqBond1);
    m_pEqBond1->addUnit("UNITA", nDoorCount);
    m_pServo->connectRemoteEquipment(m_pEqBond1);
    return 0;
}
@@ -165,9 +113,9 @@
    return m_bonder;
}
BEQ::IRemoteEquipment* CModel::getBond1()
BEQ::IEquipment* CModel::getEquipment()
{
    return m_pEqBond1;
    return m_pEquipment;
}
int CModel::notify(int code)
@@ -344,14 +292,5 @@
void CModel::onTimer(UINT nTimerid)
{
    ULONGLONG tick = GetTickCount64();
    int interval = m_configuration.getP2RemoteEqReconnectInterval() * 1000;
    if (m_pEqBond1 != nullptr) {
        if (!m_pEqBond1->isConnected()) {
            if (tick - m_pEqBond1->getConnectTick() > interval) {
                m_pEqBond1->connect();
            }
        }
    }
}
SourceCode/Bond/BondEq/Model.h
@@ -15,9 +15,8 @@
    int init();
    int term();
    void onTimer(UINT nTimerid);
    int createRemoteEqs();
    CBonder& getBonder();
    BEQ::IRemoteEquipment* getBond1();
    BEQ::IEquipment* getEquipment();
public:
    int notify(int code);
@@ -43,8 +42,7 @@
private:
    CBonder m_bonder;
    BEQ::IServo* m_pServo;
    BEQ::IRemoteEquipment* m_pEqBond1;
    BEQ::IEquipment* m_pEquipment;
    int m_nTimerID;
};