IKeyboard::AddHotKeyResult RDOKeyboard::addHotKey(const LPRDORuntime& pRuntime, const std::string& hotKey) { RDOHotKey::KeyCode scanCode = pRuntime->hotkey().toolkit().codeFromString(hotKey); if (scanCode == RDOHotKey::UNDEFINED_KEY) return IKeyboard::AddHotKeyResult::NOTFOUND; if (m_scan_code != RDOHotKey::UNDEFINED_KEY && scanCode != VK_SHIFT && scanCode != VK_CONTROL) return IKeyboard::AddHotKeyResult::ALREADY; switch (scanCode) { case VK_SHIFT: m_shift = true; pRuntime->hotkey().keyInModel().insert(VK_SHIFT); break; case VK_CONTROL: m_control = true; pRuntime->hotkey().keyInModel().insert(VK_CONTROL); break; default: m_scan_code = scanCode; if (m_scan_code) { pRuntime->hotkey().keyInModel().insert(scanCode); } break; } return IKeyboard::AddHotKeyResult::OK; }
bool RDOPROCSeize::onCheckCondition(const LPRDORuntime& pRuntime) { if (m_transacts.empty()) return false; const std::size_t Size_Seizes = forRes.size(); for (std::size_t i = 0; i < Size_Seizes; i++) { // если свободен if (forRes[i].rss->getParam(forRes[i].Id_param) == forRes[i].enum_free) { const std::size_t idBlocksTransact = m_transacts.front()->getTraceID(); const std::size_t idResourcesTransact = forRes[i].rss->transacts.front()->getTraceID(); if (idBlocksTransact != idResourcesTransact) return false; RDOTrace* tracer = pRuntime->getTracer(); forRes[i].rss->setParam(forRes[i].Id_param, forRes[i].enum_buzy); TRACE3("%7.1f SEIZES-%d, resId = %d\n", pRuntime->getCurrentTime(), index, forRes[i].rss->getTraceID()); if (!tracer->isNull()) tracer->getOStream() << forRes[i].rss->traceResourceState('\0', pRuntime) << tracer->getEOL(); m_transacts.front()->setRes(forRes[i].rss); return true; } } return false; }
bool RDOKeyboard::choiceFrom(const LPRDORuntime& pRuntime) { pRuntime->setCurrentActivity(this); if (!pRuntime->hotkey().areaList().check(m_oprName)) { if (!pRuntime->hotkey().keyDown().isPressed(m_scan_code, m_shift, m_control)) return false; } return RDOOperation::choiceFrom(pRuntime); }
LPRDORuntime RDORuntime::clone() const { LPRDORuntime pRuntime = rdo::Factory<RDORuntime>::create(m_pError); ASSERT(pRuntime); pRuntime->m_sizeofSim = sizeof(RDORuntime); LPRDORuntime pThis(const_cast<RDORuntime*>(this)); pRuntime->copyFrom(pThis); return pRuntime; }
// -------------------------------------------------------------------------------- // -------------------- RDOFunCalcNotExist // -------------------------------------------------------------------------------- RDOValue RDOFunCalcNotExist::doCalc(const LPRDORuntime& pRuntime) { bool res = true; RDORuntime::ResCIterator end = pRuntime->getResType(m_nResType)->res_end(); for (RDORuntime::ResCIterator it = pRuntime->getResType(m_nResType)->res_begin(); it != end && res; it++) { if (*it == LPRDOResource(NULL)) continue; pRuntime->pushGroupFunc(*it); if (m_pCondition->calcValue(pRuntime).getAsBool()) res = false; pRuntime->popGroupFunc(); } return RDOValue(res); }
void RDOPROCBlockForQueue::_onStart(const LPRDORuntime& pRuntime) { int Id_res = fromParser.Id_res; int Id_param = fromParser.Id_param; LPRDOResource res = pRuntime->getResourceByID(Id_res); forRes.Id_param = Id_param; forRes.rss = res.object_static_cast<RDOPROCResource>(); forRes.defaultValue = RDOValue(RDOPROCQueue::getDefaultValue()); }
bool RDOPROCRelease::onCheckCondition(const LPRDORuntime& pRuntime) { if (!m_transacts.empty()) { int Size_Seizes = forRes.size(); for(int i=0;i<Size_Seizes; i++) { if(forRes[i].rss == m_transacts.front()->getRes()) { // Занят if (forRes[i].rss->getParam(forRes[i].Id_param) == forRes[i].enum_buzy) { RDOTrace* tracer = pRuntime->getTracer(); TRACE3("%7.1f RELEASES-%d, resId = %d\n", pRuntime->getCurrentTime(), index, forRes[i].rss->getTraceID()); forRes[i].rss->setParam(forRes[i].Id_param, forRes[i].enum_free); if (!tracer->isNull()) { tracer->getOStream() << forRes[i].rss->traceResourceState('\0', pRuntime) << tracer->getEOL(); } return true; } // Не Занят и не свободен if (forRes[i].rss->getParam(forRes[i].Id_param) != forRes[i].enum_free) { //Удаляем транзакт RDOTrace* tracer = pRuntime->getTracer(); TRACE3("%7.1f RELEASES_Bad-%d, resId = %d\n", pRuntime->getCurrentTime(), index, forRes[i].rss->getTraceID()); LPRDOPROCTransact transact = m_transacts.front(); ASSERT(transact); transact->setState(RDOResource::CS_Erase); if (!tracer->isNull()) { tracer->getOStream() << transact->traceResourceState('\0', pRuntime) << tracer->getEOL(); } m_transacts.remove(transact); forRes[i].rss->transacts.remove(transact); pRuntime->onEraseRes(transact->getTraceID(), NULL); return false; } } } } return false; }
RDOValue RDOCalcFunctionCaller::doCalc(const LPRDORuntime& pRuntime) { pRuntime->pushFuncTop(); for (const auto& param: m_paramList) { pRuntime->pushFuncArgument(param->calcValue(pRuntime)); } pRuntime->resetFuncTop(m_paramList.size()); RDOValue value = m_pFunction->calcValue(pRuntime); for (std::size_t i = 0; i < m_paramList.size(); ++i) { pRuntime->popFuncArgument(); } pRuntime->popFuncTop(); return value; }
// -------------------------------------------------------------------------------- // -------------------- RDOFunCalcForAll // -------------------------------------------------------------------------------- RDOValue RDOFunCalcForAll::doCalc(const LPRDORuntime& pRuntime) { bool first_found = false; bool res = true; RDORuntime::ResCIterator end = pRuntime->getResType(m_nResType)->res_end(); for (RDORuntime::ResCIterator it = pRuntime->getResType(m_nResType)->res_begin(); it != end && res; it++) { if (*it == LPRDOResource(NULL)) continue; pRuntime->pushGroupFunc(*it); if (!m_pCondition->calcValue(pRuntime).getAsBool()) { res = false; } else if (!first_found) { first_found = true; } pRuntime->popGroupFunc(); } return RDOValue(first_found ? res : false); }
OPEN_RDO_RUNTIME_NAMESPACE // -------------------------------------------------------------------------------- // -------------------- RDODPTSearchRuntime // -------------------------------------------------------------------------------- RDODPTSearchRuntime::RDODPTSearchRuntime(const LPRDORuntime& pRuntime, LPIBaseOperationContainer parent, const LPRDOCalc& _pCondition, const LPRDOCalc& _pTermCondition, const LPRDOCalc& _pEvaluateBy, bool _compTops, RDODPTSearchTrace::TraceFlag _traceFlag) : RDODPTSearchTrace(pRuntime, parent) , pCondition (_pCondition ) , pTermCondition (_pTermCondition ) , pEvaluateBy (_pEvaluateBy ) , compTops (_compTops ) { setTraceID(pRuntime->getFreeDPTId()); traceFlag = _traceFlag; }
RDOValue RDOFunAlgorithmicCalc::doCalc(const LPRDORuntime& pRuntime) { RDOCalcList::const_iterator actionIt = m_actionList.begin(); for (const auto& condition: m_conditionList) { if (condition->calcValue(pRuntime).getAsBool()) { return (*actionIt)->calcValue(pRuntime); } ++actionIt; } // До сюда дело дойти не должно, т.к. последний conditions должен быть значением по молчанию pRuntime->error().push("Внутренняя ошибка, RDOFunAlgorithmicCalc", srcInfo()); return RDOValue(); }
void RDOPROCBlockForSeize::_onStart(const LPRDORuntime& pRuntime) { /// @todo: если потребуется стоить деревья, вершинами которых будут полные снимки БД, // как при DPT search, то инициализацию атрибутов надо будет делать в checkOperation std::vector<parser_for_Seize>::iterator it1 = fromParser.begin(); while (it1 != fromParser.end()) { int Id_res = (*it1).Id_res; int Id_param = (*it1).Id_param; LPRDOResource res = pRuntime->getResourceByID(Id_res); runtime_for_Seize bbb; bbb.Id_param = Id_param; bbb.rss = res.object_static_cast<RDOPROCResource>(); bbb.enum_free = RDOValue(bbb.rss->getParam(Id_param).getEnum(), RDOPROCBlockForSeize::getStateEnumFree()); bbb.enum_buzy = RDOValue(bbb.rss->getParam(Id_param).getEnum(), RDOPROCBlockForSeize::getStateEnumBuzy()); forRes.push_back(bbb); ++it1; } }
void RDORuntime::copyFrom(const LPRDORuntime& pOther) { ASSERT(pOther); ASSERT(m_resourceTypeList.empty()); LPRDORuntime pThis(const_cast<RDORuntime*>(this)); for (const LPRDOResourceTypeList& pRTP: pOther->m_resourceTypeList) { pRTP->clone(pThis); } m_constantList = pOther->m_constantList; m_patternParameterList = pOther->m_patternParameterList; m_resultList = pOther->m_resultList; m_pThreadProxy = pOther->m_pThreadProxy; setCurrentTime(pOther->getCurrentTime()); parent_type::copyFrom(pOther.object_parent_cast<parent_type>()); }
RDOValue RDOCalcSetConst::doCalc(const LPRDORuntime& pRuntime) { pRuntime->setConstValue(m_constantID, m_pCalc->calcValue(pRuntime)); return RDOValue(); }
RDOValue RDOCalcGetConst::doCalc(const LPRDORuntime& pRuntime) { return pRuntime->getConstValue(m_constantID); }
RDOValue RDOCalcFuncParam::doCalc(const LPRDORuntime& pRuntime) { return pRuntime->getFuncArgument(m_paramID); }