From 84925ada39fdef3f5bd7266005010103897713a6 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 11 七月 2025 17:49:15 +0800
Subject: [PATCH] 1.EAP模拟器,启用或禁用警告上报功能实现和模拟测试; 2.Master端,收到EAP的启用或警告消息上报消息后,保存相关配置,如后续机器发生警告,根据配置决定是否上报警告消息;
---
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp | 15 +++++++
SourceCode/Bond/EAPSimulator/Resource.h | 2
SourceCode/Bond/Servo/HsmsPassive.h | 2 +
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp | 14 +++++++
SourceCode/Bond/EAPSimulator/CHsmsActive.h | 3 +
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h | 1
SourceCode/Bond/Servo/HsmsPassive.cpp | 33 +---------------
SourceCode/Bond/EAPSimulator/EAPSimulator.rc | 0
SourceCode/Bond/Servo/CMaster.cpp | 5 ++
SourceCode/Bond/Servo/CMaster.h | 1
SourceCode/Bond/Servo/Model.cpp | 14 +++++-
SourceCode/Bond/Servo/CBonder.cpp | 4 +-
12 files changed, 58 insertions(+), 36 deletions(-)
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
index f610450..e3e2286 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -186,6 +186,21 @@
return 0;
}
+int CHsmsActive::hsmsEDAlarmReport(bool bEnable, unsigned int id)
+{
+ char szEnable[2] = {128, 0};
+
+ IMessage* pMessage = nullptr;
+ int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 5 | REPLY, 3, ++m_nSystemByte);
+ ISECS2Item* pItem = pMessage->getBody();
+ pItem->addBinaryItem(&szEnable[bEnable ? 0 : 1], 1, "ALED");
+ pItem->addU4Item(id, "ALID");
+ m_pActive->sendMessage(pMessage);
+ HSMS_Destroy1Message(pMessage);
+
+ return 0;
+}
+
int CHsmsActive::replyAck0(IMessage* pMessage)
{
return 0;
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.h b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
index 8d8f423..759426f 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.h
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
@@ -42,6 +42,9 @@
// Enable/Disable Event Report
int hsmsEDEventReport(bool bEnable, std::vector<int>& ids);
+ // Enable/Disable Alarm Report
+ int hsmsEDAlarmReport(bool bEnable, unsigned int id);
+
// 通过的reply函数
void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
index f5318f1..c6cb615 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
Binary files differ
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
index ef31282..6dca163 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
@@ -79,6 +79,7 @@
ON_BN_CLICKED(IDC_BUTTON_DATETIME_SYNC, &CEAPSimulatorDlg::OnBnClickedButtonDatetimeSync)
ON_BN_CLICKED(IDC_BUTTON_TERMINAL_DISPLAY, &CEAPSimulatorDlg::OnBnClickedButtonTerminalDisplay)
ON_BN_CLICKED(IDC_BUTTON_ED_EVENT_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonEdEventReport)
+ ON_BN_CLICKED(IDC_BUTTON_ED_ALARM_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonEdAlarmReport)
END_MESSAGE_MAP()
@@ -166,6 +167,7 @@
SetDlgItemInt(IDC_EDIT_PORT, 7000);
SetGroup2Enabled(FALSE);
SetGroup1Enabled(TRUE);
+ ::SetProp(GetDlgItem(IDC_BUTTON_ED_ALARM_REPORT)->m_hWnd, _T("Enable"), (void*)1);
// log edit
@@ -258,6 +260,7 @@
GetDlgItem(IDC_BUTTON_DATETIME_SYNC)->EnableWindow(enabled);
GetDlgItem(IDC_BUTTON_TERMINAL_DISPLAY)->EnableWindow(enabled);
GetDlgItem(IDC_BUTTON_ED_EVENT_REPORT)->EnableWindow(enabled);
+ GetDlgItem(IDC_BUTTON_ED_ALARM_REPORT)->EnableWindow(enabled);
}
void CEAPSimulatorDlg::OnBnClickedButtonConnect()
@@ -296,3 +299,14 @@
CEDEventReportDlg dlg;
dlg.DoModal();
}
+
+void CEAPSimulatorDlg::OnBnClickedButtonEdAlarmReport()
+{
+ int enable = (int)::GetProp(GetDlgItem(IDC_BUTTON_ED_ALARM_REPORT)->m_hWnd, _T("Enable"));
+ enable = enable == 0 ? 1 : 0;
+ theApp.m_model.m_pHsmsActive->hsmsEDAlarmReport(enable == 1, 0);
+
+ SetDlgItemText(IDC_BUTTON_ED_ALARM_REPORT,
+ enable == 1 ? _T("Disable Alarm Report") : _T("Enable Alarm Report"));
+ ::SetProp(GetDlgItem(IDC_BUTTON_ED_ALARM_REPORT)->m_hWnd, _T("Enable"), (void*)enable);
+}
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
index bd6b3a0..76fff99 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
@@ -50,4 +50,5 @@
afx_msg void OnBnClickedButtonDatetimeSync();
afx_msg void OnBnClickedButtonTerminalDisplay();
afx_msg void OnBnClickedButtonEdEventReport();
+ afx_msg void OnBnClickedButtonEdAlarmReport();
};
diff --git a/SourceCode/Bond/EAPSimulator/Resource.h b/SourceCode/Bond/EAPSimulator/Resource.h
index 088e427..fec8156 100644
--- a/SourceCode/Bond/EAPSimulator/Resource.h
+++ b/SourceCode/Bond/EAPSimulator/Resource.h
@@ -20,10 +20,10 @@
#define IDC_COMBO_TID 1008
#define IDC_BUTTON_ED_EVENT_REPORT 1008
#define IDC_EDIT_TEXT 1009
+#define IDC_BUTTON_ED_ALARM_REPORT 1009
#define IDC_BUTTON_SEND 1010
#define IDC_RADIO_ENABLE 1012
#define IDC_RADIO_DISABLE 1013
-#define IDC_EDIT1 1014
#define IDC_EDIT_CEID 1014
// Next default values for new objects
diff --git a/SourceCode/Bond/Servo/CBonder.cpp b/SourceCode/Bond/Servo/CBonder.cpp
index afe3cdf..98e2164 100644
--- a/SourceCode/Bond/Servo/CBonder.cpp
+++ b/SourceCode/Bond/Servo/CBonder.cpp
@@ -422,10 +422,10 @@
// test
static int i[2] = { 0, 0 };
i[m_nIndex]++;
- if (m_nIndex == 0 && i[m_nIndex] == 100) {
+ if (m_nIndex == 0 && i[m_nIndex] % 20 == 0) {
if (m_listener.onAlarm != nullptr) {
m_listener.onAlarm(this, 1,
- 100,
+ i[m_nIndex],
getID(),
1);
}
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 14bfb6c..592184a 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -1597,4 +1597,9 @@
{
m_bEnableAlarmReport = bEnable;
}
+
+ bool CMaster::isAlarmReportEnable()
+ {
+ return m_bEnableAlarmReport;
+ }
}
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index e8a381e..4edef98 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -72,6 +72,7 @@
void datetimeSync(SYSTEMTIME& time);
void enableEventReport(bool bEnable);
void enableAlarmReport(bool bEnable);
+ bool isAlarmReportEnable();
private:
inline void lock() { EnterCriticalSection(&m_criticalSection); }
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 07ee9a9..5660bf7 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -837,36 +837,9 @@
if (!pItem->getSubItemU4(1, ALID)) goto MYREPLY;
bCheckData = TRUE;
LOGI("EanbleDisableAlarmReport ALED:0x%02x, ALID:%d", ALED[0], ALID);
-
- double d;
- float f;
- pItem->getSubItemF4(2, f);
- pItem->getSubItemF8(3, d);
- LOGI("EanbleDisableAlarmReport d:%lf, f:%f",
- d, f);
- /*
- unsigned long long n1;
- unsigned int n2;
- unsigned short n3;
- unsigned char n4;
- long long sn1;
- int sn2;
- short sn3;
- char sn4;
- pItem->getSubItemU8(2, n1);
- pItem->getSubItemU4(3, n2);
- pItem->getSubItemU2(4, n3);
- pItem->getSubItemU1(5, n4);
- pItem->getSubItemI8(6, sn1);
- pItem->getSubItemI4(7, sn2);
- pItem->getSubItemI2(8, sn3);
- pItem->getSubItemI1(9, sn4);
-
- LOGI("EanbleDisableAlarmReport n1:%llu, n2:%u, n3:%hu, n4:%hhu",
- n1, n2, n3, n4);
- LOGI("EanbleDisableAlarmReport sn1:%lld, sn2:%d, sn3:%hd, sn4:%hhd",
- sn1, sn2, sn3, sn4);
- */
+ if (m_listener.onEnableDisableAlarmReport != nullptr) {
+ m_listener.onEnableDisableAlarmReport(this, ALED[0] != 0, ALID);
+ }
}
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index dbabb8a..25ce943 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -62,6 +62,7 @@
typedef std::function<void(void* pFrom, const char*, std::vector<CommandParameter>&)> SECSCommand;
typedef std::function<void(void* pFrom, SYSTEMTIME& time)> DATETIMESYNC;
typedef std::function<void(void* pFrom, bool bEnable, std::vector<unsigned int>& ids)> EDEVENTREPORT;
+typedef std::function<void(void* pFrom, bool bEnable, unsigned int id)> EDALARMREPORT;
typedef struct _SECSListener
{
SECSEQOFFLINE onEQOffLine;
@@ -71,6 +72,7 @@
SECSCommand onCommand;
DATETIMESYNC onDatetimeSync;
EDEVENTREPORT onEnableDisableEventReport;
+ EDALARMREPORT onEnableDisableAlarmReport;
} SECSListener;
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 476ca44..660269c 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -119,6 +119,12 @@
m_master.enableEventReport(bEnable);
}
};
+ listener.onEnableDisableAlarmReport = [&](void* pFrom, bool bEnable, unsigned int id) -> void {
+ LOGI("onEnableDisableAlarmReport bEnable:%s, id:%d", bEnable ? _T("YES") : _T("NO"), id);
+ if (id == 0) {
+ m_master.enableAlarmReport(bEnable);
+ }
+ };
m_hsmsPassive.setListener(listener);
m_hsmsPassive.setEquipmentModelType((LPTSTR)(LPCTSTR)strModeType);
m_hsmsPassive.setSoftRev((LPTSTR)(LPCTSTR)strSoftRev);
@@ -182,9 +188,11 @@
notify(RX_CODE_ALARM_CLEAR);
}
- m_hsmsPassive.requestAlarmReport(state,
- pEquipment->getBaseAlarmId() + alarmId,
- strAlarmText.c_str());
+ if (m_master.isAlarmReportEnable()) {
+ m_hsmsPassive.requestAlarmReport(state,
+ pEquipment->getBaseAlarmId() + alarmId,
+ strAlarmText.c_str());
+ }
};
masterListener.onEqVcrEventReport = [&](void* pMaster, SERVO::CEquipment* pEquipment, SERVO::CVcrEventReport* pReport) {
LOGE("<CModel>onEqVcrEventReport.");
--
Gitblit v1.9.3