| | |
| | | #include "CPageGraph1.h" |
| | | #include "afxdialogex.h" |
| | | #include "Common.h" |
| | | #include "CEquipment.h" |
| | | #include "CGlass.h" |
| | | |
| | | const std::map<SERVO::ROBOT_POSITION, RobotPositionMapping> g_positionMap = { |
| | | { SERVO::ROBOT_POSITION::Port1, { SERVO::ROBOT_POSITION::Port1, 1.00f, 0.00f } }, |
| | |
| | | |
| | | // Image |
| | | #define IMAGE_ROBOT 2 |
| | | #define IMAGE_LEGEND 3 |
| | | |
| | | #define INDICATE_BONDER1 1 |
| | | #define INDICATE_BONDER2 2 |
| | |
| | | // 定时器 |
| | | #define TIMER_ID_DEVICE_STATUS 1 // 用于初始化设备状态 |
| | | #define TIMER_ID_ROBOT_STATUS 2 // 用于周期刷新机器人位置/臂状态 |
| | | #define TIMER_ID_ROBOT_ANIMATION 3 // |
| | | |
| | | // CPageGraph1 对话框 |
| | | |
| | |
| | | CPageGraph1::CPageGraph1(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_PAGE_GRAPH1, pParent) |
| | | { |
| | | m_pGraph = nullptr; |
| | | m_pObserver = nullptr; |
| | | m_bIsRobotMoving = FALSE; |
| | | m_crBkgnd = PAGE_GRPAH1_BACKGROUND_COLOR; |
| | | m_hbrBkgnd = nullptr; |
| | | m_lastRobotPosition = SERVO::ROBOT_POSITION::Port1; |
| | | m_lastArmState[0] = FALSE; |
| | | m_lastArmState[1] = FALSE; |
| | | // ===== 图形界面相关成员变量初始化 ===== |
| | | m_pGraph = nullptr; // 图形绘图对象 |
| | | m_pObserver = nullptr; // 观察者对象(可能是事件观察者) |
| | | m_crBkgnd = PAGE_GRPAH1_BACKGROUND_COLOR; // 背景颜色 |
| | | m_hbrBkgnd = nullptr; // 背景刷句柄 |
| | | m_slotBarTestMode = 0; // 0=off,1=has,2=processing |
| | | |
| | | m_arm1Offset = LoadArmOffset("ARM1"); |
| | | m_arm2Offset = LoadArmOffset("ARM2"); |
| | | // ===== 机器人动画状态初始化 ===== |
| | | m_bIsRobotMoving = FALSE; // 当前是否正在动画移动 |
| | | m_nRobotMoveStartX = 0; // 动画起始 X 坐标 |
| | | m_nRobotMoveEndX = 0; // 动画目标 X 坐标 |
| | | m_nRobotMoveSteps = 30; // 动画总步数(动画速度控制) |
| | | m_nRobotMoveCurrentStep = 0; // 当前动画步数 |
| | | m_nRobotMoveStartAngle = 0.0f; // 动画起始角度 |
| | | m_nRobotMoveEndAngle = 0.0f; // 动画目标角度 |
| | | |
| | | // ===== 机器人上一次状态初始化 ===== |
| | | m_lastRobotPosition = SERVO::ROBOT_POSITION::Port1; // 上次机器人位置(默认 Port1) |
| | | m_lastArmState[0] = FALSE; // 上次机械臂1 状态(未占用) |
| | | m_lastArmState[1] = FALSE; // 上次机械臂2 状态(未占用) |
| | | |
| | | // ===== 机械臂相对偏移量初始化(从配置中加载) ===== |
| | | m_arm1Offset = LoadArmOffset("ARM1"); // 加载机械臂1偏移 |
| | | m_arm2Offset = LoadArmOffset("ARM2"); // 加载机械臂2偏移 |
| | | |
| | | //m_arm1Offset = { -30, -45 }; // ARM1 从中心向左47, 向上33 |
| | | //m_arm2Offset = { 27, -45 }; // ARM2 从中心向右10, 向上33 |
| | |
| | | std::string configDir = exePath.substr(0, exePath.find_last_of("\\/")) + "\\Config"; |
| | | CreateDirectoryA(configDir.c_str(), NULL); |
| | | return configDir + "\\robot_offset.ini"; |
| | | } |
| | | |
| | | void CPageGraph1::UpdateLegendPosition() |
| | | { |
| | | if (!m_pGraph) return; |
| | | auto* pImage = m_pGraph->GetImage(IMAGE_LEGEND); |
| | | if (!pImage) return; |
| | | |
| | | RECT rc = { 0 }; |
| | | ::GetClientRect(m_pGraph->GetSafeWnd(), &rc); |
| | | std::string iniPath = GetConfigPath(); |
| | | int cfgX = GetPrivateProfileIntA("Graph1", "LegendX", -1, iniPath.c_str()); |
| | | int cfgY = GetPrivateProfileIntA("Graph1", "LegendY", -1, iniPath.c_str()); |
| | | |
| | | int x = (cfgX >= 0) ? cfgX : (rc.right - pImage->bmWidth - 8); |
| | | int y = (cfgY >= 0) ? cfgY : 6; |
| | | if (x < 0) x = 0; |
| | | if (y < 0) y = 0; |
| | | if (x > rc.right - pImage->bmWidth) x = rc.right - pImage->bmWidth; |
| | | if (y > rc.bottom - pImage->bmHeight) y = rc.bottom - pImage->bmHeight; |
| | | m_pGraph->UpdateImageCoordinates(IMAGE_LEGEND, x, y); |
| | | m_pGraph->Invalidata(); |
| | | } |
| | | |
| | | void CPageGraph1::InitRxWindows() |
| | |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | InitRxWindows(); |
| | | SetTimer(TIMER_ID_DEVICE_STATUS, 3000, nullptr); |
| | | SetTimer(TIMER_ID_DEVICE_STATUS, 800, nullptr); |
| | | SetTimer(TIMER_ID_ROBOT_STATUS, 1000, nullptr); // 每 1000ms 更新一次状态 |
| | | |
| | | // 图示 |
| | |
| | | strPath.Format(_T("%s\\res\\Robot001.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | m_pGraph->AddImage(IMAGE_ROBOT, (LPTSTR)(LPCTSTR)strPath, 170, 270); |
| | | |
| | | // Legend |
| | | strPath.Format(_T("%s\\res\\GraphLegend.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | m_pGraph->AddImage(IMAGE_LEGEND, (LPTSTR)(LPCTSTR)strPath, 0, 0); |
| | | UpdateLegendPosition(); |
| | | |
| | | // 添加指示器 |
| | | // Bonder |
| | | m_pGraph->AddIndicateBox(INDICATE_BONDER1, 220, 172, 48, RGB(22, 22, 22), |
| | | // size config |
| | | std::string iniPath = GetConfigPath(); |
| | | int boxSize = GetPrivateProfileIntA("Graph1", "BoxSize", 56, iniPath.c_str()); |
| | | if (boxSize < 40) boxSize = 40; |
| | | if (boxSize > 80) boxSize = 80; |
| | | int slotSize = GetPrivateProfileIntA("Graph1", "SlotSize", 6, iniPath.c_str()); |
| | | if (slotSize < 2) slotSize = 2; |
| | | if (slotSize > 12) slotSize = 12; |
| | | m_pGraph->SetSlotBarSize(slotSize); |
| | | int armBoxSize = GetPrivateProfileIntA("Graph1", "ArmBoxSize", boxSize, iniPath.c_str()); |
| | | if (armBoxSize < 30) armBoxSize = 30; |
| | | if (armBoxSize > 80) armBoxSize = 80; |
| | | |
| | | // ArmSpacing = edge-to-edge gap between the two robot arm boxes. |
| | | int armGap = GetPrivateProfileIntA("Graph1", "ArmSpacing", 6, iniPath.c_str()); |
| | | if (armGap < 0) armGap = 0; |
| | | if (armGap > 100) armGap = 100; |
| | | |
| | | int arm1X = 190; |
| | | int arm2X = 243; |
| | | int armY = 294; |
| | | int minArmSpacing = armBoxSize + armGap; |
| | | if (minArmSpacing > 0) { |
| | | int mid = (m_arm1Offset.x + m_arm2Offset.x) / 2; |
| | | int half = minArmSpacing / 2; |
| | | if (m_arm1Offset.x <= m_arm2Offset.x) { |
| | | m_arm1Offset.x = mid - half; |
| | | m_arm2Offset.x = mid + half; |
| | | } else { |
| | | m_arm2Offset.x = mid - half; |
| | | m_arm1Offset.x = mid + half; |
| | | } |
| | | } |
| | | { |
| | | int baseMid = (arm1X + arm2X) / 2; |
| | | int half = minArmSpacing / 2; |
| | | arm1X = baseMid - half; |
| | | arm2X = baseMid + half; |
| | | } |
| | | |
| | | m_pGraph->AddIndicateBox(INDICATE_BONDER1, 220, 172, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_BONDER1, "10", "Bonder 1"); |
| | | m_pGraph->AddIndicateBox(INDICATE_BONDER2, 220, 516, 48, RGB(22, 22, 22), |
| | | m_pGraph->SetBoxText(INDICATE_BONDER1, "", "Bonder 1"); |
| | | m_pGraph->AddIndicateBox(INDICATE_BONDER2, 220, 516, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_BONDER2, "11", "Bonder 2"); |
| | | m_pGraph->SetBoxText(INDICATE_BONDER2, "", "Bonder 2"); |
| | | |
| | | |
| | | // 翻转 |
| | | m_pGraph->AddIndicateBox(INDICATE_FLIPER, 338, 172, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_FLIPER, 338, 172, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_FLIPER, "8", "Fliper"); |
| | | m_pGraph->SetBoxText(INDICATE_FLIPER, "", "Fliper"); |
| | | |
| | | |
| | | // 对位 |
| | | m_pGraph->AddIndicateBox(INDICATE_ALIGNER, 428, 172, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_ALIGNER, 428, 172, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_ALIGNER, "7", "Aligner"); |
| | | m_pGraph->SetBoxText(INDICATE_ALIGNER, "", "Aligner"); |
| | | |
| | | |
| | | // Load port 4 |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT4, 518, 172, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT4, 518, 172, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT4, "4", "LPort4"); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT4, "", "LPort4"); |
| | | |
| | | |
| | | // Load port 3 |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT3, 606, 172, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT3, 606, 172, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT3, "3", "LPort3"); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT3, "", "LPort3"); |
| | | |
| | | |
| | | // Load port 2 |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT2, 690, 172, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT2, 690, 172, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT2, "2", "LPort2"); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT2, "", "LPort2"); |
| | | |
| | | |
| | | // Load port 1 |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT1, 774, 172, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_LPORT1, 774, 172, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT1, "1", "LPort1"); |
| | | m_pGraph->SetBoxText(INDICATE_LPORT1, "", "LPort1"); |
| | | |
| | | |
| | | // Robot |
| | | m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM1, 190, 294, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM1, arm1X, armY, armBoxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_ROBOT_ARM1, "5", "Robot"); |
| | | m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM2, 243, 294, 48, RGB(22, 22, 22), |
| | | m_pGraph->SetBoxText(INDICATE_ROBOT_ARM1, "", "Robot"); |
| | | m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM2, arm2X, armY, armBoxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_ROBOT_ARM2, "6", "Robot"); |
| | | m_pGraph->SetBoxText(INDICATE_ROBOT_ARM2, "", "Robot"); |
| | | |
| | | |
| | | // Vacuum bake |
| | | m_pGraph->AddIndicateBox(INDICATE_VACUUM_BAKE, 396, 516, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_VACUUM_BAKE, 396, 516, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_VACUUM_BAKE, "9", "Vacuum bake"); |
| | | m_pGraph->SetBoxText(INDICATE_VACUUM_BAKE, "", "Vacuum bake"); |
| | | |
| | | |
| | | // Bake cooling |
| | | m_pGraph->AddIndicateBox(INDICATE_BAKE_COOLING, 566, 516, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_BAKE_COOLING, 566, 516, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_BAKE_COOLING, "12", "Bake cooling"); |
| | | m_pGraph->SetBoxText(INDICATE_BAKE_COOLING, "", "Bake cooling"); |
| | | |
| | | |
| | | // 精度检 |
| | | m_pGraph->AddIndicateBox(INDICATE_MEASUREMENT, 737, 516, 48, RGB(22, 22, 22), |
| | | m_pGraph->AddIndicateBox(INDICATE_MEASUREMENT, 737, 516, boxSize, RGB(22, 22, 22), |
| | | RGB(255, 127, 39), EQ_BOX_OFFLINE); |
| | | m_pGraph->SetBoxText(INDICATE_MEASUREMENT, "13", "Measurement"); |
| | | m_pGraph->SetBoxText(INDICATE_MEASUREMENT, "", "Measurement"); |
| | | |
| | | // slot bar positions (top row / bottom row) |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_BONDER1, SlotBarPos::Top); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_FLIPER, SlotBarPos::Top); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_ALIGNER, SlotBarPos::Top); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_LPORT4, SlotBarPos::Top); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_LPORT3, SlotBarPos::Top); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_LPORT2, SlotBarPos::Top); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_LPORT1, SlotBarPos::Top); |
| | | |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_BONDER2, SlotBarPos::Bottom); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_VACUUM_BAKE, SlotBarPos::Bottom); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_BAKE_COOLING, SlotBarPos::Bottom); |
| | | m_pGraph->SetIndicateBoxSlotBarPosition(INDICATE_MEASUREMENT, SlotBarPos::Bottom); |
| | | |
| | | UpdateSlotBars(); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // 异常: OCX 属性页应返回 FALSE |
| | |
| | | CRect rcClient; |
| | | GetClientRect(&rcClient); |
| | | GetDlgItem(IDC_SERVO_GRAPH1)->MoveWindow(0, 0, rcClient.Width(), rcClient.Height()); |
| | | UpdateLegendPosition(); |
| | | } |
| | | |
| | | void CPageGraph1::UpdateRobotPosition(float percentage) |
| | |
| | | m_lastRobotPosition = position; |
| | | } |
| | | |
| | | void CPageGraph1::StartRobotMoveToPosition(SERVO::ROBOT_POSITION position) |
| | | { |
| | | auto it = g_positionMap.find(position); |
| | | if (it == g_positionMap.end()) { |
| | | TRACE("Invalid robot position: %d\n", static_cast<int>(position)); |
| | | return; |
| | | } |
| | | |
| | | const RobotPositionMapping& mapping = it->second; |
| | | |
| | | auto* pImage = m_pGraph->GetImage(IMAGE_ROBOT); |
| | | if (!pImage) return; |
| | | |
| | | m_nRobotMoveStartX = pImage->x; |
| | | m_nRobotMoveEndX = static_cast<int>(170 + mapping.percentage * (700 - 170)); |
| | | |
| | | m_nRobotMoveStartAngle = pImage->angle; // 起始角度(当前角度) |
| | | m_nRobotMoveEndAngle = mapping.angle; // 目标角度 |
| | | |
| | | m_nRobotMoveCurrentStep = 0; |
| | | m_targetRobotPosition = position; |
| | | m_bIsRobotMoving = TRUE; |
| | | |
| | | SetTimer(TIMER_ID_ROBOT_ANIMATION, 16, nullptr); |
| | | } |
| | | |
| | | POINT CPageGraph1::LoadArmOffset(const std::string& armName) |
| | | { |
| | | std::string iniPath = GetConfigPath(); |
| | |
| | | pt.x = GetPrivateProfileIntA("Offsets", (armName + "_X").c_str(), 0, iniPath.c_str()); |
| | | pt.y = GetPrivateProfileIntA("Offsets", (armName + "_Y").c_str(), 0, iniPath.c_str()); |
| | | return pt; |
| | | } |
| | | |
| | | |
| | | void CPageGraph1::UpdateSlotBars() |
| | | { |
| | | if (m_pGraph == nullptr) return; |
| | | |
| | | if (m_slotBarTestMode != 0) { |
| | | ApplySlotBarTestPattern(m_slotBarTestMode); |
| | | return; |
| | | } |
| | | |
| | | struct SlotBarBind { |
| | | int eqId; |
| | | int indicateId; |
| | | }; |
| | | static const SlotBarBind kSlotBars[] = { |
| | | { EQ_ID_Bonder1, INDICATE_BONDER1 }, |
| | | { EQ_ID_FLIPER, INDICATE_FLIPER }, |
| | | { EQ_ID_ALIGNER, INDICATE_ALIGNER }, |
| | | { EQ_ID_LOADPORT4, INDICATE_LPORT4 }, |
| | | { EQ_ID_LOADPORT3, INDICATE_LPORT3 }, |
| | | { EQ_ID_LOADPORT2, INDICATE_LPORT2 }, |
| | | { EQ_ID_LOADPORT1, INDICATE_LPORT1 }, |
| | | { EQ_ID_Bonder2, INDICATE_BONDER2 }, |
| | | { EQ_ID_VACUUMBAKE, INDICATE_VACUUM_BAKE }, |
| | | { EQ_ID_BAKE_COOLING, INDICATE_BAKE_COOLING }, |
| | | { EQ_ID_MEASUREMENT, INDICATE_MEASUREMENT }, |
| | | }; |
| | | |
| | | for (const auto& item : kSlotBars) { |
| | | SERVO::CEquipment* pEq = theApp.m_model.m_master.getEquipment(item.eqId); |
| | | std::vector<COLORREF> colors; |
| | | BuildSlotColors(pEq, colors); |
| | | m_pGraph->SetIndicateBoxSlotColors(item.indicateId, colors); |
| | | } |
| | | } |
| | | |
| | | void CPageGraph1::BuildSlotColors(SERVO::CEquipment* pEq, std::vector<COLORREF>& colors) |
| | | { |
| | | colors.clear(); |
| | | if (pEq == nullptr) return; |
| | | |
| | | for (int i = 0; i < SLOT_MAX; ++i) { |
| | | SERVO::CSlot* pSlot = pEq->getSlot(i); |
| | | if (pSlot == nullptr || !pSlot->isEnable()) continue; |
| | | SERVO::CGlass* pGlass = (SERVO::CGlass*)pSlot->getContext(); |
| | | BOOL isProcessing = FALSE; |
| | | if (pGlass != nullptr) { |
| | | const auto st = pEq->getProcessState(i + 1); |
| | | isProcessing = (st == SERVO::PROCESS_STATE::Processing); |
| | | } |
| | | colors.push_back(GetSlotColor(pGlass, isProcessing)); |
| | | } |
| | | } |
| | | |
| | | COLORREF CPageGraph1::GetSlotColor(SERVO::CGlass* pGlass, BOOL isProcessing) |
| | | { |
| | | if (pGlass == nullptr) { |
| | | return EQ_SLOT_EMPTY; |
| | | } |
| | | const auto type = pGlass->getType(); |
| | | const bool isG2 = (type == SERVO::MaterialsType::G2 || type == SERVO::MaterialsType::G1G2); |
| | | if (isProcessing) { |
| | | return isG2 ? EQ_SLOT_PROC_G2 : EQ_SLOT_PROC_G1; |
| | | } |
| | | return isG2 ? EQ_SLOT_G2 : EQ_SLOT_G1; |
| | | } |
| | | |
| | | void CPageGraph1::ApplySlotBarTestPattern(int mode) |
| | | { |
| | | if (m_pGraph == nullptr) return; |
| | | |
| | | std::vector<COLORREF> colors; |
| | | colors.reserve(SLOT_MAX); |
| | | for (int i = 0; i < SLOT_MAX; ++i) { |
| | | if (mode == 2) { |
| | | colors.push_back((i % 2 == 0) ? EQ_SLOT_PROC_G1 : EQ_SLOT_PROC_G2); |
| | | } else if (mode == 1) { |
| | | colors.push_back((i % 2 == 0) ? EQ_SLOT_G1 : EQ_SLOT_G2); |
| | | } else { |
| | | colors.push_back(EQ_SLOT_EMPTY); |
| | | } |
| | | } |
| | | |
| | | struct SlotBarBind { |
| | | int indicateId; |
| | | }; |
| | | static const SlotBarBind kSlotBars[] = { |
| | | { INDICATE_BONDER1 }, |
| | | { INDICATE_FLIPER }, |
| | | { INDICATE_ALIGNER }, |
| | | { INDICATE_LPORT4 }, |
| | | { INDICATE_LPORT3 }, |
| | | { INDICATE_LPORT2 }, |
| | | { INDICATE_LPORT1 }, |
| | | { INDICATE_BONDER2 }, |
| | | { INDICATE_VACUUM_BAKE }, |
| | | { INDICATE_BAKE_COOLING }, |
| | | { INDICATE_MEASUREMENT }, |
| | | }; |
| | | |
| | | for (const auto& item : kSlotBars) { |
| | | m_pGraph->SetIndicateBoxSlotColors(item.indicateId, colors); |
| | | } |
| | | } |
| | | |
| | | void CPageGraph1::SaveArmOffset(const std::string& armName, const POINT& pt) |
| | |
| | | { |
| | | BYSERVOGRAPH_NMHDR* pGraphNmhdr = reinterpret_cast<BYSERVOGRAPH_NMHDR*>(pNMHDR); |
| | | |
| | | if (GetKeyState(VK_SHIFT) & 0x8000) { |
| | | // m_slotBarTestMode = (m_slotBarTestMode + 1) % 3; |
| | | UpdateSlotBars(); |
| | | *pResult = 0; |
| | | return; |
| | | } |
| | | |
| | | // 移动到指定位置 (测试使用) |
| | | if (pGraphNmhdr->dwData == INDICATE_LPORT1) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Port1); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_LPORT2) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Port2); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_LPORT3) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Port3); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_LPORT4) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Port4); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_ALIGNER) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Aligner); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_FLIPER) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Fliper); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_BONDER1) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Bonder1); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_BONDER2) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Bonder2); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_VACUUM_BAKE) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Bake); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_BAKE_COOLING) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Cooling); |
| | | } |
| | | else if (pGraphNmhdr->dwData == INDICATE_MEASUREMENT) { |
| | | MoveRobotToPosition(SERVO::ROBOT_POSITION::Measurement); |
| | | |
| | | } |
| | | |
| | | *pResult = 0; |
| | |
| | | |
| | | void CPageGraph1::OnTimer(UINT_PTR nIDEvent) |
| | | { |
| | | UpdateLegendPosition(); |
| | | |
| | | if (TIMER_ID_DEVICE_STATUS == nIDEvent) { |
| | | KillTimer(TIMER_ID_DEVICE_STATUS); |
| | | |
| | |
| | | else if (nIDEvent == TIMER_ID_ROBOT_STATUS) { |
| | | SERVO::CEFEM* pEFEM = (SERVO::CEFEM*)theApp.m_model.m_master.getEquipment(EQ_ID_EFEM); |
| | | if (!pEFEM || !pEFEM->isAlive()) { |
| | | UpdateSlotBars(); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | // 位置信息状态显示 |
| | | if (robotData.position != m_lastRobotPosition) { |
| | | MoveRobotToPosition(robotData.position); |
| | | StartRobotMoveToPosition(robotData.position); |
| | | } |
| | | |
| | | UpdateSlotBars(); |
| | | } |
| | | else if (nIDEvent == TIMER_ID_ROBOT_ANIMATION) { |
| | | if (!m_bIsRobotMoving) { |
| | | KillTimer(TIMER_ID_ROBOT_ANIMATION); |
| | | return; |
| | | } |
| | | |
| | | m_nRobotMoveCurrentStep++; |
| | | |
| | | float progress = static_cast<float>(m_nRobotMoveCurrentStep) / m_nRobotMoveSteps; |
| | | if (progress >= 1.0f) { |
| | | progress = 1.0f; |
| | | m_bIsRobotMoving = FALSE; |
| | | KillTimer(TIMER_ID_ROBOT_ANIMATION); |
| | | m_lastRobotPosition = m_targetRobotPosition; |
| | | } |
| | | |
| | | // 平滑计算位置 |
| | | int currentX = static_cast<int>(m_nRobotMoveStartX + progress * (m_nRobotMoveEndX - m_nRobotMoveStartX)); |
| | | auto* pImage = m_pGraph->GetImage(IMAGE_ROBOT); |
| | | if (!pImage) return; |
| | | |
| | | int cx = currentX + pImage->bmWidth / 2; |
| | | int y = 270; |
| | | int cy = y + pImage->bmHeight / 2; |
| | | |
| | | // 平滑计算角度 |
| | | float currentAngle = m_nRobotMoveStartAngle + progress * (m_nRobotMoveEndAngle - m_nRobotMoveStartAngle); |
| | | float radians = currentAngle * 3.1415926f / 180.0f; |
| | | |
| | | int rotatedX1 = static_cast<int>(cos(radians) * m_arm1Offset.x - sin(radians) * m_arm1Offset.y); |
| | | int rotatedY1 = static_cast<int>(sin(radians) * m_arm1Offset.x + cos(radians) * m_arm1Offset.y); |
| | | int rotatedX2 = static_cast<int>(cos(radians) * m_arm2Offset.x - sin(radians) * m_arm2Offset.y); |
| | | int rotatedY2 = static_cast<int>(sin(radians) * m_arm2Offset.x + cos(radians) * m_arm2Offset.y); |
| | | |
| | | m_pGraph->UpdateImageCoordinates(IMAGE_ROBOT, currentX, y); |
| | | m_pGraph->UpdateIndicateBoxCoordinates(INDICATE_ROBOT_ARM1, cx + rotatedX1, cy + rotatedY1); |
| | | m_pGraph->UpdateIndicateBoxCoordinates(INDICATE_ROBOT_ARM2, cx + rotatedX2, cy + rotatedY2); |
| | | m_pGraph->UpdateImageAngle(IMAGE_ROBOT, currentAngle); |
| | | |
| | | Invalidate(); |
| | | } |
| | | |
| | | CDialogEx::OnTimer(nIDEvent); |