User Tools

Site Tools


tutorials:ode-framework

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tutorials:ode-framework [2025/07/25 12:57] Timtutorials:ode-framework [2025/07/25 14:13] (current) Tim
Line 107: Line 107:
 ] ]
 </code> </code>
 +
 +===== monitorPeriodic =====
 +
 +Trigger an event in regular intervals and call the event handler. The event handler must not modify the graph.
 +
 +This allows to keep track of the changes for example:
 +<code>
 +import static java.lang.Math.*;
 +DatasetRef data = new DatasetRef("Dataplot");
 +const double PERIOD = 1.0;
 +double t;
 +double x;
 +protected void init ()
 +{
 +  data.clear().setColumnKey(0, "x");
 +  chart(data, XY_PLOT);
 +  t = 0;
 +  x = 1;
 +  data.addRow().setX(0, t).setY(0, x);
 +}
 +public void run ()
 +{
 +  monitorPeriodic(1, new Runnable() { 
 +    public void run() { data.addRow().setX(0, t).setY(0, x); }
 +  });
 +
 +  integrate(10);
 +}
 +protected void getRate()
 +{
 +  t :'= 1;
 +  x :'= 0.1 * x;
 +}
 +</code>
 +
 +
 +
 +
 +
tutorials/ode-framework.txt · Last modified: 2025/07/25 14:13 by Tim