Shaga
Shaga

Reputation: 170

Measuring time of an event in Modelica

Is there a way to measure the time at which an event occurs (without using sample or anything similar) in Modelica? something like the tic toc command in MATLAB? what I would like to see is the difference in time when different events happen. For example, in the following sample code, is there a way to see the elapsed time using test_time1 and test_time2?

when event1 then 
 a:=2;
 event2:= true;
 test_time1 := time;
end when;
when event2 then 
a:= 5;
test_time2 := time;
end when;

Upvotes: 1

Views: 308

Answers (1)

sjoelund.se
sjoelund.se

Reputation: 3523

abs(test_time2-test_time1) should do it if you do not know which occurs first. Note that this would be the simulation time, not real (wall) time. If you want to measure the real time it takes for a simulation to trigger the two events, you need to use external C functions calling your own tic and toc.

Upvotes: 1

Related Questions