LAPTOP-SNT8I5JK\Boounion
2025-07-28 e51c6d1360f9679dd8e4dd3379ce0db1886badbf
Merge branch 'EAPSimulator' into clh

# Conflicts:
# .gitignore
# SourceCode/Bond/Servo/CMaster.cpp
# SourceCode/Bond/Servo/CMaster.h
# SourceCode/Bond/Servo/Servo.rc
# SourceCode/Bond/Servo/Servo.vcxproj
# SourceCode/Bond/Servo/Servo.vcxproj.filters
# SourceCode/Bond/Servo/ServoDlg.cpp
# SourceCode/Bond/Servo/resource.h
已添加67个文件
已修改21个文件
5724 ■■■■■ 文件已修改
.gitignore 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.8(1).xlsx 补丁 | 查看 | 原始文档 | blame | 历史
Document/MASTER学习资料/LingSignal - 副本.bmp 补丁 | 查看 | 原始文档 | blame | 历史
Document/MASTER学习资料/LingSignal.bmp 补丁 | 查看 | 原始文档 | blame | 历史
Document/MASTER学习资料/LingSignal2.txt 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Document/MASTER学习资料/SECS通讯整理.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
Document/Panel Bonder八零联合 SecsTest CheckList_v3.0.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
Document/VariableList.txt 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Document/simulator/SEComSimulator.Conf 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CAddIDSDlg.cpp 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CAddIDSDlg.h 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CCollectionEvent.cpp 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CCollectionEvent.h 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CDefineReportsDlg.cpp 193 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CDefineReportsDlg.h 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.cpp 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.h 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp 286 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CHsmsActive.h 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CLinkReportDetailDlg.cpp 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CLinkReportDetailDlg.h 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CLinkReportDlg.cpp 205 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CLinkReportDlg.h 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CModel.cpp 300 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CModel.h 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CReport.cpp 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CReport.h 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CTerminalDisplayDlg.cpp 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CTerminalDisplayDlg.h 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CVariable.cpp 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/CVariable.h 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Common.h 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Context.cpp 184 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Context.h 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.cpp 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.h 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.rc 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj 247 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.user 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp 357 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Log.cpp 214 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Log.h 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/LogEdit.cpp 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/LogEdit.h 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/Resource.h 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/framework.h 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/pch.cpp 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/pch.h 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/res/EAPSimulator.ico 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/res/EAPSimulator.rc2 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/res/application.exe.manifest 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/EAPSimulator/targetver.h 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/GangBond2860.sln 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/HSMSSDK/Include/HSMSSDK.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/HSMSSDK/Include/IActive.h 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/HSMSSDK/Include/ISECS2Item.h 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CBonder.cpp 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CCollectionEvent.cpp 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CCollectionEvent.h 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.cpp 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.h 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMyStatusbar.cpp 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMyStatusbar.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageCollectionEvent.cpp 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageCollectionEvent.h 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageReport.cpp 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageReport.h 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageVarialbles.cpp 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageVarialbles.h 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CReport.cpp 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CReport.h 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CVariable.cpp 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CVariable.h 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp 551 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.h 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.cpp 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Servo.rc 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Servo.vcxproj 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Servo.vcxproj.filters 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Servo.vcxproj.user 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/ServoDlg.cpp 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/ServoDlg.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/resource.h 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/x64/Debug/CollectionEventList.txt 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/x64/Debug/ReportList.txt 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/x64/Debug/VariableList.txt 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -57,4 +57,4 @@
SourceCode/Bond/x64/Debug/Config/robot_offset.ini
*.tlog
*.pch
SourceCode/Bond/EAPSimulator/x64/Debug/
SourceCode/Bond/EAPSimulator/x64/
Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.8(1).xlsx
Binary files differ
Document/MASTERѧϰ×ÊÁÏ/LingSignal - ¸±±¾.bmp
Document/MASTERѧϰ×ÊÁÏ/LingSignal.bmp
Document/MASTERѧϰ×ÊÁÏ/LingSignal2.txt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,58 @@
| ä¿¡å·åç§°                            | EAS角色(读/写) | è¯´æ˜Ž                |
| ------------------------------- | ---------- | ----------------- |
| Downstream Inline               | è¯»          | ä¸‹æ¸¸Inline状态,设备告知主机 |
| Downstream Trouble              | è¯»          | ä¸‹æ¸¸å¼‚常通知,设备发给主机     |
| Interlock                       | è¯»          | äº’锁状态,设备反馈         |
| Send Able                       | è¯»          | è®¾å¤‡æ˜¯å¦å‡†å¤‡å¥½å‘送Glass信号  |
| Send Start                      | å†™          | ä¸»æœºæŒ‡ä»¤è®¾å¤‡å¼€å§‹å‘送Glass   |
| Job Transfer                    | å†™          | ä¸»æœºæŒ‡ä»¤è®¾å¤‡è¿›è¡ŒJob转移     |
| Send Complete                   | è¯»          | è®¾å¤‡åé¦ˆå‘送完成信号        |
| Shutter State                   | è¯»          | è®¾å¤‡æŒ¡æ¿çŠ¶æ€ï¼Œè®¾å¤‡åé¦ˆ       |
| Pin State                       | è¯»          | è®¾å¤‡é’ˆè„šçŠ¶æ€            |
| Slot Pair Flag                  | è¯»          | è®¾å¤‡åé¦ˆSlot配对状态      |
| Arm Slot Pair Flag              | è¯»          | æœºæ¢°è‡‚Slot配对状态       |
| Exchange Possible               | è¯»          | è®¾å¤‡åé¦ˆæ˜¯å¦å…è®¸äº¤æ¢        |
| Exchange Execute                | å†™          | ä¸»æœºä¸‹å‘执行交换指令        |
| Cancel Request                  | å†™          | ä¸»æœºå–消当前操作请求        |
| Cancel Ack                      | è¯»          | è®¾å¤‡ç¡®è®¤å–消操作          |
| Cancel Nck                      | è¯»          | è®¾å¤‡æ‹’绝取消操作          |
| Abort Request                   | å†™          | ä¸»æœºè¯·æ±‚中止操作          |
| Abort Ack                       | è¯»          | è®¾å¤‡ç¡®è®¤ä¸­æ­¢æ“ä½œ          |
| Abort Nck                       | è¯»          | è®¾å¤‡æ‹’绝中止操作          |
| Resume Request                  | å†™          | ä¸»æœºè¯·æ±‚恢复操作          |
| Resume Ack                      | è¯»          | è®¾å¤‡ç¡®è®¤æ¢å¤æ“ä½œ          |
| Resume Nak                      | è¯»          | è®¾å¤‡æ‹’绝恢复操作          |
| Abnormal                        | è¯»          | è®¾å¤‡å¼‚常信号            |
| Empty                           | è¯»          | è®¾å¤‡ç©ºçŠ¶æ€             |
| Idle                            | è¯»          | è®¾å¤‡ç©ºé—²çŠ¶æ€            |
| Run                             | è¯»          | è®¾å¤‡è¿è¡ŒçŠ¶æ€            |
| Complete                        | è¯»          | è®¾å¤‡å®ŒæˆçŠ¶æ€            |
| Lift Up or Pin Up               | è¯»          | è®¾å¤‡æŠ¬å‡çŠ¶æ€            |
| Lift Down or Pin Down           | è¯»          | è®¾å¤‡ä¸‹é™çŠ¶æ€            |
| Stopper Up or Shutter Open      | è¯»          | è®¾å¤‡æŒ¡æ¿å¼€çŠ¶æ€           |
| Stopper Down or Shutter Close   | è¯»          | è®¾å¤‡æŒ¡æ¿å…³çŠ¶æ€           |
| Manual Operation                | è¯»          | è®¾å¤‡æ‰‹åŠ¨æ“ä½œçŠ¶æ€          |
| Body Moving                     | è¯»          | è®¾å¤‡åŠ¨ä½œä¸­çŠ¶æ€           |
| Glass Exist #1(Check Sensor on) | è¯»          | çŽ»ç’ƒå­˜åœ¨ä¼ æ„Ÿå™¨ä¿¡å·         |
| Glass Exist #2(Check Sensor on) | è¯»          | çŽ»ç’ƒå­˜åœ¨ä¼ æ„Ÿå™¨ä¿¡å·         |
| Glass Exist #1 Exist            | è¯»          | çŽ»ç’ƒå®žé™…å­˜åœ¨çŠ¶æ€          |
| Glass Exist #2 Exist            | è¯»          | çŽ»ç’ƒå®žé™…å­˜åœ¨çŠ¶æ€          |
| Arm Stretch complete            | è¯»          | æœºæ¢°è‡‚伸展完成           |
| Arm Vacuum                      | è¯»          | æœºæ¢°è‡‚吸附状态           |
| Conveyor State                  | è¯»          | ä¼ é€å¸¦çŠ¶æ€             |
| Arm Fold complete               | è¯»          | æœºæ¢°è‡‚折叠完成           |
| Make Define #1\~#9              | è¯»          | è®¾å¤‡è‡ªå®šä¹‰ä¿¡å·ï¼Œä¸€èˆ¬è®¾å¤‡åé¦ˆ    |
总结
| ä½ éœ€è¦è¿™ä¸¤ä¸ªä¿¡å·å—? | ç­”案是:必须同时用。
| â€” | â€” |
| Robot CMD | â€œå†™æ¬è¿åŠ¨ä½œå‚æ•°â€ |
| Indexer Operation Mode Command | â€œå‘启动命令” |
Load port Status上报jobData
边检NG, Job Data Change report, è¦åŽŸè·¯é€€å›ž
sh600975 sz002818 sh600727 sh600829
Document/MASTERѧϰ×ÊÁÏ/SECSͨѶÕûÀí.xlsx
Binary files differ
Document/Panel Bonder°ËÁãÁªºÏ SecsTest CheckList_v3.0.xlsx
Binary files differ
Document/VariableList.txt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
SVID,SV Name,SV Format,SV Remark
100,PortTransferState,U1,"0=OutOfService\r\n1=TransferBlocked\r\n2=ReadyToLoad\r\n3=ReadyToUnload\r\n4=InService\r\n5=TransferReady"
300,AccessMode,U1,"1=Manual\r\n2=Auto"
500,Clock,A50,
600,CurrentControlState,U1,"0:Offline:equipment\r\n1:Offline-Attempt\r\n2:Online\r\n3:Offline:host\r\n4:Online:Local\r\n5:Online:Remote"
601,PreviousControlState,U1,
700,CurrentProcessState,U1,"0:DOWN\r\n1:IDLE\r\n2.SETUP\r\n3.EXCUTING\r\n4.MAINTAIN\r\n5.ALARM"
701,PreviousProcessState,U1,
800,EFEMPPExecName,A20,
801,EQPPExecName,A20,
1000,CJobSpace,U1,
2000,RbRAxisTorque,I2,机器人R轴扭矩
2001,RbLAxisTorque,l2,机器人L轴扭矩
2002,RbZAxisTorque,l2,机器人Z轴扭矩
2003,RbTHAxisTorque,l2,机器人TH轴扭矩
2004,RbXAxisTorque,l2,机器人X轴扭矩
2005,AxisX111,l2,X111相机前移栽电机扭矩
2006,AxisX112,l2,X112相机后移栽电机扭矩
2007,AxisU113,l2,U113产品旋转电机扭矩
2008,AxisX114,l2,X114产品左整列电机扭矩
2009,AxisY121,l2,Y121产品右整列电机扭矩
2010,AxisY122,l2,Y122产品前整列电机扭矩
2011,AxisY123,l2,Y123产品后阵列电机扭矩
2012,MainAir,U2,总进气压力值
2013,MainVacuum,l2,总真空压力值
2014,RbMainVacuum,l2,机器人真空值
2015,LPMainVacuum,l2,LP真空值#D265
2016,LPMainAir,U2,LP压空值
2017,ALVacuum,l2,Aligner真空值
2018,FFU1RPM,U2,FFU1转速
2019,FFU2RPM,U2,FFU2转速
2020,FFU3RPM,U2,FFU3转速
2021,FFU4RPM,U2,FFU4转速
2022,ESDValue,I2,静电检测值
2023,OCREnable,U2,"OCR使能:O:开启 1:屏蔽"
2024,CCDEnable,U2,"CCD使能:O:开启 1:屏蔽"
2025,FFUParameter,U2,FFU设定值
Document/simulator/SEComSimulator.Conf
@@ -10,7 +10,7 @@
        <IDENTITY>Host</IDENTITY>
      </DRVINFO>
      <LOGINFO>
        <DIR>D:\Chenluhua\dazi\a</DIR>
        <DIR>D:\Chenluhua\dazi\A</DIR>
        <SECSIMODE>D</SECSIMODE>
        <SECSIIMODE>D</SECSIIMODE>
        <XMLMODE />
@@ -20,16 +20,15 @@
      </LOGINFO>
      <SECSMODE MODE="HSMS">
        <HSMS>
          <HSMSMODE>Active</HSMSMODE>
          <HSMSMODE>Passive</HSMSMODE>
          <REMOTEIP>127.0.0.1</REMOTEIP>
          <REMOTEPORT>7000</REMOTEPORT>
          <LOCALPORT>
          </LOCALPORT>
          <LOCALPORT>7001</LOCALPORT>
        </HSMS>
        <SECS1>
          <MASTER>True</MASTER>
          <COMPORT>COM1</COMPORT>
          <AUTOBAUD>False</AUTOBAUD>
          <AUTOBAUD>True</AUTOBAUD>
          <BAUDRATE>9600</BAUDRATE>
          <INTERLEAVE>False</INTERLEAVE>
          <RETRYCOUNT>3</RETRYCOUNT>
SourceCode/Bond/EAPSimulator/CAddIDSDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
// CAddIDSDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "EAPSimulator.h"
#include "CAddIDSDlg.h"
#include "afxdialogex.h"
// CAddIDSDlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CAddIDSDlg, CDialogEx)
CAddIDSDlg::CAddIDSDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_ADD_IDS, pParent)
{
    m_nId = 0;
}
CAddIDSDlg::~CAddIDSDlg()
{
}
void CAddIDSDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAddIDSDlg, CDialogEx)
    ON_BN_CLICKED(IDOK, &CAddIDSDlg::OnBnClickedOk)
END_MESSAGE_MAP()
// CAddIDSDlg æ¶ˆæ¯å¤„理程序
void CAddIDSDlg::SetTitle(const char* pszTitle)
{
    m_strTitle = pszTitle;
}
BOOL CAddIDSDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    // TODO:  åœ¨æ­¤æ·»åŠ é¢å¤–çš„åˆå§‹åŒ–
    SetWindowText(m_strTitle);
    SetDlgItemText(IDC_GROUP_IDS, m_strTitle);
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
unsigned int CAddIDSDlg::GetId()
{
    return m_nId;
}
void CAddIDSDlg::OnBnClickedOk()
{
    m_nId = GetDlgItemInt(IDC_EDIT_ID);
    CDialogEx::OnOK();
}
SourceCode/Bond/EAPSimulator/CAddIDSDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
#pragma once
// CAddIDSDlg å¯¹è¯æ¡†
class CAddIDSDlg : public CDialogEx
{
    DECLARE_DYNAMIC(CAddIDSDlg)
public:
    CAddIDSDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CAddIDSDlg();
    void SetTitle(const char* pszTitle);
    unsigned int GetId();
private:
    CString m_strTitle;
    unsigned int m_nId;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_DIALOG_ADD_IDS };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg void OnBnClickedOk();
};
SourceCode/Bond/EAPSimulator/CCollectionEvent.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,110 @@
#include "pch.h"
#include "CCollectionEvent.h"
namespace SERVO {
    CCollectionEvent::CCollectionEvent()
    {
        m_nCEID = 0;
    }
    CCollectionEvent::CCollectionEvent(unsigned int id, const char* pszName, const char* pszDescription, std::vector<unsigned int>& prtids)
    {
        m_nCEID = id;
        m_strName = pszName;
        m_strDescription = pszDescription;
        for (auto item : prtids) {
            m_rptids.push_back(item);
        }
    }
    CCollectionEvent::~CCollectionEvent()
    {
    }
    unsigned int CCollectionEvent::getEventId()
    {
        return m_nCEID;
    }
    std::string& CCollectionEvent::getName()
    {
        return m_strName;
    }
    std::string& CCollectionEvent::getDescription()
    {
        return m_strDescription;
    }
    BOOL CCollectionEvent::addReport(CReport* pReport)
    {
        ASSERT(pReport);
        if (getReport(pReport->getReportId()) != nullptr) {
            return FALSE;
        }
        m_reports.push_back(pReport);
        return TRUE;
    }
    BOOL CCollectionEvent::deleteReport(unsigned int nReportId)
    {
        BOOL bDelete = FALSE;
        for (auto iter = m_reports.begin(); iter != m_reports.end(); ++iter) {
            if (nReportId == (*iter)->getReportId()) {
                m_reports.erase(iter);
                bDelete = TRUE;
                break;
            }
        }
        return bDelete;
    }
    CReport* CCollectionEvent::getReport(unsigned int nReportId)
    {
        for (auto item : m_reports) {
            if (nReportId == item->getReportId()) {
                return item;
            }
        }
        return nullptr;
    }
    void CCollectionEvent::setReport(unsigned int nReportId)
    {
        m_rptids.clear();
        if (nReportId != 0) {
            m_rptids.push_back(nReportId);
        }
    }
    std::vector<CReport*>& CCollectionEvent::getReports()
    {
        return m_reports;
    }
    std::vector<unsigned int>& CCollectionEvent::getReportIds()
    {
        return m_rptids;
    }
    std::string CCollectionEvent::getReportIdsText()
    {
        std::string strResult, strName;
        for (int i = 0; i < m_rptids.size(); i++) {
            strResult += std::to_string(m_rptids[i]);// (getReport(m_rptids[i]) ?
            if (nullptr == getReport(m_rptids[i])) {
                strResult += "";
            }
            if (i != m_rptids.size() - 1) {
                strResult += ",";
            }
        }
        return strResult;
    }
}
SourceCode/Bond/EAPSimulator/CCollectionEvent.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,33 @@
#pragma once
#include "CReport.h"
#include <vector>
namespace SERVO {
    class CCollectionEvent
    {
    public:
        CCollectionEvent();
        CCollectionEvent(unsigned int id, const char* pszName, const char* pszDescription, std::vector<unsigned int>& prtids);
        virtual ~CCollectionEvent();
    public:
        unsigned int getEventId();
        std::string& getName();
        std::string& getDescription();
        std::vector<CReport*>& getReports();
        std::vector<unsigned int>& getReportIds();
        std::string getReportIdsText();
        BOOL addReport(CReport* pReport);
        BOOL deleteReport(unsigned int nReportId);
        CReport* getReport(unsigned int nReportId);
        void setReport(unsigned int nReportId);
    private:
        unsigned int m_nCEID;
        std::string m_strName;
        std::string m_strDescription;
        std::vector<unsigned int> m_rptids;
        std::vector<CReport*> m_reports;
    };
}
SourceCode/Bond/EAPSimulator/CDefineReportsDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,193 @@
// CDefineReportsDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "EAPSimulator.h"
#include "CDefineReportsDlg.h"
#include "afxdialogex.h"
#include "CAddIDSDlg.h"
// CDefineReportsDlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CDefineReportsDlg, CDialogEx)
CDefineReportsDlg::CDefineReportsDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_DEFINE_REPORTS, pParent)
{
}
CDefineReportsDlg::~CDefineReportsDlg()
{
}
void CDefineReportsDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDefineReportsDlg, CDialogEx)
    ON_BN_CLICKED(IDC_BUTTON_ADD_RPTID, &CDefineReportsDlg::OnBnClickedButtonAddRptid)
    ON_LBN_SELCHANGE(IDC_LIST1, &CDefineReportsDlg::OnLbnSelchangeList1)
    ON_BN_CLICKED(IDC_BUTTON_DEL_REPORT, &CDefineReportsDlg::OnBnClickedButtonDelReport)
    ON_BN_CLICKED(IDC_BUTTON_ADD_VID, &CDefineReportsDlg::OnBnClickedButtonAddVid)
    ON_LBN_SELCHANGE(IDC_LIST2, &CDefineReportsDlg::OnLbnSelchangeList2)
    ON_BN_CLICKED(IDC_BUTTON_DEL_VID, &CDefineReportsDlg::OnBnClickedButtonDelVid)
    ON_BN_CLICKED(IDC_BUTTON_SEND, &CDefineReportsDlg::OnBnClickedButtonSend)
END_MESSAGE_MAP()
// CDefineReportsDlg æ¶ˆæ¯å¤„理程序
void CDefineReportsDlg::OnBnClickedButtonAddRptid()
{
    CAddIDSDlg dlg;
    dlg.SetTitle("RPTID");
    dlg.DoModal();
    int PRTID = dlg.GetId();
    addReport(PRTID);
}
void CDefineReportsDlg::OnBnClickedButtonAddVid()
{
    CString strReportId;
    CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
    int nSel = pListBox->GetCurSel();
    if (nSel >= 0) {
        pListBox->GetText(nSel, strReportId);
        int RPTID = atoi(strReportId);
        CAddIDSDlg dlg;
        dlg.SetTitle("RPTID");
        dlg.DoModal();
        unsigned int VID = dlg.GetId();;
        addVid(RPTID, VID);
    }
}
void CDefineReportsDlg::OnLbnSelchangeList1()
{
    CString strReportId;
    int RPTID = -1;
    CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
    int nSel = pListBox->GetCurSel();
    if (nSel >= 0) {
        pListBox->GetText(nSel, strReportId);
        RPTID = atoi(strReportId);
    }
    GetDlgItem(IDC_BUTTON_DEL_REPORT)->EnableWindow(nSel >= 0);
    GetDlgItem(IDC_BUTTON_ADD_VID)->EnableWindow(nSel >= 0);
    CListBox* pListBox2 = (CListBox*)GetDlgItem(IDC_LIST2);
    pListBox2->ResetContent();
    auto iter = m_mapReport.find(RPTID);
    if (iter != m_mapReport.end()) {
        auto& vids = m_mapReport[RPTID];
        for (auto item : vids) {
            pListBox2->AddString(std::to_string(item).c_str());
        }
    }
}
void CDefineReportsDlg::OnBnClickedButtonDelReport()
{
    CString strReportId;
    CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
    int nSel = pListBox->GetCurSel();
    if (nSel >= 0) {
        pListBox->GetText(nSel, strReportId);
        int RPTID = atoi(strReportId);
        delReport(RPTID);
        pListBox->DeleteString(nSel);
        ((CListBox*)GetDlgItem(IDC_LIST2))->ResetContent();
    }
    nSel = pListBox->GetCurSel();
    GetDlgItem(IDC_BUTTON_DEL_REPORT)->EnableWindow(nSel >= 0);
    GetDlgItem(IDC_BUTTON_ADD_VID)->EnableWindow(nSel >= 0);
}
void CDefineReportsDlg::OnLbnSelchangeList2()
{
    CListBox* pListBox2 = (CListBox*)GetDlgItem(IDC_LIST2);
    int nSel = pListBox2->GetCurSel();
    GetDlgItem(IDC_BUTTON_DEL_VID)->EnableWindow(nSel >= 0);
}
void CDefineReportsDlg::OnBnClickedButtonDelVid()
{
    CString strRPTID, strVID;
    CListBox* pListBox1 = (CListBox*)GetDlgItem(IDC_LIST1);
    CListBox* pListBox2 = (CListBox*)GetDlgItem(IDC_LIST2);
    int nSel1 = pListBox1->GetCurSel();
    int nSel2 = pListBox2->GetCurSel();
    if (nSel1 >= 0 && nSel2 >= 0) {
        pListBox1->GetText(nSel1, strRPTID);
        pListBox2->GetText(nSel2, strVID);
        int RPTID = atoi(strRPTID);
        int VID = atoi(strVID);
        delVid(RPTID, VID);
        pListBox2->DeleteString(nSel2);
    }
    nSel2 = pListBox2->GetCurSel();
    GetDlgItem(IDC_BUTTON_DEL_VID)->EnableWindow(nSel2 >= 0);
}
void CDefineReportsDlg::addReport(int RPTID)
{
    auto iter = m_mapReport.find(RPTID);
    if (iter == m_mapReport.end()) {
        std::vector<unsigned int> vids;
        m_mapReport[RPTID] = vids;
    }
    CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
    pListBox->AddString(std::to_string(RPTID).c_str());
}
bool CDefineReportsDlg::addVid(unsigned int RPTID, unsigned int vid)
{
    auto iter = m_mapReport.find(RPTID);
    if (iter == m_mapReport.end()) {
        return false;
    }
    auto& vids = m_mapReport[RPTID];
    vids.push_back(vid);
    CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST2);
    pListBox->AddString(std::to_string(vid).c_str());
    return true;
}
void CDefineReportsDlg::delReport(int RPTID)
{
    auto iter = m_mapReport.find(RPTID);
    if (iter != m_mapReport.end()) {
        m_mapReport.erase(iter);
    }
}
void CDefineReportsDlg::delVid(int RPTID, int VID)
{
    auto iter = m_mapReport.find(RPTID);
    if (iter != m_mapReport.end()) {
        auto& vids = iter->second;
        for (auto iter2 = vids.begin(); iter2 != vids.end(); iter2++) {
            if ((*iter2) == VID) {
                vids.erase(iter2);
                break;
            }
        }
    }
}
void CDefineReportsDlg::OnBnClickedButtonSend()
{
    theApp.m_model.m_pHsmsActive->hsmsDefineReports(m_mapReport);
}
SourceCode/Bond/EAPSimulator/CDefineReportsDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,40 @@
#pragma once
#include <map>
#include <vector>
// CDefineReportsDlg å¯¹è¯æ¡†
class CDefineReportsDlg : public CDialogEx
{
    DECLARE_DYNAMIC(CDefineReportsDlg)
public:
    CDefineReportsDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CDefineReportsDlg();
    void addReport(int RPTID);
    void delReport(int RPTID);
    bool addVid(unsigned int RPTID, unsigned int vid);
    void delVid(int RPTID, int VID);
private:
    std::map<unsigned int, std::vector<unsigned int>> m_mapReport;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_DIALOG_DEFINE_REPORTS };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedButtonAddRptid();
    afx_msg void OnLbnSelchangeList1();
    afx_msg void OnBnClickedButtonDelReport();
    afx_msg void OnBnClickedButtonAddVid();
    afx_msg void OnLbnSelchangeList2();
    afx_msg void OnBnClickedButtonDelVid();
    afx_msg void OnBnClickedButtonSend();
};
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,71 @@
// CEDEventReportDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "EAPSimulator.h"
#include "CEDEventReportDlg.h"
#include "afxdialogex.h"
#include <vector>
// CEDEventReportDlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CEDEventReportDlg, CDialogEx)
CEDEventReportDlg::CEDEventReportDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_ED_EVENT_REPORT, pParent)
{
}
CEDEventReportDlg::~CEDEventReportDlg()
{
}
void CEDEventReportDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CEDEventReportDlg, CDialogEx)
    ON_BN_CLICKED(IDC_BUTTON_SEND, &CEDEventReportDlg::OnBnClickedButtonSend)
END_MESSAGE_MAP()
// CEDEventReportDlg æ¶ˆæ¯å¤„理程序
BOOL CEDEventReportDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_ENABLE);
    pButton->SetCheck(BST_CHECKED);
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
void CEDEventReportDlg::OnBnClickedButtonSend()
{
    CButton* pButton = (CButton*)GetDlgItem(IDC_RADIO_ENABLE);
    bool bEnable = pButton->GetCheck() == BST_CHECKED;
    CString strText, strId;
    GetDlgItemText(IDC_EDIT_CEID, strText);
    std::vector<int> ids;
    if (!strText.IsEmpty()) {
        int i = 0;
        while (1) {
            if (!AfxExtractSubString(strId, (LPCTSTR)strText, i++, ',')) {
                break;
            }
            ids.push_back(atoi(strId));
        }
    }
    theApp.m_model.m_pHsmsActive->hsmsEDEventReport(bEnable, ids);
}
SourceCode/Bond/EAPSimulator/CEDEventReportDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
#pragma once
// CEDEventReportDlg å¯¹è¯æ¡†
class CEDEventReportDlg : public CDialogEx
{
    DECLARE_DYNAMIC(CEDEventReportDlg)
public:
    CEDEventReportDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CEDEventReportDlg();
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_DIALOG_ED_EVENT_REPORT };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg void OnBnClickedButtonSend();
};
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,286 @@
#include "pch.h"
#include "CHsmsActive.h"
#include "Log.h"
CHsmsActive::CHsmsActive()
{
    m_listener = {};
    m_pActive = nullptr;
    m_nSessionId = 0;
    m_nSystemByte = 0;
}
CHsmsActive::~CHsmsActive()
{
}
void CHsmsActive::setListener(ACTIVEListener listener)
{
    m_listener = listener;
}
int CHsmsActive::init(const char* pszIp, int port)
{
    m_strIp = pszIp;
    m_nPort = port;
    auto onStatusChanged = [&](void* pFrom, ACTIVESTATE state) -> void {
        if (m_listener.onStateChanged != nullptr) {
            m_listener.onStateChanged(this, state);
        }
        if (ACTIVESTATE::NOT_SELECTED == state) {
            LOGI("Active state changed(NOT_SELECTED).");
            hsmsSelectRequest();
        }
        else if (ACTIVESTATE::SELECTED == state) {
            LOGI("Active state changed(SELECTED).");
            hsmsEstablishCommunications();
        }
        else if (ACTIVESTATE::NOT_CONNECTED == state) {
            LOGI("Active state changed(NOT_CONNECTED).");
            m_pActive->disconnect();
        }
    };
    auto onRecvSysMessage = [&](void* pFrom, IMessage* pMessage) -> void {
        LOGI("onRecvSysMessage(sessionId:%d, sType:%d).",
            pMessage->getHeader()->sessionId, pMessage->getHeader()->sType);
        TRACE("sessionId:%d, sType:%d\n", pMessage->getHeader()->sessionId, pMessage->getHeader()->sType);
    };
    auto onError = [&](void* pFrom, int error) -> void {
        TRACE("onError:%d\n", error);
    };
    auto onRecvRawData = [&](void* pFrom, const char* pszData, int size) {
        TRACE("onRec ,vRawData:<0x%x, %d>\n", pszData, size);
    };
    auto onRecvDataMessage = [&](void* pFrom, IMessage* pMessage) -> void {
        HEADER* pHeader = pMessage->getHeader();
        int nStream = (pHeader->stream & 0x7F);
        TRACE("收到消息 S%dF%d================\n", pHeader->stream & 0x7F, pHeader->function);
        TRACE("Body:%s\n", pMessage->toString());
        LOGI("onRecvDataMessage(%s).", pMessage->toString());
        if (nStream == 5 && pHeader->function == 1) {
            // S1F1
            replyAck(5, 2, pMessage->getHeader()->systemBytes, 0, _T("ACK0"));
        }
    };
    ActiveListener listener;
    listener.funStateChanged = onStatusChanged;
    listener.funRecvRawData = onRecvRawData;
    listener.funRecvDataMessage = onRecvDataMessage;
    listener.funRecvSysMessage = onRecvSysMessage;
    listener.funError = onError;
    int nRet = HSMS_CreateActive(m_pActive, _T(""), m_strIp.c_str(), m_nPort);
    if (nRet == 0 && m_pActive != nullptr) {
        m_pActive->setListener(listener);
        m_pActive->connect();
    }
    return 0;
}
int CHsmsActive::term()
{
    if (m_pActive != nullptr) {
        ::HSMS_DestroyActive(m_pActive);
        m_pActive = nullptr;
    }
    return 0;
}
int CHsmsActive::hsmsSelectRequest()
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_CreateMessageWithSType(pMessage, MSG_SELECT_REQ, ++m_nSystemByte);
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsDeselectRequest()
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_CreateMessageWithSType(pMessage, MSG_DESELECT_REQ, ++m_nSystemByte);
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsEstablishCommunications()
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 1 | REPLY, 13, ++m_nSystemByte);
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsAreYouThere()
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 1 | REPLY, 1, ++m_nSystemByte);
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsDatetimeSync()
{
    CTime time = CTime::GetCurrentTime();
    char szTime[256];
    sprintf_s(szTime, 256, _T("%4d%02d%02d%02d%02d%02d00"), time.GetYear(),
        time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 2 | REPLY, 31, ++m_nSystemByte);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->setString((const char*)szTime, _T("Date time"));
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsTerminalDisplay(BYTE tid, const char* pszText)
{
    char szTid[1];
    szTid[0] = tid;
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 10 | REPLY, 3, ++m_nSystemByte);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addBinaryItem(szTid, 1, _T("TID"));
    pItem->addItem(pszText, _T("TEXT"));
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsEDEventReport(bool bEnable, std::vector<int>& ids)
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 2 | REPLY, 37, ++m_nSystemByte);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addBoolItem(bEnable, "CEED");
    ISECS2Item* pItem2 = pItem->addItem();
    for (auto item : ids) {
        pItem2->addU4Item(item, "CEID");
    }
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    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::hsmsDefineReports(std::map<unsigned int, std::vector<unsigned int>>& mapReport)
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 2 | REPLY, 33, ++m_nSystemByte);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addU4Item(1, "DATAID");
    ISECS2Item* pItemReportList = pItem->addItem();
    for (auto item : mapReport) {
        ISECS2Item* pItemReport = pItemReportList->addItem();
        pItemReport->addU4Item(item.first, "RPTID");
        ISECS2Item* pItemVidList = pItemReport->addItem();
        for (auto vid : item.second) {
            pItemVidList->addU4Item(vid, "VID");
        }
    }
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsLinkEventReport(std::map<unsigned int, std::vector<unsigned int>>& mapEvent)
{
    if (mapEvent.empty()) return 0;
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 2 | REPLY, 35, ++m_nSystemByte);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addU4Item(1, "DATAID");
    ISECS2Item* pItemEventList = pItem->addItem();
    for (auto item : mapEvent) {
        ISECS2Item* pItemEvent = pItemEventList->addItem();
        pItemEvent->addU4Item(item.first, "CEID");
        ISECS2Item* pItemRptidList = pItemEvent->addItem();
        for (auto vid : item.second) {
            pItemRptidList->addU4Item(vid, "RPTID");
        }
    }
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::hsmsConfigureSpooling(std::map<unsigned int, std::set<unsigned int>>& spoolingConfig)
{
    IMessage* pMessage = nullptr;
    int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 2 | REPLY, 43, ++m_nSystemByte);
    if (spoolingConfig.size() > 0) {
        for (auto s : spoolingConfig) {
            ISECS2Item* pItemStreamList = pMessage->getBody()->addItem();
            pItemStreamList->addU1Item(s.first, "STRID");
            ISECS2Item* pItemFcnList = pItemStreamList->addItem();
            for (auto f : s.second) {
                pItemFcnList->addU1Item(f, "FCNID");
            }
        }
    }
    m_pActive->sendMessage(pMessage);
    HSMS_Destroy1Message(pMessage);
    return 0;
}
int CHsmsActive::replyAck0(IMessage* pMessage)
{
    return 0;
}
// é€šç”¨çš„reply ack函数
void CHsmsActive::replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName)
{
    IMessage* pMessage = NULL;
    HSMS_Create1Message(pMessage, m_nSessionId, s, f, systemBytes);
    ASSERT(pMessage);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->setBinary((const char*)&ack, 1, pszAckName);
    m_pActive->sendMessage(pMessage);
    LOGI("<HSMS>[SECS Msg SEND]S%dF%d (SysByte=%u)", s, f, systemBytes);
    HSMS_Destroy1Message(pMessage);
}
SourceCode/Bond/EAPSimulator/CHsmsActive.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,74 @@
#pragma once
#include <string>
#include <vector>
#include <map>
#include <set>
#include "CCollectionEvent.h"
typedef std::function<void(void* pFrom, ACTIVESTATE state)> STATECHANGED;
typedef struct _ACTIVEListener
{
    STATECHANGED            onStateChanged;
} ACTIVEListener;
class CHsmsActive
{
public:
    CHsmsActive();
    ~CHsmsActive();
public:
    void setListener(ACTIVEListener listener);
    int init(const char* pszIp, int port);
    int term();
public:
    // Select
    int hsmsSelectRequest();
    // Deselect Request
    int hsmsDeselectRequest();
    // å»ºç«‹é€šè®¯(S1F13)
    int hsmsEstablishCommunications();
    // Are You There
    int hsmsAreYouThere();
    // Date time sync
    int hsmsDatetimeSync();
    // terminal display
    int hsmsTerminalDisplay(BYTE tid, const char* pszText);
    // Enable/Disable Event Report
    int hsmsEDEventReport(bool bEnable, std::vector<int>& ids);
    // Enable/Disable Alarm Report
    int hsmsEDAlarmReport(bool bEnable, unsigned int id);
    // Define reports
    int hsmsDefineReports(std::map<unsigned int, std::vector<unsigned int>>& mapReport);
    // Line Event Report
    int hsmsLinkEventReport(std::map<unsigned int, std::vector<unsigned int>>& mapEvent);
    // Configure Spooling
    int hsmsConfigureSpooling(std::map<unsigned int, std::set<unsigned int>>& spoolingConfig);
    // é€šè¿‡çš„reply函数
    void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
    // reply ack0
    int replyAck0(IMessage* pMessage);
private:
    ACTIVEListener m_listener;
    IActive* m_pActive;
    std::string m_strIp;
    int m_nPort;
    unsigned short m_nSessionId;
    unsigned int m_nSystemByte;
};
SourceCode/Bond/EAPSimulator/CLinkReportDetailDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
// CLinkReportDetailDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "EAPSimulator.h"
#include "CLinkReportDetailDlg.h"
#include "afxdialogex.h"
// CLinkReportDetailDlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CLinkReportDetailDlg, CDialogEx)
CLinkReportDetailDlg::CLinkReportDetailDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_LINK_REPORT_DETAIL, pParent)
{
    m_pEvent = nullptr;
}
CLinkReportDetailDlg::~CLinkReportDetailDlg()
{
}
void CLinkReportDetailDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CLinkReportDetailDlg, CDialogEx)
    ON_BN_CLICKED(IDOK, &CLinkReportDetailDlg::OnBnClickedOk)
END_MESSAGE_MAP()
// CLinkReportDetailDlg æ¶ˆæ¯å¤„理程序
void CLinkReportDetailDlg::SetCollectionEvent(SERVO::CCollectionEvent* pEvent)
{
    m_pEvent = pEvent;
}
BOOL CLinkReportDetailDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    ASSERT(m_pEvent);
    SetDlgItemInt(IDC_EDIT_CEID, m_pEvent->getEventId());
    SetDlgItemText(IDC_EDIT_CE_NAME, m_pEvent->getName().c_str());
    SetDlgItemText(IDC_EDIT_CE_DESCRIPTIONS, m_pEvent->getDescription().c_str());
    SetDlgItemText(IDC_EDIT_CE_RPTID, m_pEvent->getReportIdsText().c_str());
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
void CLinkReportDetailDlg::OnBnClickedOk()
{
    ASSERT(m_pEvent);
    UINT RPTID = GetDlgItemInt(IDC_EDIT_CE_RPTID);
    m_pEvent->setReport(RPTID);
    CDialogEx::OnOK();
}
SourceCode/Bond/EAPSimulator/CLinkReportDetailDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,31 @@
#pragma once
#include "CCollectionEvent.h"
// CLinkReportDetailDlg å¯¹è¯æ¡†
class CLinkReportDetailDlg : public CDialogEx
{
    DECLARE_DYNAMIC(CLinkReportDetailDlg)
public:
    CLinkReportDetailDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CLinkReportDetailDlg();
    void SetCollectionEvent(SERVO::CCollectionEvent* pEvent);
private:
    SERVO::CCollectionEvent* m_pEvent;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_DIALOG_LINK_REPORT_DETAIL };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg void OnBnClickedOk();
};
SourceCode/Bond/EAPSimulator/CLinkReportDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,205 @@
// CLinkReportDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "EAPSimulator.h"
#include "CLinkReportDlg.h"
#include "afxdialogex.h"
#include <string.h>
#include <regex>
#include "CLinkReportDetailDlg.h"
// CLinkReportDlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CLinkReportDlg, CDialogEx)
CLinkReportDlg::CLinkReportDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_LINK_REPORT, pParent)
{
}
CLinkReportDlg::~CLinkReportDlg()
{
}
void CLinkReportDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CLinkReportDlg, CDialogEx)
    ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CLinkReportDlg::OnListCtrlDoubleClick)
    ON_BN_CLICKED(IDC_BUTTON_SEND, &CLinkReportDlg::OnBnClickedButtonSend)
    ON_WM_DESTROY()
END_MESSAGE_MAP()
// CLinkReportDlg æ¶ˆæ¯å¤„理程序
BOOL CLinkReportDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
    DWORD dwStyle = pListCtrl->GetExtendedStyle();
    dwStyle |= LVS_EX_FULLROWSELECT;
    dwStyle |= LVS_EX_GRIDLINES;
    pListCtrl->SetExtendedStyle(dwStyle);
    pListCtrl->ModifyStyle(0, LVS_SHOWSELALWAYS);
    HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
    ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL);
    pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0);
    pListCtrl->InsertColumn(1, _T("CEID"), LVCFMT_LEFT, 120);
    pListCtrl->InsertColumn(2, _T("CD Name"), LVCFMT_LEFT, 120);
    pListCtrl->InsertColumn(3, _T("Descriptions"), LVCFMT_LEFT, 180);
    pListCtrl->InsertColumn(4, _T("Attached RPTID"), LVCFMT_LEFT, 120);
    pListCtrl->SetColumnWidth(4, LVSCW_AUTOSIZE_USEHEADER);
    CString strFile;
    strFile.Format(_T("%s\\CollectionEventList.txt"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    loadCollectionEvents((LPTSTR)(LPCTSTR)strFile);
    for (auto item : m_collectionEvents) {
        int index = pListCtrl->InsertItem(pListCtrl->GetItemCount(), _T(""));
        pListCtrl->SetItemData(index, (DWORD_PTR)item);
        pListCtrl->SetItemText(index, 1, std::to_string(item->getEventId()).c_str());
        pListCtrl->SetItemText(index, 2, item->getName().c_str());
        pListCtrl->SetItemText(index, 3, item->getDescription().c_str());
        pListCtrl->SetItemText(index, 4, item->getReportIdsText().c_str());
    }
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
int CLinkReportDlg::loadCollectionEvents(const char* pszFilepath)
{
    CStdioFile file;
    if (!file.Open(pszFilepath, CFile::modeRead)) {
        return -1;
    }
    std::regex pattern("^\\d+,[^,]*,[^,]*,\\(\\d+(,\\d+)*\\).*");  // åŒ¹é…ä»¥æ•°å­—+逗号开头的字符串
    std::vector<SERVO::CCollectionEvent*> events;
    int index, last;
    CString strLine, strRPTIDs;
    CString strId, strName, strDescription;
    while (file.ReadString(strLine)) {
        if (!std::regex_match((LPTSTR)(LPCTSTR)strLine, pattern)) {
            continue;
        }
        last = 0;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strId = strLine.Left(index);
        last = index + 1;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strName = strLine.Mid(last, index - last);
        last = index + 1;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strDescription = strLine.Mid(last, index - last);
        strRPTIDs = strLine.Right(strLine.GetLength() - index - 1);
        strRPTIDs.Delete(0);
        strRPTIDs.Delete(strRPTIDs.GetLength() - 1);
        auto prtids = parseVidList(strRPTIDs);
        SERVO::CCollectionEvent* pEvent = new SERVO::CCollectionEvent(
            atoi(strId), (LPTSTR)(LPCTSTR)strName, (LPTSTR)(LPCTSTR)strDescription, prtids);
        events.push_back(pEvent);
    }
    if (!events.empty()) {
        clearAllCollectionEvent();
        for (auto item : events) {
            m_collectionEvents.push_back(item);
        }
    }
    file.Close();
    return 0;
}
std::vector<unsigned int> CLinkReportDlg::parseVidList(CString& strNums)
{
    // 1. å…ˆåŽ»æŽ‰å¯èƒ½å‡ºçŽ°çš„ç©ºç™½ç¬¦ï¼ˆç©ºæ ¼ã€åˆ¶è¡¨ç¬¦ç­‰ï¼‰
    strNums.Trim();
    // 2️.
    std::vector<unsigned int> result;
    int i = 0;
    CString strVid;
    while (1) {
        if (!AfxExtractSubString(strVid, (LPCTSTR)strNums, i, ',')) {
            break;
        }
        if (!strVid.IsEmpty())                 // é˜²å¾¡æ€§æ£€æŸ¥
            result.push_back(std::stoi((LPTSTR)(LPCTSTR)strVid));
        i++;
    }
    return result;
}
void CLinkReportDlg::clearAllCollectionEvent()
{
    for (auto item : m_collectionEvents) {
        delete item;
    }
    m_collectionEvents.clear();
}
void CLinkReportDlg::OnListCtrlDoubleClick(NMHDR* pNMHDR, LRESULT* pResult)
{
    LPNMITEMACTIVATE pNMItem = (LPNMITEMACTIVATE)pNMHDR;
    int nItem = pNMItem->iItem;
    if (nItem >= 0) {
        CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
        SERVO::CCollectionEvent* pEvent = (SERVO::CCollectionEvent*)pListCtrl->GetItemData(nItem);
        CLinkReportDetailDlg dlg;
        dlg.SetCollectionEvent(pEvent);
        if (IDOK == dlg.DoModal()) {
            pListCtrl->SetItemText(nItem, 4, pEvent->getReportIdsText().c_str());
        }
    }
    *pResult = 0;
}
void CLinkReportDlg::OnBnClickedButtonSend()
{
    std::vector<SERVO::CCollectionEvent*> events;
    CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
    POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
    while (pos) {
        int nItem = pListCtrl->GetNextSelectedItem(pos);
        SERVO::CCollectionEvent* pEvent = (SERVO::CCollectionEvent*)pListCtrl->GetItemData(nItem);
        events.push_back(pEvent);
    }
    std::map<unsigned int, std::vector<unsigned int>> mapEvent;
    for (auto item : events) {
        std::vector<unsigned int> RPTIDs = item->getReportIds();
        mapEvent[item->getEventId()] = RPTIDs;
    }
    theApp.m_model.m_pHsmsActive->hsmsLinkEventReport(mapEvent);
}
void CLinkReportDlg::OnDestroy()
{
    CDialogEx::OnDestroy();
    clearAllCollectionEvent();
}
SourceCode/Bond/EAPSimulator/CLinkReportDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
#pragma once
#include "CCollectionEvent.h"
// CLinkReportDlg å¯¹è¯æ¡†
class CLinkReportDlg : public CDialogEx
{
    DECLARE_DYNAMIC(CLinkReportDlg)
public:
    CLinkReportDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CLinkReportDlg();
    int loadCollectionEvents(const char* pszFilepath);
    std::vector<unsigned int> parseVidList(CString& strNums);
    void clearAllCollectionEvent();
private:
    std::vector<SERVO::CCollectionEvent*> m_collectionEvents;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_DIALOG_LINK_REPORT };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg void OnListCtrlDoubleClick(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnBnClickedButtonSend();
    afx_msg void OnDestroy();
};
SourceCode/Bond/EAPSimulator/CModel.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,300 @@
#include "pch.h"
#include "CModel.h"
#include "Log.h"
#include "Common.h"
CModel::CModel()
{
    m_pObservableEmitter = nullptr;
    m_pObservable = nullptr;
    m_pHsmsActive = nullptr;
}
CModel::~CModel()
{
}
IObservable* CModel::getObservable()
{
    if (m_pObservable == nullptr) {
        m_pObservable = RX_AllocaObservable([&](IObservableEmitter* e) -> void {
            m_pObservableEmitter = e;            // ä¿å­˜å‘射器
            });
    }
    return m_pObservable;
}
void CModel::setWorkDir(const char* pszWorkDir)
{
    m_strWorkDir = pszWorkDir;
}
int CModel::init()
{
    CString strIniFile;
    // Log
    CString strLogDir;
    strLogDir.Format(_T("%s\\Log"), (LPTSTR)(LPCTSTR)m_strWorkDir);
    ::CreateDirectory(strLogDir, NULL);
    CLog::GetLog()->SetOnLogCallback([&](int level, const char* pszMessage) -> void {
        notifyTextAndInt(RX_CODE_LOG, pszMessage, level);
        });
    CLog::GetLog()->SetAutoAppendTimeString(TRUE);
    CLog::GetLog()->SetOutputTarget(OT_FILE);
    CLog::GetLog()->SetLogsDir(strLogDir);
    CLog::GetLog()->SetEquipmentId(_T("EAP"));
    LOGI("\r\n\r\n~~~ Prog Start! ~~~");
    return 0;
}
int CModel::term()
{
    CLog::GetLog()->SetOnLogCallback(nullptr);
    if (m_pHsmsActive != nullptr) {
        m_pHsmsActive->term();
        delete m_pHsmsActive;
    }
    return 0;
}
int CModel::connectEq(const char* pszIp, int port)
{
    if (m_pHsmsActive != nullptr) {
        m_pHsmsActive->term();
        delete m_pHsmsActive;
    }
    ACTIVEListener listener;
    listener.onStateChanged = [&](void* pFrom, ACTIVESTATE state) -> void {
        notifyInt(RX_CODE_ACTIVE_STATUS_CHANGED, (int)state);
    };
    m_pHsmsActive = new CHsmsActive();
    m_pHsmsActive->setListener(listener);
    m_pHsmsActive->init(pszIp, port);
    return 0;
}
int CModel::disconnect()
{
    if (m_pHsmsActive == nullptr) {
        return -1;
    }
    m_pHsmsActive->hsmsDeselectRequest();
    return 0;
}
int CModel::notify(int code)
{
    /* code */
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 1;
}
int CModel::notifyPtr(int code, void* ptr/* = NULL*/)
{
    /* code */
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setPtrValue("ptr", ptr);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 1;
}
int CModel::notifyObj(int code, IRxObject* pObj)
{
    /* code */
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setObject("obj", pObj);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 1;
}
int CModel::notifyObjAndPtr(int code, IRxObject* pObj, void* ptr)
{
    /* code */
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setObject("obj", pObj);
            pAny->setPtrValue("ptr", ptr);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 1;
}
int CModel::notifyInt(int code, int exCode)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setIntValue("exCode", exCode);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
int CModel::notifyInt2(int code, int exCode, int exCode2)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setIntValue("exCode", exCode);
            pAny->setIntValue("exCode2", exCode2);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
int CModel::notifyDouble(int code, double dValue)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setDoubleValue("value", dValue);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
int CModel::notifyObjAndInt(int code, IRxObject* pObj1, IRxObject* pObj2, int exCode)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            if (pObj1 != nullptr) pAny->setObject("obj", pObj1);
            if (pObj2 != nullptr) pAny->setObject("obj2", pObj2);
            pAny->setIntValue("exCode", exCode);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
int CModel::notifyText(int code, const char* pszText)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setStringValue("text", pszText);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
int CModel::notifyTextAndInt(int code, const char* pszText, int exCode)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setStringValue("text", pszText);
            pAny->setIntValue("exCode", exCode);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
int CModel::notifyPtrAndInt(int code, void* ptr1, void* ptr2, int exCode)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setPtrValue("ptr", ptr1);
            pAny->setPtrValue("ptr1", ptr1);
            pAny->setPtrValue("ptr2", ptr2);
            pAny->setIntValue("exCode", exCode);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
int CModel::notifyMesMsg(int code, int stream, int function, const char* pszText)
{
    if (m_pObservableEmitter != NULL) {
        IAny* pAny = RX_AllocaAny();
        if (pAny != NULL) {
            pAny->addRef();
            pAny->setCode(code);
            pAny->setIntValue("stream", stream);
            pAny->setIntValue("function", function);
            pAny->setStringValue("text", pszText);
            m_pObservableEmitter->onNext(pAny);
            pAny->release();
        }
    }
    return 0;
}
SourceCode/Bond/EAPSimulator/CModel.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,43 @@
#pragma once
#include "CHsmsActive.h"
class CModel
{
public:
    CModel();
    ~CModel();
public:
    IObservable* getObservable();
    void setWorkDir(const char* pszWorkDir);
    int init();
    int term();
    int connectEq(const char* pszIp, int port);
    int disconnect();
public:
    int notify(int code);
    int notifyPtr(int code, void* ptr = NULL);
    int notifyObj(int code, IRxObject* pObj);
    int notifyObjAndPtr(int code, IRxObject* pObj, void* ptr);
    int notifyObjAndInt(int code, IRxObject* pObj1, IRxObject* pObj2, int exCode);
    int notifyInt(int code, int exCode);
    int notifyInt2(int code, int exCode, int exCode2);
    int notifyDouble(int code, double dValue);
    int notifyText(int code, const char* pszText);
    int notifyPtrAndInt(int code, void* ptr1, void* ptr2, int exCode);
    int notifyTextAndInt(int code, const char* pszText, int exCode);
    int notifyMesMsg(int code, int stream, int function, const char* pszText);
public:
    CHsmsActive* m_pHsmsActive;
private:
    IObservable* m_pObservable;
    IObservableEmitter* m_pObservableEmitter;
    CString m_strWorkDir;
    CString m_strDataDir;
};
SourceCode/Bond/EAPSimulator/CReport.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,98 @@
#include "pch.h"
#include "CReport.h"
namespace SERVO {
    CReport::CReport()
    {
        m_nReportId = 0;
    }
    CReport::CReport(unsigned int reportId, std::vector<unsigned int>& vids)
    {
        m_nReportId = reportId;
        for (auto vid : vids) {
            m_vids.push_back(vid);
        }
    }
    CReport::~CReport()
    {
    }
    unsigned int CReport::getReportId()
    {
        return m_nReportId;
    }
    BOOL CReport::addVariable(CVariable* pVariable)
    {
        ASSERT(pVariable);
        if (getVariable(pVariable->getVarialbleId()) != nullptr) {
            return FALSE;
        }
        m_variabels.push_back(pVariable);
        return TRUE;
    }
    BOOL CReport::deleteVarialble(unsigned int nVarialbleId)
    {
        BOOL bDelete = FALSE;
        for (auto iter = m_variabels.begin(); iter != m_variabels.end(); ++iter) {
            if (nVarialbleId == (*iter)->getVarialbleId()) {
                m_variabels.erase(iter);
                bDelete = TRUE;
                break;
            }
        }
        return bDelete;
    }
    CVariable* CReport::getVariable(unsigned int nVarialbleId)
    {
        for (auto item : m_variabels) {
            if (nVarialbleId == item->getVarialbleId()) {
                return item;
            }
        }
        return nullptr;
    }
    std::vector<CVariable*>& CReport::getVariables()
    {
        return m_variabels;
    }
    std::string CReport::getVariablesIdsText()
    {
        std::string strResult, strName;
        for (int i = 0; i < m_vids.size(); i++) {
            strResult += std::to_string(m_vids[i]);
            strResult += "(";
            strResult += (getVariableName(m_vids[i], strName) ?
                strName : _T("null"));
            strResult += ")";
            if (i != m_vids.size() - 1) {
                strResult += ",";
            }
        }
        return strResult;
    }
    bool CReport::getVariableName(unsigned int vid, std::string& strName)
    {
        for (auto item : m_variabels) {
            if (item->getVarialbleId() == vid) {
                strName = item->getName();
                return true;
            }
        }
        return false;
    }
}
SourceCode/Bond/EAPSimulator/CReport.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
#pragma once
#include "CVariable.h"
#include <vector>
namespace SERVO {
    class CReport
    {
    public:
        CReport();
        CReport(unsigned int reportId, std::vector<unsigned int>& vids);
        virtual ~CReport();
    public:
        unsigned int getReportId();
        BOOL addVariable(CVariable* pVariable);
        BOOL deleteVarialble(unsigned int nVarialbleId);
        CVariable* getVariable(unsigned int nVarialbleId);
        std::vector<CVariable*>& getVariables();
        std::string getVariablesIdsText();
        bool getVariableName(unsigned int vid, std::string& strName);
    private:
        unsigned int m_nReportId;
        std::vector<unsigned int> m_vids;
        std::vector<CVariable*> m_variabels;
    };
}
SourceCode/Bond/EAPSimulator/CTerminalDisplayDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,73 @@
// CTerminalDisplayDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "EAPSimulator.h"
#include "CTerminalDisplayDlg.h"
#include "afxdialogex.h"
// CTerminalDisplayDlg å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CTerminalDisplayDlg, CDialogEx)
CTerminalDisplayDlg::CTerminalDisplayDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_TERMINAL_DISPLAY, pParent)
{
}
CTerminalDisplayDlg::~CTerminalDisplayDlg()
{
}
void CTerminalDisplayDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CTerminalDisplayDlg, CDialogEx)
    ON_EN_CHANGE(IDC_EDIT_TEXT, &CTerminalDisplayDlg::OnEnChangeEditText)
    ON_BN_CLICKED(IDC_BUTTON_SEND, &CTerminalDisplayDlg::OnBnClickedButtonSend)
END_MESSAGE_MAP()
// CTerminalDisplayDlg æ¶ˆæ¯å¤„理程序
BOOL CTerminalDisplayDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    // æ·»åŠ ç»ˆç«¯id
    CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_TID);
    pComboBox->InsertString(0, _T("0(全部)"));
    pComboBox->InsertString(1, _T("1(终端1)"));
    pComboBox->InsertString(2, _T("2(终端2)"));
    pComboBox->InsertString(3, _T("3(终端3)"));
    pComboBox->InsertString(4, _T("4(终端4)"));
    pComboBox->SetCurSel(0);
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
void CTerminalDisplayDlg::OnEnChangeEditText()
{
    CString strText;
    GetDlgItemText(IDC_EDIT_TEXT, strText);
    GetDlgItem(IDC_BUTTON_SEND)->EnableWindow(!strText.IsEmpty());
}
void CTerminalDisplayDlg::OnBnClickedButtonSend()
{
    CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_TID);
    BYTE tid = (BYTE)pComboBox->GetCurSel();
    CString strText;
    GetDlgItemText(IDC_EDIT_TEXT, strText);
    theApp.m_model.m_pHsmsActive->hsmsTerminalDisplay(tid, (LPTSTR)(LPCTSTR)strText);
}
SourceCode/Bond/EAPSimulator/CTerminalDisplayDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
#pragma once
// CTerminalDisplayDlg å¯¹è¯æ¡†
class CTerminalDisplayDlg : public CDialogEx
{
    DECLARE_DYNAMIC(CTerminalDisplayDlg)
public:
    CTerminalDisplayDlg(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CTerminalDisplayDlg();
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_DIALOG_TERMINAL_DISPLAY };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg void OnEnChangeEditText();
    afx_msg void OnBnClickedButtonSend();
};
SourceCode/Bond/EAPSimulator/CVariable.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,90 @@
#include "pch.h"
#include "CVariable.h"
namespace SERVO {
    CVariable::CVariable()
    {
        m_nVarialbeId = 0;
        m_format = SVFromat::U1;
    }
    CVariable::CVariable(const char* pszId, const char* pszName, const char* pszFormat, const char* pszRemark)
    {
        m_nVarialbeId = atoi(pszId);
        m_strName = pszName;
        m_format = toFormat(pszFormat);
        m_strRemark = pszRemark;
        TRACE("CVariable .....%d,%s,%d,%s\n", m_nVarialbeId, m_strName.c_str(),
            m_format, m_strRemark.c_str());
    }
    CVariable::~CVariable()
    {
    }
    SVFromat CVariable::toFormat(const char* pszFormat)
    {
        if (_strcmpi("U1", pszFormat) == 0) {
            return SVFromat::U1;
        }
        if (_strcmpi("U2", pszFormat) == 0) {
            return SVFromat::U2;
        }
        if (_strcmpi("I2", pszFormat) == 0) {
            return SVFromat::I2;
        }
        if (_strcmpi("A50", pszFormat) == 0) {
            return SVFromat::A50;
        }
        if (_strcmpi("A20", pszFormat) == 0) {
            return SVFromat::A20;
        }
        return SVFromat::U1;
    }
    std::string CVariable::formatToString(SVFromat format)
    {
        if (SVFromat::U1 == format) {
            return "U1";
        }
        if (SVFromat::U2 == format) {
            return "U1";
        }
        if (SVFromat::I2 == format) {
            return "I2";
        }
        if (SVFromat::A50 == format) {
            return "A50";
        }
        if (SVFromat::A20 == format) {
            return "A20";
        }
        return "U1";
    }
    unsigned int CVariable::getVarialbleId()
    {
        return m_nVarialbeId;
    }
    std::string& CVariable::getName()
    {
        return m_strName;
    }
    SVFromat CVariable::getFormat()
    {
        return m_format;
    }
    std::string& CVariable::getRemark()
    {
        return m_strRemark;
    }
}
SourceCode/Bond/EAPSimulator/CVariable.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
#pragma once
#include <string>
namespace SERVO {
    // å˜é‡æ ¼å¼
    enum class SVFromat {
        U1 = 0,
        U2,
        I2,
        A20,
        A50
    };
    class CVariable
    {
    public:
        CVariable();
        CVariable(const char* pszId, const char* pszName, const char* pszFormat, const char* pszRemark);
        ~CVariable();
    public:
        static SVFromat toFormat(const char* pszFormat);
        static std::string formatToString(SVFromat format);
        unsigned int getVarialbleId();
        std::string& getName();
        SVFromat getFormat();
        std::string& getRemark();
    private:
        unsigned int m_nVarialbeId;
        std::string m_strName;
        SVFromat m_format;
        std::string m_strRemark;
    };
}
SourceCode/Bond/EAPSimulator/Common.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,6 @@
#pragma once
#define RX_CODE_TEST                    0
#define RX_CODE_LOG                        1000
#define RX_CODE_ACTIVE_STATUS_CHANGED    1001
SourceCode/Bond/EAPSimulator/Context.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,184 @@
#include "pch.h"
#include "Context.h"
#include <dbghelp.h>
#pragma comment(lib, "dbghelp.lib")
void PrintStackTrace()
{
    void* stack[62]; // æœ€å¤šæŠ“62层
    USHORT frames = CaptureStackBackTrace(0, 62, stack, NULL);
    HANDLE process = GetCurrentProcess();
    SymInitialize(process, NULL, TRUE);
    for (USHORT i = 0; i < frames; ++i) {
        DWORD64 address = (DWORD64)(stack[i]);
        char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
        PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
        symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
        symbol->MaxNameLen = MAX_SYM_NAME;
        if (SymFromAddr(process, address, 0, symbol)) {
            TRACE(">>>> name:%s\n", symbol->Name);
        }
        else {
            TRACE(">>>> name:%s\n", "SymFromAddr failed");
        }
    }
    SymCleanup(process);
}
CContext::CContext()
{
    m_onReleaseCallback = nullptr;
    m_nRef = 0;
    m_nRetCode = 0;
    m_hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
    InitializeCriticalSection(&m_criticalSection);
}
CContext::~CContext()
{
    if (m_hEvent != NULL) {
        CloseHandle(m_hEvent);
        m_hEvent = NULL;
    }
    DeleteCriticalSection(&m_criticalSection);
}
void CContext::setOnRelease(ONRELEASECALLBACK fOnRelease)
{
    m_onReleaseCallback = fOnRelease;
}
int CContext::addRef()
{
    Lock();
    m_nRef++;
    Unlock();
    return m_nRef;
}
int CContext::release()
{
    Lock();
    if (m_nRef > 0) {
        m_nRef--;
        BOOL bRefCount0 = m_nRef == 0;
        Unlock();
        if (bRefCount0 && m_onReleaseCallback != nullptr) {
            m_onReleaseCallback(this);
        }
    }
    else {
        Unlock();
    }
    return m_nRef;
}
void CContext::setRetCode(int code)
{
    m_nRetCode = code;
}
int CContext::getRetCode()
{
    return m_nRetCode;
}
void CContext::setRetMsg(const char* pszMsg)
{
    m_strRetMsg = pszMsg;
}
std::string& CContext::getRetMsg()
{
    return m_strRetMsg;
}
HANDLE CContext::getEventHandle()
{
    return m_hEvent;
}
void CContext::setEvent()
{
    if (m_hEvent != NULL) {
        SetEvent(m_hEvent);
    }
}
void CContext::resetEvent()
{
    if (m_hEvent != NULL) {
        ResetEvent(m_hEvent);
    }
}
void CContext::ReadString(CArchive& ar, std::string& string)
{
    CString strTemp;
    ar >> strTemp;
    string = (LPTSTR)(LPCTSTR)strTemp;
}
void CContext::WriteString(CArchive& ar, std::string& string)
{
    CString strTemp = string.c_str();
    ar << strTemp;
}
void CContext::createDir(CString strDir)
{
    int lastIndex = 0;
    int index = strDir.Find(_T("\\"), lastIndex);
    while (index > 0) {
        CString strTempDir = strDir.Left(index);
        CreateDirectory(strTempDir, NULL);
        lastIndex = index + 1;
        index = strDir.Find(_T("\\"), lastIndex);
    }
    CreateDirectory(strDir, NULL);
}
BOOL CContext::IsBoxId(CString& strId)
{
    //'W20'开头,倒数第五位为'Z'的字符串
    if (strId.GetLength() < 8) {
        return FALSE;
    }
    if (strId.Left(3).Compare(_T("W20")) != 0) {
        return FALSE;
    }
    if (strId.Right(5).GetAt(0) != (char)'Z') {
        return FALSE;
    }
    return TRUE;
}
BOOL CContext::IsLotId(CString& strId)
{
    //'N20'开头,倒数第五位为'Z'的字符串
    if (strId.GetLength() < 8) {
        return FALSE;
    }
    if (strId.Left(3).Compare(_T("N20")) != 0) {
        return FALSE;
    }
    if (strId.Right(5).GetAt(0) != (char)'Z') {
        return FALSE;
    }
    return TRUE;
}
SourceCode/Bond/EAPSimulator/Context.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,48 @@
#pragma once
#include "Common.h"
#include <functional>
typedef std::function<void(void*)> ONRELEASECALLBACK;
class CContext : public IRxObject
{
public:
    CContext();
    virtual ~CContext();
public:
    void setOnRelease(ONRELEASECALLBACK fOnRelease);
    int addRef();
    int release();
public:
    virtual std::string& getClassName() = 0;
    virtual std::string toString() = 0;
    void setRetCode(int code);
    int getRetCode();
    void setRetMsg(const char* pszMsg);
    std::string& getRetMsg();
    HANDLE getEventHandle();
    void setEvent();
    void resetEvent();
    static void createDir(CString strDir);
protected:
    inline void Lock() { EnterCriticalSection(&m_criticalSection); }
    inline void Unlock() { LeaveCriticalSection(&m_criticalSection); }
    void ReadString(CArchive& ar, std::string& string);
    void WriteString(CArchive& ar, std::string& string);
    static BOOL IsBoxId(CString& strId);
    static BOOL IsLotId(CString& strId);
private:
    ONRELEASECALLBACK m_onReleaseCallback;
    int m_nRef;
    CRITICAL_SECTION m_criticalSection;
protected:
    int m_nRetCode;
    std::string m_strRetMsg;
    HANDLE m_hEvent;
};
SourceCode/Bond/EAPSimulator/EAPSimulator.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,133 @@

// EAPSimulator.cpp: å®šä¹‰åº”用程序的类行为。
//
#include "pch.h"
#include "framework.h"
#include "EAPSimulator.h"
#include "EAPSimulatorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CEAPSimulatorApp
BEGIN_MESSAGE_MAP(CEAPSimulatorApp, CWinApp)
    ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CEAPSimulatorApp æž„造
CEAPSimulatorApp::CEAPSimulatorApp()
{
    // æ”¯æŒé‡æ–°å¯åŠ¨ç®¡ç†å™¨
    m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
    // TODO: åœ¨æ­¤å¤„添加构造代码,
    // å°†æ‰€æœ‰é‡è¦çš„初始化放置在 InitInstance ä¸­
}
// å”¯ä¸€çš„ CEAPSimulatorApp å¯¹è±¡
CEAPSimulatorApp theApp;
// CEAPSimulatorApp åˆå§‹åŒ–
BOOL CEAPSimulatorApp::InitInstance()
{
    // å¦‚果一个运行在 Windows XP ä¸Šçš„应用程序清单指定要
    // ä½¿ç”¨ ComCtl32.dll ç‰ˆæœ¬ 6 æˆ–更高版本来启用可视化方式,
    //则需要 InitCommonControlsEx()。  å¦åˆ™ï¼Œå°†æ— æ³•创建窗口。
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    // å°†å®ƒè®¾ç½®ä¸ºåŒ…括所有要在应用程序中使用的
    // å…¬å…±æŽ§ä»¶ç±»ã€‚
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);
    CWinApp::InitInstance();
    AfxEnableControlContainer();
    // åˆ›å»º shell ç®¡ç†å™¨ï¼Œä»¥é˜²å¯¹è¯æ¡†åŒ…含
    // ä»»ä½• shell æ ‘视图控件或 shell åˆ—表视图控件。
    CShellManager *pShellManager = new CShellManager;
    // æ¿€æ´»â€œWindows Native”视觉管理器,以便在 MFC æŽ§ä»¶ä¸­å¯ç”¨ä¸»é¢˜
    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
    // æ ‡å‡†åˆå§‹åŒ–
    // å¦‚果未使用这些功能并希望减小
    // æœ€ç»ˆå¯æ‰§è¡Œæ–‡ä»¶çš„大小,则应移除下列
    // ä¸éœ€è¦çš„特定初始化例程
    // æ›´æ”¹ç”¨äºŽå­˜å‚¨è®¾ç½®çš„æ³¨å†Œè¡¨é¡¹
    // TODO: åº”适当修改该字符串,
    // ä¾‹å¦‚修改为公司或组织名
    SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
    // æœ¬ç¨‹åºæ–‡ä»¶ç›®å½•
    TCHAR sDrive[_MAX_DRIVE];
    TCHAR sDir[_MAX_DIR];
    TCHAR sFilename[_MAX_FNAME], sAppFilename[_MAX_FNAME];
    TCHAR sExt[_MAX_EXT];
    GetModuleFileName(AfxGetInstanceHandle(), sAppFilename, _MAX_FNAME);
    _tsplitpath_s(sAppFilename, sDrive, sDir, sFilename, sExt);
    m_strAppDir = CString(sDrive) + CString(sDir);
    m_strAppFile = CString(sFilename);
    // åˆå§‹åŒ–Rx库
    RX_Init();
    HSMS_Initialize();
    CEAPSimulatorDlg dlg;
    m_pMainWnd = &dlg;
    INT_PTR nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
        // TODO: åœ¨æ­¤æ”¾ç½®å¤„理何时用
        //  â€œç¡®å®šâ€æ¥å…³é—­å¯¹è¯æ¡†çš„代码
    }
    else if (nResponse == IDCANCEL)
    {
        // TODO: åœ¨æ­¤æ”¾ç½®å¤„理何时用
        //  â€œå–消”来关闭对话框的代码
    }
    else if (nResponse == -1)
    {
        TRACE(traceAppMsg, 0, "警告: å¯¹è¯æ¡†åˆ›å»ºå¤±è´¥ï¼Œåº”用程序将意外终止。\n");
        TRACE(traceAppMsg, 0, "警告: å¦‚果您在对话框上使用 MFC æŽ§ä»¶ï¼Œåˆ™æ— æ³• #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
    }
    // åˆ é™¤ä¸Šé¢åˆ›å»ºçš„ shell ç®¡ç†å™¨ã€‚
    if (pShellManager != nullptr)
    {
        delete pShellManager;
    }
#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
    ControlBarCleanUp();
#endif
    // ç”±äºŽå¯¹è¯æ¡†å·²å…³é—­ï¼Œæ‰€ä»¥å°†è¿”回 FALSE ä»¥ä¾¿é€€å‡ºåº”用程序,
    //  è€Œä¸æ˜¯å¯åŠ¨åº”ç”¨ç¨‹åºçš„æ¶ˆæ¯æ³µã€‚
    return FALSE;
}
int CEAPSimulatorApp::ExitInstance()
{
    HSMS_Term();
    RX_Term();
    return CWinApp::ExitInstance();
}
SourceCode/Bond/EAPSimulator/EAPSimulator.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,40 @@

// EAPSimulator.h: PROJECT_NAME åº”用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
    #error "在包含此文件之前包含 'pch.h' ä»¥ç”Ÿæˆ PCH"
#endif
#include "resource.h"        // ä¸»ç¬¦å·
#include "CModel.h"
// CEAPSimulatorApp:
// æœ‰å…³æ­¤ç±»çš„实现,请参阅 EAPSimulator.cpp
//
class CEAPSimulatorApp : public CWinApp
{
public:
    CEAPSimulatorApp();
public:
    CModel m_model;
    CString m_strAppDir;
    CString m_strAppFile;
// é‡å†™
public:
    virtual BOOL InitInstance();
// å®žçް
    DECLARE_MESSAGE_MAP()
    virtual int ExitInstance();
};
extern CEAPSimulatorApp theApp;
SourceCode/Bond/EAPSimulator/EAPSimulator.rc
Binary files differ
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,247 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <VCProjectVersion>16.0</VCProjectVersion>
    <ProjectGuid>{9EA43050-B71C-47A7-AC90-F0D7A88C5F50}</ProjectGuid>
    <Keyword>MFCProj</Keyword>
    <RootNamespace>EAPSimulator</RootNamespace>
    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v142</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
    <UseOfMfc>Dynamic</UseOfMfc>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v142</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
    <UseOfMfc>Dynamic</UseOfMfc>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v142</PlatformToolset>
    <CharacterSet>MultiByte</CharacterSet>
    <UseOfMfc>Dynamic</UseOfMfc>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v142</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
    <UseOfMfc>Dynamic</UseOfMfc>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="Shared">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <LinkIncremental>true</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LinkIncremental>true</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <LinkIncremental>false</LinkIncremental>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
    </Link>
    <Midl>
      <MkTypLibCompatible>false</MkTypLibCompatible>
      <ValidateAllParameters>true</ValidateAllParameters>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </Midl>
    <ResourceCompile>
      <Culture>0x0804</Culture>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ResourceCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
    </Link>
    <Midl>
      <MkTypLibCompatible>false</MkTypLibCompatible>
      <ValidateAllParameters>true</ValidateAllParameters>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </Midl>
    <ResourceCompile>
      <Culture>0x0804</Culture>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ResourceCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
    <Midl>
      <MkTypLibCompatible>false</MkTypLibCompatible>
      <ValidateAllParameters>true</ValidateAllParameters>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </Midl>
    <ResourceCompile>
      <Culture>0x0804</Culture>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ResourceCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
    <Midl>
      <MkTypLibCompatible>false</MkTypLibCompatible>
      <ValidateAllParameters>true</ValidateAllParameters>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </Midl>
    <ResourceCompile>
      <Culture>0x0804</Culture>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ResourceCompile>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClInclude Include="CAddIDSDlg.h" />
    <ClInclude Include="CCollectionEvent.h" />
    <ClInclude Include="CDefineReportsDlg.h" />
    <ClInclude Include="CEDEventReportDlg.h" />
    <ClInclude Include="CHsmsActive.h" />
    <ClInclude Include="CLinkReportDetailDlg.h" />
    <ClInclude Include="CLinkReportDlg.h" />
    <ClInclude Include="CModel.h" />
    <ClInclude Include="Common.h" />
    <ClInclude Include="Context.h" />
    <ClInclude Include="CReport.h" />
    <ClInclude Include="CTerminalDisplayDlg.h" />
    <ClInclude Include="CVariable.h" />
    <ClInclude Include="EAPSimulator.h" />
    <ClInclude Include="EAPSimulatorDlg.h" />
    <ClInclude Include="framework.h" />
    <ClInclude Include="Log.h" />
    <ClInclude Include="LogEdit.h" />
    <ClInclude Include="pch.h" />
    <ClInclude Include="Resource.h" />
    <ClInclude Include="targetver.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="CAddIDSDlg.cpp" />
    <ClCompile Include="CCollectionEvent.cpp" />
    <ClCompile Include="CDefineReportsDlg.cpp" />
    <ClCompile Include="CEDEventReportDlg.cpp" />
    <ClCompile Include="CHsmsActive.cpp" />
    <ClCompile Include="CLinkReportDetailDlg.cpp" />
    <ClCompile Include="CLinkReportDlg.cpp" />
    <ClCompile Include="CModel.cpp" />
    <ClCompile Include="Context.cpp" />
    <ClCompile Include="CReport.cpp" />
    <ClCompile Include="CTerminalDisplayDlg.cpp" />
    <ClCompile Include="CVariable.cpp" />
    <ClCompile Include="EAPSimulator.cpp" />
    <ClCompile Include="EAPSimulatorDlg.cpp" />
    <ClCompile Include="Log.cpp" />
    <ClCompile Include="LogEdit.cpp" />
    <ClCompile Include="pch.cpp">
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="EAPSimulator.rc" />
  </ItemGroup>
  <ItemGroup>
    <None Include="res\EAPSimulator.rc2" />
  </ItemGroup>
  <ItemGroup>
    <Image Include="res\EAPSimulator.ico" />
  </ItemGroup>
  <ItemGroup>
    <Manifest Include="res\application.exe.manifest" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Filter Include="源文件">
      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
      <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
    </Filter>
    <Filter Include="头文件">
      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
      <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
    </Filter>
    <Filter Include="资源文件">
      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
    </Filter>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="EAPSimulator.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="EAPSimulatorDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="framework.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="targetver.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="Resource.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="pch.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="Log.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="LogEdit.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CModel.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="Context.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CHsmsActive.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="Common.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CTerminalDisplayDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CEDEventReportDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CDefineReportsDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CAddIDSDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CLinkReportDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CCollectionEvent.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CReport.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CVariable.h">
      <Filter>头文件</Filter>
    </ClInclude>
    <ClInclude Include="CLinkReportDetailDlg.h">
      <Filter>头文件</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="EAPSimulator.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="EAPSimulatorDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="pch.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="Log.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="LogEdit.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CModel.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="Context.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CHsmsActive.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CTerminalDisplayDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CEDEventReportDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CDefineReportsDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CAddIDSDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CLinkReportDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CCollectionEvent.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CReport.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CVariable.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
    <ClCompile Include="CLinkReportDetailDlg.cpp">
      <Filter>源文件</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="EAPSimulator.rc">
      <Filter>资源文件</Filter>
    </ResourceCompile>
  </ItemGroup>
  <ItemGroup>
    <None Include="res\EAPSimulator.rc2">
      <Filter>资源文件</Filter>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Image Include="res\EAPSimulator.ico">
      <Filter>资源文件</Filter>
    </Image>
  </ItemGroup>
  <ItemGroup>
    <Manifest Include="res\application.exe.manifest" />
  </ItemGroup>
</Project>
SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.user
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <RESOURCE_FILE>EAPSimulator.rc</RESOURCE_FILE>
  </PropertyGroup>
</Project>
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,357 @@

// EAPSimulatorDlg.cpp: å®žçŽ°æ–‡ä»¶
//
#include "pch.h"
#include "framework.h"
#include "EAPSimulator.h"
#include "EAPSimulatorDlg.h"
#include "afxdialogex.h"
#include "Common.h"
#include <regex>
#include "CTerminalDisplayDlg.h"
#include "CEDEventReportDlg.h"
#include "CDefineReportsDlg.h"
#include "CLinkReportDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// ç”¨äºŽåº”用程序“关于”菜单项的 CAboutDlg å¯¹è¯æ¡†
class CAboutDlg : public CDialogEx
{
public:
    CAboutDlg();
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_ABOUTBOX };
#endif
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
// å®žçް
protected:
    DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// CEAPSimulatorDlg å¯¹è¯æ¡†
CEAPSimulatorDlg::CEAPSimulatorDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_EAPSIMULATOR_DIALOG, pParent)
{
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    m_pObserver = nullptr;
}
void CEAPSimulatorDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_EDIT_LOG, m_logEdit);
}
BEGIN_MESSAGE_MAP(CEAPSimulatorDlg, CDialogEx)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_WM_DESTROY()
    ON_BN_CLICKED(IDC_BUTTON_CONNECT, &CEAPSimulatorDlg::OnBnClickedButtonConnect)
    ON_BN_CLICKED(IDC_BUTTON_DISCONNECT, &CEAPSimulatorDlg::OnBnClickedButtonDisconnect)
    ON_BN_CLICKED(IDC_BUTTON_ARE_YOU_THERE, &CEAPSimulatorDlg::OnBnClickedButtonAreYouThere)
    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)
    ON_BN_CLICKED(IDC_BUTTON_DEFINE_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonDefineReport)
    ON_BN_CLICKED(IDC_BUTTON_LINE_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonLineReport)
    ON_BN_CLICKED(IDC_BUTTON_CONFIGURE_SPOOLING, &CEAPSimulatorDlg::OnBnClickedButtonConfigureSpooling)
END_MESSAGE_MAP()
// CEAPSimulatorDlg æ¶ˆæ¯å¤„理程序
void CEAPSimulatorDlg::InitRxWindow()
{
    /* code */
    // è®¢é˜…数据
    IRxWindows* pRxWindows = RX_GetRxWindows();
    pRxWindows->enableLog(5);
    if (m_pObserver == NULL) {
        m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
            // onNext
            pAny->addRef();
            int code = pAny->getCode();
            if (RX_CODE_LOG == code && ::IsWindow(m_hWnd)) {
                const char* pszLogMsg;
                int level;
                if (pAny->getStringValue("text", pszLogMsg)
                    && pAny->getIntValue("exCode", level)) {
                    CString strText = pszLogMsg;
                    strText.Replace("\n", "\r\n");
                    AppendLog(level, (LPTSTR)(LPCTSTR)strText);
                }
            }
            else if (RX_CODE_ACTIVE_STATUS_CHANGED == code) {
                int state;
                if (pAny->getIntValue("exCode", state)) {
                    if ((ACTIVESTATE)state == ACTIVESTATE::SELECTED) {
                        SetGroup2Enabled(TRUE);
                    }
                    if ((ACTIVESTATE)state == ACTIVESTATE::NOT_CONNECTED) {
                        SetGroup2Enabled(FALSE);
                        SetGroup1Enabled(TRUE);
                    }
                }
            }
            pAny->release();
            }, [&]() -> void {
                // onComplete
            }, [&](IThrowable* pThrowable) -> void {
                // onErrorm
                pThrowable->printf();
            });
        theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
            ->subscribe(m_pObserver);
    }
    theApp.m_model.init();
}
BOOL CEAPSimulatorDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    // å°†â€œå…³äºŽ...”菜单项添加到系统菜单中。
    // IDM_ABOUTBOX å¿…须在系统命令范围内。
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);
    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != nullptr)
    {
        BOOL bNameValid;
        CString strAboutMenu;
        bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
        ASSERT(bNameValid);
        if (!strAboutMenu.IsEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }
    // è®¾ç½®æ­¤å¯¹è¯æ¡†çš„图标。  å½“应用程序主窗口不是对话框时,框架将自动
    //  æ‰§è¡Œæ­¤æ“ä½œ
    SetIcon(m_hIcon, TRUE);            // è®¾ç½®å¤§å›¾æ ‡
    SetIcon(m_hIcon, FALSE);        // è®¾ç½®å°å›¾æ ‡
    SetDlgItemText(IDC_EDIT_IP, _T("127.0.0.1"));
    SetDlgItemInt(IDC_EDIT_PORT, 7000);
    SetGroup2Enabled(FALSE);
    SetGroup1Enabled(TRUE);
    ::SetProp(GetDlgItem(IDC_BUTTON_ED_ALARM_REPORT)->m_hWnd, _T("Enable"), (void*)1);
    // log edit
    m_logEdit.SetMaxLineCount(8000);
    m_logEdit.SetLimitText(-1);
    InitRxWindow();
    return TRUE;  // é™¤éžå°†ç„¦ç‚¹è®¾ç½®åˆ°æŽ§ä»¶ï¼Œå¦åˆ™è¿”回 TRUE
}
void CEAPSimulatorDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
    else
    {
        CDialogEx::OnSysCommand(nID, lParam);
    }
}
// å¦‚果向对话框添加最小化按钮,则需要下面的代码
//  æ¥ç»˜åˆ¶è¯¥å›¾æ ‡ã€‚  å¯¹äºŽä½¿ç”¨æ–‡æ¡£/视图模型的 MFC åº”用程序,
//  è¿™å°†ç”±æ¡†æž¶è‡ªåŠ¨å®Œæˆã€‚
void CEAPSimulatorDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // ç”¨äºŽç»˜åˆ¶çš„设备上下文
        SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
        // ä½¿å›¾æ ‡åœ¨å·¥ä½œåŒºçŸ©å½¢ä¸­å±…中
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;
        // ç»˜åˆ¶å›¾æ ‡
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialogEx::OnPaint();
    }
}
//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR CEAPSimulatorDlg::OnQueryDragIcon()
{
    return static_cast<HCURSOR>(m_hIcon);
}
void CEAPSimulatorDlg::AppendLog(int level, const char* pszText)
{
    if (!::IsWindow(m_logEdit.m_hWnd)) {
        return;
    }
    m_logEdit.AppendText(pszText);
}
void CEAPSimulatorDlg::OnDestroy()
{
    CDialogEx::OnDestroy();
    ASSERT(m_pObserver != NULL);
    m_pObserver->unsubscribe();
    m_pObserver = NULL;
}
void CEAPSimulatorDlg::SetGroup1Enabled(bool enabled)
{
    GetDlgItem(IDC_EDIT_IP)->EnableWindow(enabled);
    GetDlgItem(IDC_EDIT_PORT)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_CONNECT)->EnableWindow(enabled);
}
void CEAPSimulatorDlg::SetGroup2Enabled(bool enabled)
{
    GetDlgItem(IDC_BUTTON_DISCONNECT)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_ARE_YOU_THERE)->EnableWindow(enabled);
    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);
    GetDlgItem(IDC_BUTTON_DEFINE_REPORT)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_LINE_REPORT)->EnableWindow(enabled);
    GetDlgItem(IDC_BUTTON_CONFIGURE_SPOOLING)->EnableWindow(enabled);
}
void CEAPSimulatorDlg::OnBnClickedButtonConnect()
{
    CString strIp;
    UINT port;
    GetDlgItemText(IDC_EDIT_IP, strIp);
    port = GetDlgItemInt(IDC_EDIT_PORT);
    theApp.m_model.connectEq((LPTSTR)(LPCTSTR)strIp, port);
    SetGroup1Enabled(FALSE);
}
void CEAPSimulatorDlg::OnBnClickedButtonDisconnect()
{
    theApp.m_model.disconnect();
}
void CEAPSimulatorDlg::OnBnClickedButtonAreYouThere()
{
    theApp.m_model.m_pHsmsActive->hsmsAreYouThere();
}
void CEAPSimulatorDlg::OnBnClickedButtonDatetimeSync()
{
    theApp.m_model.m_pHsmsActive->hsmsDatetimeSync();
}
void CEAPSimulatorDlg::OnBnClickedButtonTerminalDisplay()
{
    CTerminalDisplayDlg dlg;
    dlg.DoModal();
}
void CEAPSimulatorDlg::OnBnClickedButtonEdEventReport()
{
    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);
}
void CEAPSimulatorDlg::OnBnClickedButtonDefineReport()
{
    CDefineReportsDlg dlg;
    dlg.DoModal();
}
void CEAPSimulatorDlg::OnBnClickedButtonLineReport()
{
    CLinkReportDlg dlg;
    dlg.DoModal();
}
void CEAPSimulatorDlg::OnBnClickedButtonConfigureSpooling()
{
    std::map<unsigned int, std::set<unsigned int>> spoolingConfig;
    // test clear all
    // theApp.m_model.m_pHsmsActive->hsmsConfigureSpooling(spoolingConfig);
    // test add s2[1,3,5];
    // spoolingConfig[2].insert(1);
    // spoolingConfig[2].insert(3);
    // spoolingConfig[2].insert(5);
    // spoolingConfig[3].insert(2);
    // spoolingConfig[3].insert(4);
    // spoolingConfig[3].insert(6);
    // theApp.m_model.m_pHsmsActive->hsmsConfigureSpooling(spoolingConfig);
    // test clear S2
    // spoolingConfig[2].clear();
    // theApp.m_model.m_pHsmsActive->hsmsConfigureSpooling(spoolingConfig);
    spoolingConfig[5].insert(66);
    theApp.m_model.m_pHsmsActive->hsmsConfigureSpooling(spoolingConfig);
}
SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,57 @@

// EAPSimulatorDlg.h: å¤´æ–‡ä»¶
//
#pragma once
#include "LogEdit.h"
// CEAPSimulatorDlg å¯¹è¯æ¡†
class CEAPSimulatorDlg : public CDialogEx
{
// æž„造
public:
    CEAPSimulatorDlg(CWnd* pParent = nullptr);    // æ ‡å‡†æž„造函数
private:
    void AppendLog(int level, const char* pszText);
    void InitRxWindow();
    void SetGroup1Enabled(bool enabled);
    void SetGroup2Enabled(bool enabled);
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_EAPSIMULATOR_DIALOG };
#endif
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
// å®žçް
protected:
    HICON m_hIcon;
    CLogEdit m_logEdit;
    IObserver* m_pObserver;
    // ç”Ÿæˆçš„æ¶ˆæ¯æ˜ å°„函数
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnDestroy();
    afx_msg void OnBnClickedButtonConnect();
    afx_msg void OnBnClickedButtonDisconnect();
    afx_msg void OnBnClickedButtonAreYouThere();
    afx_msg void OnBnClickedButtonDatetimeSync();
    afx_msg void OnBnClickedButtonTerminalDisplay();
    afx_msg void OnBnClickedButtonEdEventReport();
    afx_msg void OnBnClickedButtonEdAlarmReport();
    afx_msg void OnBnClickedButtonDefineReport();
    afx_msg void OnBnClickedButtonLineReport();
    afx_msg void OnBnClickedButtonConfigureSpooling();
};
SourceCode/Bond/EAPSimulator/Log.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,214 @@
#include "pch.h"
#include "Log.h"
static const char* pszLevel[] = {" [Debug] ", " [Info] ", " [Warn] ", " [Error] "};
CLog::CLog()
{
    m_nLevel = 0;
    m_nOutputTarget = OT_TRACE;
    m_bAutoAppendTime = TRUE;
    m_strEquipmentId = _T("Unknown");
    m_nDay = 0;
    m_funOnLog = nullptr;
    InitializeCriticalSection(&m_criticalSection);
}
CLog::~CLog()
{
    DeleteCriticalSection(&m_criticalSection);
}
CLog *CLog::GetLog(void)
{
    static CLog* pLog = NULL;
    if (pLog == NULL) {
        static CLog log;
        pLog = &log;
    }
    return pLog;
}
void CLog::SetOnLogCallback(ONLOG funOnLog)
{
    m_funOnLog = funOnLog;
}
void CLog::SetOutputTarget(int flag)
{
    m_nOutputTarget = flag;
}
void CLog::SetEquipmentId(const char* pszEquipmentId)
{
    m_strEquipmentId = pszEquipmentId;
}
void CLog::SetAutoAppendTimeString(BOOL bAutoAppendTime)
{
    m_bAutoAppendTime = bAutoAppendTime;
}
void CLog::Batch()
{
    if (m_file.m_hFile != CFile::hFileNull) {
        m_file.Close();
    }
}
BOOL CLog::BatchAndNew(int& nDay)
{
    Batch();
    if ( (m_nOutputTarget & OT_FILE) && m_file.m_hFile == CFile::hFileNull) {
        CString strFilepath;
        BOOL bRet = m_file.Open(MakeFilepathD(strFilepath, nDay), CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::shareDenyWrite);
        if (bRet) {
            m_file.SeekToEnd();
        }
        return bRet;
    }
    return FALSE;
}
#define BUFFERSIZE        1024*10
void CLog::LogFormat(int nLevel, const char* pszTag, char* szMessage, ...)
{
    // æ£€æŸ¥æ—¥æœŸæ˜¯å¦æœ‰å˜åŒ–,有变化则结批
    Lock();
    _SYSTEMTIME sysTime;
    GetLocalTime(&sysTime);
    if(m_nDay != sysTime.wDay) {
        int nDay = 0;
        if (BatchAndNew(nDay)) {
            m_nDay = nDay;
        }
    }
    Unlock();
    if (nLevel < m_nLevel) {
        return;
    }
    char szFullMessage[BUFFERSIZE];
    char szFormatMessage[BUFFERSIZE];
    // format message
    va_list ap;
    va_start(ap, szMessage);
    _vsnprintf_s(szFormatMessage, BUFFERSIZE, szMessage, ap);
    va_end(ap);
    if (m_bAutoAppendTime) {
        CString strTime;
        strcpy_s(szFullMessage, BUFFERSIZE, (LPTSTR)(LPCTSTR)GetCurTime(strTime));
    }
    strcat_s(szFullMessage, BUFFERSIZE, pszLevel[nLevel]);
    strcat_s(szFullMessage, szFormatMessage);
    strcat_s(szFullMessage, BUFFERSIZE, "\n");
    if (m_nOutputTarget & OT_FILE) {
        Lock();
        if (m_file.m_hFile != CFile::hFileNull) {
            m_file.WriteString(szFullMessage);
        }
        Unlock();
    }
    if (m_nOutputTarget & OT_ODSTRING) {
        OutputDebugStringA(szFullMessage);
    }
    else if(m_nOutputTarget & OT_TRACE) {
        TRACE(szFormatMessage);
    }
    if (m_funOnLog != nullptr) {
        m_funOnLog(nLevel, szFullMessage);
    }
}
void CLog::Log(int nLevel, const char* pszTag, const char* szMessage)
{
    // æ£€æŸ¥æ—¥æœŸæ˜¯å¦æœ‰å˜åŒ–,有变化则结批
    Lock();
    _SYSTEMTIME sysTime;
    GetLocalTime(&sysTime);
    if (m_nDay != sysTime.wDay) {
        int nDay = 0;
        if (BatchAndNew(nDay)) {
            m_nDay = nDay;
        }
    }
    Unlock();
    if (nLevel < m_nLevel) {
        return;
    }
    CString strMsg;
    if (m_bAutoAppendTime) {
        CString strTime;
        GetCurTime(strTime);
        strMsg.Append(strTime);
    }
    strMsg.Append(pszTag);
    strMsg.Append(szMessage);
    strMsg.Append("\n");
    if (m_nOutputTarget & OT_FILE) {
        Lock();
        if (m_file.m_hFile != CFile::hFileNull) {
            m_file.WriteString(strMsg);
        }
        Unlock();
    }
    if (m_nOutputTarget & OT_ODSTRING) {
        OutputDebugStringA(strMsg);
    }
    else if (m_nOutputTarget & OT_TRACE) {
        TRACE(strMsg);
    }
    if (m_funOnLog != nullptr) {
        m_funOnLog(nLevel, strMsg);
    }
}
CString& CLog::GetCurTime(CString& strTime)
{
    _SYSTEMTIME sysTime;
    GetLocalTime(&sysTime);
    strTime.Format(_T("%d/%02d/%02d %02d:%02d:%02d.%03d"), sysTime.wYear, sysTime.wMonth, sysTime.wDay,
        sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds);
    return strTime;
}
CString& CLog::MakeFilepath(CString& strFilepath)
{
    _SYSTEMTIME sysTime;
    GetLocalTime(&sysTime);
    strFilepath.Format(_T("%s\\Log(%s)_%d_%02d_%02d.log"), (LPTSTR)(LPCTSTR)m_strLogsDir,
        (LPTSTR)(LPCTSTR)m_strEquipmentId,
        sysTime.wYear, sysTime.wMonth, sysTime.wDay);
    return strFilepath;
}
CString& CLog::MakeFilepathD(CString& strFilepath, int& day)
{
    _SYSTEMTIME sysTime;
    GetLocalTime(&sysTime);
    strFilepath.Format(_T("%s\\Log(%s)_%d_%02d_%02d.log"), (LPTSTR)(LPCTSTR)m_strLogsDir,
        (LPTSTR)(LPCTSTR)m_strEquipmentId,
        sysTime.wYear, sysTime.wMonth, sysTime.wDay);
    day = sysTime.wDay;
    return strFilepath;
}
void CLog::SetLogsDir(CString strDir)
{
    m_strLogsDir = strDir;
}
SourceCode/Bond/EAPSimulator/Log.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
#pragma once
#include <functional>
#define LEVEL_DEBUG        0
#define LEVEL_INFO        1
#define LEVEL_WARN        2
#define LEVEL_ERROR        3
#define LOGD(msg, ...)        CLog::GetLog()->LogFormat(LEVEL_DEBUG, "", msg, __VA_ARGS__)
#define LOGI(msg, ...)        CLog::GetLog()->LogFormat(LEVEL_INFO, "", msg, __VA_ARGS__)
#define LOGW(msg, ...)        CLog::GetLog()->LogFormat(LEVEL_WARN, "", msg, __VA_ARGS__)
#define LOGE(msg, ...)        CLog::GetLog()->LogFormat(LEVEL_ERROR, "", msg, __VA_ARGS__)
#define OT_FILE            0x01
#define OT_ODSTRING        0x02
#define OT_TRACE        0x04
#define LOGBATHCH()                CLog::GetLog()->Batch()
#define LOGNEW()                CLog::GetLog()->BatchAndNew()
typedef std::function<void(int level, const char* pszMessage)> ONLOG;
class CLog
{
public:
    CLog();
    ~CLog();
public:
    void SetOnLogCallback(ONLOG funOnLog);
    static CLog *GetLog(void);
    void SetOutputTarget(int flag);
    void SetEquipmentId(const char* pszEquipmentId);
    static CString& GetCurTime(CString& strTime);
    CString& MakeFilepath(CString& strFilepath);
    CString& MakeFilepathD(CString& strFilepath, int& day);
    void LogFormat(int nLevel, const char* pszTag, char* szMessage, ...);
    void Log(int nLevel, const char* pszTag, const char* szMessage);
    void SetAutoAppendTimeString(BOOL bAutoAppendTime);
    void SetLogsDir(CString strDir);
    void Batch();
    BOOL BatchAndNew(int& nDay);
private:
    inline void Lock() { EnterCriticalSection(&m_criticalSection); }
    inline void Unlock() { LeaveCriticalSection(&m_criticalSection); }
private:
    ONLOG m_funOnLog;
    int m_nOutputTarget;
    int m_nLevel;
    BOOL m_bAutoAppendTime;
    CString m_strLogsDir;
    CString m_strEquipmentId;
    CStdioFile m_file;
    int m_nDay;                        // æŒ‰æ—¥ä¿å­˜ä¸€æ¡è®°å½•,比较此数字,以决定是否结批并创建新文件
    CRITICAL_SECTION m_criticalSection;
};
SourceCode/Bond/EAPSimulator/LogEdit.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,117 @@
#include "pch.h"
#include "LogEdit.h"
#define MENU_ITEM_SEL_ALL        0x666
#define MENU_ITEM_COPY            0x667
#define MENU_ITEM_CLEAR            0x668
CLogEdit::CLogEdit()
{
    m_nMaxLines = 0xffff;
    m_nTrimLines = 100;
    m_bAutoScroll = TRUE;
}
CLogEdit::~CLogEdit()
{
}
BEGIN_MESSAGE_MAP(CLogEdit, CEdit)
    ON_WM_CONTEXTMENU()
    ON_WM_VSCROLL()
    ON_WM_MOUSEWHEEL()
END_MESSAGE_MAP()
void CLogEdit::SetMaxLineCount(int line)
{
    m_nMaxLines = line;
    m_nTrimLines = min(m_nMaxLines, 4000);
}
void CLogEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
    HMENU hMenu = CreatePopupMenu();
    InsertMenu(hMenu, 0, MF_BYPOSITION, MENU_ITEM_SEL_ALL, "ȫѡ");
    InsertMenu(hMenu, 1, MF_BYPOSITION, MENU_ITEM_COPY, "复制");
    InsertMenu(hMenu, 2, MF_BYPOSITION | MF_SEPARATOR, NULL, NULL);
    InsertMenu(hMenu, 3, MF_BYPOSITION, MENU_ITEM_CLEAR, "全部清除");
    int cmd = ::TrackPopupMenu(hMenu,
        TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
        point.x, point.y + 2, 0, m_hWnd, NULL);
    DestroyMenu(hMenu);
    if (cmd == MENU_ITEM_SEL_ALL) {
        SetFocus();
        this->SetSel(0, -1);
    }
    else if (cmd == MENU_ITEM_COPY) {
        this->Copy();
    }
    else if (cmd == MENU_ITEM_CLEAR) {
        SetWindowText(_T(""));
    }
}
void CLogEdit::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
    // æ¯æ¬¡æ»šåŠ¨æ—¶æ£€æŸ¥æ˜¯å¦è¿˜åœ¨åº•éƒ¨
    m_bAutoScroll = IsScrollBarAtBottom();
    CEdit::OnVScroll(nSBCode, nPos, pScrollBar);
}
BOOL CLogEdit::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
    // æ¯æ¬¡æ»šåŠ¨æ—¶æ£€æŸ¥æ˜¯å¦è¿˜åœ¨åº•éƒ¨
    m_bAutoScroll = IsScrollBarAtBottom();
    return CEdit::OnMouseWheel(nFlags, zDelta, pt);
}
BOOL CLogEdit::IsScrollBarAtBottom()
{
    SCROLLINFO si = { sizeof(si), SIF_ALL };
    GetScrollInfo(SB_VERT, &si);
    return (si.nPos + (int)si.nPage >= si.nMax);
}
void CLogEdit::AppendText(const char* pszText)
{
    SetRedraw(FALSE);
    // å‰ªåˆ‡è¿‡å¤šè¡Œ
    int totalLines = GetLineCount();
    if (totalLines > m_nMaxLines) {
        int startChar = LineIndex(0);
        int endChar = LineIndex(m_nTrimLines);
        if (startChar >= 0 && endChar > startChar) {
            SetSel(startChar, endChar);
            ReplaceSel(_T(""));
        }
    }
    // ä¿å­˜å½“前选择
    int start, end;
    GetSel(start, end);
    bool hasSelection = (start != end);
    int endPos = GetWindowTextLength();
    SetSel(endPos, endPos);
    ReplaceSel(pszText);
    if (m_bAutoScroll && !hasSelection) {
        LineScroll(GetLineCount());
    }
    // æ¢å¤é€‰æ‹©
    if (hasSelection) {
        SetSel(start, end);
    }
    SetRedraw(TRUE);
    if (m_bAutoScroll && !hasSelection) {
        Invalidate();
        UpdateWindow();
    }
}
SourceCode/Bond/EAPSimulator/LogEdit.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
#pragma once
#include "afxwin.h"
class CLogEdit :
    public CEdit
{
public:
    CLogEdit();
    ~CLogEdit();
public:
    void SetMaxLineCount(int line);
    void AppendText(const char* pszText);
    BOOL IsScrollBarAtBottom();
private:
    int m_nMaxLines;
    int m_nTrimLines;
    BOOL m_bAutoScroll;        // æ˜¯å¦è‡ªåŠ¨æ»šåŠ¨
    DECLARE_MESSAGE_MAP()
    afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
    afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
public:
    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
};
SourceCode/Bond/EAPSimulator/Resource.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,58 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ ç”Ÿæˆçš„包含文件。
// ä¾› EAPSimulator.rc ä½¿ç”¨
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_EAPSIMULATOR_DIALOG         102
#define IDR_MAINFRAME                   128
#define IDD_DIALOG_TERMINAL_DISPLAY     129
#define IDD_DIALOG_ED_EVENT_REPORT      131
#define IDD_DIALOG_DEFINE_REPORTS       133
#define IDD_DIALOG_ADD_IDS              135
#define IDD_DIALOG_LINK_REPORT          137
#define IDD_DIALOG_LINK_REPORT_DETAIL   139
#define IDC_EDIT_LOG                    1000
#define IDC_EDIT_IP                     1001
#define IDC_EDIT_PORT                   1002
#define IDC_BUTTON_CONNECT              1003
#define IDC_BUTTON_DISCONNECT           1004
#define IDC_BUTTON_ARE_YOU_THERE        1005
#define IDC_BUTTON_DATETIME_SYNC        1006
#define IDC_BUTTON_TERMINAL_DISPLAY     1007
#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_BUTTON_DEFINE_REPORT        1010
#define IDC_BUTTON_LINE_REPORT          1011
#define IDC_RADIO_ENABLE                1012
#define IDC_BUTTON_LINE_REPORT2         1012
#define IDC_BUTTON_CONFIGURE_SPOOLING   1012
#define IDC_RADIO_DISABLE               1013
#define IDC_EDIT_CEID                   1014
#define IDC_LIST1                       1015
#define IDC_EDIT_CE_NAME                1015
#define IDC_LIST2                       1016
#define IDC_EDIT_CE_DESCRIPTIONS        1016
#define IDC_BUTTON_ADD_RPTID            1017
#define IDC_EDIT_CE_RPTID               1017
#define IDC_BUTTON_DEL_REPORT           1018
#define IDC_BUTTON_ADD_VID              1019
#define IDC_BUTTON_DEL_VID              1020
#define IDC_GROUP_IDS                   1021
#define IDC_EDIT_ID                     1022
#define IDC_BUTTON1                     1023
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        141
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1025
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
SourceCode/Bond/EAPSimulator/framework.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN            // ä»Ž Windows å¤´ä¸­æŽ’除极少使用的资料
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // æŸäº› CString æž„造函数将是显式的
// å…³é—­ MFC çš„一些常见且经常可放心忽略的隐藏警告消息
#define _AFX_ALL_WARNINGS
#include <afxwin.h>         // MFC æ ¸å¿ƒç»„件和标准组件
#include <afxext.h>         // MFC æ‰©å±•
#include <afxdisp.h>        // MFC è‡ªåŠ¨åŒ–ç±»
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h>           // MFC å¯¹ Internet Explorer 4 å…¬å…±æŽ§ä»¶çš„æ”¯æŒ
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>             // MFC å¯¹ Windows å…¬å…±æŽ§ä»¶çš„æ”¯æŒ
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h>     // MFC æ”¯æŒåŠŸèƒ½åŒºå’ŒæŽ§åˆ¶æ¡
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
SourceCode/Bond/EAPSimulator/pch.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
// pch.cpp: ä¸Žé¢„编译标头对应的源文件
#include "pch.h"
// å½“使用预编译的头时,需要使用此源文件,编译才能成功。
SourceCode/Bond/EAPSimulator/pch.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
// pch.h: è¿™æ˜¯é¢„编译标头文件。
// ä¸‹æ–¹åˆ—出的文件仅编译一次,提高了将来生成的生成性能。
// è¿™è¿˜å°†å½±å“ IntelliSense æ€§èƒ½ï¼ŒåŒ…括代码完成和许多代码浏览功能。
// ä½†æ˜¯ï¼Œå¦‚果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
// è¯·å‹¿åœ¨æ­¤å¤„添加要频繁更新的文件,这将使得性能优势无效。
#ifndef PCH_H
#define PCH_H
// æ·»åŠ è¦åœ¨æ­¤å¤„é¢„ç¼–è¯‘çš„æ ‡å¤´
#include "framework.h"
#include "..\RxWindows1.0\include\RxWindowsLib.h"
#include "..\HSMSSDK\Include\HSMSSDK.h"
#endif //PCH_H
SourceCode/Bond/EAPSimulator/res/EAPSimulator.ico
SourceCode/Bond/EAPSimulator/res/EAPSimulator.rc2
Binary files differ
SourceCode/Bond/EAPSimulator/res/application.exe.manifest
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity
         name="XP style manifest"
         processorArchitecture="amd64"
         version="1.0.0.0"
         type="win32"/>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="amd64"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            />
        </dependentAssembly>
    </dependency>
</assembly>
SourceCode/Bond/EAPSimulator/targetver.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
#pragma once
// åŒ…括 SDKDDKVer.h å°†å®šä¹‰å¯ç”¨çš„æœ€é«˜ç‰ˆæœ¬çš„ Windows å¹³å°ã€‚
//如果要为以前的 Windows å¹³å°ç”Ÿæˆåº”用程序,请包括 WinSDKVer.h,并
// å°† _WIN32_WINNT å®è®¾ç½®ä¸ºè¦æ”¯æŒçš„平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>
SourceCode/Bond/GangBond2860.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.31729.503
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BEQLibrary", "BEQLibrary\BEQLibrary.vcxproj", "{8421CE64-06F9-48F4-A3F3-ACFB683C94D4}"
EndProject
@@ -14,6 +14,8 @@
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Servo", "Servo\Servo.vcxproj", "{66ADACE5-3166-4D1F-B30B-DE5E01FB01A2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BoounionPLC", "BoounionPLC\BoounionPLC.vcxproj", "{6DC0600E-5588-4033-A281-3626A4F74B67}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPSimulator", "EAPSimulator\EAPSimulator.vcxproj", "{9EA43050-B71C-47A7-AC90-F0D7A88C5F50}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -71,6 +73,14 @@
        {6DC0600E-5588-4033-A281-3626A4F74B67}.Release|x64.Build.0 = Release|x64
        {6DC0600E-5588-4033-A281-3626A4F74B67}.Release|x86.ActiveCfg = Release|Win32
        {6DC0600E-5588-4033-A281-3626A4F74B67}.Release|x86.Build.0 = Release|Win32
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Debug|x64.ActiveCfg = Debug|x64
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Debug|x64.Build.0 = Debug|x64
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Debug|x86.ActiveCfg = Debug|Win32
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Debug|x86.Build.0 = Debug|Win32
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Release|x64.ActiveCfg = Release|x64
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Release|x64.Build.0 = Release|x64
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Release|x86.ActiveCfg = Release|Win32
        {9EA43050-B71C-47A7-AC90-F0D7A88C5F50}.Release|x86.Build.0 = Release|Win32
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
SourceCode/Bond/HSMSSDK/Include/HSMSSDK.h
@@ -1,6 +1,7 @@
#pragma once
#include <functional>
#include "IPassive.h"
#include "IActive.h"
#include "IMessage.h"
@@ -62,7 +63,10 @@
    int                EXPORTED    HSMS_Term();
    int                EXPORTED    HSMS_CreatePassive(OUT IPassive*& pPassive, const char* pName, const unsigned int nPort);
    int                EXPORTED    HSMS_DestroyPassive(IPassive* pPassive);
    int                EXPORTED    HSMS_CreateActive(OUT IActive*& pAcitve, const char* pName, const char* pszIp, const unsigned int nPort);
    int                EXPORTED    HSMS_DestroyActive(IActive* pAcitve);
    int                EXPORTED    HSMS_Create1Message(OUT IMessage*& pMessage, unsigned short sessionId, BYTE stream, BYTE function, unsigned int nSystemBytes);
    int                EXPORTED    HSMS_CreateMessageWithSType(OUT IMessage*& pMessage, BYTE sType, unsigned int nSystemBytes);
    int                EXPORTED    HSMS_Destroy1Message(IMessage* pMessage);
#ifdef __cplusplus
SourceCode/Bond/HSMSSDK/Include/IActive.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
#pragma once
#include <functional>
#include "IMessage.h"
enum class ACTIVESTATE
{
    NOT_CONNECTED = 0,
    NOT_SELECTED = 1,
    SELECTED = 2
};
typedef std::function<void(void* pFrom, ACTIVESTATE state)> ONACTIVESTATECHANGED;
typedef std::function<void(void* pFrom, const char* pszData, int size)> ONRECVRAWDATA;
typedef std::function<void(void* pFrom, IMessage* pMessage)> ONRECVDATAMSG;
typedef std::function<void(void* pFrom, IMessage* pMessage)> ONRECVSYSMSG;
typedef std::function<void(void* pFrom, int error)> ONDATAERROR;
typedef struct _ActiveListener
{
    ONACTIVESTATECHANGED    funStateChanged;
    ONRECVRAWDATA            funRecvRawData;
    ONRECVDATAMSG            funRecvDataMessage;
    ONRECVSYSMSG            funRecvSysMessage;
    ONDATAERROR                funError;
} ActiveListener;
class IActive
{
public:
    virtual void setListener(ActiveListener listener) = 0;
    virtual void setTimeout3(int timeout) = 0;
    virtual void setTimeout5(int timeout) = 0;
    virtual void setTimeout6(int timeout) = 0;
    virtual void setTimeout7(int timeout) = 0;
    virtual void setTimeout8(int timeout) = 0;
    virtual int sendMessage(IMessage* pMessage) = 0;
    virtual ACTIVESTATE getState() = 0;
    virtual int connect() = 0;
    virtual int disconnect() = 0;
};
SourceCode/Bond/HSMSSDK/Include/ISECS2Item.h
@@ -55,7 +55,7 @@
    virtual bool getSubItemU1(int index, unsigned char& value) = 0;
    virtual void reset() = 0;
    virtual ISECS2Item* addItem(const char* pszText, const char* pszNote) = 0;
    virtual ISECS2Item* addBinaryItem(BYTE bin, const char* pszNote) = 0;
    virtual ISECS2Item* addBinaryItem(const char* pszData, unsigned int len, const char* pszNote) = 0;
    virtual ISECS2Item* addBoolItem(bool boolValue, const char* pszNote) = 0;
    virtual ISECS2Item* addI8Item(long long value, const char* pszNote) = 0;
    virtual ISECS2Item* addI4Item(int value, const char* pszNote) = 0;
@@ -68,5 +68,6 @@
    virtual ISECS2Item* addU2Item(unsigned short value, const char* pszNote) = 0;
    virtual ISECS2Item* addU1Item(unsigned char value, const char* pszNote) = 0;
    virtual void setBinary(const char* pszData, unsigned int len, const char* pszNote) = 0;
    virtual void setString(const char* pszText, const char* pszNote) = 0;
    virtual ISECS2Item* addItem() = 0;
};
SourceCode/Bond/Servo/CBonder.cpp
@@ -423,10 +423,13 @@
        /*
        static int i[2] = { 0, 0 };
        i[m_nIndex]++;
        if (i[m_nIndex] == 15) {
            char szBuffer[26];
            decodeJobProcessStartReport(getStep(STEP_ID_JOB_PROCESS_START_REPORT), szBuffer, 26);
        if (m_nIndex == 0 && i[m_nIndex] % 20 == 0) {
            if (m_listener.onAlarm != nullptr) {
                m_listener.onAlarm(this, 1,
                    i[m_nIndex],
                    getID(),
                    1);
            }
        }
        */
    }
SourceCode/Bond/Servo/CCollectionEvent.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,113 @@
#include "stdafx.h"
#include "CCollectionEvent.h"
namespace SERVO {
    CCollectionEvent::CCollectionEvent()
    {
        m_nCEID = 0;
    }
    CCollectionEvent::CCollectionEvent(unsigned int id, const char* pszName, const char* pszDescription, std::vector<unsigned int>& prtids)
    {
        m_nCEID = id;
        m_strName = pszName;
        m_strDescription = pszDescription;
        for (auto item : prtids) {
            m_rptids.push_back(item);
        }
    }
    CCollectionEvent::~CCollectionEvent()
    {
    }
    unsigned int CCollectionEvent::getEventId()
    {
        return m_nCEID;
    }
    std::string& CCollectionEvent::getName()
    {
        return m_strName;
    }
    std::string& CCollectionEvent::getDescription()
    {
        return m_strDescription;
    }
    BOOL CCollectionEvent::addReport(CReport* pReport)
    {
        ASSERT(pReport);
        if (getReport(pReport->getReportId()) != nullptr) {
            return FALSE;
        }
        m_reports.push_back(pReport);
        return TRUE;
    }
    void CCollectionEvent::setReport(CReport* pReport)
    {
        m_rptids.clear();
        m_reports.clear();
        if (pReport != nullptr) {
            m_rptids.push_back(pReport->getReportId());
            m_reports.push_back(pReport);
        }
    }
    unsigned int CCollectionEvent::getPortID()
    {
        if (m_reports.empty()) return -1;
        return m_reports.front()->getReportId();
    }
    BOOL CCollectionEvent::deleteReport(unsigned int nReportId)
    {
        BOOL bDelete = FALSE;
        for (auto iter = m_reports.begin(); iter != m_reports.end(); ++iter) {
            if (nReportId == (*iter)->getReportId()) {
                m_reports.erase(iter);
                bDelete = TRUE;
                break;
            }
        }
        return bDelete;
    }
    CReport* CCollectionEvent::getReport(unsigned int nReportId)
    {
        for (auto item : m_reports) {
            if (nReportId == item->getReportId()) {
                return item;
            }
        }
        return nullptr;
    }
    std::vector<CReport*>& CCollectionEvent::getReports()
    {
        return m_reports;
    }
    std::string CCollectionEvent::getReportIdsText()
    {
        std::string strResult, strName;
        for (int i = 0; i < m_rptids.size(); i++) {
            strResult += std::to_string(m_rptids[i]);// (getReport(m_rptids[i]) ?
            if (nullptr == getReport(m_rptids[i])) {
                strResult += "?";
            }
            if (i != m_rptids.size() - 1) {
                strResult += ",";
            }
        }
        return strResult;
    }
}
SourceCode/Bond/Servo/CCollectionEvent.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
#pragma once
#include "CReport.h"
#include <vector>
namespace SERVO {
    class CCollectionEvent
    {
    public:
        CCollectionEvent();
        CCollectionEvent(unsigned int id, const char* pszName, const char* pszDescription, std::vector<unsigned int>& prtids);
        virtual ~CCollectionEvent();
    public:
        unsigned int getEventId();
        std::string& getName();
        std::string& getDescription();
        std::vector<CReport*>& getReports();
        std::string getReportIdsText();
        BOOL addReport(CReport* pReport);
        BOOL deleteReport(unsigned int nReportId);
        CReport* getReport(unsigned int nReportId);
        /* å¦‚果一个CEID只有一个Report的场景,调用此函数设置或取消 */
        void setReport(CReport* pReport);
        unsigned int getPortID();
    private:
        unsigned int m_nCEID;
        std::string m_strName;
        std::string m_strDescription;
        std::vector<unsigned int> m_rptids;
        std::vector<CReport*> m_reports;
    };
}
SourceCode/Bond/Servo/CMaster.cpp
@@ -52,6 +52,8 @@
        m_pActiveRobotTask = nullptr;
        m_nLastError = 0;
        m_isCompareMapsBeforeProceeding = FALSE;
        m_bEnableEventReport = true;
        m_bEnableAlarmReport = true;
        InitializeCriticalSection(&m_criticalSection);
    }
@@ -1503,4 +1505,27 @@
    {
        m_isCompareMapsBeforeProceeding = bCompare;
    }
    void CMaster::datetimeSync(SYSTEMTIME& time)
    {
        for (auto item : m_listEquipment) {
            item->setDateTime(time.wYear, time.wMonth, time.wDay,
                time.wHour, time.wMinute, time.wSecond);
        }
    }
    void CMaster::enableEventReport(bool bEnable)
    {
        m_bEnableEventReport = bEnable;
    }
    void CMaster::enableAlarmReport(bool bEnable)
    {
        m_bEnableAlarmReport = bEnable;
    }
    bool CMaster::isAlarmReportEnable()
    {
        return m_bEnableAlarmReport;
    }
}
SourceCode/Bond/Servo/CMaster.h
@@ -74,6 +74,10 @@
            int cassetteType, int transferMode, BOOL autoChangeEnable);
        void setPortCassetteType(unsigned int index, SERVO::CassetteType type);
        void setCompareMapsBeforeProceeding(BOOL bCompare);
        void datetimeSync(SYSTEMTIME& time);
        void enableEventReport(bool bEnable);
        void enableAlarmReport(bool bEnable);
        bool isAlarmReportEnable();
    private:
        inline void lock() { EnterCriticalSection(&m_criticalSection); }
@@ -138,6 +142,9 @@
        // åœ¨å¼€å§‹å·¥è‰ºå‰æ˜¯å¦å…ˆéœ€è¦å…ˆæ¯”较map
        BOOL m_isCompareMapsBeforeProceeding;
    private:
        bool m_bEnableEventReport;
        bool m_bEnableAlarmReport;
    };
}
SourceCode/Bond/Servo/CMyStatusbar.cpp
@@ -75,6 +75,11 @@
    SetDlgItemText(IDC_BUTTON_ROBOTTASK, pszText);
}
void CMyStatusbar::setCimBtnText(const char* pszText)
{
    SetDlgItemText(IDC_BUTTON_CIM, pszText);
}
BOOL CMyStatusbar::OnInitDialog()
{
    CDialogEx::OnInitDialog();
@@ -87,6 +92,11 @@
    m_btnCurTask.SetFrameColor(BS_HOVER, RGB(218, 218, 218));
    m_btnCurTask.SetFrameColor(BS_PRESS, RGB(168, 168, 168));
    m_btnCim.SubclassDlgItem(IDC_BUTTON_CIM, this);
    m_btnCim.SetFaceColor(m_crBkgnd);
    m_btnCim.SetFrameColor(m_crBkgnd);
    m_btnCim.SetFrameColor(BS_HOVER, RGB(218, 218, 218));
    m_btnCim.SetFrameColor(BS_PRESS, RGB(168, 168, 168));
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
@@ -129,6 +139,11 @@
        pItem->GetWindowRect(rcItem);
        GetParent()->SendMessage(ID_MSG_STATUSBAR_BTN_CLICKED, rcItem.left, LOWORD(wParam));
        break;
    case IDC_BUTTON_CIM:
        pItem = GetDlgItem(IDC_BUTTON_CIM);
        pItem->GetWindowRect(rcItem);
        GetParent()->SendMessage(ID_MSG_STATUSBAR_BTN_CLICKED, rcItem.left, LOWORD(wParam));
        break;
    }
    return CDialogEx::OnCommand(wParam, lParam);
@@ -165,4 +180,16 @@
    pItem->GetClientRect(rcItem);
    pItem->MoveWindow(x, (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
    x += rcItem.Width();
    x += 8;
    pItem = GetDlgItem(IDC_LABEL_CIM);
    pItem->GetClientRect(rcItem);
    pItem->MoveWindow(x, (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
    x += rcItem.Width();
    x += 8;
    pItem = GetDlgItem(IDC_BUTTON_CIM);
    pItem->GetClientRect(rcItem);
    pItem->MoveWindow(x, (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
    x += rcItem.Width();
}
SourceCode/Bond/Servo/CMyStatusbar.h
@@ -21,6 +21,7 @@
    void setForegroundColor(COLORREF cr);
    void setRunTimeText(const char* pszText);
    void setCurTaskBtnText(const char* pszText);
    void setCimBtnText(const char* pszText);
private:
    void Resize();
@@ -30,6 +31,7 @@
    COLORREF m_crBkgnd;
    CBrush m_brBkgnd;
    CBlButton m_btnCurTask;
    CBlButton m_btnCim;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
SourceCode/Bond/Servo/CPageCollectionEvent.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,126 @@
// CPageCollectionEvent.cpp: å®žçŽ°æ–‡ä»¶
//
#include "stdafx.h"
#include "Servo.h"
#include "CPageCollectionEvent.h"
#include "afxdialogex.h"
// CPageCollectionEvent å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CPageCollectionEvent, CHMPropertyPage)
CPageCollectionEvent::CPageCollectionEvent(CWnd* pParent /*=nullptr*/)
    : CHMPropertyPage(IDD_PAGE_COLLECTION_EVENT, pParent)
{
}
CPageCollectionEvent::~CPageCollectionEvent()
{
}
void CPageCollectionEvent::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_LIST1, m_listCtrl);
}
BEGIN_MESSAGE_MAP(CPageCollectionEvent, CHMPropertyPage)
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
END_MESSAGE_MAP()
// CPageCollectionEvent æ¶ˆæ¯å¤„理程序
BOOL CPageCollectionEvent::OnInitDialog()
{
    CHMPropertyPage::OnInitDialog();
    // è¯»å‡ºåˆ—宽
    CString strIniFile, strItem;
    strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    int width[8] = { 0, 218, 180, 180, 180, 180, 180, 180 };
    for (int i = 0; i < 8; i++) {
        strItem.Format(_T("Col_%d_Width"), i);
        width[i] = GetPrivateProfileInt("PageCollectionListCtrl", strItem, width[i], strIniFile);
    }
    // æŠ¥è¡¨æŽ§ä»¶
    DWORD dwStyle = m_listCtrl.GetExtendedStyle();
    dwStyle |= LVS_EX_FULLROWSELECT;
    dwStyle |= LVS_EX_GRIDLINES;
    m_listCtrl.SetExtendedStyle(dwStyle);
    HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
    ListView_SetImageList(m_listCtrl.GetSafeHwnd(), imageList, LVSIL_SMALL);
    m_listCtrl.InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]);
    m_listCtrl.InsertColumn(1, _T("CEID"), LVCFMT_LEFT, width[1]);
    m_listCtrl.InsertColumn(2, _T("CE Name"), LVCFMT_LEFT, width[2]);
    m_listCtrl.InsertColumn(3, _T("Descriptions"), LVCFMT_LEFT, width[3]);
    m_listCtrl.InsertColumn(4, _T("Attached RPTID"), LVCFMT_LEFT, width[4]);
    loadCollectionEvents();
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
HBRUSH CPageCollectionEvent::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CHMPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
    // TODO:  åœ¨æ­¤æ›´æ”¹ DC çš„任何特性
    // TODO:  å¦‚果默认的不是所需画笔,则返回另一个画笔
    return hbr;
}
void CPageCollectionEvent::OnDestroy()
{
    CHMPropertyPage::OnDestroy();
    // ä¿å­˜åˆ—宽
    CString strIniFile, strItem, strTemp;
    strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    CHeaderCtrl* pHeader = m_listCtrl.GetHeaderCtrl();
    for (int i = 0; i < pHeader->GetItemCount(); i++) {
        RECT rect;
        pHeader->GetItemRect(i, &rect);
        strItem.Format(_T("Col_%d_Width"), i);
        strTemp.Format(_T("%d"), rect.right - rect.left);
        WritePrivateProfileString("PageCollectionListCtrl", strItem, strTemp, strIniFile);
    }
}
void CPageCollectionEvent::OnSize(UINT nType, int cx, int cy)
{
    CHMPropertyPage::OnSize(nType, cx, cy);
    if (GetDlgItem(IDC_LIST1) == nullptr) return;
    CWnd* pItem;
    CRect rcClient, rcItem;
    GetClientRect(&rcClient);
    m_listCtrl.MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
}
void CPageCollectionEvent::loadCollectionEvents()
{
    auto& collectionEvent = theApp.m_model.m_hsmsPassive.getCollectionEvents();
    for (auto item : collectionEvent) {
        int index = m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), _T(""));
        m_listCtrl.SetItemData(index, (DWORD_PTR)item);
        m_listCtrl.SetItemText(index, 1, std::to_string(item->getEventId()).c_str());
        m_listCtrl.SetItemText(index, 2, item->getName().c_str());
        m_listCtrl.SetItemText(index, 3, item->getDescription().c_str());
        m_listCtrl.SetItemText(index, 4, item->getReportIdsText().c_str());
    }
}
SourceCode/Bond/Servo/CPageCollectionEvent.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
#pragma once
#include "CHMPropertyPage.h"
#include "ListCtrlEx.h"
// CPageCollectionEvent å¯¹è¯æ¡†
class CPageCollectionEvent : public CHMPropertyPage
{
    DECLARE_DYNAMIC(CPageCollectionEvent)
public:
    CPageCollectionEvent(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CPageCollectionEvent();
    void loadCollectionEvents();
private:
    CListCtrlEx m_listCtrl;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_PAGE_COLLECTION_EVENT };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void OnDestroy();
    afx_msg void OnSize(UINT nType, int cx, int cy);
};
SourceCode/Bond/Servo/CPageReport.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,126 @@
// CPageReport.cpp: å®žçŽ°æ–‡ä»¶
//
#include "stdafx.h"
#include "Servo.h"
#include "CPageReport.h"
#include "afxdialogex.h"
// CPageReport å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CPageReport, CHMPropertyPage)
CPageReport::CPageReport(CWnd* pParent /*=nullptr*/)
    : CHMPropertyPage(IDD_PAGE_REPORT, pParent)
{
}
CPageReport::~CPageReport()
{
}
void CPageReport::DoDataExchange(CDataExchange* pDX)
{
    CHMPropertyPage::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_LIST1, m_listCtrl);
}
BEGIN_MESSAGE_MAP(CPageReport, CHMPropertyPage)
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
END_MESSAGE_MAP()
// CPageReport æ¶ˆæ¯å¤„理程序
BOOL CPageReport::OnInitDialog()
{
    CHMPropertyPage::OnInitDialog();
    // è¯»å‡ºåˆ—宽
    CString strIniFile, strItem;
    strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    int width[8] = { 0, 218, 180, 180, 180, 180, 180, 180 };
    for (int i = 0; i < 8; i++) {
        strItem.Format(_T("Col_%d_Width"), i);
        width[i] = GetPrivateProfileInt("PageReportListCtrl", strItem, width[i], strIniFile);
    }
    // æŠ¥è¡¨æŽ§ä»¶
    DWORD dwStyle = m_listCtrl.GetExtendedStyle();
    dwStyle |= LVS_EX_FULLROWSELECT;
    dwStyle |= LVS_EX_GRIDLINES;
    m_listCtrl.SetExtendedStyle(dwStyle);
    HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
    ListView_SetImageList(m_listCtrl.GetSafeHwnd(), imageList, LVSIL_SMALL);
    m_listCtrl.InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]);
    m_listCtrl.InsertColumn(1, _T("RPT ID"), LVCFMT_LEFT, width[1]);
    m_listCtrl.InsertColumn(2, _T("VID"), LVCFMT_LEFT, width[2]);
    loadReports();
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
HBRUSH CPageReport::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CHMPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
    // TODO:  åœ¨æ­¤æ›´æ”¹ DC çš„任何特性
    // TODO:  å¦‚果默认的不是所需画笔,则返回另一个画笔
    return hbr;
}
void CPageReport::OnDestroy()
{
    CHMPropertyPage::OnDestroy();
    // ä¿å­˜åˆ—宽
    CString strIniFile, strItem, strTemp;
    strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    CHeaderCtrl* pHeader = m_listCtrl.GetHeaderCtrl();
    for (int i = 0; i < pHeader->GetItemCount(); i++) {
        RECT rect;
        pHeader->GetItemRect(i, &rect);
        strItem.Format(_T("Col_%d_Width"), i);
        strTemp.Format(_T("%d"), rect.right - rect.left);
        WritePrivateProfileString("PageReportListCtrl", strItem, strTemp, strIniFile);
    }
}
void CPageReport::OnSize(UINT nType, int cx, int cy)
{
    CHMPropertyPage::OnSize(nType, cx, cy);
    if (GetDlgItem(IDC_LIST1) == nullptr) return;
    CWnd* pItem;
    CRect rcClient, rcItem;
    GetClientRect(&rcClient);
    m_listCtrl.MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
}
void CPageReport::loadReports()
{
    auto& reports = theApp.m_model.m_hsmsPassive.getReports();
    for (auto item : reports) {
        int index = m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), _T(""));
        m_listCtrl.SetItemData(index, (DWORD_PTR)item);
        m_listCtrl.SetItemText(index, 1, std::to_string(item->getReportId()).c_str());
        m_listCtrl.SetItemText(index, 2, item->getVariablesIdsText().c_str());
    }
}
SourceCode/Bond/Servo/CPageReport.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
#pragma once
#include "CHMPropertyPage.h"
#include "ListCtrlEx.h"
// CPageReport å¯¹è¯æ¡†
class CPageReport : public CHMPropertyPage
{
    DECLARE_DYNAMIC(CPageReport)
public:
    CPageReport(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CPageReport();
    void loadReports();
private:
    CListCtrlEx m_listCtrl;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_PAGE_REPORT };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void OnDestroy();
    afx_msg void OnSize(UINT nType, int cx, int cy);
};
SourceCode/Bond/Servo/CPageVarialbles.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,133 @@
// CPageVarialbles.cpp: å®žçŽ°æ–‡ä»¶
//
#include "stdafx.h"
#include "Servo.h"
#include "CPageVarialbles.h"
#include "afxdialogex.h"
// CPageVarialbles å¯¹è¯æ¡†
IMPLEMENT_DYNAMIC(CPageVarialbles, CHMPropertyPage)
CPageVarialbles::CPageVarialbles(CWnd* pParent /*=nullptr*/)
    : CHMPropertyPage(IDD_PAGE_VARIABLE, pParent)
{
}
CPageVarialbles::~CPageVarialbles()
{
}
void CPageVarialbles::DoDataExchange(CDataExchange* pDX)
{
    CHMPropertyPage::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_LIST1, m_listCtrl);
}
BEGIN_MESSAGE_MAP(CPageVarialbles, CHMPropertyPage)
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
END_MESSAGE_MAP()
// CPageVarialbles æ¶ˆæ¯å¤„理程序
BOOL CPageVarialbles::OnInitDialog()
{
    CHMPropertyPage::OnInitDialog();
    // è¯»å‡ºåˆ—宽
    CString strIniFile, strItem;
    strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    int width[8] = { 0, 218, 180, 180, 180, 180, 180, 180 };
    for (int i = 0; i < 8; i++) {
        strItem.Format(_T("Col_%d_Width"), i);
        width[i] = GetPrivateProfileInt("PageVariableListCtrl", strItem, width[i], strIniFile);
    }
    // æŠ¥è¡¨æŽ§ä»¶
    DWORD dwStyle = m_listCtrl.GetExtendedStyle();
    dwStyle |= LVS_EX_FULLROWSELECT;
    dwStyle |= LVS_EX_GRIDLINES;
    m_listCtrl.SetExtendedStyle(dwStyle);
    HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
    ListView_SetImageList(m_listCtrl.GetSafeHwnd(), imageList, LVSIL_SMALL);
    m_listCtrl.InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]);
    m_listCtrl.InsertColumn(1, _T("SV ID"), LVCFMT_LEFT, width[1]);
    m_listCtrl.InsertColumn(2, _T("SV Name"), LVCFMT_LEFT, width[2]);
    m_listCtrl.InsertColumn(3, _T("SV Format"), LVCFMT_LEFT, width[3]);
    m_listCtrl.InsertColumn(4, _T("SV Remark"), LVCFMT_LEFT, width[4]);
    loadVariables();
    return TRUE;  // return TRUE unless you set the focus to a control
                  // å¼‚常: OCX å±žæ€§é¡µåº”返回 FALSE
}
HBRUSH CPageVarialbles::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CHMPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
    // TODO:  åœ¨æ­¤æ›´æ”¹ DC çš„任何特性
    // TODO:  å¦‚果默认的不是所需画笔,则返回另一个画笔
    return hbr;
}
void CPageVarialbles::OnDestroy()
{
    CHMPropertyPage::OnDestroy();
    // ä¿å­˜åˆ—宽
    CString strIniFile, strItem, strTemp;
    strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
    CHeaderCtrl* pHeader = m_listCtrl.GetHeaderCtrl();
    for (int i = 0; i < pHeader->GetItemCount(); i++) {
        RECT rect;
        pHeader->GetItemRect(i, &rect);
        strItem.Format(_T("Col_%d_Width"), i);
        strTemp.Format(_T("%d"), rect.right - rect.left);
        WritePrivateProfileString("PageVariableListCtrl", strItem, strTemp, strIniFile);
    }
}
void CPageVarialbles::OnSize(UINT nType, int cx, int cy)
{
    CHMPropertyPage::OnSize(nType, cx, cy);
    if (GetDlgItem(IDC_LIST1) == nullptr) return;
    CWnd* pItem;
    CRect rcClient, rcItem;
    GetClientRect(&rcClient);
    m_listCtrl.MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
}
void CPageVarialbles::OnApply()
{
    __super::OnApply();
}
void CPageVarialbles::loadVariables()
{
    auto& variables = theApp.m_model.m_hsmsPassive.getVariables();
    for (auto item : variables) {
        int index = m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), _T(""));
        m_listCtrl.SetItemData(index, (DWORD_PTR)item);
        m_listCtrl.SetItemText(index, 1, std::to_string(item->getVarialbleId()).c_str());
        m_listCtrl.SetItemText(index, 2, item->getName().c_str());
        m_listCtrl.SetItemText(index, 3, SERVO::CVariable::formatToString(item->getFormat()).c_str());
        m_listCtrl.SetItemText(index, 4, item->getRemark().c_str());
    }
}
SourceCode/Bond/Servo/CPageVarialbles.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
#pragma once
#include "CHMPropertyPage.h"
#include "ListCtrlEx.h"
// CPageVarialbles å¯¹è¯æ¡†
class CPageVarialbles : public CHMPropertyPage
{
    DECLARE_DYNAMIC(CPageVarialbles)
public:
    CPageVarialbles(CWnd* pParent = nullptr);   // æ ‡å‡†æž„造函数
    virtual ~CPageVarialbles();
    virtual void OnApply();
    void loadVariables();
private:
    CListCtrlEx m_listCtrl;
// å¯¹è¯æ¡†æ•°æ®
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_PAGE_VARIABLE };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV æ”¯æŒ
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    afx_msg void OnDestroy();
    afx_msg void OnSize(UINT nType, int cx, int cy);
};
SourceCode/Bond/Servo/CReport.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,98 @@
#include "stdafx.h"
#include "CReport.h"
namespace SERVO {
    CReport::CReport()
    {
        m_nReportId = 0;
    }
    CReport::CReport(unsigned int reportId, std::vector<unsigned int>& vids)
    {
        m_nReportId = reportId;
        for (auto vid : vids) {
            m_vids.push_back(vid);
        }
    }
    CReport::~CReport()
    {
    }
    unsigned int CReport::getReportId()
    {
        return m_nReportId;
    }
    BOOL CReport::addVariable(CVariable* pVariable)
    {
        ASSERT(pVariable);
        if (getVariable(pVariable->getVarialbleId()) != nullptr) {
            return FALSE;
        }
        m_variabels.push_back(pVariable);
        return TRUE;
    }
    BOOL CReport::deleteVarialble(unsigned int nVarialbleId)
    {
        BOOL bDelete = FALSE;
        for (auto iter = m_variabels.begin(); iter != m_variabels.end(); ++iter) {
            if (nVarialbleId == (*iter)->getVarialbleId()) {
                m_variabels.erase(iter);
                bDelete = TRUE;
                break;
            }
        }
        return bDelete;
    }
    CVariable* CReport::getVariable(unsigned int nVarialbleId)
    {
        for (auto item : m_variabels) {
            if (nVarialbleId == item->getVarialbleId()) {
                return item;
            }
        }
        return nullptr;
    }
    std::vector<CVariable*>& CReport::getVariables()
    {
        return m_variabels;
    }
    std::string CReport::getVariablesIdsText()
    {
        std::string strResult, strName;
        for (int i = 0; i < m_vids.size(); i++) {
            strResult += std::to_string(m_vids[i]);
            strResult += "(";
            strResult += (getVariableName(m_vids[i], strName) ?
                strName : _T("null"));
            strResult += ")";
            if (i != m_vids.size() - 1) {
                strResult += ",";
            }
        }
        return strResult;
    }
    bool CReport::getVariableName(unsigned int vid, std::string& strName)
    {
        for (auto item : m_variabels) {
            if (item->getVarialbleId() == vid) {
                strName = item->getName();
                return true;
            }
        }
        return false;
    }
}
SourceCode/Bond/Servo/CReport.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
#pragma once
#include "CVariable.h"
#include <vector>
namespace SERVO {
    class CReport
    {
    public:
        CReport();
        CReport(unsigned int reportId, std::vector<unsigned int>& vids);
        virtual ~CReport();
    public:
        unsigned int getReportId();
        BOOL addVariable(CVariable* pVariable);
        BOOL deleteVarialble(unsigned int nVarialbleId);
        CVariable* getVariable(unsigned int nVarialbleId);
        std::vector<CVariable*>& getVariables();
        std::string getVariablesIdsText();
        bool getVariableName(unsigned int vid, std::string& strName);
    private:
        unsigned int m_nReportId;
        std::vector<unsigned int> m_vids;
        std::vector<CVariable*> m_variabels;
    };
}
SourceCode/Bond/Servo/CVariable.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,90 @@
#include "stdafx.h"
#include "CVariable.h"
namespace SERVO {
    CVariable::CVariable()
    {
        m_nVarialbeId = 0;
        m_format = SVFromat::U1;
    }
    CVariable::CVariable(const char* pszId, const char* pszName, const char* pszFormat, const char* pszRemark)
    {
        m_nVarialbeId = atoi(pszId);
        m_strName = pszName;
        m_format = toFormat(pszFormat);
        m_strRemark = pszRemark;
        TRACE("CVariable .....%d,%s,%d,%s\n", m_nVarialbeId, m_strName.c_str(),
            m_format, m_strRemark.c_str());
    }
    CVariable::~CVariable()
    {
    }
    SVFromat CVariable::toFormat(const char* pszFormat)
    {
        if (_strcmpi("U1", pszFormat) == 0) {
            return SVFromat::U1;
        }
        if (_strcmpi("U2", pszFormat) == 0) {
            return SVFromat::U2;
        }
        if (_strcmpi("I2", pszFormat) == 0) {
            return SVFromat::I2;
        }
        if (_strcmpi("A50", pszFormat) == 0) {
            return SVFromat::A50;
        }
        if (_strcmpi("A20", pszFormat) == 0) {
            return SVFromat::A20;
        }
        return SVFromat::U1;
    }
    std::string CVariable::formatToString(SVFromat format)
    {
        if (SVFromat::U1 == format) {
            return "U1";
        }
        if (SVFromat::U2 == format) {
            return "U1";
        }
        if (SVFromat::I2 == format) {
            return "I2";
        }
        if (SVFromat::A50 == format) {
            return "A50";
        }
        if (SVFromat::A20 == format) {
            return "A20";
        }
        return "U1";
    }
    unsigned int CVariable::getVarialbleId()
    {
        return m_nVarialbeId;
    }
    std::string& CVariable::getName()
    {
        return m_strName;
    }
    SVFromat CVariable::getFormat()
    {
        return m_format;
    }
    std::string& CVariable::getRemark()
    {
        return m_strRemark;
    }
}
SourceCode/Bond/Servo/CVariable.h
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
#pragma once
#include <string>
namespace SERVO {
    // å˜é‡æ ¼å¼
    enum class SVFromat {
        U1 = 0,
        U2,
        I2,
        A20,
        A50
    };
    class CVariable
    {
    public:
        CVariable();
        CVariable(const char* pszId, const char* pszName, const char* pszFormat, const char* pszRemark);
        ~CVariable();
    public:
        static SVFromat toFormat(const char* pszFormat);
        static std::string formatToString(SVFromat format);
        unsigned int getVarialbleId();
        std::string& getName();
        SVFromat getFormat();
        std::string& getRemark();
    private:
        unsigned int m_nVarialbeId;
        std::string m_strName;
        SVFromat m_format;
        std::string m_strRemark;
    };
}
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "HsmsPassive.h"
#include "Log.h"
#include "Model.h"
@@ -8,7 +8,12 @@
#include <time.h>  
#include <stdlib.h>  
#include <string.h>  
#include <regex>
const char ACK[2] = {0, 1};
const char* ACK0 = &ACK[0];
const char* ACK1 = &ACK[1];
unsigned __stdcall CimWorkThreadFunction(LPVOID lpParam)
{
@@ -68,11 +73,7 @@
void CHsmsPassive::setListener(SECSListener listener)
{
    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;
    m_listener = listener;
}
void CHsmsPassive::setActionTimeout(int nSecond)
@@ -97,70 +98,45 @@
}
void CHsmsPassive::addReport(unsigned int id, const char* pszName)
void CHsmsPassive::linkEventReport(unsigned int CEID, unsigned int RPTID)
{
    Lock();
    REPORT report;
    report.id = id;
    strcpy_s(report.szName, REPORT_NAME_MAX, pszName);
    m_mapReport[id] = report;
    Unlock();
    SERVO::CCollectionEvent* pEvent = getEvent(CEID);
    SERVO::CReport* pReport = getReport(RPTID);
    if (pEvent != nullptr) {
        pEvent->setReport(pReport);
}
void CHsmsPassive::linkEventReport(unsigned int RPTID, unsigned int CEID)
{
    m_mapReportIdToCEID[RPTID] = CEID;
}
void CHsmsPassive::unlinkEventReport(unsigned int CEID)
{
    for (auto it = m_mapReportIdToCEID.begin(); it != m_mapReportIdToCEID.end(); ) {
        if (it->second == CEID) {
            m_mapReportIdToCEID.erase(it++);  // æ›´æ–°è¿­ä»£å™¨
        }
        else {
            ++it;
    SERVO::CCollectionEvent* pEvent = getEvent(CEID);
    if (pEvent != nullptr) {
        pEvent->setReport(nullptr);
        }
    }
}
unsigned int CHsmsPassive::getCEID(int RPTID)
SERVO::CReport* CHsmsPassive::defineReport(unsigned int RPTID, std::vector<unsigned int>& vids)
{
    auto iter = m_mapReportIdToCEID.find(RPTID);
    if (iter != m_mapReportIdToCEID.end()) return iter->second;
    return 0;
    // æ·»åŠ å®šä¹‰report
    SERVO::CReport* pReport = new SERVO::CReport(RPTID, vids);
    for (auto vid : vids) {
        SERVO::CVariable* pVariable = getVariable(vid);
        if (pVariable != nullptr) {
            pReport->addVariable(pVariable);
}
    }
    m_reports.push_back(pReport);
void CHsmsPassive::deleteReport(unsigned int RPTID)
{
    for (auto it = m_mapValueIdToPRTID.begin(); it != m_mapValueIdToPRTID.end(); ) {
        if (it->second == RPTID) {
            m_mapValueIdToPRTID.erase(it++);  // æ›´æ–°è¿­ä»£å™¨
        }
        else {
            ++it;
        }
    }
}
void CHsmsPassive::deleteAllReport()
{
    m_mapValueIdToPRTID.clear();
}
void CHsmsPassive::defineReport(unsigned int VID, unsigned int RPTID)
{
    m_mapValueIdToPRTID[VID] = RPTID;
    return pReport;
}
void CHsmsPassive::OnTimer(UINT nTimerid)
{
    // æ‰€æœ‰å·²å‘送的Action自加1
    // æ‰€æœ‰å·²å‘送的Action自加1
    Lock();
    for (auto iter = m_listActionSent.begin(); iter != m_listActionSent.end();) {
        if ((*iter)->incrementAndCheckTimeout()) {
            TRACE("CHsmsPassive::超时\n");
            TRACE("CHsmsPassive::超时\n");
            delete (*iter);
            m_listActionSent.erase(iter++);
        }
@@ -178,7 +154,7 @@
    CHsmsAction* pAction = nullptr;
    for (auto iter = m_listActionSent.begin(); iter != m_listActionSent.end(); iter++) {
        if ((*iter)->getSendMessage()->getHeader()->systemBytes == pMessage->getHeader()->systemBytes) {
            LOGI("CHsmsPassive::找到");
            LOGI("CHsmsPassive::找到");
            pAction = (*iter);
            m_listActionSent.erase(iter);
            break;
@@ -187,12 +163,277 @@
    Unlock();
    if (pAction != nullptr) {
        LOGI("onRecvMsg::相应处理");
        LOGI("onRecvMsg::相应处理");
        delete pAction;
    }
    return 0;
}
int CHsmsPassive::loadVarialbles(const char* pszFilepath)
{
    CStdioFile file;
    if (!file.Open(pszFilepath, CFile::modeRead)) {
        return -1;
    }
    std::regex pattern("^\\d+,.*");  // åŒ¹é…ä»¥æ•°å­—+逗号开头的字符串
    std::vector<SERVO::CVariable*> variables;
    int index, last;
    CString strLine;
    CString strId, strName, strFormat, strRemark;
    while (file.ReadString(strLine)) {
        if (!std::regex_match((LPTSTR)(LPCTSTR)strLine, pattern)) {
            continue;
        }
        last = 0;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strId = strLine.Left(index);
        last = index + 1;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strName = strLine.Mid(last, index - last);
        last = index + 1;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strFormat = strLine.Mid(last, index - last);
        strRemark = strLine.Right(strLine.GetLength() - index - 1);
        strRemark.Replace(_T("\\r\\n"), _T("\r\n"));
        SERVO::CVariable* pVarialble = new SERVO::CVariable(
            (LPTSTR)(LPCTSTR)strId, (LPTSTR)(LPCTSTR)strName, (LPTSTR)(LPCTSTR)strFormat, (LPTSTR)(LPCTSTR)strRemark);
        variables.push_back(pVarialble);
    }
    if (!variables.empty()) {
        clearAllVariabel();
        for (auto item : variables) {
            m_variabels.push_back(item);
        }
    }
    file.Close();
    return 0;
}
std::vector<SERVO::CVariable*>& CHsmsPassive::getVariables()
{
    return m_variabels;
}
SERVO::CVariable* CHsmsPassive::getVariable(int variableId)
{
    for (auto item : m_variabels) {
        if (item->getVarialbleId() == variableId) {
            return item;
        }
    }
    return nullptr;
}
void CHsmsPassive::clearAllVariabel()
{
    for (auto item : m_variabels) {
        delete item;
    }
    m_variabels.clear();
}
int CHsmsPassive::loadReports(const char* pszFilepath)
{
    CStdioFile file;
    if (!file.Open(pszFilepath, CFile::modeRead)) {
        return -1;
    }
    std::regex pattern("^\\d+,\\(\\d+(,\\d+)*\\).*");  // åŒ¹é…ä»¥æ•°å­—+逗号开头的字符串
    std::vector<SERVO::CReport*> reports;
    int index;
    CString strLine, strVariable;
    CString strId;
    while (file.ReadString(strLine)) {
        if (!std::regex_match((LPTSTR)(LPCTSTR)strLine, pattern)) {
            continue;
        }
        index = strLine.Find(",", 0);
        if (index < 0) continue;
        strId = strLine.Left(index);
        strVariable = strLine.Right(strLine.GetLength() - index - 1);
        strVariable.Delete(0);
        strVariable.Delete(strVariable.GetLength() - 1);
        auto vids = parseVidList(strVariable);
        SERVO::CReport* pReport = new SERVO::CReport(atoi((LPTSTR)(LPCTSTR)strId), vids);
        for (auto vid : vids) {
            SERVO::CVariable* pVariable = getVariable(vid);
            if (pVariable != nullptr) {
                pReport->addVariable(pVariable);
            }
        }
        reports.push_back(pReport);
    }
    if (!reports.empty()) {
        clearAllReport();
        for (auto item : reports) {
            m_reports.push_back(item);
        }
    }
    file.Close();
    return 0;
}
std::vector<SERVO::CReport*>& CHsmsPassive::getReports()
{
    return m_reports;
}
SERVO::CReport* CHsmsPassive::getReport(int rptid)
{
    for (auto item : m_reports) {
        if (item->getReportId() == rptid) {
            return item;
        }
    }
    return nullptr;
}
bool CHsmsPassive::removeReport(int rptid)
{
    for (auto iter = m_reports.begin(); iter != m_reports.end(); ++iter) {
        if ((*iter)->getReportId() == rptid) {
            delete (*iter);
            m_reports.erase(iter);
            return true;
        }
    }
    return false;
}
void CHsmsPassive::clearAllReport()
{
    for (auto item : m_reports) {
        delete item;
    }
    m_reports.clear();
}
int CHsmsPassive::loadCollectionEvents(const char* pszFilepath)
{
    CStdioFile file;
    if (!file.Open(pszFilepath, CFile::modeRead)) {
        return -1;
    }
    std::regex pattern("^\\d+,[^,]*,[^,]*,\\(\\d+(,\\d+)*\\).*");  // åŒ¹é…ä»¥æ•°å­—+逗号开头的字符串
    std::vector<SERVO::CCollectionEvent*> events;
    int index, last;
    CString strLine, strRPTIDs;
    CString strId, strName, strDescription;
    while (file.ReadString(strLine)) {
        if (!std::regex_match((LPTSTR)(LPCTSTR)strLine, pattern)) {
            continue;
        }
        last = 0;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strId = strLine.Left(index);
        last = index + 1;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strName = strLine.Mid(last, index - last);
        last = index + 1;
        index = strLine.Find(",", last);
        if (index < 0) continue;
        strDescription = strLine.Mid(last, index - last);
        strRPTIDs = strLine.Right(strLine.GetLength() - index - 1);
        strRPTIDs.Delete(0);
        strRPTIDs.Delete(strRPTIDs.GetLength() - 1);
        auto prtids = parseVidList(strRPTIDs);
        SERVO::CCollectionEvent* pEvent = new SERVO::CCollectionEvent(
            atoi(strId), (LPTSTR)(LPCTSTR)strName, (LPTSTR)(LPCTSTR)strDescription, prtids);
        for (auto rptid : prtids) {
            SERVO::CReport* pReport = getReport(rptid);
            if (pReport != nullptr) {
                pEvent->addReport(pReport);
            }
        }
        events.push_back(pEvent);
    }
    if (!events.empty()) {
        clearAllCollectionEvent();
        for (auto item : events) {
            m_collectionEvents.push_back(item);
        }
    }
    file.Close();
    return 0;
}
std::vector<SERVO::CCollectionEvent*>& CHsmsPassive::getCollectionEvents()
{
    return m_collectionEvents;
}
void CHsmsPassive::clearAllCollectionEvent()
{
    for (auto item : m_collectionEvents) {
        delete item;
    }
    m_collectionEvents.clear();
}
SERVO::CCollectionEvent* CHsmsPassive::getEvent(unsigned short CEID)
{
    for (auto item : m_collectionEvents) {
        if (item->getEventId() == CEID) {
            return item;
        }
    }
    return nullptr;
}
std::vector<unsigned int> CHsmsPassive::parseVidList(CString& strNums)
{
    // 1. å…ˆåŽ»æŽ‰å¯èƒ½å‡ºçŽ°çš„ç©ºç™½ç¬¦ï¼ˆç©ºæ ¼ã€åˆ¶è¡¨ç¬¦ç­‰ï¼‰
    strNums.Trim();
    // 2️.
    std::vector<unsigned int> result;
    int i = 0;
    CString strVid;
    while (1) {
        if (!AfxExtractSubString(strVid, (LPCTSTR)strNums, i, ',')) {
            break;
        }
        if (!strVid.IsEmpty())                 // é˜²å¾¡æ€§æ£€æŸ¥
            result.push_back(std::stoi((LPTSTR)(LPCTSTR)strVid));
        i++;
    }
    return result;
}
int CHsmsPassive::init(CModel* pModel, const char* pszName, unsigned int port)
@@ -205,8 +446,8 @@
    auto onStatusChanged = [&](void* pFrom, STATE state) -> void {
        m_pModel->notifyInt(RX_CODE_PASSIVE_STATUS_CHANGED, (int)state);
        // è¿žä¸Šä¹‹åŽå‘S1F1
        // ä¿®æ”¹ä¸ºä¸ä¸»åŠ¨å‘é€ï¼Œè€Œæ˜¯å“åº”
        // è¿žä¸Šä¹‹åŽå‘S1F1
        // ä¿®æ”¹ä¸ºä¸ä¸»åŠ¨å‘é€ï¼Œè€Œæ˜¯å“åº”
        /*
        if (STATE::SELECTED == state) {
            m_bAreYouThereRequest = FALSE;
@@ -245,7 +486,7 @@
        HEADER* pHeader = pMessage->getHeader();
        int nStream = (pHeader->stream & 0x7F);
        LOGI("<HSMS>收到消息 S%dF%d", nStream, pHeader->function);
        LOGI("<HSMS>收到消息 S%dF%d", nStream, pHeader->function);
        if (nStream == 1 && pHeader->function == 1) {
            // S1F1
            replyAreYouThere(pMessage);
@@ -280,6 +521,9 @@
        else if (nStream == 2 && pHeader->function == 41) {
            replyCommand(pMessage);
        }
        else if (nStream == 2 && pHeader->function == 43) {
            replyConfigureSpooling(pMessage);
        }
        else if (nStream == 5 && pHeader->function == 3) {
            replyEanbleDisableAlarmReport(pMessage);
        }
@@ -299,7 +543,7 @@
    listener.funError = onError;
    m_pPassive->setListener(listener);
    // å¯åŠ¨å·¥ä½œçº¿ç¨‹
    // å¯åŠ¨å·¥ä½œçº¿ç¨‹
    m_bCimWorking = TRUE;
    m_hCimWorkThreadHandle = (HANDLE)_beginthreadex(NULL, 0, ::CimWorkThreadFunction, this,
        0, &m_nCimWorkThrdaddr);
@@ -312,7 +556,7 @@
int CHsmsPassive::term()
{
    // ç»“束线程
    // ç»“束线程
    m_bCimWorking = FALSE;
    SetEvent(m_hCimWorkEvent);
    if (m_hCimWorkThreadHandle != NULL) {
@@ -326,6 +570,10 @@
        m_pPassive = NULL;
    }
    clearAllVariabel();
    clearAllReport();
    clearAllCollectionEvent();
    return 0;
}
@@ -333,12 +581,12 @@
{
    while (m_bCimWorking) {
        // å¾…退出信号或时间到
        // å¾…退出信号或时间到
        int nRet = WaitForSingleObject(m_hCimWorkEvent, INFINITE);
        ResetEvent(m_hCimWorkEvent);
        if (!m_bCimWorking) break;
        // å–出请求列表并进行处理
        // å–出请求列表并进行处理
        std::list<CHsmsAction*> list;
        Lock();
        list.splice(list.end(), m_listAction);
@@ -357,14 +605,14 @@
            LOGI("<HSMS> [SEND] SysByte=%u sessionId:%d", pMessage->getHeader()->systemBytes, pMessage->getHeader()->sessionId);
            if (pAction->isNeedWaitReply()) {
                // å¦‚果需要等待回复
                // å¦‚果需要等待回复
                int nRet = WaitForSingleObject(pAction->getEvent(), pAction->getTimeout() * 1000);
                if (nRet == WAIT_TIMEOUT) {
                    TRACE("Timeout...\n");
                    CContext* pContext = pAction->getContext();
                    if (pContext != NULL) {
                        //pContext->setRetCode(CRC_TIMEOUT);
                        //pContext->setRetMsg("超时");
                        //pContext->setRetMsg("超时");
                        //pContext->setEvent();
                    }
                }
@@ -390,7 +638,7 @@
    return 0;
}
// é€šç”¨çš„reply ack函数
// é€šç”¨çš„reply ack函数
void CHsmsPassive::replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName)
{
    IMessage* pMessage = NULL;
@@ -453,13 +701,13 @@
    }
    // äº¤ç”±ä¸Šå±‚应用来获取机器常量值
    // äº¤ç”±ä¸Šå±‚应用来获取机器常量值
    if (m_listener.onEQOffLine != nullptr) {
        m_listener.onEQOffLine(this);
    }
    // å›žå¤
    // å›žå¤
    replyAck(1, 16, pRecv->getHeader()->systemBytes, BYTE(0), "OFLACK");
    return 0;
}
@@ -472,13 +720,13 @@
    }
    // äº¤ç”±ä¸Šå±‚应用来获取机器常量值
    // äº¤ç”±ä¸Šå±‚应用来获取机器常量值
    if (m_listener.onEQOnLine != nullptr) {
        m_listener.onEQOnLine(this);
    }
    // å›žå¤
    // å›žå¤
    replyAck(1, 18, pRecv->getHeader()->systemBytes, BYTE(0), "ONLACK");
    return 0;
}
@@ -494,12 +742,12 @@
    ASSERT(pMessage);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addBinaryItem(BYTE(0), "COMMACK");
    pItem->addBinaryItem(ACK0, 1, "COMMACK");
    ISECS2Item* pList = pItem->addItem();
    pList->addItem(m_strEquipmentModelType.c_str(), "MDLN");
    pList->addItem(m_strSoftRev.c_str(), "SOFTREV");
    m_pPassive->sendMessage(pMessage);
    LOGI("<HSMS>[SECS Msg SEND]S1F14 (SysByte=%u)", pMessage->getHeader()->systemBytes);
    LOGI("<HSMS>[SECS Msg SEND]%s", pMessage->toString());
    HSMS_Destroy1Message(pMessage);
    return 0;
@@ -513,7 +761,7 @@
    }
    // è¦èŽ·å–çš„å¸¸é‡è¡¨è¡¨
    // è¦èŽ·å–çš„å¸¸é‡è¡¨è¡¨
    BOOL bCheckData = FALSE;
    std::vector<EQConstant> eqcs;
    {
@@ -530,13 +778,13 @@
    }
    // äº¤ç”±ä¸Šå±‚应用来获取机器常量值
    // äº¤ç”±ä¸Šå±‚应用来获取机器常量值
    if (m_listener.onEQConstantRequest != nullptr) {
        m_listener.onEQConstantRequest(this, eqcs);
    }
    // å›žå¤
    // å›žå¤
    IMessage* pMessage = NULL;
    HSMS_Create1Message(pMessage, m_nSessionId, 1, 14, pRecv->getHeader()->systemBytes);
    ASSERT(pMessage);
@@ -560,7 +808,7 @@
    }
    // è¦è®¾ç½®çš„常量表表
    // è¦è®¾ç½®çš„常量表表
    BOOL bCheckData = FALSE;
    std::vector<EQConstant> eqcs;
    {
@@ -583,14 +831,14 @@
    }
    // äº¤ç”±ä¸Šå±‚应用来保存和设置机器常量值
    // äº¤ç”±ä¸Šå±‚应用来保存和设置机器常量值
    std::vector<unsigned int> ecvs;
    if (m_listener.onEQConstantSend != nullptr) {
        m_listener.onEQConstantSend(this, eqcs);
    }
    // å›žå¤
    // å›žå¤
    replyAck(2, 16, pRecv->getHeader()->systemBytes, BYTE(0), "EACK");
    return 0;
}
@@ -605,7 +853,7 @@
    if (pBody == nullptr || pBody->getType() != SITYPE::A) ER_PARAM_ERROR;
    const char* pszMessage;
    if (pBody->getString(pszMessage)) {
        // æ›´æ–°æ—¶é—´
        // æ›´æ–°æ—¶é—´
        SYSTEMTIME time;
        char szBuffer[20];
        memcpy(szBuffer, pszMessage, 16);
@@ -623,6 +871,9 @@
        time.wYear = atoi(&szBuffer[0]);
        time.wMilliseconds = 0;
        SetLocalTime(&time);
        if (m_listener.onDatetimeSync != nullptr) {
            m_listener.onDatetimeSync(this, time);
        }
    }
    replyAck(2, 32, pRecv->getHeader()->systemBytes, BYTE(0), "TIACK");
@@ -640,40 +891,47 @@
    ISECS2Item* pBody = pRecv->getBody();
    ISECS2Item* defineItem, *rptListItem, * vidListItem;
    unsigned int dataId, rptid, vid;
    if (!pBody->getSubItemU4(0, dataId)) goto MYREPLY;
    rptListItem = pBody->getSubItem(1);
    if (rptListItem == nullptr) goto MYREPLY;
    if (rptListItem->getSubItemSize() == 0) {
        deleteAllReport();
        clearAllReport();
        goto MYREPLY;
    }
    for (int i = 0; i < rptListItem->getSubItemSize(); i++) {
        defineItem = rptListItem->getSubItem(i);
        if (defineItem == nullptr) continue;
        std::vector<unsigned int> vids;
        SERVO::CReport* pReport = nullptr;
        vidListItem = defineItem->getSubItem(1);
        if (defineItem->getSubItemU4(0, rptid)
            && vidListItem != nullptr) {
            int vidCount = vidListItem->getSubItemSize();
            if (vidCount == 0) {
                deleteReport(rptid);
            }
            else {
                for (int k = 0; k < vidCount; k++) {
            for (int k = 0; k < vidListItem->getSubItemSize(); k++) {
                    if (vidListItem->getSubItemU4(k, vid)) {
                        defineReport(vid, rptid);
                    vids.push_back(vid);
                    }
                }
        }
        removeReport(rptid);
        if (!vids.empty()) {
            pReport = defineReport(rptid, vids);
        }
        // æ£€éªŒç»“果是否正确
        if (pReport != nullptr) {
            auto variables = pReport->getVariables();
            for (auto item : variables) {
                LOGE("=== prtid:%d, vid:%d", rptid, item->getVarialbleId());
            }
        }
    }
MYREPLY:
    // æ£€éªŒç»“果是否正确
    for (auto item : m_mapValueIdToPRTID) {
        LOGE("=== vid:%d, prtid:%d", item.first, item.second);
    }
    replyAck(2, 34, pRecv->getHeader()->systemBytes, BYTE(0), "DRACK");
    return 0;
}
@@ -705,7 +963,7 @@
            else {
                for (int k = 0; k < prtCount; k++) {
                    if (rptListItem->getSubItemU4(k, rptid)) {
                        linkEventReport(rptid, ceid);
                        linkEventReport(ceid, rptid);
                    }
                }
            }
@@ -713,9 +971,9 @@
    }
    // æ£€éªŒç»“果是否正确
    for (auto item : m_mapReportIdToCEID) {
        LOGE("=== prtid:%d, ceid:%d", item.first, item.second);
    // æ£€éªŒç»“果是否正确
    for (auto item : m_collectionEvents) {
        LOGE("=== ceid:%d, prtid:%d", item->getEventId(), item->getPortID());
    }
MYREPLY:
@@ -751,15 +1009,15 @@
            }
        }
        bCheckData = TRUE;
        LOGI("EanbleDisableAlarm bEnable:%s", bEnable ? _T("YES") : _T("NO"));
        for (auto item : ids) {
            LOGI("ID:%u", item);
        if (m_listener.onEnableDisableEventReport != nullptr) {
            m_listener.onEnableDisableEventReport(this, bEnable, ids);
        }
    }
MYREPLY:
    replyAck(2, 38, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK");
    replyAck(2, 38, pRecv->getHeader()->systemBytes,
        bCheckData ? BYTE(0) : BYTE(1), "ERACK");
    return 0;
}
@@ -800,13 +1058,58 @@
    }
    // å›žè°ƒåˆ°åº”用层
    // å›žè°ƒåˆ°åº”用层
    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;
}
// S2F43
int CHsmsPassive::replyConfigureSpooling(IMessage* pRecv)
{
    if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
        return ER_NOTSELECT;
    }
    ISECS2Item* pBody = pRecv->getBody();
    if (pBody == nullptr || pBody->getType() != SITYPE::L) ER_PARAM_ERROR;
    // æ¸…空所有
    if (pBody->getSubItemSize() == 0) {
        m_spoolingConfig.clear();
        goto MYREPLY;
    }
    // ä¾æ¬¡é…ç½®Stream
    for (int i = 0; i < pBody->getSubItemSize(); i++) {
        ISECS2Item* pStreamItem = pBody->getSubItem(i);
        ASSERT(pStreamItem);
        unsigned char STRID, FCNID;
        pStreamItem->getSubItemU1(0, STRID);
        ISECS2Item* pFcnItemList = pStreamItem->getSubItem(1);
        if (pFcnItemList->getSubItemSize() == 0) {
            m_spoolingConfig[STRID].clear();
        }
        else {
            for (int j = 0; j < pFcnItemList->getSubItemSize(); j++) {
                pFcnItemList->getSubItemU1(j, FCNID);
                m_spoolingConfig[STRID].insert(FCNID);
            }
        }
    }
    // æ‰“印验证结果
    for (auto s : m_spoolingConfig) {
        LOGI("====> stream:%d", s.first);
        for (auto f : s.second) {
            LOGI("function:%d", f);
        }
    }
MYREPLY:
    replyAck(2, 42, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK");
    return 0;
@@ -834,36 +1137,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);
        }
    }
@@ -936,6 +1212,9 @@
        return ER_NOTSELECT;
    }
    char szALCD[1];
    szALCD[0] = ALCD & 0xff;
    Lock();
    CHsmsAction* pAction = new CHsmsAction(ACTION_ALARM_REPORT, TRUE, m_nActionTimeout);
    m_listAction.push_back(pAction);
@@ -943,7 +1222,7 @@
    HSMS_Create1Message(pMessage, m_nSessionId, 5 | REPLY, 1, ++m_nSystemByte);
    ASSERT(pMessage);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addBinaryItem(BYTE(ALCD & 0xff), "ALCD");
    pItem->addBinaryItem(szALCD, 1, "ALCD");
    pItem->addU4Item(ALID, "ALID");
    pItem->addItem(ALTX, "ALTX");
    pAction->setSendMessage(pMessage);
@@ -955,10 +1234,18 @@
}
// S6F11
int CHsmsPassive::requestEventReportSend(unsigned int DATAID, unsigned int RPTID, const std::vector<std::string>& values)
int CHsmsPassive::requestEventReportSend(unsigned int DATAID, unsigned int CEID, const std::vector<std::string>& values)
{
    if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
        return ER_NOTSELECT;
    }
    SERVO::CCollectionEvent* pEvent = getEvent(CEID);
    if (pEvent == nullptr) {
        return ER_NO_EVENT;
    }
    if (pEvent == nullptr) {
        return ER_UNLINK_EVENT_REPORT;
    }
    Lock();
@@ -969,10 +1256,10 @@
    ASSERT(pMessage);
    ISECS2Item* pItem = pMessage->getBody();
    pItem->addU4Item(DATAID, "DATAID");
    pItem->addU4Item(getCEID(RPTID), "CEID");
    pItem->addU4Item(CEID, "CEID");
    ISECS2Item* pItemList1 = pItem->addItem();
    ISECS2Item* pItemList2 = pItemList1->addItem();
    pItemList2->addU4Item(RPTID, "RPTID");
    pItemList2->addU4Item(pEvent->getPortID(), "RPTID");
    ISECS2Item* pItemList3 = pItemList2->addItem();
    for (auto item : values) {
        pItemList3->addItem(item.c_str(), "V");
SourceCode/Bond/Servo/HsmsPassive.h
@@ -5,6 +5,8 @@
#include <functional>
#include <vector>
#include <map>
#include <set>
#include "CCollectionEvent.h"
#define EQCONSTANT_VALUE_MAX    64
@@ -18,6 +20,8 @@
#define ER_NOTSELECT        -1
#define ER_BUSY                -2
#define ER_PARAM_ERROR        -3
#define ER_NO_EVENT                -4
#define ER_UNLINK_EVENT_REPORT    -5
/*
@@ -60,6 +64,9 @@
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 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;
@@ -67,6 +74,9 @@
    SECSEQCONSTANTREQUEST        onEQConstantRequest;
    SECSEQCONSTANTREQUEST        onEQConstantSend;
    SECSCommand                    onCommand;
    DATETIMESYNC                onDatetimeSync;
    EDEVENTREPORT                onEnableDisableEventReport;
    EDALARMREPORT                onEnableDisableAlarmReport;
} SECSListener;
@@ -84,25 +94,48 @@
    /* è®¾ç½®è½¯ä»¶ç‰ˆæœ¬å· æœ€å¤§é•¿åº¦ 20 bytes */
    void setSoftRev(const char* pszRev);
    /* æ·»åŠ Report */
    void addReport(unsigned int id, const char* pszName);
    // è¿žæŽ¥Report
    void linkEventReport(unsigned int RPTID, unsigned int CEID);
    void linkEventReport(unsigned int CEID, unsigned int RPTID);
    // å–消连接report
    void unlinkEventReport(unsigned int CEID);
    unsigned int getCEID(int RPTID);
    // define Report
    void defineReport(unsigned int VID, unsigned int RPTID);
    SERVO::CReport* defineReport(unsigned int RPTID, std::vector<unsigned int>& vids);
    // å–消 define report
    void deleteReport(unsigned int RPTID);
    bool removeReport(int rptid);
    void clearAllReport();
    // å–消/删除所有 define report
    void deleteAllReport();
    // ä»Žæ–‡ä»¶ä¸­åŠ è½½CVariable列表
    int loadVarialbles(const char* pszFilepath);
    // å–å¾—CVariable列表
    std::vector<SERVO::CVariable*>& getVariables();
    // å–得指定Variable
    SERVO::CVariable* getVariable(int variableId);
    // ä»Žæ–‡ä»¶ä¸­åŠ è½½CReport列表
    int loadReports(const char* pszFilepath);
    // å–å¾—Report列表
    std::vector<SERVO::CReport*>& getReports();
    // ä»Žæ–‡ä»¶ä¸­åŠ è½½CCollectionEvent列表
    int loadCollectionEvents(const char* pszFilepath);
    // å–å¾—CCollectionEvent列表
    std::vector<SERVO::CCollectionEvent*>& getCollectionEvents();
    // å–消/删除所有CollectionEvent
    void clearAllCollectionEvent();
    // å–å¾—CCollectionEvent
    SERVO::CCollectionEvent* getEvent(unsigned short CEID);
    // å–å¾—Report
    SERVO::CReport* getReport(int rptid);
    void setListener(SECSListener listener);
    unsigned OnCimWork();
@@ -115,7 +148,7 @@
    /* request开头的函数为主动发送数据的函数 */
    int requestAreYouThere();
    int requestAlarmReport(int ALCD, int ALID, const char* ALTX);
    int requestEventReportSend(unsigned int DATAID, unsigned int RPTID, const std::vector<std::string>& values);
    int requestEventReportSend(unsigned int DATAID, unsigned int CEID, const std::vector<std::string>& values);
private:
    void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
@@ -132,6 +165,7 @@
    int replyLinkEventReport(IMessage* pRecv);
    int replyEanbleDisableEventReport(IMessage* pRecv);
    int replyCommand(IMessage* pRecv);
    int replyConfigureSpooling(IMessage* pRecv);
    int replyEanbleDisableAlarmReport(IMessage* pRecv);
    int replyQueryPPIDList(IMessage* pRecv);
    int replyTerminalDisplay(IMessage* pRecv);
@@ -140,6 +174,8 @@
    inline void Lock() { EnterCriticalSection(&m_criticalSection); }
    inline void Unlock() { LeaveCriticalSection(&m_criticalSection); }
    int onRecvMsg(IMessage* pMessage);
    void clearAllVariabel();
    std::vector<unsigned int> parseVidList(CString& strNums);
private:
    CModel* m_pModel;
@@ -162,16 +198,16 @@
    unsigned m_nCimWorkThrdaddr;
private:
    // RPTID to CEID
    std::map<unsigned int, unsigned int> m_mapReportIdToCEID;
    // CVariable vector
    std::vector<SERVO::CVariable*> m_variabels;
    
    // RPTID to Report
    std::map<unsigned int, REPORT> m_mapReport;
    // CReport vector
    std::vector<SERVO::CReport*> m_reports;
    // VID to RPTID
    std::map<unsigned int, unsigned int> m_mapValueIdToPRTID;
    // CollectionEvent vector
    std::vector<SERVO::CCollectionEvent*> m_collectionEvents;
    // VID to Report
    std::map<unsigned int, VALUE> m_mapValue;
    // Spooling Config
    std::map<uint16_t, std::set<uint16_t>> m_spoolingConfig;
};
SourceCode/Bond/Servo/Model.cpp
@@ -114,11 +114,34 @@
            LOGI("onEQConstantRequest: %d, %s", item.id, item.szValue);
        }
    };
    listener.onDatetimeSync = [&](void* pFrom, SYSTEMTIME& time) -> void {
        LOGI("onDatetimeSync: %d%02d%02d%02d%02d%02d", time.wYear,
            time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
        m_master.datetimeSync(time);
    };
    listener.onEnableDisableEventReport = [&](void* pFrom, bool bEnable, std::vector<unsigned int> ids) -> void {
        LOGI("EanbleDisableEventReport bEnable:%s", bEnable ? _T("YES") : _T("NO"));
        if (ids.empty()) {
            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);
    CString strVarialbleFile;
    strVarialbleFile.Format(_T("%s\\VariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
    m_hsmsPassive.loadVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile);
    m_hsmsPassive.init(this, "APP", 7000);
    strVarialbleFile.Format(_T("%s\\ReportList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
    m_hsmsPassive.loadReports((LPTSTR)(LPCTSTR)strVarialbleFile);
    strVarialbleFile.Format(_T("%s\\CollectionEventList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
    m_hsmsPassive.loadCollectionEvents((LPTSTR)(LPCTSTR)strVarialbleFile);
    SERVO::MasterListener masterListener;
@@ -178,9 +201,11 @@
            notify(RX_CODE_ALARM_CLEAR);
        }
        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.");
SourceCode/Bond/Servo/Servo.rc
Binary files differ
SourceCode/Bond/Servo/Servo.vcxproj
@@ -201,16 +201,22 @@
  <ItemGroup>
    <ClInclude Include="CBaseDlg.h" />
    <ClInclude Include="CCustomCheckBox.h" />
    <ClInclude Include="CCollectionEvent.h" />
    <ClInclude Include="CEquipmentPage3.h" />
    <ClInclude Include="CGlassPool.h" />
    <ClInclude Include="ChangePasswordDlg.h" />
    <ClInclude Include="CMyStatusbar.h" />
    <ClInclude Include="CPageCollectionEvent.h" />
    <ClInclude Include="CPageLinkSignal.h" />
    <ClInclude Include="CPageReport.h" />
    <ClInclude Include="CPageVarialbles.h" />
    <ClInclude Include="CReport.h" />
    <ClInclude Include="CRobotCmdContainerDlg.h" />
    <ClInclude Include="CRobotCmdTestDlg.h" />
    <ClInclude Include="CPagePortStatus.h" />
    <ClInclude Include="CPortStatusReport.h" />
    <ClInclude Include="CRobotTaskDlg.h" />
    <ClInclude Include="CVariable.h" />
    <ClInclude Include="GridControl\CellRange.h" />
    <ClInclude Include="GridControl\GridCell.h" />
    <ClInclude Include="GridControl\GridCellBase.h" />
@@ -344,16 +350,22 @@
  <ItemGroup>
    <ClCompile Include="CBaseDlg.cpp" />
    <ClCompile Include="CCustomCheckBox.cpp" />
    <ClCompile Include="CCollectionEvent.cpp" />
    <ClCompile Include="CEquipmentPage3.cpp" />
    <ClCompile Include="CGlassPool.cpp" />
    <ClCompile Include="ChangePasswordDlg.cpp" />
    <ClCompile Include="CMyStatusbar.cpp" />
    <ClCompile Include="CPageCollectionEvent.cpp" />
    <ClCompile Include="CPageLinkSignal.cpp" />
    <ClCompile Include="CPageReport.cpp" />
    <ClCompile Include="CPageVarialbles.cpp" />
    <ClCompile Include="CReport.cpp" />
    <ClCompile Include="CRobotCmdContainerDlg.cpp" />
    <ClCompile Include="CRobotCmdTestDlg.cpp" />
    <ClCompile Include="CPagePortStatus.cpp" />
    <ClCompile Include="CPortStatusReport.cpp" />
    <ClCompile Include="CRobotTaskDlg.cpp" />
    <ClCompile Include="CVariable.cpp" />
    <ClCompile Include="GridControl\GridCell.cpp" />
    <ClCompile Include="GridControl\GridCellBase.cpp" />
    <ClCompile Include="GridControl\GridCellButton.cpp" />
SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -170,6 +170,12 @@
    <ClCompile Include="RecipeManager.cpp" />
    <ClCompile Include="RecipeDeviceBindDlg.cpp" />
    <ClCompile Include="CCustomCheckBox.cpp" />
    <ClCompile Include="CCollectionEvent.cpp" />
    <ClCompile Include="CReport.cpp" />
    <ClCompile Include="CVariable.cpp" />
    <ClCompile Include="CPageVarialbles.cpp" />
    <ClCompile Include="CPageReport.cpp" />
    <ClCompile Include="CPageCollectionEvent.cpp" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="AlarmManager.h" />
@@ -345,6 +351,12 @@
    <ClInclude Include="RecipeManager.h" />
    <ClInclude Include="RecipeDeviceBindDlg.h" />
    <ClInclude Include="CCustomCheckBox.h" />
    <ClInclude Include="CCollectionEvent.h" />
    <ClInclude Include="CReport.h" />
    <ClInclude Include="CVariable.h" />
    <ClInclude Include="CPageVarialbles.h" />
    <ClInclude Include="CPageReport.h" />
    <ClInclude Include="CPageCollectionEvent.h" />
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="Servo.rc" />
SourceCode/Bond/Servo/Servo.vcxproj.user
@@ -7,6 +7,6 @@
    <RemoteDebuggerCommand>\\DESKTOP-IODBVIQ\Servo\Debug\Servo.exe</RemoteDebuggerCommand>
    <RemoteDebuggerWorkingDirectory>\\DESKTOP-IODBVIQ\Servo\Debug\</RemoteDebuggerWorkingDirectory>
    <RemoteDebuggerServerName>DESKTOP-IODBVIQ</RemoteDebuggerServerName>
    <DebuggerFlavor>WindowsRemoteDebugger</DebuggerFlavor>
    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
  </PropertyGroup>
</Project>
SourceCode/Bond/Servo/ServoDlg.cpp
@@ -22,6 +22,10 @@
#include "UserManager.h"
#include "SystemLogManager.h"
#include "PortConfigurationDlg.h"
#include "CHMPropertyDlg.h"
#include "CPageVarialbles.h"
#include "CPageReport.h"
#include "CPageCollectionEvent.h"
#ifdef _DEBUG
@@ -118,6 +122,8 @@
    ON_UPDATE_COMMAND_UI(ID_MENU_FILE_SETTINGS, &CServoDlg::OnUpdateMenuFileSettings)
    ON_COMMAND(ID_MENU_FILE_SECSTEST, &CServoDlg::OnMenuFileSecsTest)
    ON_UPDATE_COMMAND_UI(ID_MENU_FILE_SECSTEST, &CServoDlg::OnUpdateMenuFileSecsTest)
    ON_COMMAND(ID_MENU_PROJECT_VARIABLE_LIST, &CServoDlg::OnMenuProjectVarialbleList)
    ON_UPDATE_COMMAND_UI(ID_MENU_PROJECT_VARIABLE_LIST, &CServoDlg::OnUpdateMenuProjectVarialbleList)
    ON_COMMAND(ID_MENU_TEST_MESSAGE_SET, &CServoDlg::OnMenuTestMessageSet)
    ON_UPDATE_COMMAND_UI(ID_MENU_TEST_MESSAGE_SET, &CServoDlg::OnUpdateMenuTestMessageSet)
    ON_COMMAND(ID_MENU_TEST_MESSAGE_CLEAR, &CServoDlg::OnMenuTestMessageClear)
@@ -250,6 +256,26 @@
                }
            }
            if (RX_CODE_PASSIVE_STATUS_CHANGED == code) {
                int state = 0;
                pAny->getIntValue("exCode", state);
                if (STATE::NOT_CONNECTED == state) {
                    m_pMyStatusbar->setCimBtnText("Disconnected");
                    //m_labelPassiveState.setBackground(DISCONNECTED_BACKGROUND);
                    //m_labelPassiveState.setForeground(DISCONNECTED_FOREGROUND, TRUE);
                }
                else if (STATE::NOT_SELECTED == state) {
                    m_pMyStatusbar->setCimBtnText("Not Selected");
                    //m_labelPassiveState.setBackground(NOT_SELECTED_BACKGROUND);
                    //m_labelPassiveState.setForeground(NOT_SELECTED_FOREGROUND, TRUE);
                }
                else if (STATE::SELECTED == state) {
                    m_pMyStatusbar->setCimBtnText("Selected");
                    //m_labelPassiveState.setBackground(SELECTED_BACKGROUND);
                    //m_labelPassiveState.setForeground(SELECTED_FOREGROUND, TRUE);
                }
            }
            pAny->release();
        }, [&]() -> void {
            // onComplete
@@ -537,6 +563,30 @@
}
void CServoDlg::OnUpdateMenuFileExit(CCmdUI* pCmdUI)
{
    pCmdUI->Enable(TRUE);
}
void CServoDlg::OnMenuProjectVarialbleList()
{
    CHMPropertyDlg dlg(_T("Variable | Rreport | Collection Event"), 658, 788);
    CPageCollectionEvent* pPage1 = new CPageCollectionEvent();
    pPage1->Create(IDD_PAGE_COLLECTION_EVENT);
    dlg.addPage(pPage1, "Event");
    CPageReport* pPage2 = new CPageReport();
    pPage2->Create(IDD_PAGE_REPORT);
    dlg.addPage(pPage2, "Report");
    CPageVarialbles* pPage3 = new CPageVarialbles();
    pPage3->Create(IDD_PAGE_VARIABLE);
    dlg.addPage(pPage3, "Variable");
    dlg.DoModal();
}
void CServoDlg::OnUpdateMenuProjectVarialbleList(CCmdUI* pCmdUI)
{
    pCmdUI->Enable(TRUE);
}
@@ -989,6 +1039,9 @@
        m_pRobotTaskDlg->MoveWindow(x, rcBar.top - h, w, h);
        m_pRobotTaskDlg->ShowWindow(SW_SHOW);
    }
    else if (id == IDC_BUTTON_CIM) {
        AfxMessageBox("IDC_BUTTON_CIM");
    }
    return 0;
}
SourceCode/Bond/Servo/ServoDlg.h
@@ -90,6 +90,8 @@
    afx_msg void OnUpdateMenuFileSecsTest(CCmdUI* pCmdUI);
    afx_msg void OnMenuFileExit();
    afx_msg void OnUpdateMenuFileExit(CCmdUI* pCmdUI);
    afx_msg void OnMenuProjectVarialbleList();
    afx_msg void OnUpdateMenuProjectVarialbleList(CCmdUI* pCmdUI);
    afx_msg void OnMenuTestMessageSet();
    afx_msg void OnUpdateMenuTestMessageSet(CCmdUI* pCmdUI);
    afx_msg void OnMenuTestMessageClear();
SourceCode/Bond/Servo/resource.h
Binary files differ
SourceCode/Bond/x64/Debug/CollectionEventList.txt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,39 @@
300,AccessMode_To_Manual,,(300)
301,AccessMode_To_Auto,,(301)
600,ControlStateChanged,,(600)
700,ProcessStateChanged,,(700)
10000,RecipeChanged,,(10000)
10030,CarrierArrived,,(10300)
10031,CarrierRemoved,,(10300)
10040,ReadyToLoad,,(10300)
10041,ReadyToUnLoad,,(10300)
10051,CarrierIDWaitingForHost,,(10051)
10052,CarrierIDVerificationOK,,(10052)
10053,CarrierIDVerificationNG,,(10052)
10061,SlotMapWaitingForHost,,(10061)
10062,SlotMapVerificationOK,,(10062)
10063,SlotMapVerificationNG,,(10062)
10071,GlassIDReadWaitingForHost,,(10071)
10072,GlassIDReadVerificationOK,,(10072)
10073,GlassIDReadVerificationNG,,(10072)
10080,CarrierStart,,(10080)
10081,CarrierCompleted,,(10080)
10082,CarrierStopped,,(10080)
20000,GlassSlotStart,,(20000)
20001,GlassSlotCompleted,,(20000)
30000,PrJobPooled,,(30000)
30001,PrJobAbort,,(30000)
30010,PrJobProcessing,,(30000)
30011,PrJobCompleted,,(30000)
30013,PrJobPaused,,(30000)
30014,PrJobResume,,(30000)
30020,PrJobDeleted,,(30000)
31000,CJobQueued,,(31000)
31001,CJobAbort,,(31000)
31010,CJobExecuting,,(31000)
31020,CJobCompleted,,(31000)
31021,CJobDeleted,,(31000)
31031,CJobPaused,,(31000)
31032,CJobResume,,(31000)
40000,E90_SPSM_NoState_To_NeedsProcessing,,(40000)
40001,E90_SPSM_InProcess_To_ProcessCompleted,,(40000)
SourceCode/Bond/x64/Debug/ReportList.txt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
RPTID,(VID1,VID2,...)
300,(1,300)
301,(1,300)
600,(500,600,601)
700,(500,700,701)
10000,(200,201)
10300,(1,10000)
10051,(1,10000,10100,10101)
10061,(1,10000,10100,10200)
10062,(1,10000,10100,10201,10202)
10071,(1,10000,10100,10203,20000)
10072,(1,10000,10100,10203,20000,20001)
10080,(1,10000,10100)
20000,(1,10000,10203)
30000,(1,30000,30001)
31000,(1,31000,31001)
40000,(1,10203,20000)
SourceCode/Bond/x64/Debug/VariableList.txt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
SVID,SV Name,SV Format,SV Remark
100,PortTransferState,U1,0=OutOfService\r\n1=TransferBlocked\r\n2=ReadyToLoad\r\n3=ReadyToUnload\r\n4=InService\r\n5=TransferReady
300,AccessMode,U1,1=Manual\r\n2=Auto
500,Clock,A50,
600,CurrentControlState,U1,0:Offline:equipment\r\n1:Offline-Attempt\r\n2:Online\r\n3:Offline:host\r\n4:Online:Local\r\n5:Online:Remote
601,PreviousControlState,U1,
700,CurrentProcessState,U1,0:DOWN\r\n1:IDLE\r\n2.SETUP\r\n3.EXCUTING\r\n4.MAINTAIN\r\n5.ALARM
701,PreviousProcessState,U1,
800,EFEMPPExecName,A20,
801,EQPPExecName,A20,
1000,CJobSpace,U1,
2000,RbRAxisTorque,I2,机器人R轴扭矩
2001,RbLAxisTorque,l2,机器人L轴扭矩
2002,RbZAxisTorque,l2,机器人Z轴扭矩
2003,RbTHAxisTorque,l2,机器人TH轴扭矩
2004,RbXAxisTorque,l2,机器人X轴扭矩
2005,AxisX111,l2,X111相机前移栽电机扭矩
2006,AxisX112,l2,X112相机后移栽电机扭矩
2007,AxisU113,l2,U113产品旋转电机扭矩
2008,AxisX114,l2,X114产品左整列电机扭矩
2009,AxisY121,l2,Y121产品右整列电机扭矩
2010,AxisY122,l2,Y122产品前整列电机扭矩
2011,AxisY123,l2,Y123产品后阵列电机扭矩
2012,MainAir,U2,总进气压力值
2013,MainVacuum,l2,总真空压力值
2014,RbMainVacuum,l2,机器人真空值
2015,LPMainVacuum,l2,LP真空值#D265
2016,LPMainAir,U2,LP压空值
2017,ALVacuum,l2,Aligner真空值
2018,FFU1RPM,U2,FFU1转速
2019,FFU2RPM,U2,FFU2转速
2020,FFU3RPM,U2,FFU3转速
2021,FFU4RPM,U2,FFU4转速
2022,ESDValue,I2,静电检测值
2023,OCREnable,U2,"OCR使能:O:开启 1:屏蔽"
2024,CCDEnable,U2,"CCD使能:O:开启 1:屏蔽"
2025,FFUParameter,U2,FFU设定值