| | |
| | | } |
| | | } |
| | | |
| | | void CModel::setPortCassetteType(unsigned int index, SERVO::CassetteType type) |
| | | { |
| | | m_master.setPortCassetteType(index, type); |
| | | m_configuration.setPortCassetteType(index, (int)type); |
| | | } |
| | | |
| | | int CModel::init() |
| | | { |
| | | CString strIniFile; |
| | |
| | | notify(RX_CODE_MASTER_STATE_CHANGED); |
| | | }; |
| | | masterListener.onEqAlive = [&](void* pMaster, SERVO::CEquipment* pEquipment, BOOL bAlive) -> void { |
| | | LOGI("<CModel>Equipment onAlive:%s(%s).\n", pEquipment->getName().c_str(), |
| | | LOGI("<CModel>Equipment onAlive:%s(%s).", pEquipment->getName().c_str(), |
| | | bAlive ? _T("ON") : _T("OFF")); |
| | | notifyPtr(RX_CODE_EQ_ALIVE, pEquipment); |
| | | |
| | | }; |
| | | masterListener.onEqCimStateChanged = [&](void* pMaster, SERVO::CEquipment* pEquipment, BOOL bOn) -> void { |
| | | LOGI("<CModel>Equipment Cim State:%s(%s).\n", pEquipment->getName().c_str(), |
| | | LOGI("<CModel>Equipment Cim State:%s(%s).", pEquipment->getName().c_str(), |
| | | bOn ? _T("ON") : _T("OFF")); |
| | | notifyPtr(RX_CODE_EQ_ALIVE, pEquipment); |
| | | |
| | |
| | | } |
| | | |
| | | // 任务描述与 ID 用于日志 |
| | | SERVO::CGlass* pGlass = (SERVO::CGlass*)pTask->getContext(); |
| | | const std::string& strDesc = pTask->getDescription(); |
| | | const std::string& strClassID = pTask->getId(); |
| | | std::string strClassID; |
| | | if (pGlass != nullptr) { |
| | | strClassID = pGlass->getID(); |
| | | if (pGlass->getBuddy() != nullptr) { |
| | | strClassID += "/"; |
| | | strClassID += pGlass->getBuddy()->getID(); |
| | | } |
| | | } |
| | | |
| | | // 日志输出与状态处理 |
| | | switch (code) { |
| | |
| | | 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()); |
| | |
| | | |
| | | // 安全格式化时间 |
| | | auto format_time = [](time_t t) -> std::string { |
| | | if (t < 0 || t == _I64_MIN || t == _I64_MAX) { |
| | | if (t <= 0 || t == _I64_MIN || t == _I64_MAX) { |
| | | return ""; |
| | | } |
| | | |
| | |
| | | |
| | | // 状态映射 |
| | | static const char* STATUS_STR[] = { |
| | | "Unknown", "Ready", "Running", "Error", "Abort", "Completed" |
| | | "Ready", "Running", "Picking", "Picked", "Placing", "Restoring", "Error", "Abort", "Restored", "Completed" |
| | | }; |
| | | auto state = pTask->getState(); |
| | | int index = static_cast<int>(state); |
| | | if (index > 0 && index < static_cast<int>(std::size(STATUS_STR))) { |
| | | if (index >= 0 && index < static_cast<int>(std::size(STATUS_STR))) { |
| | | data.strStatus = STATUS_STR[index]; |
| | | } |
| | | else { |
| | | data.strStatus = STATUS_STR[0]; |
| | | data.strStatus = "Unknown"; |
| | | } |
| | | |
| | | // 写入数据库 |
| | | int nRecordId = 0; |
| | | TransferManager::getInstance().addTransferRecord(data, nRecordId); |
| | | |
| | | if (code == ROBOT_EVENT_FINISH || code == ROBOT_EVENT_ERROR |
| | | || code == ROBOT_EVENT_ABORT || code == ROBOT_EVENT_RESTORE) { |
| | | int nRecordId = 0; |
| | | TransferManager::getInstance().addTransferRecord(data, nRecordId); |
| | | LOGI("<CModel>onRobotTaskEvent: 任务记录已保存,RecordID=%d", nRecordId); |
| | | } |
| | | notifyPtrAndInt(RX_CODE_EQ_ROBOT_TASK, pTask, nullptr, code); |
| | | LOGI("<CModel>onRobotTaskEvent: 任务记录已保存,RecordID=%d", nRecordId); |
| | | |
| | | }; |
| | | masterListener.onLoadPortInUse = [&] (void* pMaster, SERVO::CEquipment* pEquipment, short scanMap) { |
| | | LOGE("<CModel>onLoadPortInUse. scanMap = %d", scanMap); |
| | | notifyPtr(RX_CODE_LOADPORT_INUSE, pEquipment); |
| | | }; |
| | | m_master.setListener(masterListener); |
| | | |
| | |
| | | CString strMasterDataFile; |
| | | strMasterDataFile.Format(_T("%s\\Master.dat"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | m_master.setCacheFilepath((LPTSTR)(LPCTSTR)strMasterDataFile); |
| | | |
| | | m_master.setCompareMapsBeforeProceeding(m_configuration.isCompareMapsBeforeProceeding()); |
| | | |
| | | // 加载警告信息 |
| | | AlarmManager& alarmManager = AlarmManager::getInstance(); |