Print

Print


Last week Mark asked about a bug where simstate.kill() would cause  
chart generators to appear to delete their data.

After poking around I think I've found the source of the problem.   
It's not that the data is going away.  It's that the chart generators  
are receiving a spurious request to update some data at time Infinity  
(which in MASON represents "the simulation is over").  The chart  
generator dutifully adds that timestamp, stretching the space to  
Infinity, and subtly breaking JFreeChart's series mechanism.

It's an easy fix: identify where your chart is being updated and  
check to see if the timestamp is valid.  In ChartingPropertyInspector  
I've fixed it by changing

	        if (lastTime < time || !updatedOnceAlready)
to	
	        if (time >= state.schedule.EPOCH && time <  
state.schedule.AFTER_SIMULATION &&
			 (lastTime < time || !updatedOnceAlready))  // bug fix


If you're following the example in the howto.html file about making a  
programmatic chart, you can change the line

                // now add the data
                series.add(x, y, true);
to

                // now add the data
                if (x >= state.schedule.EPOCH && x <  
state.schedule.AFTER_SIMULATION)
                    series.add(x, y, true);

There's a more subtle, minor, bug that I still have to track down:  
MASON is requesting that elements update themselves at Infinity  
(probably because SimState.kill() advanced the time to Infinity), but  
the Console still shows the next time tick.  I'll mull that over.

Sean