| SourceCode/Bond/Servo/Common.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/HsmsPassive.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/HsmsPassive.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/Servo.rc | 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/Servo.vcxproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/Servo.vcxproj.filters | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/ServoDlg.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/ServoDlg.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/Servo/resource.h | 补丁 | 查看 | 原始文档 | blame | 历史 |
SourceCode/Bond/Servo/Common.h
@@ -6,6 +6,7 @@ #define RX_CODE_LOG 1000 #define RX_CODE_PASSIVE_STATUS_CHANGED 1001 #define RX_CODE_MES_MESSAGE 1002 #define RX_HSMS_TERMINAL_TEXT 1003 /* Channel Name */ SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -191,6 +191,9 @@ else if (nStream == 5 && pHeader->function == 3) { replyEanbleDisableAlarmReport(pMessage); } else if (nStream == 10 && pHeader->function == 3) { replyTerminalDisplay(pMessage); } }; PassiveListener listener; @@ -292,6 +295,19 @@ return 0; } // 通用的reply ack函数 void CHsmsPassive::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(ack, pszAckName); m_pPassive->sendMessage(pMessage); LOGI("<HSMS>[SECS Msg SEND]S%dF%d (SysByte=%u)", s, f, systemBytes); HSMS_Destroy1Message(pMessage); } // S1F1 int CHsmsPassive::requestAreYouThere() { @@ -387,17 +403,7 @@ SetLocalTime(&time); } IMessage* pMessage = NULL; HSMS_Create1Message(pMessage, m_nSessionId, 2, 32, pRecv->getHeader()->systemBytes); ASSERT(pMessage); ISECS2Item* pItem = pMessage->getBody(); pItem->setBinary(BYTE(0), "TIACK"); m_pPassive->sendMessage(pMessage); LOGI("<HSMS>[SECS Msg SEND]S2F32 (SysByte=%u)", pRecv->getHeader()->systemBytes); HSMS_Destroy1Message(pMessage); replyAck(2, 32, pRecv->getHeader()->systemBytes, BYTE(0), "TIACK"); return 0; } @@ -437,18 +443,7 @@ MYREPLY: int s = 2; int f = 38; IMessage* pMessage = NULL; HSMS_Create1Message(pMessage, m_nSessionId, s, f, pRecv->getHeader()->systemBytes); ASSERT(pMessage); ISECS2Item* pItem = pMessage->getBody(); pItem->setBinary(BYTE(0), "ERACK"); m_pPassive->sendMessage(pMessage); LOGI("<HSMS>[SECS Msg SEND]S%dF%d (SysByte=%u)", s, f, pRecv->getHeader()->systemBytes); HSMS_Destroy1Message(pMessage); replyAck(2, 38, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK"); return 0; } @@ -477,18 +472,37 @@ MYREPLY: int s = 5; int f = 4; IMessage* pMessage = NULL; HSMS_Create1Message(pMessage, m_nSessionId, s, f, pRecv->getHeader()->systemBytes); ASSERT(pMessage); ISECS2Item* pItem = pMessage->getBody(); pItem->setBinary(BYTE(0), "ACKC5"); m_pPassive->sendMessage(pMessage); LOGI("<HSMS>[SECS Msg SEND]S%dF%d (SysByte=%u)", s, f, pRecv->getHeader()->systemBytes); HSMS_Destroy1Message(pMessage); replyAck(5, 4, pRecv->getHeader()->systemBytes, BYTE(0), "ACKC5"); return 0; } // S10F3 int CHsmsPassive::replyTerminalDisplay(IMessage* pRecv) { if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) { return ER_NOTSELECT; } ISECS2Item* pBody = pRecv->getBody(); if (pBody == nullptr || pBody->getType() != SITYPE::A) ER_PARAM_ERROR; BOOL bCheckData = FALSE; BYTE tid; char* pszText = nullptr;; { ISECS2Item* pItem = pRecv->getBody(); if (pItem->getSubItemSize() < 2) goto MYREPLY; if (!pItem->getSubItemBinary(0, tid)) goto MYREPLY; if (!pItem->getSubItemString(1, pszText)) goto MYREPLY; bCheckData = TRUE; LOGI("TerminalDisplay tid:%d, pszText:%s", tid, pszText); m_pModel->notifyText(RX_HSMS_TERMINAL_TEXT, pszText); } MYREPLY: replyAck(10, 4, pRecv->getHeader()->systemBytes, BYTE(0), "ACKC10"); return 0; } SourceCode/Bond/Servo/HsmsPassive.h
@@ -35,12 +35,15 @@ int requestAlarmReport(int ALCD, int ALID, const char* ALTX); private: void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName); /* reply开头的函数为回复函数 */ int replyAreYouThere(unsigned int systemBytes); int replyEstablishCommunications(unsigned int systemBytes); int replyDatetime(IMessage* pRecv); int replyEanbleDisableEventReport(IMessage* pRecv); int replyEanbleDisableAlarmReport(IMessage* pRecv); int replyTerminalDisplay(IMessage* pRecv); private: inline void Lock() { EnterCriticalSection(&m_criticalSection); } SourceCode/Bond/Servo/Servo.rcBinary files differ
SourceCode/Bond/Servo/Servo.vcxproj
@@ -21,7 +21,7 @@ <PropertyGroup Label="Globals"> <ProjectGuid>{66ADACE5-3166-4D1F-B30B-DE5E01FB01A2}</ProjectGuid> <RootNamespace>Servo</RootNamespace> <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion> <Keyword>MFCProj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> @@ -43,7 +43,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <PlatformToolset>v140</PlatformToolset> <PlatformToolset>v142</PlatformToolset> <CharacterSet>MultiByte</CharacterSet> <UseOfMfc>Dynamic</UseOfMfc> </PropertyGroup> @@ -207,6 +207,7 @@ <ClInclude Include="ServoGraph.h" /> <ClInclude Include="stdafx.h" /> <ClInclude Include="targetver.h" /> <ClInclude Include="TerminalDisplayDlg.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="BlButton.cpp" /> @@ -228,11 +229,13 @@ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> </ClCompile> <ClCompile Include="TerminalDisplayDlg.cpp" /> </ItemGroup> <ItemGroup> <ResourceCompile Include="Servo.rc" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> <None Include="res\Servo.rc2" /> </ItemGroup> <ItemGroup> @@ -243,10 +246,19 @@ </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> <Import Project="..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" /> <Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" /> </ImportGroup> <ProjectExtensions> <VisualStudio> <UserProperties RESOURCE_FILE="Servo.rc" /> </VisualStudio> </ProjectExtensions> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets'))" /> <Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" /> </Target> </Project> SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -69,6 +69,9 @@ <ClInclude Include="SecsTestDlg.h"> <Filter>头文件</Filter> </ClInclude> <ClInclude Include="TerminalDisplayDlg.h"> <Filter>头文件</Filter> </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="Servo.cpp"> @@ -113,6 +116,9 @@ <ClCompile Include="SecsTestDlg.cpp"> <Filter>源文件</Filter> </ClCompile> <ClCompile Include="TerminalDisplayDlg.cpp"> <Filter>源文件</Filter> </ClCompile> </ItemGroup> <ItemGroup> <ResourceCompile Include="Servo.rc"> @@ -123,6 +129,7 @@ <None Include="res\Servo.rc2"> <Filter>资源文件</Filter> </None> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <Image Include="res\Servo.ico"> SourceCode/Bond/Servo/ServoDlg.cpp
@@ -31,6 +31,10 @@ #define INDICATE_MEASUREMENT 13 /* 创建终端的定时器 */ #define TIMER_ID_CREATE_TERMINAL 1 // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialogEx @@ -76,6 +80,8 @@ m_hbrBkgnd = nullptr; m_bShowLogWnd = FALSE; m_pLogDlg = nullptr; m_pTerminalDisplayDlg = nullptr; m_pObserver = nullptr; } void CServoDlg::DoDataExchange(CDataExchange* pDX) @@ -108,10 +114,41 @@ ON_UPDATE_COMMAND_UI(ID_MENU_WND_LOG, &CServoDlg::OnUpdateMenuWndLog) ON_COMMAND(ID_MENU_HELP_ABOUT, &CServoDlg::OnMenuHelpAbout) ON_WM_INITMENUPOPUP() ON_WM_TIMER() END_MESSAGE_MAP() // CServoDlg 消息处理程序 void CServoDlg::InitRxWindows() { /* 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_HSMS_TERMINAL_TEXT == code) { const char* pszText; if (pAny->getStringValue("text", pszText)) { ShowTerminalText(pszText); } } pAny->release(); }, [&]() -> void { // onComplete }, [&](IThrowable* pThrowable) -> void { // onErrorm pThrowable->printf(); }); theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread()) ->subscribe(m_pObserver); } } BOOL CServoDlg::OnInitDialog() { @@ -242,6 +279,8 @@ theApp.m_model.init(); SetTimer(TIMER_ID_CREATE_TERMINAL, 3000, nullptr); InitRxWindows(); UpdateLogBtn(); Resize(); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE @@ -452,10 +491,21 @@ delete m_pLogDlg; m_pLogDlg = nullptr; } if (m_pTerminalDisplayDlg != nullptr) { m_pTerminalDisplayDlg->DestroyWindow(); delete m_pTerminalDisplayDlg; m_pTerminalDisplayDlg = nullptr; } if (m_hbrBkgnd != nullptr) { ::DeleteObject(m_hbrBkgnd); } if (m_pObserver != nullptr) { m_pObserver->unsubscribe(); m_pObserver = NULL; } } void CServoDlg::OnBnClickedButtonLog() @@ -544,3 +594,24 @@ CDialogEx::OnMove(x, y); } void CServoDlg::ShowTerminalText(const char* pszText, unsigned int duration/* = -1*/) { ASSERT(m_pTerminalDisplayDlg); m_pTerminalDisplayDlg->ShowText(pszText, duration); } void CServoDlg::OnTimer(UINT_PTR nIDEvent) { if (TIMER_ID_CREATE_TERMINAL == nIDEvent) { // 预先创建终端窗口 KillTimer(TIMER_ID_CREATE_TERMINAL); char szBuffer[MAX_PATH]; sprintf_s(szBuffer, MAX_PATH, "%s\\RES\\TeminalMsg.html", (LPTSTR)(LPCTSTR)theApp.m_strAppDir); m_pTerminalDisplayDlg = new CTerminalDisplayDlg(); m_pTerminalDisplayDlg->SetTemplateHtml(szBuffer); m_pTerminalDisplayDlg->Create(IDD_DIALOG_TERMINAL_DISPLAY, this); } CDialogEx::OnTimer(nIDEvent); } SourceCode/Bond/Servo/ServoDlg.h
@@ -6,6 +6,7 @@ #include "ServoGraph.h" #include "BlButton.h" #include "LogDlg.h" #include "TerminalDisplayDlg.h" // CServoDlg 对话框 @@ -16,9 +17,20 @@ CServoDlg(CWnd* pParent = NULL); // 标准构造函数 public: void ShowTerminalText(const char* pszText, unsigned int duration = -1); private: void InitRxWindows(); void Resize(); void UpdateLogBtn(); private: IObserver* m_pObserver; BOOL m_bShowLogWnd; CLogDlg* m_pLogDlg; CTerminalDisplayDlg* m_pTerminalDisplayDlg; // 对话框数据 @@ -29,10 +41,6 @@ protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 private: BOOL m_bShowLogWnd; CLogDlg* m_pLogDlg; // 实现 protected: @@ -70,4 +78,5 @@ afx_msg void OnMenuFileExit(); afx_msg void OnUpdateMenuFileExit(CCmdUI* pCmdUI); afx_msg void OnMenuHelpAbout(); afx_msg void OnTimer(UINT_PTR nIDEvent); }; SourceCode/Bond/Servo/resource.hBinary files differ