1.修复MSGDLg跨线程更新界面闪退问题;
2.完善拔片存片日志;
| | |
| | | CGlass* pPreviousGlass; |
| | | pPreviousGlass = (CGlass*)m_slot[0].getContext(); |
| | | if (pPreviousGlass != nullptr) { |
| | | LOGE("<CArm>tempStore, overwrite previous glass: %s (%d,%d)", |
| | | pPreviousGlass->getID().c_str(), |
| | | pPreviousGlass->getCassetteSequenceNo(), |
| | | pPreviousGlass->getJobSequenceNo()); |
| | | pPreviousGlass->release(); |
| | | } |
| | | m_slot[0].setContext(pGlass); |
| | | Unlock(); |
| | | |
| | | if (pGlass != nullptr) { |
| | | LOGI("<CArm>tempStore: GlassId:%s, Cassette:%d, Job:%d", |
| | | pGlass->getID().c_str(), |
| | | pGlass->getCassetteSequenceNo(), |
| | | pGlass->getJobSequenceNo()); |
| | | } |
| | | |
| | | if (m_listener.onDataChanged != nullptr) { |
| | | m_listener.onDataChanged(this, 0); |
| | |
| | | CGlass* pPreviousGlass = (CGlass*)m_slot[0].getContext(); |
| | | if (pPreviousGlass == nullptr) { |
| | | Unlock(); |
| | | LOGE("<CArm>tempFetchOut failed: arm slot empty."); |
| | | return -1; |
| | | } |
| | | pGlass = pPreviousGlass; |
| | |
| | | m_slot[0].setContext(nullptr); |
| | | Unlock(); |
| | | |
| | | LOGI("<CArm>tempFetchOut: GlassId:%s, Cassette:%d, Job:%d", |
| | | pGlass->getID().c_str(), |
| | | pGlass->getCassetteSequenceNo(), |
| | | pGlass->getJobSequenceNo()); |
| | | |
| | | if (m_listener.onDataChanged != nullptr) { |
| | | m_listener.onDataChanged(this, 0); |
| | | } |
| | |
| | | } |
| | | } |
| | | if (pContext == nullptr) { |
| | | LOGE("<CEquipment-%s>fetchedOutJob, no glass for JobDataB(%d, %d)", m_strName.c_str(), |
| | | pJobDataB->getCassetteSequenceNo(), pJobDataB->getJobSequenceNo()); |
| | | Unlock(); |
| | | return -3; |
| | | } |
| | | LOGI("<CEquipment-%s>fetchedOutJob -> Arm: GlassId:%s, Cassette:%d, Job:%d", m_strName.c_str(), |
| | | pContext->getID().c_str(), pJobDataB->getCassetteSequenceNo(), pJobDataB->getJobSequenceNo()); |
| | | |
| | | ((CArm*)m_pArm)->tempStore(pContext); |
| | | pContext->release(); |
| | |
| | | |
| | | CGlass* pGlass = nullptr; |
| | | if (((CArm*)m_pArm)->tempFetchOut(pGlass) != 0) { |
| | | LOGE("<CEquipment-%s>storedJob, tempFetchOut failed (arm empty).", m_strName.c_str()); |
| | | return -2; |
| | | } |
| | | |
| | | |
| | | ASSERT(pGlass); |
| | | LOGI("<CEquipment-%s>storedJob <- Arm: GlassId:%s, Cassette:%d, Job:%d", m_strName.c_str(), |
| | | pGlass->getID().c_str(), pJobDataB->getCassetteSequenceNo(), pJobDataB->getJobSequenceNo()); |
| | | Lock(); |
| | | pGlass->addPath(m_nID, getSlotUnit(putSlot), putSlot); |
| | | CGlass* pBuddy = pGlass->getBuddy(); |
| | |
| | | // 当前要存片,之前肯定有拔片,因此片子在Arm那里 |
| | | CGlass* pGlass = ((CArm*)m_pArm)->getGlassFromSlot(1); |
| | | if (pGlass == nullptr) { |
| | | LOGE("<CFliper-%s>onPreStoredJob,缓存中没有找到对应的Glass(CassetteSequenceNo:%d, JobSequenceNo:%d),请检查数据,注意风险。", m_strName.c_str(), |
| | | LOGE("<CEquipment-%s>onPreStoredJob,缓存中没有找到对应的Glass(CassetteSequenceNo:%d, JobSequenceNo:%d),请检查数据,注意风险。", m_strName.c_str(), |
| | | pJobDataB->getCassetteSequenceNo(), pJobDataB->getJobSequenceNo()); |
| | | LOGE("<CEquipment-%s>onPreStoredJob, arm temp empty (arm:%s).", m_strName.c_str(), |
| | | (m_pArm != nullptr) ? ((CEquipment*)m_pArm)->getName().c_str() : "null"); |
| | | return FALSE; |
| | | } |
| | | |
| | | CJobDataS* pJobDataS = pGlass->getJobDataS(); |
| | | ASSERT(pJobDataS); |
| | | LOGI("<CEquipment-%s>onPreStoredJob, Arm has GlassId:%s, Cassette:%d, Job:%d", |
| | | m_strName.c_str(), pGlass->getID().c_str(), |
| | | pJobDataS->getCassetteSequenceNo(), pJobDataS->getJobSequenceNo()); |
| | | if (!compareJobData(pJobDataB, pJobDataS)) { |
| | | LOGE("<CEquipemnt-%s>onPreStoredJob,JobData数据不匹配(JobDataB(%d, %d),JobDataS(%d, %d)), 注意排查风险!", m_strName.c_str(), |
| | | pJobDataB->getCassetteSequenceNo(), pJobDataB->getJobSequenceNo(), |
| | |
| | | #include "Servo.h" |
| | | #include "MsgDlg.h" |
| | | #include "afxdialogex.h" |
| | | #include <memory> |
| | | |
| | | |
| | | // CMsgDlg 对话框 |
| | |
| | | CMsgDlg::CMsgDlg(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_DIALOG_MSG, pParent) |
| | | { |
| | | m_uiThreadId = ::GetCurrentThreadId(); |
| | | m_nCompleteCode = 0; |
| | | m_dwData = 0; |
| | | m_dwDataEx = 0; |
| | |
| | | CMsgDlg::CMsgDlg(CString strTitle, CString strMessage) |
| | | : CDialogEx(IDD_DIALOG_MSG, NULL) |
| | | { |
| | | m_uiThreadId = ::GetCurrentThreadId(); |
| | | m_strTitle = strTitle; |
| | | m_strMessage = strMessage; |
| | | m_crBkgnd = CR_MSGBOX_BKGND; |
| | |
| | | CMsgDlg::CMsgDlg(int nIcon, CString strTitle, CString strMessage) |
| | | : CDialogEx(IDD_DIALOG_MSG, NULL) |
| | | { |
| | | m_uiThreadId = ::GetCurrentThreadId(); |
| | | m_strTitle = strTitle; |
| | | m_strMessage = strMessage; |
| | | m_crBkgnd = CR_MSGBOX_BKGND; |
| | |
| | | CDialogEx::DoDataExchange(pDX); |
| | | } |
| | | |
| | | bool CMsgDlg::IsUiThread() const |
| | | { |
| | | return ::GetCurrentThreadId() == m_uiThreadId; |
| | | } |
| | | |
| | | LRESULT CMsgDlg::OnMsgSetTitle(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | std::unique_ptr<CString> str(reinterpret_cast<CString*>(lParam)); |
| | | SetTitle(*str); |
| | | return 0; |
| | | } |
| | | |
| | | LRESULT CMsgDlg::OnMsgSetMessage(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | std::unique_ptr<CString> str(reinterpret_cast<CString*>(lParam)); |
| | | SetMessage(*str); |
| | | return 0; |
| | | } |
| | | |
| | | LRESULT CMsgDlg::OnMsgSetIcon(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | SetIcon(static_cast<int>(wParam)); |
| | | return 0; |
| | | } |
| | | |
| | | LRESULT CMsgDlg::OnMsgSetMarquee(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | SetMarquee((BOOL)wParam, (int)lParam); |
| | | return 0; |
| | | } |
| | | |
| | | LRESULT CMsgDlg::OnMsgDelayClose(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | DelayClose((int)wParam); |
| | | return 0; |
| | | } |
| | | |
| | | LRESULT CMsgDlg::OnMsgSetComplete(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | SetCompleteCode((int)wParam); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CMsgDlg, CDialogEx) |
| | | ON_WM_TIMER() |
| | | ON_WM_CTLCOLOR() |
| | | ON_WM_SIZE() |
| | | ON_MESSAGE(WM_MSGDLG_SET_TITLE, &CMsgDlg::OnMsgSetTitle) |
| | | ON_MESSAGE(WM_MSGDLG_SET_MESSAGE, &CMsgDlg::OnMsgSetMessage) |
| | | ON_MESSAGE(WM_MSGDLG_SET_ICON, &CMsgDlg::OnMsgSetIcon) |
| | | ON_MESSAGE(WM_MSGDLG_SET_MARQUEE, &CMsgDlg::OnMsgSetMarquee) |
| | | ON_MESSAGE(WM_MSGDLG_DELAY_CLOSE, &CMsgDlg::OnMsgDelayClose) |
| | | ON_MESSAGE(WM_MSGDLG_SET_COMPLETE, &CMsgDlg::OnMsgSetComplete) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | |
| | | void CMsgDlg::SetCompleteCode(int code) |
| | | { |
| | | if (!IsUiThread()) { |
| | | PostMessage(WM_MSGDLG_SET_COMPLETE, (WPARAM)code, 0); |
| | | return; |
| | | } |
| | | m_nCompleteCode = code; |
| | | CWnd* pProgressCtrl = GetDlgItem(IDC_PROGRESS1); |
| | | if(pProgressCtrl != nullptr) pProgressCtrl->ShowWindow(SW_HIDE); |
| | |
| | | |
| | | void CMsgDlg::SetIcon(int nIcon) |
| | | { |
| | | if (!IsUiThread()) { |
| | | PostMessage(WM_MSGDLG_SET_ICON, (WPARAM)nIcon, 0); |
| | | return; |
| | | } |
| | | m_nIcon = nIcon; |
| | | if (::IsWindow(m_hWnd)) { |
| | | UpdateIcon(); |
| | |
| | | |
| | | void CMsgDlg::SetTitle(CString strTitle) |
| | | { |
| | | if (!IsUiThread()) { |
| | | CString* pStr = new CString(strTitle); |
| | | if (!PostMessage(WM_MSGDLG_SET_TITLE, 0, (LPARAM)pStr)) { |
| | | delete pStr; |
| | | } |
| | | return; |
| | | } |
| | | m_strTitle = strTitle; |
| | | if (::IsWindow(m_hWnd) && GetDlgItem(IDC_LABEL_TITLE) != NULL) { |
| | | SetWindowText(m_strTitle); |
| | |
| | | |
| | | void CMsgDlg::SetMessage(CString strMessage) |
| | | { |
| | | if (!IsUiThread()) { |
| | | CString* pStr = new CString(strMessage); |
| | | if (!PostMessage(WM_MSGDLG_SET_MESSAGE, 0, (LPARAM)pStr)) { |
| | | delete pStr; |
| | | } |
| | | return; |
| | | } |
| | | m_strMessage = strMessage; |
| | | if (::IsWindow(m_hWnd) && GetDlgItem(IDC_LABEL_MSG) != NULL) { |
| | | SetDlgItemText(IDC_LABEL_MSG, m_strMessage); |
| | |
| | | |
| | | void CMsgDlg::SetMarquee(_In_ BOOL fMarqueeMode, _In_ int nInterval) |
| | | { |
| | | if (!IsUiThread()) { |
| | | PostMessage(WM_MSGDLG_SET_MARQUEE, (WPARAM)fMarqueeMode, (LPARAM)nInterval); |
| | | return; |
| | | } |
| | | if (!::IsWindow(m_hWnd)) { |
| | | return; |
| | | } |
| | |
| | | |
| | | void CMsgDlg::DelayClose(int nDelay) |
| | | { |
| | | if (!IsUiThread()) { |
| | | PostMessage(WM_MSGDLG_DELAY_CLOSE, (WPARAM)nDelay, 0); |
| | | return; |
| | | } |
| | | if (!m_bDelayClose) { |
| | | m_bDelayClose = TRUE; |
| | | SetTimer(1, nDelay, NULL); |
| | |
| | | BOOL CMsgDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | m_uiThreadId = ::GetCurrentThreadId(); |
| | | |
| | | SetWindowText(m_strTitle); |
| | | SetDlgItemText(IDC_LABEL_TITLE, m_strTitle); |
| | |
| | | #define MSG_BOX_ERROR 0x03 |
| | | #define MSG_BOX_SUCCEED 0x04 |
| | | |
| | | #define WM_MSGDLG_SET_TITLE (WM_APP + 400) |
| | | #define WM_MSGDLG_SET_MESSAGE (WM_APP + 401) |
| | | #define WM_MSGDLG_SET_ICON (WM_APP + 402) |
| | | #define WM_MSGDLG_SET_MARQUEE (WM_APP + 403) |
| | | #define WM_MSGDLG_DELAY_CLOSE (WM_APP + 404) |
| | | #define WM_MSGDLG_SET_COMPLETE (WM_APP + 405) |
| | | |
| | | class CMsgDlg : public CDialogEx |
| | | { |
| | | DECLARE_DYNAMIC(CMsgDlg) |
| | |
| | | private: |
| | | void Resize(); |
| | | void UpdateIcon(); |
| | | bool IsUiThread() const; |
| | | LRESULT OnMsgSetTitle(WPARAM wParam, LPARAM lParam); |
| | | LRESULT OnMsgSetMessage(WPARAM wParam, LPARAM lParam); |
| | | LRESULT OnMsgSetIcon(WPARAM wParam, LPARAM lParam); |
| | | LRESULT OnMsgSetMarquee(WPARAM wParam, LPARAM lParam); |
| | | LRESULT OnMsgDelayClose(WPARAM wParam, LPARAM lParam); |
| | | LRESULT OnMsgSetComplete(WPARAM wParam, LPARAM lParam); |
| | | |
| | | private: |
| | | COLORREF m_crBkgnd; |
| | |
| | | DWORD_PTR m_dwData; |
| | | DWORD_PTR m_dwDataEx; |
| | | BOOL m_bDelayClose; |
| | | DWORD m_uiThreadId; |
| | | |
| | | |
| | | // 对话框数据 |