1.PLC连接状态在最左侧树控件中的小圆点展示;
2.当前PLC名称修改为CPLC指针;
| | |
| | | m_model.setWorkDir((LPTSTR)(LPCTSTR)m_strAppDir); |
| | | |
| | | |
| | | // gdi+ |
| | | Gdiplus::GdiplusStartupInput gdiplusStartupInput; |
| | | Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); |
| | | |
| | | |
| | | CString strIniFile; |
| | | strIniFile.Format(_T("%s\\BoounionPLCconfiguration.ini"), (LPTSTR)(LPCTSTR)m_strAppDir); |
| | | int plcTimeout = GetPrivateProfileInt("PLC", "Timeout", 700, strIniFile); |
| | |
| | | |
| | | int CBoounionPLCApp::ExitInstance() |
| | | { |
| | | // gdi+ |
| | | Gdiplus::GdiplusShutdown(m_gdiplusToken); |
| | | |
| | | m_model.term(); |
| | | RX_Term(); |
| | | MCL_Term(); |
| | |
| | | CString m_strAppFile; |
| | | int m_nVersionNumber; |
| | | CString m_strVersionName; |
| | | ULONG_PTR m_gdiplusToken; |
| | | |
| | | // 重写 |
| | | public: |
| | |
| | | theApp.m_model.setCurrentPlc(pPlc); |
| | | } |
| | | } |
| | | else if (RX_PLC_STATE_CHANGED == code) { |
| | | |
| | | } |
| | | else if (code == RX_CODE_ALARM_ON) { |
| | | CPLC* pPlc; |
| | | if (pAny->getPtrValue("ptr", (void*&)pPlc) && pPlc == theApp.m_model.getCurrentPlc()) { |
| | |
| | | #define RX_CODE_TACT_TIME 1014 // 节拍时间 |
| | | #define RX_CODE_DAY_SHIFT_CAPACTITY 1015 // 白班产量 |
| | | #define RX_CODE_NIGHT_SHIFT_CAPACTITY 1016 // 夜班产量 |
| | | #define RX_PLC_STATE_CHANGED 1017 /* PLC状态改变 */ |
| | | |
| | | |
| | | /* 定制颜色 */ |
| | |
| | | #define BTN_SOUND_ON_BKGND_HOVER RGB(150, 250, 150) |
| | | #define BTN_SOUND_ON_BKGND_PRESS RGB(50, 150, 50) |
| | | |
| | | /* 树控件小圆点 */ |
| | | #define TREE_BADGE_BACKGROUND RGB(34, 177, 76) |
| | | #define TREE_BADGE_FOREGROUND RGB(222, 222, 222) |
| | | #define TREE_BADGE2_BACKGROUND RGB(255, 127, 39) |
| | | #define TREE_BADGE2_FOREGROUND RGB(222, 222, 222) |
| | | |
| | | |
| | | /* 按钮id */ |
| | | #define VIEW_TOOL_BTN_CLOSE 0x1016 |
| | |
| | | m_pObservableEmitter = nullptr; |
| | | m_pObservable = nullptr; |
| | | m_nTimerID = 0; |
| | | m_pActivePlc = nullptr; |
| | | } |
| | | |
| | | |
| | |
| | | pPLC->setWorkDir((LPTSTR)(LPCTSTR)strPlcDir); |
| | | PLCListener listener; |
| | | listener.onStateChanged = [&](void* pFrom, int state) -> void { |
| | | LOGD("PLC状态改变,%d", state); |
| | | notifyPtr(RX_PLC_STATE_CHANGED, pFrom); |
| | | }; |
| | | listener.onMonitorData = [&](void* pFrom, int id) -> void { |
| | | LOGD("PLConMonitorData,%d", id); |
| | |
| | | |
| | | void CModel::setCurrentPlc(CPLC* pPlc) |
| | | { |
| | | if (pPlc != nullptr) { |
| | | m_strCurrPlc = pPlc->getName(); |
| | | } else { |
| | | m_strCurrPlc = ""; |
| | | } |
| | | m_pActivePlc = pPlc; |
| | | } |
| | | |
| | | CPLC* CModel::getCurrentPlc() |
| | | { |
| | | auto item = m_mapPlc.find(m_strCurrPlc); |
| | | if (item != m_mapPlc.end()) { |
| | | return item->second; |
| | | } |
| | | |
| | | return nullptr; |
| | | return m_pActivePlc; |
| | | } |
| | |
| | | IObservableEmitter* m_pObservableEmitter; |
| | | CString m_strWorkDir; |
| | | std::map<std::string, CPLC*> m_mapPlc; |
| | | std::string m_strCurrPlc; |
| | | CPLC* m_pActivePlc; |
| | | |
| | | private: |
| | | int m_nTimerID; |
| | |
| | | theApp.m_model.notifyPtr(RX_CODE_SELECT_PLC, pSelectedPlc); |
| | | } |
| | | } |
| | | else if (RX_PLC_STATE_CHANGED == code) { |
| | | CPLC* pPlc; |
| | | if (pAny->getPtrValue("ptr", (void*&)pPlc)) { |
| | | HTREEITEM hItem = FindItem(pPlc); |
| | | if (hItem != nullptr && pPlc->isConnected()) { |
| | | m_treeCtrl.ShowItemBadgeDotMode(hItem); |
| | | } |
| | | else { |
| | | m_treeCtrl.HideItemBadge(hItem); |
| | | } |
| | | } |
| | | } |
| | | |
| | | pAny->release(); |
| | | }, [&]() -> void { |
| | |
| | | for (auto item : plcs) { |
| | | HTREEITEM hItem = m_treeCtrl.InsertItem(item.second->getName().c_str(), nullptr, nullptr); |
| | | m_treeCtrl.SetItemData(hItem, (DWORD_PTR)item.second); |
| | | m_treeCtrl.SetItemBadge(hItem, TREE_BADGE_BACKGROUND, TREE_BADGE_FOREGROUND); |
| | | if (item.second->isConnected()) { |
| | | m_treeCtrl.ShowItemBadgeDotMode(hItem); |
| | | } |
| | | if (hItemFirst == nullptr) { |
| | | hItemFirst = hItem; |
| | | } |