OMSimulator
OMSimulator copied to clipboard
Zero values in connectors are replaced with initial value
Description
Zero simulated values are not read from system connectors, but are replaced with initial values.
Steps to reproduce the behavior
- Create a model where data is read from a connector with a non-zero initial value.
- Pass a value of zero to the connector.
- Read the connector.
- Instead of zero, the initial value is returned.
Screenshots
The attached simple SSP with an SCSystem inside a WCSystem:
Output from "pulse" is an alternating value between 220 and 0. Input to "SCSystem" is a flat line of 220.0.
Cause
This is caused by the condition in oms::System::getReal() for checking the existence of a simulated value.
if (oms_modelState_simulation == getModel().getModelState() && values.realValues[cref] != 0.0)
It should check for the existence of a value in the map instead of comparing it against zero.