Opened 15 years ago
Last modified 14 years ago
#1229 closed defect (fixed)
Watchdog model fails on if-equations
Reported by: | Per Östlund | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | ||
Keywords: | Cc: | Per Östlund, AlexeyLebedev |
Description
The attached model gives the following error message:
true record SimulationResult resultFile = "Simulation failed. Error: The language feature if-equations is not supported. Suggested workaround: rewrite equations using if-expressions: equation if dm.watch_dog.battery_level > 0.0 then if dm.watch_dog.Operation_Modes.Region_0.Active.active OR dm.watch_dog.Operation_Modes.Region_0.Alarmed.active then der(dm.watch_dog.battery_level) = -1.0; else der(dm.watch_dog.battery_level) = 0.0; end if; else der(dm.watch_dog.battery_level) = 0.0; end if; " end SimulationResult;
If equations does normally work, since they are automatically rewritten to if-expressions, but in this case that seems to fail. The attached zip-file includes the model itself as well as a Word document that shows the settings and output in MathModelica.
Attachments (1)
Change History (3)
by , 15 years ago
Attachment: | Watchdog.zip added |
---|
comment:1 by , 15 years ago
The bug was caused by if-equation having another if-equation in one of the branches. I have implemented translation of such if-equations to normal equations with if-expressions in revision 5572.
Also, such equations could have wrong equation count. For example, the following equation:
{{{ if bool then
if z>0 then
x=z;
y=z;
else
x=-z;
y=-z;
end if;
else
x=0;
y=0;
end if;}}}
would be considered to have 1 equation in true branch and 2 equations in false branch. I have fixed this, also.
Watchdog model