Book a Demo

Author Topic: SIMULATION ERROR: ... is undefined Expression ...  (Read 2277 times)

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
SIMULATION ERROR: ... is undefined Expression ...
« on: April 25, 2024, 04:13:32 pm »
Code: [Select]
[1209933004]      SIMULATION ERROR: sim.Discrete_28VDC is undefined Expression: sim['Discrete_28VDC']['status']=1;

I'm trying to get a statechart simulation to work but ran into the message above when triggering an event based on a signal. The signal is recognized because I get the dialog box showing the signal attribute "status". I type in a 1, and the message above immediately prints out in red in the simulation tab. The transition is labeled like this:

Guard: sim.Discrete_28VDC.status==1
Trigger name: Discrete_28VDC
Trigger type: Discrete_28VDC
Trigger specification: Discrete_28VDC

The signal is defined in a package called "1-Input-Output Definitions" at the top level package in Model > Context. The block containing the statechart is in a separate package at the following level: Model > Context > SoI > 1-Black Box Specification > 2-Structure > <<block>> SoI > statechart

The problem seems to be related to scope, but I find it rather strange that EA cannot resolve signals located elsewhere in the model. The signal I am using will be used by other subsystems and I cannot be making copies of the signal in other packages.

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
Re: SIMULATION ERROR: ... is undefined Expression ...
« Reply #1 on: April 25, 2024, 10:51:30 pm »
I FINALLY figured it out. It's all about scope, and the solution is a package import. You can define signals anywhere in the model, and then use a package import to get access to those signals. The documentation in EA was the key to the answer:

Quote
If the diagram contains any external elements (those not in the same Package as the diagram) you will have to create an
Import connector from the diagram's Package to the Package containing the external elements. To do this, drag both
Packages from the Browser window onto a diagram and then use the Quick Linker arrow to create the connector between
them.

When a simulation starts, the scope for sim is the current package. That explained why signals defined in the same package worked. Anything outside of the package is of course out of scope and needs to be imported.