| | |
| | | |
| | | namespace SERVO { |
| | | static inline std::string trimCopy(std::string s) { |
| | | auto notspace = [](int ch) { return !std::isspace(ch); }; |
| | | s.erase(s.begin(), std::find_if(s.begin(), s.end(), notspace)); |
| | | s.erase(std::find_if(s.rbegin(), s.rend(), notspace).base(), s.end()); |
| | | s.erase(s.begin(), |
| | | std::find_if(s.begin(), s.end(), |
| | | [](char c) { return !std::isspace(static_cast<unsigned char>(c)); })); |
| | | s.erase(std::find_if(s.rbegin(), s.rend(), |
| | | [](char c) { return !std::isspace(static_cast<unsigned char>(c)); }).base(), |
| | | s.end()); |
| | | return s; |
| | | } |
| | | |
| | |
| | | CProcessJob::CProcessJob(std::string pjId) |
| | | : m_pjId(trimCopy(pjId)) |
| | | { |
| | | clampString(m_pjId, MAX_ID_LEN); |
| | | } |
| | | |
| | | void CProcessJob::setId(std::string& id) |
| | | { |
| | | m_pjId = trimCopy(id); |
| | | clampString(m_pjId, MAX_ID_LEN); |
| | | } |
| | | |
| | |
| | | m_pauseEvents.erase(std::unique(m_pauseEvents.begin(), m_pauseEvents.end()), m_pauseEvents.end()); |
| | | } |
| | | |
| | | const std::vector<CProcessJob::ValidationIssue>& CProcessJob::issues() |
| | | const std::vector<CProcessJob::ValidationIssue>& CProcessJob::issues() const |
| | | { |
| | | return m_issues; |
| | | } |
| | | |
| | | void CProcessJob::addIssue(uint32_t code, const std::string& msg) |
| | | { |
| | | m_issues.push_back({ code, msg }); |
| | | } |
| | | |
| | | bool CProcessJob::validate(const IResourceView& rv) |
| | |
| | | auto add = [&](uint32_t code, std::string msg) { |
| | | m_issues.push_back({ code, std::move(msg) }); |
| | | }; |
| | | |
| | | if (!rv.isProcessJobsEmpty()) { |
| | | add(1000, "ProcessJobs Conflict!"); |
| | | } |
| | | |
| | | // —— 基本 / 标识 —— |
| | | if (m_pjId.empty()) add(1001, "PJID empty"); |
| | |
| | | return true; |
| | | } |
| | | |
| | | bool CProcessJob::abort() { |
| | | bool CProcessJob::abort(std::string reason) { |
| | | if (m_state == PJState::Completed || m_state == PJState::Aborted || m_state == PJState::Failed) |
| | | return false; |
| | | m_failReason = trimCopy(reason); |
| | | clampString(m_failReason, 128); |
| | | m_state = PJState::Aborted; |
| | | markEnd(); |
| | | return true; |
| | |
| | | } |
| | | } |
| | | |
| | | bool CProcessJob::setCarrierSlotsAndContexts(std::string carrierId, std::vector<uint8_t> slots, std::vector<void*> contexts) |
| | | { |
| | | for (auto& c : m_carriers) { |
| | | if (c.carrierId.compare(carrierId) == 0) { |
| | | c.slots = std::move(slots); |
| | | c.contexts = std::move(contexts); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | bool CProcessJob::setCarrierContexts(std::string carrierId, std::vector<void*> contexts) |
| | | { |
| | | for (auto& c : m_carriers) { |
| | | if (c.carrierId.compare(carrierId) == 0) { |
| | | c.contexts = std::move(contexts); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | // --------- 核心:serialize/deserialize --------- |
| | | void CProcessJob::serialize(std::ostream& os) const { |
| | | // ͷ |
| | |
| | | |
| | | // 配方 |
| | | uint8_t recipeType = static_cast<uint8_t>(m_recipeMethod); |
| | | write_pod(os, m_recipeMethod); |
| | | write_pod(os, recipeType); |
| | | write_string(os, m_recipeSpec); |
| | | |
| | | // 物料(多 Carrier & Slot) |
| | |
| | | return "InProcess"; |
| | | break; |
| | | case SERVO::PJState::Paused: |
| | | return "Queued"; |
| | | return "Paused"; |
| | | break; |
| | | case SERVO::PJState::Aborting: |
| | | return "Aborting"; |
| | | break; |
| | | case SERVO::PJState::Completed: |
| | | return "Queued"; |
| | | return "Completed"; |
| | | break; |
| | | case SERVO::PJState::Aborted: |
| | | return "Aborted"; |
| | |
| | | return ""; |
| | | } |
| | | |
| | | CarrierSlotInfo* CProcessJob::getCarrier(std::string& strId) |
| | | CarrierSlotInfo* CProcessJob::getCarrier(const std::string& strId) |
| | | { |
| | | for (auto& item : m_carriers) { |
| | | if (item.carrierId.compare(strId) == 0) { |
| | |
| | | |
| | | return nullptr; |
| | | } |
| | | |
| | | void CProcessJob::setLotId(std::string strLotId) |
| | | { |
| | | m_strLotId = strLotId; |
| | | } |
| | | |
| | | std::string& CProcessJob::getLotId() |
| | | { |
| | | return m_strLotId; |
| | | } |
| | | |
| | | void CProcessJob::setProductId(std::string strProductId) |
| | | { |
| | | m_strProductId = strProductId; |
| | | } |
| | | |
| | | std::string& CProcessJob::getProductId() |
| | | { |
| | | return m_strProductId; |
| | | } |
| | | |
| | | void CProcessJob::setOperationId(std::string strOperationId) |
| | | { |
| | | m_strOperationId = strOperationId; |
| | | } |
| | | |
| | | std::string& CProcessJob::getOperationId() |
| | | { |
| | | return m_strOperationId; |
| | | } |
| | | |
| | | void CProcessJob::setPjWarp(PJWarp pjWarp) |
| | | { |
| | | m_pjWarp = pjWarp; |
| | | } |
| | | |
| | | PJWarp& CProcessJob::getPjWarp() |
| | | { |
| | | return m_pjWarp; |
| | | } |
| | | } |