public void run()
{
System.out.println("start automation thread");
// Get generators
Generator genList[] = new Generator[generators.size()];
genList = generators.toArray(genList);
// init automation:
int currentIndex = 0;
currentValue = initialValue;
boolean reloaded = false;
double currentTime = 0.0;
double startTime = 0.0;
// init historic:
double totalDuration = getTotalDuration();
int histoNbPoints = (int)Math.ceil( totalDuration / stepDelay );
fireAutomationHasStarted();
while( (currentIndex < genList.length) && (quit==false) )
{
if( reloaded )
{
fireAutomationReloaded();
}
// prepare to execute generator:
Generator currentGen = genList[currentIndex];
currentGen.setInitialValue(currentValue);
double duration = currentGen.getDuration();
startTime = currentTime;
notifyGeneratorHasStarted(currentGen);
while( (currentTime < startTime + duration) && (quit==false) )
{
// set current automation value:
currentValue = currentGen.getValue( currentTime-startTime );
//if( previousValue != currentValue )
//{
fireCurrentValueChanged(currentTime, currentValue);
//}
try
{
while( (suspended == true) && (quit == false) )
{
System.out.println("suspended");
synchronized(this)
{
wait();
}
}
suspended = false;
if( quit == false )
{
Thread.sleep( (long)(stepDelay*1000.0) );
}
}
catch (InterruptedException ex)
{
Logger.getLogger(Automation.class.getName()).log(Level.SEVERE, null, ex);
}
currentTime += stepDelay;
//previousValue = currentValue;
}
// finish the execution of the generator
//previousValue = currentValue;
currentValue = currentGen.getValue(duration);
notifyGeneratorHasEnded(currentGen);
currentIndex++;
if( currentIndex >= genList.length )
{