From 7ff57d1c8b155826b72ef627f367734ec9c0c412 Mon Sep 17 00:00:00 2001 From: bogachev-pa Date: Wed, 8 Oct 2014 00:35:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BF=D0=BE=D1=80=D1=8F=D0=B4=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BB=D0=BA=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20SMR?= =?UTF-8?q?=20(#21)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simulator/compiler/parser/grammar/rdoevn.yx | 8 +++----- simulator/compiler/parser/rdoparser.cpp | 8 +++++++- simulator/compiler/parser/rdosmr.cpp | 8 ++++---- simulator/compiler/parser/rdosmr.h | 6 ++++++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/simulator/compiler/parser/grammar/rdoevn.yx b/simulator/compiler/parser/grammar/rdoevn.yx index 475cfb35c..528c86318 100644 --- a/simulator/compiler/parser/grammar/rdoevn.yx +++ b/simulator/compiler/parser/grammar/rdoevn.yx @@ -9520,11 +9520,9 @@ smr_main { #PASS2 { - PARSER->error().error(@1, @3, "Невозможно изменить параметр ресурса до запуска модели"); - // TODO вернуть возможность изменить параметр ресурса во вкладке SMR - // LPRDOFUNArithm pArithm = PARSER->stack().pop($5); - // ASSERT(pArithm); - // PARSER->getSMR()->setResParValue(PARSER->stack().pop($1)->src_info(), PARSER->stack().pop($3)->src_info(), pArithm); + LPRDOFUNArithm pArithm = PARSER->stack().pop($5); + ASSERT(pArithm); + PARSER->getSMR()->setResParValue(PARSER->stack().pop($1)->src_info(), PARSER->stack().pop($3)->src_info(), pArithm); } } | RDO_IDENTIF '.' RDO_Seed '=' RDO_INT_CONST diff --git a/simulator/compiler/parser/rdoparser.cpp b/simulator/compiler/parser/rdoparser.cpp index b9750067f..0b823e227 100644 --- a/simulator/compiler/parser/rdoparser.cpp +++ b/simulator/compiler/parser/rdoparser.cpp @@ -346,7 +346,7 @@ Context::LPFindResult RDOParser::onFindContext(const std::string& method, const } } } - + } return rdo::Factory::create(); @@ -531,6 +531,12 @@ void RDOParser::runRSSPost() void RDOParser::runSMRPost() { + //! Калки, созданные в SMR + const std::vector calcList = m_pSMR->getCalcList(); + for (const rdo::runtime::LPRDOCalc& initCalc: calcList) + { + runtime()->addInitCalc(initCalc); + } //! Планирование событий, описанных в SMR for (const LPRDOPATPattern& pattern: getPATPatterns()) { diff --git a/simulator/compiler/parser/rdosmr.cpp b/simulator/compiler/parser/rdosmr.cpp index 4e49baef9..a12ae3329 100644 --- a/simulator/compiler/parser/rdosmr.cpp +++ b/simulator/compiler/parser/rdosmr.cpp @@ -3,8 +3,8 @@ \file rdosmr.cpp \authors Барс Александр \authors Урусов Андрей (rdo@rk9.bmstu.ru) - \date - \brief + \date + \brief \indent 4T */ @@ -124,7 +124,7 @@ void RDOSMR::setConstValue(const RDOParserSrcInfo& const_info, LPRDOFUNArithm& p ASSERT(pArithm); pArithm->checkParamType(pConstant->getTypeInfo()); rdo::runtime::LPRDOCalc pCalc = pArithm->createCalc(pConstant->getTypeInfo()); - RDOParser::s_parser()->runtime()->addInitCalc(rdo::Factory::create(pConstant->getNumber(), pCalc)); + this->addCalc(rdo::Factory::create(pConstant->getNumber(), pCalc)); RDOParser::s_parser()->insertChanges(pConstant->src_text(), pArithm->src_text()); } @@ -147,7 +147,7 @@ void RDOSMR::setResParValue(const RDOParserSrcInfo& res_info, const RDOParserSrc pArithm->checkParamType(pParam->getTypeInfo()); const std::size_t parNumb = pResource->getType()->getRTPParamNumber(par_info.src_text()); rdo::runtime::LPRDOCalc pCalc = pArithm->createCalc(pParam->getTypeInfo()); - RDOParser::s_parser()->runtime()->addInitCalc(rdo::Factory::create(pResource->getID(), parNumb, pCalc)); + this->addCalc(rdo::Factory::create(pResource->getID(), parNumb, pCalc)); RDOParser::s_parser()->insertChanges(res_info.src_text() + "." + par_info.src_text(), pArithm->src_text()); } diff --git a/simulator/compiler/parser/rdosmr.h b/simulator/compiler/parser/rdosmr.h index 4fdcb776b..4f3f815ab 100644 --- a/simulator/compiler/parser/rdosmr.h +++ b/simulator/compiler/parser/rdosmr.h @@ -70,6 +70,8 @@ DECLARE_FACTORY(RDOSMR); void setSeed (const RDOParserSrcInfo& seq_info, int base); void insertBreakPoint(const RDOParserSrcInfo& src_info, LPRDOFUNLogic& pLogic); + std::vector getCalcList() const { return m_SMRCalcList; } + private: RDOSMR(); @@ -95,6 +97,10 @@ DECLARE_FACTORY(RDOSMR); YYLTYPE m_traceEndTime_pos; LPRDOFUNLogic m_pTerminateIf; BreakPointList m_breakPointList; + + void addCalc(const rdo::runtime::LPRDOCalc pCalc) { m_SMRCalcList.push_back(pCalc); } + + std::vector m_SMRCalcList; }; CLOSE_RDO_PARSER_NAMESPACE