| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 读缓存数据 |
| | | readCache(); |
| | | loadState(); |
| | | |
| | | |
| | | // 定时器 |
| | |
| | | return true; |
| | | } |
| | | |
| | | bool CMaster::loadState(const std::string& path) |
| | | bool CMaster::loadState() |
| | | { |
| | | // 保存文件路径 |
| | | m_strStatePath = path; |
| | | |
| | | |
| | | std::ifstream ifs(path, std::ios::binary); |
| | | std::ifstream ifs(m_strStatePath, std::ios::binary); |
| | | if (!ifs) return false; |
| | | |
| | | // 文件头 |
| | |
| | | m_pControlJob->setPJs(tempPjs); |
| | | |
| | | |
| | | // 更新contexts |
| | | auto pjs = m_pControlJob->getPjs(); |
| | | for (auto pj : pjs) { |
| | | for (auto& c : pj->carriers()) { |
| | | auto p = getPortWithCarrierId(c.carrierId); |
| | | if (p == nullptr) continue; |
| | | |
| | | std::vector<void*> contexts; |
| | | for (auto s : c.slots) { |
| | | auto g = getGlass(p->getIndex(), s - 1); |
| | | if (g == nullptr) continue; |
| | | contexts.push_back(g); |
| | | } |
| | | pj->setCarrierContexts(c.carrierId, contexts); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 如果版本升级,可在这里判断 version 来加载新字段 |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | void CMaster::setStateFile(const std::string& path) |
| | | { |
| | | m_strStatePath = path; |
| | | } |
| | | |
| | | CProcessJob* CMaster::acquireNextProcessJob() |
| | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | CGlass* CMaster::getGlass(int scrPort, int scrSlot) |
| | | { |
| | | for (auto eq : m_listEquipment) { |
| | | std::vector<CGlass*> glasses; |
| | | eq->getAllGlass(glasses); |
| | | for (auto g : glasses) { |
| | | int p, s; |
| | | g->getOrginPort(p, s); |
| | | if (p == scrPort && s == scrSlot) { |
| | | return g; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return nullptr; |
| | | } |
| | | } |