1.修复 :
多 PJ 支持仍是单槽实现:isProcessJobsEmpty/validate 仍只允许 1 个 PJ/CJ;Host 一次下多 PJ 或运行中追加 PJ 会被拒绝/无明确反馈。需要:协议上明示只支持 1,或补齐 ACK/NAK 与队列管理、PJobSpace 动态更新。
| | |
| | | for (auto p : pjs) { |
| | | LOGI("<Model>onPRJobMultiCreate %s %s", p->id().c_str(), p->recipeSpec().c_str()); |
| | | } |
| | | |
| | | auto rejectAll = [&](uint32_t code, const std::string& msg) -> int { |
| | | LOGW("<Model>onPRJobMultiCreate rejected: %s", msg.c_str()); |
| | | for (auto p : pjs) { |
| | | if (p != nullptr) p->addIssue(code, msg); |
| | | } |
| | | return -1; |
| | | }; |
| | | |
| | | // 单 PJ 模式:只接受 1 条且当前无在制 PJ |
| | | if (pjs.size() != 1) { |
| | | return rejectAll(1200, "Only 1 ProcessJob supported (single-PJ mode)"); |
| | | } |
| | | if (!m_master.isProcessJobsEmpty()) { |
| | | return rejectAll(1201, "ProcessJob exists, cannot create new in single-PJ mode"); |
| | | } |
| | | |
| | | int nRet = m_master.setProcessJobs(pjs); |
| | | auto processJobs = m_master.getProcessJobs(); |
| | | std::vector<SERVO::CVariable> vars; |
| | |
| | | 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) |
| | | { |
| | | m_issues.clear(); |
| | |
| | | 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"); |
| | |
| | | // 返回问题清单(空=通过) |
| | | bool validate(const IResourceView& rv); |
| | | const std::vector<ValidationIssue>& issues() const; |
| | | void addIssue(uint32_t code, const std::string& msg); |
| | | |
| | | // —— 状态机(带守卫)—— |
| | | bool queue(); // NoState -> Queued |