| | |
| | | void CAlarmMonitor::addAlarmToHistoryRecord(CAlarm* pAlarm) |
| | | { |
| | | // å å
¥æ°æ®åº |
| | | /* |
| | | AlarmManager::getInstance().addAlarm( |
| | | std::to_string(pAlarm->getId()).c_str(), |
| | | getAlarmText(pAlarm->getId()), |
| | | CToolUnits::timeToString2(pAlarm->getOnTime()).c_str(), |
| | | CToolUnits::timeToString2(pAlarm->getOffTime()).c_str()); |
| | | */ |
| | | } |
| | | |
| | | BOOL CAlarmMonitor::addAlarming(CAlarm* pAlarm) |
| | |
| | | <Optimization>Disabled</Optimization> |
| | | <PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
| | | <SDLCheck>true</SDLCheck> |
| | | <AdditionalIncludeDirectories>.;.\DBManager;..\DatabaseSDK\include</AdditionalIncludeDirectories> |
| | | <AdditionalIncludeDirectories>.;.\DBManager;.\FileManager;..\DatabaseSDK\include;..\BLControlsSDK\include;..\BLControlsSDK\GridControl</AdditionalIncludeDirectories> |
| | | </ClCompile> |
| | | <Link> |
| | | <SubSystem>Windows</SubSystem> |
| | |
| | | <IntrinsicFunctions>true</IntrinsicFunctions> |
| | | <PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
| | | <SDLCheck>true</SDLCheck> |
| | | <AdditionalIncludeDirectories>.;.\DBManager;..\DatabaseSDK\include</AdditionalIncludeDirectories> |
| | | <AdditionalIncludeDirectories>.;.\DBManager;.\FileManager;..\DatabaseSDK\include;..\BLControlsSDK\include;..\BLControlsSDK\GridControl</AdditionalIncludeDirectories> |
| | | </ClCompile> |
| | | <Link> |
| | | <SubSystem>Windows</SubSystem> |
| | |
| | | <ClInclude Include="AlarmMonitor.h" /> |
| | | <ClInclude Include="AlarmPopupDlg.h" /> |
| | | <ClInclude Include="ApredTreeCtrl.h" /> |
| | | <ClInclude Include="AxisDetailSettingsDlg.h" /> |
| | | <ClInclude Include="AxisSettingsDlg.h" /> |
| | | <ClInclude Include="BlButton.h" /> |
| | | <ClInclude Include="BoounionPLC.h" /> |
| | | <ClInclude Include="BoounionPLCDlg.h" /> |
| | | <ClInclude Include="CBaseDlg.h" /> |
| | | <ClInclude Include="CBaseView.h" /> |
| | | <ClInclude Include="CMainContainer.h" /> |
| | | <ClInclude Include="Common.h" /> |
| | |
| | | <ClInclude Include="Context.h" /> |
| | | <ClInclude Include="CPageLogcat.h" /> |
| | | <ClInclude Include="DBManager\AlarmManager.h" /> |
| | | <ClInclude Include="DBManager\AxisManager.h" /> |
| | | <ClInclude Include="DBManager\SystemLogManager.h" /> |
| | | <ClInclude Include="DBManager\UserManager.h" /> |
| | | <ClInclude Include="FileManager\AxisManager.h" /> |
| | | <ClInclude Include="FileManager\IOManager.h" /> |
| | | <ClInclude Include="FileManager\pugiconfig.hpp" /> |
| | | <ClInclude Include="FileManager\pugixml.hpp" /> |
| | | <ClInclude Include="InputDialog.h" /> |
| | | <ClInclude Include="Intent.h" /> |
| | | <ClInclude Include="IOMonitoringDlg.h" /> |
| | | <ClInclude Include="Log.h" /> |
| | | <ClInclude Include="LogEdit.h" /> |
| | | <ClInclude Include="McBool.h" /> |
| | |
| | | <ClInclude Include="PagePlcList.h" /> |
| | | <ClInclude Include="PLC.h" /> |
| | | <ClInclude Include="PlcView.h" /> |
| | | <ClInclude Include="RegexEdit.h" /> |
| | | <ClInclude Include="Resource.h" /> |
| | | <ClInclude Include="stdafx.h" /> |
| | | <ClInclude Include="targetver.h" /> |
| | |
| | | <ClCompile Include="AlarmMonitor.cpp" /> |
| | | <ClCompile Include="AlarmPopupDlg.cpp" /> |
| | | <ClCompile Include="ApredTreeCtrl.cpp" /> |
| | | <ClCompile Include="AxisDetailSettingsDlg.cpp" /> |
| | | <ClCompile Include="AxisSettingsDlg.cpp" /> |
| | | <ClCompile Include="BlButton.cpp" /> |
| | | <ClCompile Include="BoounionPLC.cpp" /> |
| | | <ClCompile Include="BoounionPLCDlg.cpp" /> |
| | | <ClCompile Include="CBaseDlg.cpp" /> |
| | | <ClCompile Include="CBaseView.cpp" /> |
| | | <ClCompile Include="CMainContainer.cpp" /> |
| | | <ClCompile Include="Component.cpp" /> |
| | |
| | | <ClCompile Include="DBManager\AlarmManager.cpp"> |
| | | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader> |
| | | </ClCompile> |
| | | <ClCompile Include="DBManager\AxisManager.cpp" /> |
| | | <ClCompile Include="DBManager\SystemLogManager.cpp" /> |
| | | <ClCompile Include="DBManager\UserManager.cpp" /> |
| | | <ClCompile Include="FileManager\AxisManager.cpp" /> |
| | | <ClCompile Include="FileManager\IOManager.cpp" /> |
| | | <ClCompile Include="FileManager\pugixml.cpp"> |
| | | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader> |
| | | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader> |
| | | </ClCompile> |
| | | <ClCompile Include="InputDialog.cpp" /> |
| | | <ClCompile Include="Intent.cpp" /> |
| | | <ClCompile Include="IOMonitoringDlg.cpp" /> |
| | | <ClCompile Include="Log.cpp" /> |
| | | <ClCompile Include="LogEdit.cpp" /> |
| | | <ClCompile Include="McBool.cpp" /> |
| | |
| | | <ClCompile Include="PagePlcList.cpp" /> |
| | | <ClCompile Include="PLC.cpp" /> |
| | | <ClCompile Include="PlcView.cpp" /> |
| | | <ClCompile Include="RegexEdit.cpp" /> |
| | | <ClCompile Include="stdafx.cpp"> |
| | | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> |
| | | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> |
| | |
| | | <Filter Include="DBManager"> |
| | | <UniqueIdentifier>{c5603403-bc3a-451f-b300-c56d9fe09307}</UniqueIdentifier> |
| | | </Filter> |
| | | <Filter Include="FileManager"> |
| | | <UniqueIdentifier>{d7763e1c-46cf-48f9-b0da-001138287bcd}</UniqueIdentifier> |
| | | </Filter> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <Text Include="ReadMe.txt" /> |
| | |
| | | <ClInclude Include="DBManager\AlarmManager.h"> |
| | | <Filter>DBManager</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="DBManager\AxisManager.h"> |
| | | <Filter>DBManager</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="DBManager\SystemLogManager.h"> |
| | | <Filter>DBManager</Filter> |
| | | </ClInclude> |
| | |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="LogEdit.h"> |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="FileManager\IOManager.h"> |
| | | <Filter>FileManager</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="FileManager\pugiconfig.hpp"> |
| | | <Filter>FileManager</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="FileManager\pugixml.hpp"> |
| | | <Filter>FileManager</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="InputDialog.h"> |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="IOMonitoringDlg.h"> |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="FileManager\AxisManager.h"> |
| | | <Filter>FileManager</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="AxisDetailSettingsDlg.h"> |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="AxisSettingsDlg.h"> |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="CBaseDlg.h"> |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="RegexEdit.h"> |
| | | <Filter>头æä»¶</Filter> |
| | | </ClInclude> |
| | | </ItemGroup> |
| | |
| | | <ClCompile Include="DBManager\AlarmManager.cpp"> |
| | | <Filter>DBManager</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="DBManager\AxisManager.cpp"> |
| | | <Filter>DBManager</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="DBManager\SystemLogManager.cpp"> |
| | | <Filter>DBManager</Filter> |
| | | </ClCompile> |
| | |
| | | <ClCompile Include="LogEdit.cpp"> |
| | | <Filter>æºæä»¶</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="FileManager\IOManager.cpp"> |
| | | <Filter>FileManager</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="FileManager\pugixml.cpp"> |
| | | <Filter>FileManager</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="InputDialog.cpp"> |
| | | <Filter>æºæä»¶</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="IOMonitoringDlg.cpp"> |
| | | <Filter>æºæä»¶</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="FileManager\AxisManager.cpp"> |
| | | <Filter>FileManager</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="AxisDetailSettingsDlg.cpp"> |
| | | <Filter>æºæä»¶</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="AxisSettingsDlg.cpp"> |
| | | <Filter>æºæä»¶</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="CBaseDlg.cpp"> |
| | | <Filter>æºæä»¶</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="RegexEdit.cpp"> |
| | | <Filter>æºæä»¶</Filter> |
| | | </ClCompile> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <ResourceCompile Include="BoounionPLC.rc"> |
| | |
| | | #include "afxdialogex.h" |
| | | #include "Common.h" |
| | | #include "PlcView.h" |
| | | #include "AlarmMonitor.h" |
| | | #include "Log.h" |
| | | #include "InputDialog.h" |
| | | #include "AxisManager.h" |
| | | #include "IOManager.h" |
| | | |
| | | // æµè¯ |
| | | #include "AxisSettingsDlg.h" |
| | | #include "IOMonitoringDlg.h" |
| | | |
| | | |
| | | #ifdef _DEBUG |
| | |
| | | if (RX_CODE_SELECT_PLC == code) { |
| | | CPLC* pPlc; |
| | | if (pAny->getPtrValue("ptr", (void*&)pPlc)) { |
| | | ASSERT(m_pMainContainer != nullptr); |
| | | if (m_pActiveView == nullptr) { |
| | | m_pActiveView = (CPlcView*)CreatePlcView(pPlc); |
| | | if (pPlc != nullptr) { |
| | | ASSERT(m_pMainContainer != nullptr); |
| | | if (m_pActiveView == nullptr) { |
| | | m_pActiveView = (CPlcView*)CreatePlcView(pPlc); |
| | | } |
| | | ASSERT(m_pActiveView); |
| | | if (m_pActiveView->GetContext() != (void*)pPlc) { |
| | | m_pActiveView->SetWindowText(pPlc->getName().c_str()); |
| | | m_pActiveView->SetContext(pPlc); |
| | | m_pActiveView->SendMessage(WM_NCPAINT, 0, 0); |
| | | } |
| | | } else { |
| | | CloseView(m_pActiveView); |
| | | } |
| | | ASSERT(m_pActiveView); |
| | | if (m_pActiveView->GetContext() != (void*)pPlc) { |
| | | m_pActiveView->SetWindowText(pPlc->getName().c_str()); |
| | | m_pActiveView->SetContext(pPlc); |
| | | m_pActiveView->SendMessage(WM_NCPAINT, 0, 0); |
| | | } |
| | | |
| | | theApp.m_model.setCurrentPlc(pPlc); |
| | | } |
| | | } |
| | | else if (code == RX_CODE_ALARM_ON) { |
| | | AlarmOn(); |
| | | // CAlarmMonitor* pComponent = (CAlarmMonitor*)theApp.m_model.getBonder().GetComponent(ALARM_MONITOR); |
| | | // m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(pComponent->isAlarming()); |
| | | CPLC* pPlc; |
| | | if (pAny->getPtrValue("ptr", (void*&)pPlc) && pPlc == theApp.m_model.getCurrentPlc()) { |
| | | AlarmOn(pPlc); |
| | | CAlarmMonitor* pComponent = (CAlarmMonitor*)pPlc->getComponent(ALARM_MONITOR); |
| | | m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(pComponent->isAlarming()); |
| | | } |
| | | } |
| | | else if (code == RX_CODE_ALARM_OFF) { |
| | | AlarmOff(); |
| | | // CAlarmMonitor* pComponent = (CAlarmMonitor*)theApp.m_model.getBonder().GetComponent(ALARM_MONITOR); |
| | | // m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(pComponent->isAlarming()); |
| | | CPLC* pPlc; |
| | | if (pAny->getPtrValue("ptr", (void*&)pPlc) && pPlc == theApp.m_model.getCurrentPlc()) { |
| | | AlarmOff(pPlc); |
| | | CAlarmMonitor* pComponent = (CAlarmMonitor*)pPlc->getComponent(ALARM_MONITOR); |
| | | m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(pComponent->isAlarming()); |
| | | } |
| | | } |
| | | pAny->release(); |
| | | }, [&]() -> void { |
| | |
| | | { |
| | | int id = (int)lParam; |
| | | if (id == IDC_BUTTON_ADD) { |
| | | static int i = 0; |
| | | char szName[256]; |
| | | sprintf_s(szName, 256, "PLC%d", ++i); |
| | | theApp.m_model.addPlc(szName, "192.168.1.188", 1001); |
| | | CInputDialog inputDialog(_T("æ°å»ºè®¾å¤"), _T("请è¾å
¥è®¾å¤åç§°ï¼")); |
| | | if (inputDialog.DoModal() != IDOK) { |
| | | AfxMessageBox(_T("åæ¶éªè¯ï¼")); |
| | | return 0; |
| | | } |
| | | |
| | | CString strName; |
| | | strName = inputDialog.GetInputText(); |
| | | if (!strName.IsEmpty()) { |
| | | theApp.m_model.addPlc((LPTSTR)(LPCTSTR)strName, "192.168.1.188", 1001); |
| | | |
| | | // æ°å»ºè½´æä»¶ |
| | | AxisManager axisManager; |
| | | axisManager.SaveAxis((LPTSTR)(LPCTSTR)strName); |
| | | |
| | | // æ°å»ºIOæä»¶ |
| | | IOManager ioManager; |
| | | ioManager.SaveToFile((LPTSTR)(LPCTSTR)strName); |
| | | } |
| | | } |
| | | else if (id == IDC_BUTTON_DELETE) { |
| | | static int i = 0; |
| | | i += 1; |
| | | char szName[256]; |
| | | sprintf_s(szName, 256, "PLC%d", i); |
| | | theApp.m_model.removePlc(szName); |
| | | CPLC* pPlc = theApp.m_model.getCurrentPlc(); |
| | | if (pPlc != nullptr) { |
| | | theApp.m_model.removePlc(pPlc->getName().c_str()); |
| | | } |
| | | } |
| | | else if (id == IDC_BUTTON_SETTINGS) { |
| | | // æµè¯ IO模å |
| | | CPLC* pPLC = theApp.m_model.getCurrentPlc(); |
| | | if (pPLC != nullptr) { |
| | | //CIOMonitoringDlg dlg; |
| | | //dlg.DoModal(); |
| | | |
| | | CAxisSettingsDlg dlg; |
| | | dlg.DoModal(); |
| | | } |
| | | } |
| | | else if (id == IDC_BUTTON_OPERATOR) { |
| | | /* |
| | |
| | | m_pMainContainer->Resize(); |
| | | } |
| | | |
| | | void CBoounionPLCDlg::AlarmOn() |
| | | void CBoounionPLCDlg::AlarmOn(CPLC* pPlc) |
| | | { |
| | | if (m_pAlarmWnd == nullptr) { |
| | | m_pAlarmWnd = new CAlarmPopupDlg(); |
| | | //m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)")); |
| | | m_pAlarmWnd->SetPLC(pPlc); |
| | | m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this); |
| | | m_pAlarmWnd->CenterWindow(); |
| | | } |
| | | m_pAlarmWnd->AlarmOn(); |
| | | } |
| | | |
| | | void CBoounionPLCDlg::AlarmOff() |
| | | void CBoounionPLCDlg::AlarmOff(CPLC* pPlc) |
| | | { |
| | | if (m_pAlarmWnd == nullptr) { |
| | | m_pAlarmWnd = new CAlarmPopupDlg(); |
| | | //m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)")); |
| | | m_pAlarmWnd->SetPLC(pPlc); |
| | | m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this); |
| | | m_pAlarmWnd->CenterWindow(); |
| | | } |
| | |
| | | void Resize(); |
| | | CBaseView* CreatePlcView(CPLC* pPlc); |
| | | void CloseView(CBaseView* pView); |
| | | void AlarmOn(); |
| | | void AlarmOff(); |
| | | void AlarmOn(CPLC* pPlc); |
| | | void AlarmOff(CPLC* pPlc); |
| | | |
| | | private: |
| | | COLORREF m_crBkgnd; |
| | |
| | | m_bIncludeRegex = pCheckBox->GetCheck(); |
| | | theApp.m_model.m_configuration.setLogcatIncludeRegex(m_bIncludeRegex); |
| | | } |
| | | |
| | | |
| | | BOOL CPageLogcat::PreTranslateMessage(MSG* pMsg) |
| | | { |
| | | if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE) { |
| | | return TRUE; |
| | | } |
| | | |
| | | return CDialogEx::PreTranslateMessage(pMsg); |
| | | } |
| | |
| | | afx_msg void OnButtonIncludeMenuClicked(NMHDR* pNMHDR, LRESULT* pResult); |
| | | afx_msg void OnEnChangeEditInclude(); |
| | | afx_msg void OnBnClickedCheckRegex(); |
| | | virtual BOOL PreTranslateMessage(MSG* pMsg); |
| | | }; |
| | |
| | | #define PLC_VIEW_BACKGROUND RGB(252, 252, 255) |
| | | #define LOGCAT_BACKGROUND_COLOR RGB(252, 252, 255) |
| | | |
| | | /* PLC页é¢é¢è²å®ä¹ */ |
| | | |
| | | /* PLCVIEWæé® */ |
| | | #define BTN_PLCVIEW_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_PLCVIEW_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_PLCVIEW_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_PLCVIEW_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_PLCVIEW_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_PLCVIEW_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_PLCVIEW_OFF_BKGND_NORMAL RGB(255, 127, 39) |
| | | #define BTN_PLCVIEW_OFF_BKGND_HOVER RGB(255, 157, 59) |
| | | #define BTN_PLCVIEW_OFF_BKGND_PRESS RGB(255, 100, 29) |
| | |
| | | #define BTN_PLCVIEW_ON_BKGND_HOVER RGB(150, 250, 150) |
| | | #define BTN_PLCVIEW_ON_BKGND_PRESS RGB(50, 150, 50) |
| | | |
| | | /* 轴设å®é¡µé¢é¢è²å®ä¹ */ |
| | | |
| | | /* 5个æé®é¡µ, æé®èæ¯è²ï¼æ£å¸¸ç¶æ*/ |
| | | #define BTN_PAGE_FACE_NORMAL_COLOR RGB(0, 168, 0) |
| | | #define BTN_PAGE_FACE_SELECT_COLOR RGB(0, 232, 0) |
| | | #define BTN_PAGE_TEXT_NORMAL_COLOR RGB(22, 22, 22) |
| | | #define BTN_PAGE_TEXT_SELECT_COLOR RGB(22, 22, 22) |
| | | |
| | | /* JOG+, JOG-*/ |
| | | #define BTN_JOG_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_JOG_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_JOG_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_JOG_BKGND_NORMAL RGB(0, 232, 0) |
| | | #define BTN_JOG_BKGND_HOVER RGB(0, 222, 0) |
| | | #define BTN_JOG_BKGND_PRESS RGB(0, 168, 0) |
| | | |
| | | /* Sevæé® */ |
| | | #define BTN_SEV_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_SEV_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_SEV_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_SEV_BKGND_NORMAL RGB(0, 232, 0) |
| | | #define BTN_SEV_BKGND_HOVER RGB(0, 222, 0) |
| | | #define BTN_SEV_BKGND_PRESS RGB(222, 0, 0) |
| | | |
| | | /* Stopæé® */ |
| | | #define BTN_STOP_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_STOP_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_STOP_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_STOP_BKGND_NORMAL RGB(0, 168, 0) |
| | | #define BTN_STOP_BKGND_HOVER RGB(0, 138, 0) |
| | | #define BTN_STOP_BKGND_PRESS RGB(222, 0, 0) |
| | | |
| | | /* OPR æé® */ |
| | | #define BTN_OPR_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_OPR_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_OPR_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_OPR_BKGND_NORMAL RGB(222, 222, 222) |
| | | #define BTN_OPR_BKGND_HOVER RGB(208, 208, 222) |
| | | #define BTN_OPR_BKGND_PRESS RGB(0, 232, 0) |
| | | |
| | | /* å®ä½æé® */ |
| | | #define BTN_POINT_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_POINT_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_POINT_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_POINT_BKGND_NORMAL RGB(222, 222, 222) |
| | | #define BTN_POINT_BKGND_HOVER RGB(208, 208, 222) |
| | | #define BTN_POINT_BKGND_PRESS RGB(0, 232, 0) |
| | | |
| | | /* æ¥è¦é¡µé¢é¢è²å®ä¹ */ |
| | | |
| | | /* è§£é¤è¦å æé® */ |
| | | #define BTN_ALARM_OFF_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_ALARM_OFF_FRAME_HOVER RGB(88, 88, 88) |
| | |
| | | CConfiguration::CConfiguration(const char* pszFilepath) |
| | | { |
| | | m_strFilepath = pszFilepath; |
| | | loadPLCListFromFile(); |
| | | } |
| | | |
| | | CConfiguration::~CConfiguration() |
| | |
| | | void CConfiguration::setFilepath(const char* pszFilepath) |
| | | { |
| | | m_strFilepath = pszFilepath; |
| | | loadPLCListFromFile(); |
| | | } |
| | | |
| | | void CConfiguration::getUnitId(CString& strUnitId) |
| | |
| | | std::to_string(second).c_str(), m_strFilepath); |
| | | } |
| | | |
| | | // ================================== PLC é
ç½®æä½ ================================== |
| | | // æ·»å PLC |
| | | bool CConfiguration::addPLC(const CString& strName, const CString& strIp, UINT nPort) |
| | | { |
| | | // æ£æ¥æ¯å¦éå¤ |
| | | auto it = std::find_if(m_plcList.begin(), m_plcList.end(), |
| | | [&strName](const PlcInfo& plc) { return plc.strName == strName; }); |
| | | |
| | | if (it != m_plcList.end()) { |
| | | return false; |
| | | } |
| | | |
| | | // æ·»å PLC |
| | | PlcInfo plc; |
| | | plc.strName = strName; |
| | | plc.strIp = strIp; |
| | | plc.nPort = nPort; |
| | | |
| | | m_plcList.push_back(plc); |
| | | savePLCListToFile(); |
| | | return true; |
| | | } |
| | | |
| | | // å é¤ PLC |
| | | bool CConfiguration::removePLC(const CString& strName) |
| | | { |
| | | auto it = std::find_if(m_plcList.begin(), m_plcList.end(), |
| | | [&strName](const PlcInfo& plc) { return plc.strName == strName; }); |
| | | |
| | | if (it != m_plcList.end()) { |
| | | m_plcList.erase(it); |
| | | savePLCListToFile(); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // æ´æ° PLC |
| | | bool CConfiguration::updatePLC(const CString& strOldName, const CString& strNewName, const CString& strNewIp, UINT nNewPort) |
| | | { |
| | | auto it = std::find_if(m_plcList.begin(), m_plcList.end(), |
| | | [&strOldName](const PlcInfo& plc) { return plc.strName == strOldName; }); |
| | | |
| | | if (it != m_plcList.end()) { |
| | | it->strName = strNewName; |
| | | it->strIp = strNewIp; |
| | | it->nPort = nNewPort; |
| | | savePLCListToFile(); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // æ ¹æ®åç§°è·å PLC ä¿¡æ¯ |
| | | bool CConfiguration::getPLCByName(const CString& strName, CString& strIp, UINT& nPort) |
| | | { |
| | | auto it = std::find_if(m_plcList.begin(), m_plcList.end(), |
| | | [&strName](const PlcInfo& plc) { return plc.strName == strName; }); |
| | | |
| | | if (it != m_plcList.end()) { |
| | | strIp = it->strIp; |
| | | nPort = it->nPort; |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // è·å PLC åè¡¨çæ°é |
| | | int CConfiguration::getPLCListCount() |
| | | { |
| | | return (int)m_plcList.size(); |
| | | } |
| | | |
| | | // è·åææç PLC ä¿¡æ¯ |
| | | void CConfiguration::getAllPLCInfo(std::vector<PlcInfo>& plcList) |
| | | { |
| | | plcList.resize(m_plcList.size()); |
| | | plcList.assign(m_plcList.begin(), m_plcList.end()); |
| | | } |
| | | |
| | | // 仿件å è½½ PLC å表 |
| | | void CConfiguration::loadPLCListFromFile() |
| | | { |
| | | m_plcList.clear(); |
| | | |
| | | // 读å PLC æ°é |
| | | int nPLCCount = GetPrivateProfileInt("PLCs", "PLCCount", 0, m_strFilepath); |
| | | |
| | | char szSection[256], szTemp[256]; |
| | | for (int i = 0; i < nPLCCount; i++) { |
| | | sprintf_s(szSection, 256, "PLC%d", i + 1); |
| | | GetPrivateProfileString("PLCs", szSection, _T(""), szTemp, 256, m_strFilepath); |
| | | if (szTemp[0] != '\0') { |
| | | CString strInfo(szTemp); |
| | | // æ ¼å¼æ¯ Name,IP,Port |
| | | int nPos1 = strInfo.Find(_T(',')); |
| | | int nPos2 = strInfo.Find(_T(','), nPos1 + 1); |
| | | |
| | | if (nPos1 != -1 && nPos2 != -1) { |
| | | PlcInfo plcInfo; |
| | | plcInfo.strName = strInfo.Left(nPos1); |
| | | plcInfo.strIp = strInfo.Mid(nPos1 + 1, nPos2 - nPos1 - 1); |
| | | plcInfo.nPort = _ttoi(strInfo.Mid(nPos2 + 1)); |
| | | |
| | | m_plcList.push_back(plcInfo); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // ä¿å PLC åè¡¨å°æä»¶ |
| | | void CConfiguration::savePLCListToFile() |
| | | { |
| | | // æ¸
空æä»¶ä¸åæ¥ç PLC é
ç½®æ°æ® |
| | | WritePrivateProfileString("PLCs", NULL, NULL, m_strFilepath); |
| | | |
| | | // ä¿å PLC æ°é |
| | | int nPLCCount = (int)m_plcList.size(); |
| | | WritePrivateProfileString("PLCs", "PLCCount", std::to_string(nPLCCount).c_str(), m_strFilepath); |
| | | |
| | | // éæ°åå
¥æ°æ® |
| | | for (int i = 0; i < nPLCCount; i++) { |
| | | char szSection[256]; |
| | | sprintf_s(szSection, 256, "PLC%d", i + 1); |
| | | CString strInfo; |
| | | strInfo.Format(_T("%s,%s,%d"), m_plcList[i].strName, m_plcList[i].strIp, m_plcList[i].nPort); |
| | | WritePrivateProfileString("PLCs", szSection, strInfo, m_strFilepath); |
| | | } |
| | | } |
| | | |
| | |
| | | #pragma once |
| | | #include <vector> |
| | | #include <string> |
| | | #include <algorithm> |
| | | |
| | | // PLCä¿¡æ¯ |
| | | struct PlcInfo { |
| | | CString strName; // PLC åç§° |
| | | CString strIp; // IP å°å |
| | | UINT nPort; // 端å£å· |
| | | }; |
| | | |
| | | class CConfiguration |
| | | { |
| | |
| | | void setP2RemoteEqReconnectInterval(int second); |
| | | int getP2RemoteEqReconnectInterval(); |
| | | |
| | | public: |
| | | // PLCé
ç½®æä½ |
| | | bool addPLC(const CString& strName, const CString& strIp, UINT nPort); |
| | | bool removePLC(const CString& strName); |
| | | bool updatePLC(const CString& strOldName, const CString& strNewName, const CString& strNewIp, UINT nNewPort); |
| | | bool getPLCByName(const CString& strName, CString& strIp, UINT& nPort); |
| | | void getAllPLCInfo(std::vector<PlcInfo>& plcList); |
| | | int getPLCListCount(); |
| | | |
| | | private: |
| | | void loadPLCListFromFile(); |
| | | void savePLCListToFile(); |
| | | |
| | | private: |
| | | CString m_strFilepath; |
| | | std::vector<PlcInfo> m_plcList; |
| | | }; |
| | | |
| | |
| | | #include "Model.h" |
| | | #include "Log.h" |
| | | #include "Common.h" |
| | | #include "ToolUnits.h" |
| | | |
| | | // 常é |
| | | |
| | | |
| | | CModel* g_pModel = NULL; |
| | |
| | | g_pModel = this; |
| | | |
| | | |
| | | // 模æä»ææ¡£ææ°æ®åºå è½½PLCå表 |
| | | addPlc("Test1", "127.0.0.1", 1001); |
| | | addPlc("Test2", "127.0.0.1", 1002); |
| | | |
| | | // è·åææPLCä¿¡æ¯ |
| | | std::vector<PlcInfo> plcList; |
| | | m_configuration.getAllPLCInfo(plcList); |
| | | for (const auto& plc : plcList) { |
| | | addPlc(plc.strName, plc.strIp, plc.nPort); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 读å产è½ä¿¡æ¯ |
| | | CPLC* pPlc = getCurrentPlc(); |
| | | if (pPlc != nullptr) { |
| | | pPlc->readPLCDataRegularly(); |
| | | } |
| | | } |
| | | |
| | | std::map<std::string, CPLC*>& CModel::getPlcMap() |
| | |
| | | { |
| | | auto iter = m_mapPlc.find(pszName); |
| | | if (iter != m_mapPlc.end()) return -1; |
| | | CString strPlcDir; |
| | | strPlcDir.Format(_T("%s\\Plcs\\%s"), (LPTSTR)(LPCTSTR)m_strWorkDir, pszName); |
| | | CPLC* pPLC = new CPLC(pszName, pszIp, port); |
| | | pPLC->setWorkDir((LPTSTR)(LPCTSTR)strPlcDir); |
| | | PLCListener listener; |
| | | listener.onStateChanged = [&](void* pFrom, int state) -> void { |
| | | LOGD("PLCç¶ææ¹åï¼%d", state); |
| | | }; |
| | | listener.onMonitorData = [&](void* pFrom, int id) -> void { |
| | | LOGD("PLConMonitorDataï¼%d", id); |
| | | }; |
| | | listener.onAlarm = [&](void* pFrom, CAlarm* pAlarm, int flag) -> void { |
| | | LOGE("onAlarmï¼%d %s", pAlarm->getId(), flag != 0 ? "ON" : "Off"); |
| | | if (flag == 1) { |
| | | pAlarm->addRef(); |
| | | notifyObjAndPtr(RX_CODE_ALARM_ON, pAlarm, pFrom); |
| | | pAlarm->release(); |
| | | } |
| | | else { |
| | | pAlarm->addRef(); |
| | | notifyObjAndPtr(RX_CODE_ALARM_OFF, pAlarm, pFrom); |
| | | pAlarm->release(); |
| | | } |
| | | |
| | | }; |
| | | pPLC->setListener(listener); |
| | | pPLC->init(); |
| | | m_mapPlc[pszName] = pPLC; |
| | | |
| | | CString strDir; |
| | | strDir.Format(_T("%s\\PLCs\\%s"), (LPTSTR)(LPCTSTR)m_strWorkDir, (LPTSTR)(LPCTSTR)pszName); |
| | | CToolUnits::createDir(strDir); |
| | | m_configuration.addPLC(pszName, pszIp, port); |
| | | |
| | | notifyPtr(RX_CODE_ADD_PLC, pPLC); |
| | | return 0; |
| | |
| | | auto iter = m_mapPlc.find(pszName); |
| | | if (iter == m_mapPlc.end()) return -1; |
| | | |
| | | CString strDir; |
| | | strDir.Format(_T("%s\\PLCs\\%s"), (LPTSTR)(LPCTSTR)m_strWorkDir, (LPTSTR)(LPCTSTR)pszName); |
| | | CToolUnits::deleteDir(strDir); |
| | | m_configuration.removePLC(pszName); |
| | | |
| | | notifyPtr(RX_CODE_REMOVE_PLC, iter->second); |
| | | delete iter->second; |
| | | m_mapPlc.erase(iter); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | void CModel::setCurrentPlc(CPLC* pPlc) |
| | | { |
| | | if (pPlc != nullptr) { |
| | | m_strCurrPlc = pPlc->getName(); |
| | | } else { |
| | | m_strCurrPlc = ""; |
| | | } |
| | | } |
| | | |
| | | CPLC* CModel::getCurrentPlc() |
| | | { |
| | | auto item = m_mapPlc.find(m_strCurrPlc); |
| | | if (item != m_mapPlc.end()) { |
| | | return item->second; |
| | | } |
| | | |
| | | return nullptr; |
| | | } |
| | |
| | | int addPlc(const char* pszName, const char* pszIp, const unsigned int port); |
| | | int removePlc(const char* pszName); |
| | | |
| | | // 设置/è·åå½åPLC |
| | | void setCurrentPlc(CPLC* pPlc); |
| | | CPLC* getCurrentPlc(); |
| | | |
| | | public: |
| | | int notify(int code); |
| | | int notifyPtr(int code, void* ptr = NULL); |
| | |
| | | public: |
| | | CConfiguration m_configuration; |
| | | |
| | | |
| | | private: |
| | | IObservable* m_pObservable; |
| | | IObservableEmitter* m_pObservableEmitter; |
| | | CString m_strWorkDir; |
| | | std::map<std::string, CPLC*> m_mapPlc; |
| | | std::string m_strCurrPlc; |
| | | |
| | | private: |
| | | int m_nTimerID; |
| | |
| | | #include "stdafx.h" |
| | | #include "PLC.h" |
| | | #include "Log.h" |
| | | #include "ToolUnits.h" |
| | | |
| | | |
| | | #define ADDR_NIGHT_SHIFT_CAPACTITY 1627 |
| | | |
| | | void CALLBACK TimerFileProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) |
| | | { |
| | |
| | | m_nTimerId = 0; |
| | | m_hTimeEvent = nullptr; |
| | | m_bMute = false; |
| | | m_pPlcData = new char[4096]; |
| | | m_nVelocityRatio = 0; |
| | | InitializeCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | | CPLC::CPLC(const char* pszName, const char* pszIp, const unsigned int port) |
| | |
| | | m_state = PLCSTATE::READY; |
| | | m_listener.onStateChanged = nullptr; |
| | | m_listener.onMonitorData = nullptr; |
| | | m_listener.onAlarm = nullptr; |
| | | m_nUnHeartBeat = 0; |
| | | m_hTimeEvent = nullptr; |
| | | m_hMcMonitorStop = nullptr; |
| | |
| | | m_mcMonitorThrdaddr = 0; |
| | | m_nTimerId = 0; |
| | | m_hTimeEvent = nullptr; |
| | | m_pPlcData = new char[4096]; |
| | | m_nVelocityRatio = 0; |
| | | m_dTactTime = 0.0; |
| | | m_nDayShiftCapacity = 0; |
| | | m_nNightShiftCapacity = 0; |
| | | for (int i = 0; i < 7; i++) { |
| | | m_bBlBtnsStates[i] = false; |
| | | } |
| | | |
| | | InitializeCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | | CPLC::~CPLC() |
| | | { |
| | | if (m_pPlcData != nullptr) { |
| | | delete[] m_pPlcData; |
| | | m_pPlcData = nullptr; |
| | | } |
| | | DeleteCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | | void CPLC::setListener(PLCListener& listener) |
| | | { |
| | | m_listener.onStateChanged = listener.onStateChanged; |
| | | m_listener.onMonitorData = listener.onMonitorData; |
| | | m_listener.onAlarm = listener.onAlarm; |
| | | } |
| | | |
| | | void CPLC::setWorkDir(const char* pszDir) |
| | |
| | | |
| | | CAlarmMonitor* CPLC::getAlarmMonitor() |
| | | { |
| | | return (CAlarmMonitor*)getComponent("PLC(1)"); |
| | | return (CAlarmMonitor*)getComponent("è¦åä¿¡æ¯"); |
| | | } |
| | | |
| | | int CPLC::addMonitor(int id, int beginAddr, int endAddr, MC::SOFT_COMPONENT softComponent, char* pszRecvBuffer) |
| | | { |
| | | // æ£æ¥æ¯å¦æéå¤ç |
| | | Lock(); |
| | | for (auto& m : m_monitors) { |
| | | if (m.id == id) { |
| | | Unlock(); |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | MONITOR m; |
| | | memset(&m, 0, sizeof(MONITOR)); |
| | | m.id = id; |
| | | m.beginAddr = beginAddr; |
| | | m.readLen = (endAddr - beginAddr + 1) * 2; |
| | | m.softComponent = softComponent; |
| | | m.szRecvBuffer = pszRecvBuffer; |
| | | m.hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL); |
| | | m_monitors.push_back(m); |
| | | |
| | | Unlock(); |
| | | return 0; |
| | | } |
| | | |
| | | void CPLC::init() |
| | |
| | | m_pChannel->setChannelListener(&m_mcChannellistener); |
| | | m_pChannel->setActionInterval(m_nActionInterval); |
| | | } |
| | | addMonitor(MONITOR_ID_ALARM, 10001, 10064, MC::SOFT_COMPONENT::M, &m_pPlcData[600]); |
| | | |
| | | |
| | | // è¦åçæ§ |
| | | CString strAlarmFile; |
| | | strAlarmFile.Format(_T("%s\\%s\\AlarmList.txt"), m_strWorkDir.c_str(), m_strName.c_str()); |
| | | strAlarmFile.Format(_T("%s\\AlarmList.txt"), m_strWorkDir.c_str()); |
| | | CAlarmMonitor* pAlarmMonitor = new CAlarmMonitor(); |
| | | pAlarmMonitor->setName("è¦åä¿¡æ¯"); |
| | | pAlarmMonitor->setDescription("è¦åä¿¡æ¯çæ§"); |
| | |
| | | WaitForSingleObject(monitor.hEvent, INFINITE); |
| | | ResetEvent(monitor.hEvent); |
| | | if (bReadOk) { |
| | | ASSERT(m_listener.onMonitorData); |
| | | onMonitorData(monitor); |
| | | } |
| | | } |
| | | |
| | | int CPLC::onMonitorData(MONITOR& monitor) |
| | | { |
| | | // 转åå°è¦å模åå¤çè§£éæ°æ® |
| | | if (monitor.id == MONITOR_ID_ALARM) { |
| | | for (auto c : m_components) { |
| | | c->onData(monitor.id, monitor.szRecvBuffer, monitor.readLen); |
| | | } |
| | | } |
| | | |
| | | if (m_listener.onMonitorData) { |
| | | m_listener.onMonitorData(this, monitor.id); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int CPLC::readWord(MC::SOFT_COMPONENT softComponent, unsigned int addr, |
| | |
| | | } |
| | | } |
| | | |
| | | void CPLC::readPLCDataRegularly() |
| | | { |
| | | if (!isConnected()) return; |
| | | |
| | | { |
| | | auto funOnReadData = [this](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == 2 && flag == 0) { |
| | | int nVelocityRatio = CToolUnits::toInt16(&pData[0]); |
| | | if (nVelocityRatio != m_nVelocityRatio) { |
| | | m_nVelocityRatio = nVelocityRatio; |
| | | //notifyInt(RX_CODE_VELOCITY_RATIO, m_nVelocityRatio); |
| | | } |
| | | } |
| | | }; |
| | | readData(MC::D, 530, 2, funOnReadData); |
| | | } |
| | | |
| | | { |
| | | auto funOnReadData = [this](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == 2 && flag == 0) { |
| | | double dTactTime = (double)CToolUnits::toInt16(&pData[0]); |
| | | if (dTactTime != m_dTactTime) { |
| | | m_dTactTime = dTactTime; |
| | | // notifyDouble(RX_CODE_TACT_TIME, m_dTactTime); |
| | | } |
| | | } |
| | | }; |
| | | readData(MC::ZR, 1500, 2, funOnReadData); |
| | | } |
| | | |
| | | { |
| | | auto funOnReadData = [this](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == (ADDR_NIGHT_SHIFT_CAPACTITY - 1612 + 1) * 2 && flag == 0) { |
| | | int nDayShiftCapacity = CToolUnits::toInt16(&pData[0]); |
| | | int nNightShiftCapacity = CToolUnits::toInt16(&pData[(ADDR_NIGHT_SHIFT_CAPACTITY - 1612) * 2]); |
| | | if (nDayShiftCapacity != m_nDayShiftCapacity) { |
| | | m_nDayShiftCapacity = nDayShiftCapacity; |
| | | // notifyInt(RX_CODE_DAY_SHIFT_CAPACTITY, nDayShiftCapacity); |
| | | } |
| | | if (nNightShiftCapacity != m_nNightShiftCapacity) { |
| | | m_nNightShiftCapacity = nNightShiftCapacity; |
| | | // notifyInt(RX_CODE_NIGHT_SHIFT_CAPACTITY, nNightShiftCapacity); |
| | | } |
| | | |
| | | } |
| | | }; |
| | | readData(MC::ZR, 1612, (ADDR_NIGHT_SHIFT_CAPACTITY - 1612 + 1) * 2, funOnReadData); |
| | | } |
| | | |
| | | { |
| | | int nStartAddress = 1000; |
| | | int nEndAddress = 1200; |
| | | int nReadSize = (nEndAddress - nStartAddress + 1) * 2; |
| | | auto funOnReadData = [this, nStartAddress, nReadSize](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void { |
| | | if (nDataSize == nReadSize && flag == 0) { |
| | | bool bRun = CToolUnits::toInt16(&pData[(1103 - nStartAddress) * 2]) != 0; // å¯å¨ |
| | | bool bAuto = CToolUnits::toInt16(&pData[(1100 - nStartAddress) * 2]) != 0; // èªå¨ |
| | | bool bPuase = CToolUnits::toInt16(&pData[(1104 - nStartAddress) * 2]) != 0; // æå |
| | | bool bManual = CToolUnits::toInt16(&pData[(1100 - nStartAddress) * 2]) != 0; // æå¨ |
| | | bool bBeep = CToolUnits::toInt16(&pData[(1003 - nStartAddress) * 2]) != 0; // éé³ |
| | | bool bResetting = CToolUnits::toInt16(&pData[(1150 - nStartAddress) * 2]) != 0; // å¤ä½ |
| | | bool bStop = CToolUnits::toInt16(&pData[(1114 - nStartAddress) * 2]) != 0; // ֹͣ |
| | | |
| | | if (m_bBlBtnsStates[0] != bRun) { |
| | | m_bBlBtnsStates[0] = bRun; |
| | | // notifyInt(RX_CODE_ACTIVATE, bRun); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[1] != bAuto) { |
| | | m_bBlBtnsStates[1] = bAuto; |
| | | // notifyInt(RX_CODE_AUTO, bAuto); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[2] != bPuase) { |
| | | m_bBlBtnsStates[2] = bPuase; |
| | | // notifyInt(RX_CODE_PUASE, bPuase); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[3] != bManual) { |
| | | m_bBlBtnsStates[3] = bManual; |
| | | // notifyInt(RX_CODE_MANUAL, bManual); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[4] != bBeep) { |
| | | m_bBlBtnsStates[4] = bBeep; |
| | | // notifyInt(RX_CODE_BEEP, bBeep); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[5] != bResetting) { |
| | | m_bBlBtnsStates[5] = bResetting; |
| | | // notifyInt(RX_CODE_RESETTING, bResetting); |
| | | } |
| | | |
| | | if (m_bBlBtnsStates[6] != bStop) { |
| | | m_bBlBtnsStates[6] = bStop; |
| | | // notifyInt(RX_CODE_STOP, bStop); |
| | | } |
| | | } |
| | | }; |
| | | readData(MC::M, nStartAddress, nReadSize, funOnReadData); |
| | | } |
| | | } |
| | | |
| | | int CPLC::getVelocityRatio() |
| | | { |
| | | return m_nVelocityRatio; |
| | | } |
| | | |
| | | double CPLC::getTackTime() |
| | | { |
| | | return m_dTactTime; |
| | | } |
| | | |
| | | int CPLC::getDayShiftCapacity() |
| | | { |
| | | return m_nDayShiftCapacity; |
| | | } |
| | | |
| | | int CPLC::getNightShiftCapacity() |
| | | { |
| | | return m_nNightShiftCapacity; |
| | | } |
| | |
| | | #pragma comment(lib,"winmm") |
| | | |
| | | |
| | | #define ALARM_MONITOR _T("è¦åä¿¡æ¯") |
| | | |
| | | typedef std::function<void(void* pFrom, int)> ONPLCSTATECHANGED; |
| | | typedef std::function<void(void* pFrom, int)> ONPLCMONITORDATA; |
| | | typedef std::function<void(void* pFrom, CAlarm*, int)> ONALARM; |
| | |
| | | ~CPLC(); |
| | | |
| | | public: |
| | | void setListener(PLCListener& listener); |
| | | void setWorkDir(const char* pszDir); |
| | | void init(); |
| | | void term(); |
| | |
| | | int writeDWord(MC::SOFT_COMPONENT softComponent, unsigned int addr, int value, ONWRITE funOnWrite); |
| | | int writeBit(MC::SOFT_COMPONENT softComponent, unsigned int addr, BOOL bValue, ONWRITE funOnWrite); |
| | | int writeData(MC::SOFT_COMPONENT softComponent, unsigned int addr, const char* pszData, unsigned int length, ONWRITE funOnWrite); |
| | | void readPLCDataRegularly(); |
| | | |
| | | public: |
| | | int getVelocityRatio(); |
| | | double getTackTime(); |
| | | int getDayShiftCapacity(); |
| | | int getNightShiftCapacity(); |
| | | |
| | | public: |
| | | HANDLE m_hTimeEvent; |
| | | |
| | | private: |
| | | inline void Lock() { EnterCriticalSection(&m_criticalSection); } |
| | | inline void Unlock() { LeaveCriticalSection(&m_criticalSection); } |
| | | void setState(PLCSTATE state); |
| | | void monitorReadData(MONITOR& monitor); |
| | | CString& dataToHexString(const char* pData, const int size, CString& strOut); |
| | | int onMonitorData(MONITOR& monitor); |
| | | |
| | | private: |
| | | std::string m_strWorkDir; |
| | |
| | | unsigned int m_nActionInterval; |
| | | unsigned int m_nUnHeartBeat; |
| | | std::vector<CComponent*> m_components; |
| | | char* m_pPlcData; |
| | | |
| | | private: |
| | | CRITICAL_SECTION m_criticalSection; |
| | | std::vector<MONITOR> m_monitors; |
| | | HANDLE m_hMcMonitorStop; |
| | | HANDLE m_hMcMonitorThreadHandle; |
| | | unsigned m_mcMonitorThrdaddr; |
| | | MMRESULT m_nTimerId; |
| | | bool m_bMute; |
| | | |
| | | private: |
| | | int m_nVelocityRatio; // éåº¦æ¯ |
| | | double m_dTactTime; // 卿æ¶é´ |
| | | int m_nDayShiftCapacity; // ç½çäº§è½ |
| | | int m_nNightShiftCapacity; // å¤çäº§è½ |
| | | bool m_bBlBtnsStates[7]; // PLC Viewæé®ç¶æ |
| | | }; |
| | | |
| | |
| | | BOOL bNoPLC = m_treeCtrl.GetChildItem(nullptr) == nullptr; |
| | | m_treeCtrl.ShowWindow(bNoPLC ? SW_HIDE : SW_SHOW); |
| | | GetDlgItem(IDC_LABEL_NO_PLC)->ShowWindow(bNoPLC ? SW_SHOW : SW_HIDE); |
| | | |
| | | // æ´æ°èç¹ |
| | | HTREEITEM hSelectedItem = m_treeCtrl.GetSelectedItem(); |
| | | CPLC* pSelectedPlc = nullptr; |
| | | if (hSelectedItem != NULL) { |
| | | pSelectedPlc = (CPLC*)m_treeCtrl.GetItemData(hSelectedItem); |
| | | } |
| | | theApp.m_model.notifyPtr(RX_CODE_SELECT_PLC, pSelectedPlc); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | HTREEITEM CPagePlcList::FindItem(CPLC* pPlc) |
| | | { |
| | | |
| | | HTREEITEM item = m_treeCtrl.GetChildItem(nullptr); |
| | | while (item != nullptr) { |
| | | if (m_treeCtrl.GetItemData(item) == (DWORD_PTR)pPlc) { |
| | | return item; |
| | | } |
| | | item = m_treeCtrl.GetNextSiblingItem(item); |
| | | |
| | | item = m_treeCtrl.GetNextItem(item, TVGN_NEXT); |
| | | } |
| | | |
| | | return nullptr; |
| | |
| | | ON_BN_CLICKED(IDC_BUTTON_SOUND_OFF, &CPlcView::OnBnClickedButtonSoundOff) |
| | | ON_BN_CLICKED(IDC_BUTTON_RESETTING, &CPlcView::OnBnClickedButtonResetting) |
| | | ON_BN_CLICKED(IDC_BUTTON_STOP, &CPlcView::OnBnClickedButtonStop) |
| | | ON_WM_TIMER() |
| | | END_MESSAGE_MAP() |
| | | |
| | | // CComponentData1Dlg æ¶æ¯å¤çç¨åº |
| | |
| | | SetDlgItemText(IDC_EDIT_DAY_SHIFT_CAPACITY, _T("0")); |
| | | SetDlgItemText(IDC_EDIT_NIGHT_SHIFT_CAPACITY, _T("0")); |
| | | |
| | | |
| | | SetTimer(1, 1000, nullptr); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // å¼å¸¸: OCX 屿§é¡µåºè¿å FALSE |
| | | } |
| | |
| | | { |
| | | // TODO: 卿¤æ·»å æ§ä»¶éç¥å¤çç¨åºä»£ç |
| | | HandleOperation(OperationType::STOP); |
| | | } |
| | | } |
| | | |
| | | void CPlcView::OnTimer(UINT_PTR nIDEvent) |
| | | { |
| | | if (1 == nIDEvent) { |
| | | ASSERT(m_pContext); |
| | | CPLC* pPlc = ((CPLC*)m_pContext); |
| | | |
| | | CString strText; |
| | | strText.Format(_T("%d %s"), pPlc->getVelocityRatio(), _T("%")); |
| | | GetDlgItem(IDC_EDIT_VELOCITY_RATIO)->SetWindowText(strText); |
| | | strText.Format(_T("%.2f"), pPlc->getTackTime() * 0.01); |
| | | GetDlgItem(IDC_EDIT_TACT_TIME)->SetWindowText(strText); |
| | | SetDlgItemInt(IDC_EDIT_DAY_SHIFT_CAPACITY, pPlc->getDayShiftCapacity()); |
| | | SetDlgItemInt(IDC_EDIT_NIGHT_SHIFT_CAPACITY, pPlc->getNightShiftCapacity()); |
| | | } |
| | | |
| | | CBaseView::OnTimer(nIDEvent); |
| | | } |
| | |
| | | afx_msg void OnBnClickedButtonSoundOff(); |
| | | afx_msg void OnBnClickedButtonResetting(); |
| | | afx_msg void OnBnClickedButtonStop(); |
| | | afx_msg void OnTimer(UINT_PTR nIDEvent); |
| | | }; |
| | | |
| | |
| | | CreateDirectory(strDir, NULL); |
| | | } |
| | | |
| | | void CToolUnits::deleteDir(const char* pszDir) |
| | | { |
| | | WIN32_FIND_DATA findFileData; |
| | | HANDLE hFind = INVALID_HANDLE_VALUE; |
| | | |
| | | // æ¼æ¥ä¸ "\\*"ï¼è¡¨ç¤ºç®å½ä¸çæææä»¶åæä»¶å¤¹ |
| | | std::string dirPath = pszDir; |
| | | dirPath.append("\\*"); |
| | | |
| | | // æå¼ç®å½ï¼æ¥æ¾ç¬¬ä¸ä¸ªæä»¶ |
| | | hFind = FindFirstFile(dirPath.c_str(), &findFileData); |
| | | |
| | | if (hFind == INVALID_HANDLE_VALUE) { |
| | | return; |
| | | } |
| | | |
| | | do { |
| | | const std::string fileName = findFileData.cFileName; |
| | | if (fileName == "." || fileName == "..") { |
| | | continue; |
| | | } |
| | | |
| | | std::string fullPath = pszDir; |
| | | fullPath.append("\\").append(fileName); |
| | | |
| | | if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { |
| | | deleteDir(fullPath.c_str()); |
| | | } |
| | | else { |
| | | DWORD fileAttributes = GetFileAttributes(fullPath.c_str()); |
| | | if (fileAttributes != INVALID_FILE_ATTRIBUTES) { |
| | | if (fileAttributes & FILE_ATTRIBUTE_READONLY) { |
| | | SetFileAttributes(fullPath.c_str(), fileAttributes & ~FILE_ATTRIBUTE_READONLY); |
| | | } |
| | | } |
| | | |
| | | if (!DeleteFile(fullPath.c_str())) { |
| | | return; |
| | | } |
| | | } |
| | | } while (FindNextFile(hFind, &findFileData) != 0); |
| | | |
| | | FindClose(hFind); |
| | | |
| | | RemoveDirectory(pszDir); |
| | | } |
| | | |
| | | CString& CToolUnits::floatToString1(float value, CString& strOut) |
| | | { |
| | | strOut.Format(_T("%.1f"), value); |
| | |
| | | static CString& floatToString3(float value, CString& strOut); |
| | | static ULONGLONG getTimestamp(); |
| | | static void createDir(const char* pszDir); |
| | | static void deleteDir(const char* pszDir); |
| | | static BOOL copyTextToClipboard(CWnd* pWnd, const CString& strText); |
| | | static std::string getCurrentExePath(); |
| | | static bool isFile(const std::string& path); |
| | |
| | | #include <afxcontrolbars.h> // åè½åºåæ§ä»¶æ¡ç MFC æ¯æ |
| | | |
| | | |
| | | // æ§ä»¶æ ·å¼ |
| | | static UINT g_nGridFixCellColor = RGB(144, 200, 246); |
| | | static UINT g_nGridFixFontColor = RGB(0, 0, 0); |
| | | static UINT g_nGridCellColor = RGB(255, 255, 224); |
| | | static UINT g_nGridCellColor_NonSelect = RGB(150, 150, 150); |
| | | static UINT g_nGridCellReadyColor = RGB(255, 255, 0); |
| | | static UINT g_nGridCellOnColor = RGB(255, 69, 0); |
| | | static UINT g_nGridCellOffColor = RGB(128, 191, 255); |
| | | static UINT g_nPropertyGridFixCellColor = RGB(150, 150, 150); |
| | | static UINT g_nPropertyGridFixFontColor = RGB(0, 0, 0); |
| | | static UINT g_nSequenceOffColor = RGB(0, 0, 0); |
| | | static UINT g_nSequenceOnColor = RGB(0, 180, 0); |
| | | static UINT g_nSequenceErrorColor = RGB(255, 0, 0); |
| | | static UINT g_nSequenceWarningColor = RGB(255, 255, 0); |
| | | static UINT g_nSequenceReadyColor = RGB(0, 0, 255); |
| | | static UINT g_nSequenceRunningColor = RGB(0, 255, 255); |
| | | static UINT g_nSequencePauseColor = RGB(255, 0, 255); |
| | | static UINT g_nSequenceStopColor = RGB(128, 128, 128); |
| | | |
| | | |
| | | #include "..\RxWindows1.0\include\RxWindowsLib.h" |
| | |
| | | #if defined(_WIN64) |
| | | #if defined(_DEBUG) |
| | | #pragma comment(lib, "..\\DatabaseSDK\\lib\\x64\\Debug\\DatabaseEx.lib") |
| | | #pragma comment(lib, "..\\BLControlsSDK\\lib\\x64\\Debug\\BLControlsD.lib") |
| | | #else |
| | | #pragma comment(lib, "..\\DatabaseSDK\\lib\\x64\\Release\\DatabaseEx.lib") |
| | | #pragma comment(lib, "..\\BLControlsSDK\\lib\\x64\\Release\\BLControls.lib") |
| | | #endif |
| | | #else |
| | | #if defined(_DEBUG) |
| | | #pragma comment(lib, "..\\DatabaseSDK\\lib\\Win32\\Debug\\DatabaseEx.lib") |
| | | #pragma comment(lib, "..\\BLControlsSDK\\lib\\Win32\\Debug\\BLControlsD.lib") |
| | | #else |
| | | #pragma comment(lib, "..\\DatabaseSDK\\lib\\Win32\\Release\\DatabaseEx.lib") |
| | | #pragma comment(lib, "..\\BLControlsSDK\\lib\\Win32\\Release\\BLControls.lib") |
| | | #endif |
| | | #endif |
| | | |