@@ -53,6 +53,7 @@ oms::Values::~Values()
5353oms_status_enu_t oms::Values::setReal (const ComRef& cref, double value)
5454{
5555 realStartValues[cref] = value;
56+
5657 // update start values in ssv template
5758 auto realValue = modelDescriptionRealStartValues.find (cref);
5859 if (realValue != modelDescriptionRealStartValues.end ())
@@ -64,6 +65,7 @@ oms_status_enu_t oms::Values::setReal(const ComRef& cref, double value)
6465oms_status_enu_t oms::Values::setInteger (const ComRef& cref, int value)
6566{
6667 integerStartValues[cref] = value;
68+
6769 // update start values in ssv template
6870 auto integerValue = modelDescriptionIntegerStartValues.find (cref);
6971 if (integerValue != modelDescriptionIntegerStartValues.end ())
@@ -75,6 +77,7 @@ oms_status_enu_t oms::Values::setInteger(const ComRef& cref, int value)
7577oms_status_enu_t oms::Values::setBoolean (const ComRef& cref, bool value)
7678{
7779 booleanStartValues[cref] = value;
80+
7881 // update start values in ssv template
7982 auto boolValue = modelDescriptionBooleanStartValues.find (cref);
8083 if (boolValue != modelDescriptionBooleanStartValues.end ())
@@ -83,6 +86,18 @@ oms_status_enu_t oms::Values::setBoolean(const ComRef& cref, bool value)
8386 return oms_status_ok;
8487}
8588
89+ oms_status_enu_t oms::Values::setString (const ComRef& cref, const std::string& value)
90+ {
91+ stringStartValues[cref] = value;
92+
93+ // update start values in ssv template
94+ auto stringValue = modelDescriptionStringStartValues.find (cref);
95+ if (stringValue != modelDescriptionStringStartValues.end ())
96+ modelDescriptionStringStartValues[cref] = value;
97+
98+ return oms_status_ok;
99+ }
100+
86101oms_status_enu_t oms::Values::getReal (const ComRef& cref, double & value)
87102{
88103 auto realValue = realStartValues.find (cref);
@@ -169,6 +184,40 @@ oms_status_enu_t oms::Values::setRealResources(const ComRef& cref, double value,
169184 return oms_status_ok;
170185}
171186
187+ oms_status_enu_t oms::Values::setStringResources (const ComRef& cref, const std::string& value, const ComRef& fullCref, bool externalInput, oms_modelState_enu_t modelState)
188+ {
189+ bool resourceAvailable = false ;
190+ for (auto &it : parameterResources)
191+ {
192+ for (auto &res : it.allresources )
193+ {
194+ // update the value in all resources, so that same cref in multiple ssv can be updated, this can result in duplication
195+ auto stringValue = res.second .stringStartValues .find (cref);
196+ if (stringValue != res.second .stringStartValues .end ())
197+ {
198+ if (oms_modelState_simulation == modelState && externalInput)
199+ res.second .stringValues [cref] = value;
200+ else
201+ res.second .setString (cref, value);
202+ resourceAvailable = true ;
203+ // return oms_status_ok; return here to avoid updating the same value in different ssv file
204+ }
205+ }
206+ }
207+
208+ if (!resourceAvailable)
209+ {
210+ auto &it = parameterResources.front ();
211+ for (auto &res : it.allresources )
212+ {
213+ // insert the new signal at the first resource available
214+ res.second .setString (cref, value);
215+ break ;
216+ }
217+ }
218+ return oms_status_ok;
219+ }
220+
172221oms_status_enu_t oms::Values::setIntegerResources (const ComRef& cref, int value, const ComRef& fullCref, bool externalInput, oms_modelState_enu_t modelState)
173222{
174223 bool resourceAvailable = false ;
0 commit comments