OMSimulator icon indicating copy to clipboard operation
OMSimulator copied to clipboard

Zero values in connectors are replaced with initial value

Open rruusu opened this issue 3 weeks ago • 0 comments

Description

Zero simulated values are not read from system connectors, but are replaced with initial values.

Steps to reproduce the behavior

  1. Create a model where data is read from a connector with a non-zero initial value.
  2. Pass a value of zero to the connector.
  3. Read the connector.
  4. Instead of zero, the initial value is returned.

Screenshots

The attached simple SSP with an SCSystem inside a WCSystem:

Image

Output from "pulse" is an alternating value between 220 and 0. Input to "SCSystem" is a flat line of 220.0.

Image

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.

PWMTest.zip

rruusu avatar Dec 19 '25 15:12 rruusu