LAPTOP-SNT8I5JK\Boounion
2025-06-20 5ee30b85c394e60b5ac4169a8093a8089345189a
1.任务的回撤实现,在任务详情上增加"回撤"按钮
已修改11个文件
97 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CMaster.cpp 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CRobotTask.cpp 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CRobotTask.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CRobotTaskDlg.cpp 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CRobotTaskDlg.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Common.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/Model.cpp 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/ServoCommo.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/ServoDlg.cpp 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/resource.h 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CMaster.cpp
@@ -879,11 +879,22 @@
                        LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
                    }
                }
                // 是否回撤
                else if (m_pActiveRobotTask->isRestoring() &&
                    m_pActiveRobotTask->getSrcPosition() == p->getID()) {
                    CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getSrcSlot());
                    if (pGlass == nullptr) {
                        bOk = TRUE;
                        slot = m_pActiveRobotTask->getSrcSlot();
                        LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
                    }
                }
            }
            unlock();
            if (!bOk) {
                LOGE("<CMaster>onPreFethedOutJob, 数据校验失败.");
                LOGE("<CMaster>onPreStoredJob, 数据校验失败.");
            }
            return bOk;
@@ -932,6 +943,25 @@
                    }
                    delete m_pActiveRobotTask;
                    m_pActiveRobotTask = nullptr;
                }
                else if (m_pActiveRobotTask != nullptr
                    && m_pActiveRobotTask->isRestoring()
                    && m_pActiveRobotTask->getSrcPosition() == p->getID()) {
                    m_pActiveRobotTask->stored();
                    m_pActiveRobotTask->restored();
                    LOGI("回撤完成...");
                    // 完成此条搬送任务,但要把数据和消息上抛应用层
                    unlock();
                    lock();
                    if (m_listener.onRobotTaskEvent != nullptr) {
                        m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, ROBOT_EVENT_RESTORE);
                    }
                    delete m_pActiveRobotTask;
                    m_pActiveRobotTask = nullptr;
                    stop();
                }
                unlock();
            }
@@ -1462,6 +1492,18 @@
        return 0;
    }
    int CMaster::restoreCurrentTask()
    {
        lock();
        if (m_pActiveRobotTask != nullptr) {
            m_pActiveRobotTask->restore();
        }
        unlock();
        return 0;
    }
    void CMaster::setPortType(unsigned int index, BOOL enable, int type, int mode,
        int cassetteType, int transferMode, BOOL autoChangeEnable)
    {
SourceCode/Bond/Servo/CMaster.h
@@ -66,6 +66,7 @@
        CEquipment* getEquipment(int id);
        void setCacheFilepath(const char* pszFilepath);
        int abortCurrentTask();
        int restoreCurrentTask();
        void setPortType(unsigned int index, BOOL enable, int type, int mode,
            int cassetteType, int transferMode, BOOL autoChangeEnable);
SourceCode/Bond/Servo/CRobotTask.cpp
@@ -290,6 +290,11 @@
        m_state = ROBOT_TASK_STATE::Completed;
    }
    void CRobotTask::restored()
    {
        m_state = ROBOT_TASK_STATE::Restored;
    }
    void CRobotTask::error()
    {
        m_state = ROBOT_TASK_STATE::Error;
SourceCode/Bond/Servo/CRobotTask.h
@@ -38,6 +38,7 @@
        void pick();
        void place();
        void restore();
        void restored();
        void completed();
        void error();
        void abort();
SourceCode/Bond/Servo/CRobotTaskDlg.cpp
@@ -33,6 +33,7 @@
    ON_WM_SIZE()
    ON_WM_ACTIVATE()
    ON_BN_CLICKED(IDC_BUTTON_ABORT_TASK, &CRobotTaskDlg::OnBnClickedAbortTask)
    ON_BN_CLICKED(IDC_BUTTON_RESTORE, &CRobotTaskDlg::OnBnClickedRestore)
END_MESSAGE_MAP()
@@ -50,6 +51,9 @@
    if (m_btnAbortTask.m_hWnd) {
        m_btnAbortTask.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE);
    }
    if (m_btnRestore.m_hWnd) {
        m_btnRestore.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE);
    }
    if (m_pRobotTask != nullptr) {
@@ -97,14 +101,16 @@
    CDialogEx::OnInitDialog();
    // TODO:  在此添加额外的初始化
    // 创建“停止任务”按钮
    // 创建“停止任务”按钮和“撤回”按钮
    m_btnAbortTask.Create(_T("停止任务"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_ABORT_TASK);
    m_btnRestore.Create(_T("撤回"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_RESTORE);
    // 动态按钮创建后设置字体
    if (m_fontButton.GetSafeHandle() == nullptr) {
        m_fontButton.CreatePointFont(110, _T("微软雅黑")); // 或 "Segoe UI"
    }
    m_btnAbortTask.SetFont(&m_fontButton);
    m_btnRestore.SetFont(&m_fontButton);
    // 设置 LABEL 控件的字体
    if (m_fontDetail.GetSafeHandle() == nullptr) {
@@ -180,15 +186,21 @@
    }
    // 设置“停止任务”按钮位置(右下角)
    if (m_btnAbortTask.m_hWnd != nullptr) {
        const int nBtnWidth = 100;
        const int nBtnHeight = 28;
        const int nMargin = 12;
    const int nMargin2 = 8;
    const int x = rcClient.right - nBtnWidth - nMargin;
    int y = rcClient.bottom - nMargin;
    if (m_btnAbortTask.m_hWnd != nullptr) {
        m_btnAbortTask.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight);
        y -= nBtnHeight;
        y -= nMargin2;
    }
        const int nPosX = rcClient.right - nBtnWidth - nMargin;
        const int nPosY = rcClient.bottom - nBtnHeight - nMargin;
        m_btnAbortTask.MoveWindow(nPosX, nPosY, nBtnWidth, nBtnHeight);
    // 设置“停止任务”按钮位置(右下角)
    if (m_btnRestore.m_hWnd != nullptr) {
        m_btnRestore.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight);
    }
}
@@ -201,3 +213,13 @@
    theApp.m_model.getMaster().abortCurrentTask();
}
void CRobotTaskDlg::OnBnClickedRestore()
{
    int ret = AfxMessageBox(_T("物料将会被搬运回原位置,确认要回撤当前任务吗?除非发生了异常,否则请不要回撤任务!"), MB_OKCANCEL | MB_ICONEXCLAMATION);
    if (ret != IDOK) {
        return;
    }
    theApp.m_model.getMaster().restoreCurrentTask();
}
SourceCode/Bond/Servo/CRobotTaskDlg.h
@@ -22,6 +22,7 @@
private:
    SERVO::CRobotTask* m_pRobotTask;
    CButton m_btnAbortTask;
    CButton m_btnRestore;
    CFont m_fontButton;
    CFont m_fontDetail;
@@ -42,4 +43,5 @@
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
    afx_msg void OnBnClickedAbortTask();
    afx_msg void OnBnClickedRestore();
};
SourceCode/Bond/Servo/Common.h
@@ -495,3 +495,4 @@
#define ROBOT_EVENT_FINISH        1   // 正常完成
#define ROBOT_EVENT_ERROR        2   // 出现错误
#define ROBOT_EVENT_ABORT        3   // 人为中止
#define ROBOT_EVENT_RESTORE        4   // 回撤
SourceCode/Bond/Servo/Model.cpp
@@ -203,11 +203,12 @@
            break;
        case ROBOT_EVENT_ERROR:
            LOGE("<CModel>onRobotTaskEvent: 任务错误(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
            pTask->error();
            break;
        case ROBOT_EVENT_ABORT:
            LOGE("<CModel>onRobotTaskEvent: 任务停止(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
            pTask->abort();
            break;
        case ROBOT_EVENT_RESTORE:
            LOGE("<CModel>onRobotTaskEvent: 任务回撤(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
            break;
        default:
            LOGE("<CModel>onRobotTaskEvent: 未知事件 code=%d, 任务=%s", code, strDesc.c_str());
SourceCode/Bond/Servo/ServoCommo.h
@@ -121,6 +121,7 @@
        Restoring,
        Error,
        Abort,
        Restored,
        Completed
    };
SourceCode/Bond/Servo/ServoDlg.cpp
@@ -235,6 +235,9 @@
                    else if (exCode == ROBOT_EVENT_ABORT) {
                        m_pMyStatusbar->setCurTaskBtnText("无");
                    }
                    else if (exCode == ROBOT_EVENT_RESTORE) {
                        m_pMyStatusbar->setCurTaskBtnText("无");
                    }
                }
            }
SourceCode/Bond/Servo/resource.h
Binary files differ