Help - Search - Members - Calendar
Full Version: Sample() function bug??
Modelica Forum > Modelica > MathModelica / OpenModelica
Jawhar
Hi,

I have a problem with OpenModelica and i think that is a bug with the sample() function.

I have a model wich uses an external function to send messages using sockets. This function is used in a while loop like this:
CODE

...
...
Modelica.Blocks.Interfaces.RealInput din;
Real a;
Real b(start=0);
Boolean SampleEvent;
algorithm
SampleEvent := sample(0,1);
when SampleEvent then
a:= sendMessage(String(din));
b:=b+a;
end when;



I noticed that the function sendMessage() was executed two time in each step. The plot of b variable is a confirmation of this.
The same code is working without any problem under Dymola.

The sendMessage external function return 1, so each time sendMessage is executed a is equal to 1. At the first step b is equal to 2. so it means that is is twice time executed. (see the plot file)

I am using OpenModelica 1.4.3, i installed it last year exactly 16 february 2007.

Can any one help me? is this a known bug?

Best Regards,
Hassen
Jawhar
I changed the word algorithm by equation and it seems working!

when i change the step of my sample function, the simulation end before the stopTime specified. I noticed that the simulation ended at StopTime specified divised by step time of sample.

Any idea?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.