| ¶Ô±ÈÐÂÎļþ |
| | |
| | | // CPageCtrlState.cpp: å®ç°æä»¶ |
| | | // |
| | | |
| | | #include "stdafx.h" |
| | | #include "Servo.h" |
| | | #include "CPageCtrlState.h" |
| | | #include "afxdialogex.h" |
| | | #include "Common.h" |
| | | #include "Model.h" |
| | | #include "ColorTransfer.h" |
| | | |
| | | |
| | | // CPageCtrlState å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CPageCtrlState, CDialogEx) |
| | | |
| | | CPageCtrlState::CPageCtrlState(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_PROD_CTRL_STATE, pParent) |
| | | { |
| | | |
| | | } |
| | | |
| | | CPageCtrlState::~CPageCtrlState() |
| | | { |
| | | } |
| | | |
| | | void CPageCtrlState::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialogEx::DoDataExchange(pDX); |
| | | DDX_Control(pDX, IDC_BUTTON_OFFLINE, m_btnOffline); |
| | | DDX_Control(pDX, IDC_BUTTON_ONLINE_LOCAL, m_btnOnlineLocal); |
| | | DDX_Control(pDX, IDC_BUTTON_ONLINE_REMOTE, m_btnOnlineRemote); |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CPageCtrlState, CDialogEx) |
| | | ON_WM_CTLCOLOR() |
| | | ON_WM_SIZE() |
| | | ON_WM_DESTROY() |
| | | ON_BN_CLICKED(IDC_BUTTON_OFFLINE, &CPageCtrlState::OnBnClickedOffline) |
| | | ON_BN_CLICKED(IDC_BUTTON_ONLINE_LOCAL, &CPageCtrlState::OnBnClickedOnlineLocal) |
| | | ON_BN_CLICKED(IDC_BUTTON_ONLINE_REMOTE, &CPageCtrlState::OnBnClickedOnlineRemote) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | | // CPageCtrlState æ¶æ¯å¤çç¨åº |
| | | |
| | | void CPageCtrlState::InitRxWindows() |
| | | { |
| | | IRxWindows* pRxWindows = RX_GetRxWindows(); |
| | | if (m_pObserver == nullptr) { |
| | | m_pObserver = pRxWindows->allocObserver([this](IAny* pAny) -> void { |
| | | pAny->addRef(); |
| | | const int code = pAny->getCode(); |
| | | if (code == RX_CODE_CONTROL_STATE_CHANGED && ::IsWindow(m_hWnd)) { |
| | | UpdateButtonStyles(); |
| | | } |
| | | pAny->release(); |
| | | }, [&]() -> void { |
| | | // onComplete |
| | | }, [&](IThrowable* pThrowable) -> void { |
| | | // onError |
| | | pThrowable->printf(); |
| | | }); |
| | | |
| | | theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread()) |
| | | ->subscribe(m_pObserver); |
| | | } |
| | | } |
| | | |
| | | void CPageCtrlState::ApplyButtonTheme(CBlButton& btn, bool active) |
| | | { |
| | | const COLORREF text = active ? RGB(255, 255, 255) : RGB(0, 0, 0); |
| | | const COLORREF normal = active ? RGB(34, 177, 76) : RGB(222, 222, 222); |
| | | const COLORREF hover = CColorTransfer::ApproximateColor(normal, active ? 0.08 : 0.05); |
| | | const COLORREF press = CColorTransfer::ApproximateColor(normal, active ? -0.10 : -0.12); |
| | | const COLORREF frame = active ? CColorTransfer::ApproximateColor(normal, -0.18) : RGB(168, 168, 168); |
| | | |
| | | btn.SetRoundWidth(6); |
| | | btn.SetTextColor(BS_NORMAL, text); |
| | | btn.SetTextColor(BS_HOVER, text); |
| | | btn.SetTextColor(BS_PRESS, text); |
| | | btn.SetTextColor(BS_DISABLE, RGB(120, 120, 120)); |
| | | |
| | | btn.SetBkgndColor(BS_NORMAL, normal); |
| | | btn.SetBkgndColor(BS_HOVER, hover); |
| | | btn.SetBkgndColor(BS_PRESS, press); |
| | | btn.SetBkgndColor(BS_DISABLE, RGB(210, 210, 210)); |
| | | |
| | | btn.SetFrameColor(BS_NORMAL, frame); |
| | | btn.SetFrameColor(BS_HOVER, frame); |
| | | btn.SetFrameColor(BS_PRESS, frame); |
| | | btn.SetFrameColor(BS_DISABLE, RGB(180, 180, 180)); |
| | | } |
| | | |
| | | void CPageCtrlState::UpdateButtonStyles() |
| | | { |
| | | const auto state = theApp.m_model.getControlState(); |
| | | ApplyButtonTheme(m_btnOffline, state == ControlState::OfflineEquipment || state == ControlState::OfflineHost); |
| | | ApplyButtonTheme(m_btnOnlineLocal, state == ControlState::OnlineLocal); |
| | | ApplyButtonTheme(m_btnOnlineRemote, state == ControlState::OnlineRemote); |
| | | |
| | | Invalidate(); |
| | | UpdateWindow(); |
| | | } |
| | | |
| | | BOOL CPageCtrlState::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | InitRxWindows(); |
| | | UpdateButtonStyles(); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // å¼å¸¸: OCX 屿§é¡µåºè¿å FALSE |
| | | } |
| | | |
| | | |
| | | HBRUSH CPageCtrlState::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) |
| | | { |
| | | HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor); |
| | | |
| | | // TODO: 卿¤æ´æ¹ DC çä»»ä½ç¹æ§ |
| | | |
| | | // TODO: 妿é»è®¤ç䏿¯æéç»ç¬ï¼åè¿åå¦ä¸ä¸ªç»ç¬ |
| | | return hbr; |
| | | } |
| | | |
| | | void CPageCtrlState::OnSize(UINT nType, int cx, int cy) |
| | | { |
| | | CDialogEx::OnSize(nType, cx, cy); |
| | | |
| | | // TODO: 卿¤å¤æ·»å æ¶æ¯å¤çç¨åºä»£ç |
| | | } |
| | | |
| | | void CPageCtrlState::OnDestroy() |
| | | { |
| | | CDialogEx::OnDestroy(); |
| | | |
| | | // TODO: 卿¤å¤æ·»å æ¶æ¯å¤çç¨åºä»£ç |
| | | } |
| | | |
| | | void CPageCtrlState::OnBnClickedOffline() |
| | | { |
| | | theApp.m_model.setControlState(ControlState::OfflineEquipment); |
| | | } |
| | | |
| | | void CPageCtrlState::OnBnClickedOnlineLocal() |
| | | { |
| | | theApp.m_model.setControlState(ControlState::OnlineLocal); |
| | | } |
| | | |
| | | void CPageCtrlState::OnBnClickedOnlineRemote() |
| | | { |
| | | theApp.m_model.setControlState(ControlState::OnlineRemote); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #pragma once |
| | | #include "BlButton.h" |
| | | |
| | | // CPageCtrlState å¯¹è¯æ¡ |
| | | |
| | | class CPageCtrlState : public CDialogEx |
| | | { |
| | | DECLARE_DYNAMIC(CPageCtrlState) |
| | | |
| | | public: |
| | | CPageCtrlState(CWnd* pParent = nullptr); // æ åæé 彿° |
| | | virtual ~CPageCtrlState(); |
| | | |
| | | private: |
| | | void InitRxWindows(); |
| | | void UpdateButtonStyles(); |
| | | void ApplyButtonTheme(CBlButton& btn, bool active); |
| | | |
| | | CBlButton m_btnOffline; |
| | | CBlButton m_btnOnlineLocal; |
| | | CBlButton m_btnOnlineRemote; |
| | | IObserver* m_pObserver{ nullptr }; |
| | | |
| | | // å¯¹è¯æ¡æ°æ® |
| | | #ifdef AFX_DESIGN_TIME |
| | | enum { IDD = IDD_PROD_CTRL_STATE }; |
| | | #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 OnSize(UINT nType, int cx, int cy); |
| | | afx_msg void OnDestroy(); |
| | | afx_msg void OnBnClickedOffline(); |
| | | afx_msg void OnBnClickedOnlineLocal(); |
| | | afx_msg void OnBnClickedOnlineRemote(); |
| | | }; |
| | |
| | | m_pStatsThread = nullptr; |
| | | m_pAccordionWnd = nullptr; |
| | | m_pPageProdOverview = nullptr; |
| | | m_pPageCtrlState = nullptr; |
| | | } |
| | | |
| | | CPanelProduction::~CPanelProduction() |
| | |
| | | m_pAccordionWnd->Setpadding(PADDING_BOTTOM, 2); |
| | | m_pAccordionWnd->LoadExpandIcon(strExpandIcon, strCloseIcon); |
| | | |
| | | m_pPageCtrlState = new CPageCtrlState(); |
| | | m_pPageCtrlState->SetBackgroundColor(m_crBkgnd); |
| | | m_pPageCtrlState->Create(IDD_PROD_CTRL_STATE, GetDlgItem(IDC_ACCORDION_WND1)); |
| | | m_pPageCtrlState->ShowWindow(SW_HIDE); |
| | | m_pAccordionWnd->AddItem("ç¶æ", m_pPageCtrlState, 120, TRUE, TRUE); |
| | | |
| | | m_pPageProdOverview = new CPageProdOverview(); |
| | | m_pPageProdOverview->SetBackgroundColor(m_crBkgnd); |
| | | m_pPageProdOverview->Create(IDD_PROD_OVERVIEW, GetDlgItem(IDC_ACCORDION_WND1)); |
| | |
| | | |
| | | CDialogEx::OnDestroy(); |
| | | |
| | | if (m_pPageCtrlState != nullptr) { |
| | | m_pPageCtrlState->DestroyWindow(); |
| | | delete m_pPageCtrlState; |
| | | m_pPageCtrlState = nullptr; |
| | | } |
| | | if (m_pPageProdOverview != nullptr) { |
| | | m_pPageProdOverview->DestroyWindow(); |
| | | delete m_pPageProdOverview; |
| | | m_pPageProdOverview = nullptr; |
| | | } |
| | | |
| | | if (m_hbrBkgnd != nullptr) { |
| | | ::DeleteObject(m_hbrBkgnd); |
| | | } |
| | |
| | | #include "AccordionWnd.h" |
| | | #include "ProductionStats.h" |
| | | #include "CPageProdOverview.h" |
| | | #include "CPageCtrlState.h" |
| | | |
| | | // CPanelProduction dialog |
| | | class CPanelProduction : public CDialogEx |
| | |
| | | CWinThread* m_pStatsThread; |
| | | CEvent m_evStopStats; |
| | | CPageProdOverview* m_pPageProdOverview; |
| | | CPageCtrlState* m_pPageCtrlState; |
| | | |
| | | protected: |
| | | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support |
| | |
| | | #define RX_CODE_MASTER_STATE_CHANGED 1011 |
| | | #define RX_CODE_EQ_ROBOT_TASK 1012 |
| | | #define RX_CODE_LOADPORT_STATUS_CHANGED 1014 |
| | | #define RX_CODE_CONTROL_STATE_CHANGED 1015 |
| | | |
| | | |
| | | /* Channel Name */ |
| | |
| | | m_hsmsPassive.setVariableValue("PJobSpace", (__int64)(m_master.isProcessJobsEmpty() ? 1 : 0)); |
| | | } |
| | | |
| | | void CModel::setControlState(ControlState newState) |
| | | { |
| | | const auto prev = m_currentControlState; |
| | | if (newState != m_currentControlState) { |
| | | m_hsmsPassive.setVariableValue("PreviousControlState", (__int64)static_cast<uint8_t>(prev)); |
| | | m_currentControlState = newState; |
| | | } |
| | | |
| | | // Always keep SV in sync (even if state didn't change or variables were just loaded). |
| | | m_hsmsPassive.setVariableValue("CurrentControlState", (__int64)static_cast<uint8_t>(m_currentControlState)); |
| | | |
| | | if (newState != prev) { |
| | | notifyInt(RX_CODE_CONTROL_STATE_CHANGED, static_cast<int>(m_currentControlState)); |
| | | } |
| | | } |
| | | |
| | | IObservable* CModel::getObservable() |
| | | { |
| | | if (m_pObservable == nullptr) { |
| | |
| | | |
| | | |
| | | SECSListener listener; |
| | | listener.onEQOffLine = [&](void* pFrom) -> void { |
| | | listener.onEQOffLine = [this](void* pFrom) -> void { |
| | | LOGI("è¿ç¨è¯·æ±OffLine"); |
| | | (void)pFrom; |
| | | setControlState(ControlState::OfflineHost); |
| | | }; |
| | | listener.onEQOnLine = [&](void* pFrom) -> void { |
| | | listener.onEQOnLine = [this](void* pFrom) -> void { |
| | | LOGI("è¿ç¨è¯·æ±OnLine"); |
| | | (void)pFrom; |
| | | // Customer flow: S1F17 RequestOnline defaults to OnlineRemote. |
| | | setControlState(ControlState::OnlineRemote); |
| | | }; |
| | | listener.onCommand = [&](void* pFrom, const char* pszName, std::vector<CommandParameter>& params) -> void { |
| | | listener.onCommand = [this](void* pFrom, const char* pszName, std::vector<CommandParameter>& params) -> void { |
| | | LOGI("onCommand:%s", pszName); |
| | | (void)pFrom; |
| | | for (auto& item : params) { |
| | | LOGI("param:%s,%s", item.szName, item.szValue); |
| | | } |
| | | |
| | | if (pszName == nullptr) return; |
| | | // S2F41 GoLocal / GoRemote (RCMD) |
| | | if (_strcmpi(pszName, "GoLocal") == 0 || _strcmpi(pszName, "LOCAL") == 0 || _strcmpi(pszName, "GoLOCAL") == 0) { |
| | | setControlState(ControlState::OnlineLocal); |
| | | } |
| | | else if (_strcmpi(pszName, "GoRemote") == 0 || _strcmpi(pszName, "REMOTE") == 0 || _strcmpi(pszName, "GoREMOTE") == 0) { |
| | | setControlState(ControlState::OnlineRemote); |
| | | } |
| | | }; |
| | | listener.onEQConstantRequest = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void { |
| | |
| | | CString strVarialbleFile; |
| | | strVarialbleFile.Format(_T("%s\\VariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | m_hsmsPassive.loadVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile); |
| | | setControlState(m_currentControlState); |
| | | refreshDerivedSVs(); |
| | | m_hsmsPassive.init(this, "APP", 7000); |
| | | strVarialbleFile.Format(_T("%s\\ReportList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | |
| | | #include "HsmsPassive.h" |
| | | #include "CMaster.h" |
| | | #include "CGlassPool.h" |
| | | #include <cstdint> |
| | | |
| | | enum class ControlState : uint8_t { |
| | | OfflineEquipment = 0, |
| | | OfflineAttempt = 1, |
| | | Online = 2, |
| | | OfflineHost = 3, |
| | | OnlineLocal = 4, |
| | | OnlineRemote = 5, |
| | | }; |
| | | |
| | | class CModel |
| | | { |
| | |
| | | void setPortEnable(unsigned int index, BOOL bEnable); |
| | | int init(); |
| | | int term(); |
| | | |
| | | ControlState getControlState() const noexcept { return m_currentControlState; } |
| | | void setControlState(ControlState newState); |
| | | |
| | | private: |
| | | void refreshDerivedSVs(); |
| | |
| | | IObservableEmitter* m_pObservableEmitter; |
| | | CString m_strWorkDir; |
| | | CString m_strDataDir; |
| | | }; |
| | | |
| | | private: |
| | | ControlState m_currentControlState{ ControlState::OfflineEquipment }; |
| | | }; |
| | |
| | | CTEXT "-",IDC_PROD_NIGHT_TAKT,126,82,68,45,SS_CENTERIMAGE |
| | | END |
| | | |
| | | IDD_PROD_CTRL_STATE DIALOGEX 0, 0, 216, 97 |
| | | STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU |
| | | FONT 8, "MS Shell Dlg", 400, 0, 0x1 |
| | | BEGIN |
| | | PUSHBUTTON "Offline",IDC_BUTTON_OFFLINE,9,15,58,27 |
| | | PUSHBUTTON "Online Local",IDC_BUTTON_ONLINE_LOCAL,74,15,58,27 |
| | | PUSHBUTTON "Online Remote",IDC_BUTTON_ONLINE_REMOTE,138,15,58,27 |
| | | END |
| | | |
| | | |
| | | ///////////////////////////////////////////////////////////////////////////// |
| | | // |
| | |
| | | TOPMARGIN, 7 |
| | | BOTTOMMARGIN, 152 |
| | | END |
| | | |
| | | IDD_PROD_CTRL_STATE, DIALOG |
| | | BEGIN |
| | | LEFTMARGIN, 7 |
| | | RIGHTMARGIN, 209 |
| | | TOPMARGIN, 7 |
| | | BOTTOMMARGIN, 90 |
| | | END |
| | | END |
| | | #endif // APSTUDIO_INVOKED |
| | | |
| | |
| | | 0 |
| | | END |
| | | |
| | | IDD_PROD_CTRL_STATE AFX_DIALOG_LAYOUT |
| | | BEGIN |
| | | 0 |
| | | END |
| | | |
| | | |
| | | ///////////////////////////////////////////////////////////////////////////// |
| | | // |
| | |
| | | <ClInclude Include="ClientListDlg.h" /> |
| | | <ClInclude Include="CMyStatusbar.h" /> |
| | | <ClInclude Include="CPageCollectionEvent.h" /> |
| | | <ClInclude Include="CPageCtrlState.h" /> |
| | | <ClInclude Include="CPageGlassList.h" /> |
| | | <ClInclude Include="CPageLinkSignal.h" /> |
| | | <ClInclude Include="CPageProdOverview.h" /> |
| | |
| | | <ClCompile Include="ClientListDlg.cpp" /> |
| | | <ClCompile Include="CMyStatusbar.cpp" /> |
| | | <ClCompile Include="CPageCollectionEvent.cpp" /> |
| | | <ClCompile Include="CPageCtrlState.cpp" /> |
| | | <ClCompile Include="CPageGlassList.cpp" /> |
| | | <ClCompile Include="CPageLinkSignal.cpp" /> |
| | | <ClCompile Include="CPageProdOverview.cpp" /> |
| | |
| | | <ClCompile Include="AccordionWnd.cpp" /> |
| | | <ClCompile Include="CPageProdOverview.cpp" /> |
| | | <ClCompile Include="HmLabel.cpp" /> |
| | | <ClCompile Include="CPageCtrlState.cpp" /> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <ClInclude Include="AlarmManager.h" /> |
| | |
| | | <ClInclude Include="AccordionWnd.h" /> |
| | | <ClInclude Include="CPageProdOverview.h" /> |
| | | <ClInclude Include="HmLabel.h" /> |
| | | <ClInclude Include="CPageCtrlState.h" /> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <ResourceCompile Include="Servo.rc" /> |
| | |
| | | #define IDD_CJ_PAGE3 180 |
| | | #define IDD_DIALOG_USER_MANAGER2 181 |
| | | #define IDD_DIALOG_USER_EDIT2 182 |
| | | #define IDD_PROD_OVERVIEW 183 |
| | | #define IDD_PROD_OVERVIEW 183 |
| | | #define IDD_DIALOG_USERX_LOG 184 |
| | | #define IDD_DIALOG_VARIABLE_EDIT2 186 |
| | | #define IDD_DIALOG_REPORT_EDIT 187 |
| | | #define IDD_DIALOG_EVENT_EDIT 188 |
| | | #define IDD_PANEL_PRODUCTION 189 |
| | | #define IDD_PROD_CTRL_STATE 190 |
| | | #define IDC_SERVO_GRAPH1 1001 |
| | | #define IDC_BUTTON_LOG 1002 |
| | | #define IDC_EDIT_LOG 1003 |
| | |
| | | #define IDC_EDIT_EVT_DESC 1245 |
| | | #define IDC_LIST_EVT_RPTS 1246 |
| | | #define IDC_ACCORDION_WND1 1247 |
| | | #define IDC_PROD_DAY_OUTPUT 1248 |
| | | #define IDC_PROD_NIGHT_OUTPUT 1249 |
| | | #define IDC_PROD_DAY_TAKT 1250 |
| | | #define IDC_PROD_NIGHT_TAKT 1251 |
| | | #define IDC_PROD_DAY_OUTPUT 1248 |
| | | #define IDC_PROD_NIGHT_OUTPUT 1249 |
| | | #define IDC_PROD_DAY_TAKT 1250 |
| | | #define IDC_PROD_NIGHT_TAKT 1251 |
| | | #define IDC_BUTTON_OFFLINE 1252 |
| | | #define IDC_BUTTON_ONLINE_LOCAL 1253 |
| | | #define IDC_BUTTON_ONLINE_REMOTE 1254 |
| | | #define ID_MENU_HELP_ABOUT 32771 |
| | | #define ID_MENU_FILE_EXIT 32772 |
| | | #define ID_MENU_FILE_SECSTEST 32773 |
| | |
| | | #ifndef APSTUDIO_READONLY_SYMBOLS |
| | | #define _APS_NEXT_RESOURCE_VALUE 191 |
| | | #define _APS_NEXT_COMMAND_VALUE 32804 |
| | | #define _APS_NEXT_CONTROL_VALUE 1252 |
| | | #define _APS_NEXT_CONTROL_VALUE 1255 |
| | | #define _APS_NEXT_SYMED_VALUE 101 |
| | | #endif |
| | | #endif |