chenluhua1980
5 天以前 4b7616f61a6a37cc917cdbcb131f91272ab2e6fb
1.修复MSGDLg跨线程更新界面闪退问题;
2.完善拔片存片日志;
已修改4个文件
130 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CArm.cpp 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CEquipment.cpp 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/MsgDlg.cpp 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/MsgDlg.h 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CArm.cpp
@@ -71,10 +71,21 @@
        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);
@@ -89,6 +100,7 @@
        CGlass* pPreviousGlass = (CGlass*)m_slot[0].getContext();
        if (pPreviousGlass == nullptr) {
            Unlock();
            LOGE("<CArm>tempFetchOut failed: arm slot empty.");
            return -1;
        }
        pGlass = pPreviousGlass;
@@ -96,6 +108,11 @@
        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);
        }
SourceCode/Bond/Servo/CEquipment.cpp
@@ -934,9 +934,13 @@
            }
        }
        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();
@@ -962,11 +966,14 @@
        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();
@@ -2109,13 +2116,18 @@
        // 当前要存片,之前肯定有拔片,因此片子在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(),
SourceCode/Bond/Servo/MsgDlg.cpp
@@ -5,6 +5,7 @@
#include "Servo.h"
#include "MsgDlg.h"
#include "afxdialogex.h"
#include <memory>
// CMsgDlg 对话框
@@ -14,6 +15,7 @@
CMsgDlg::CMsgDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_MSG, pParent)
{
    m_uiThreadId = ::GetCurrentThreadId();
    m_nCompleteCode = 0;
    m_dwData = 0;
    m_dwDataEx = 0;
@@ -28,6 +30,7 @@
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;
@@ -40,6 +43,7 @@
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;
@@ -58,11 +62,60 @@
    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()
@@ -70,6 +123,10 @@
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);
@@ -102,6 +159,10 @@
void CMsgDlg::SetIcon(int nIcon)
{
    if (!IsUiThread()) {
        PostMessage(WM_MSGDLG_SET_ICON, (WPARAM)nIcon, 0);
        return;
    }
    m_nIcon = nIcon;
    if (::IsWindow(m_hWnd)) {
        UpdateIcon();
@@ -127,6 +188,13 @@
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);
@@ -136,6 +204,13 @@
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);
@@ -144,6 +219,10 @@
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;
    }
@@ -170,6 +249,10 @@
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);
@@ -186,6 +269,7 @@
BOOL CMsgDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    m_uiThreadId = ::GetCurrentThreadId();
    SetWindowText(m_strTitle);
    SetDlgItemText(IDC_LABEL_TITLE, m_strTitle);
SourceCode/Bond/Servo/MsgDlg.h
@@ -9,6 +9,13 @@
#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)
@@ -38,6 +45,13 @@
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;
@@ -53,6 +67,7 @@
    DWORD_PTR m_dwData;
    DWORD_PTR m_dwDataEx;
    BOOL m_bDelayClose;
    DWORD m_uiThreadId;
// 对话框数据