org.jbpm.sim.def
Class JbpmSimulationClock

java.lang.Object
  extended by org.jbpm.sim.def.JbpmSimulationClock
All Implemented Interfaces:
java.util.Observer, org.jbpm.util.Clock.DateGenerator

public class JbpmSimulationClock
extends java.lang.Object
implements org.jbpm.util.Clock.DateGenerator, java.util.Observer

This SimulationClock can be configured to be the clock for jbpm and observe the real simulation clock of DESMOJ. So it always returns the current simulation time, but converted in a Date object (simulation time 1 = new Date(1))

Author:
bernd.ruecker@camunda.com

Field Summary
static java.util.Date currentTime
          the clock always reflects the current simulation time as a java.util.Date
static long timeScaleFactor
          For the moment, we think of the smallest amount of model time to be seconds but the representation as double is in hours.
 
Constructor Summary
JbpmSimulationClock()
           
 
Method Summary
static double getAsDouble(long l)
          Currently we have a problem of converting the simulation time (represented as double) to a representation as long, needed for the jbpm log.
static long getAsLong(double d)
           
 java.util.Date getCurrentTime()
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentTime

public static java.util.Date currentTime
the clock always reflects the current simulation time as a java.util.Date


timeScaleFactor

public static long timeScaleFactor
For the moment, we think of the smallest amount of model time to be seconds but the representation as double is in hours. Maybe not very realistic by the way, but sufficient for the moment. See ApiDoc on getAsDouble for the weakness of conversation for more information.

Constructor Detail

JbpmSimulationClock

public JbpmSimulationClock()
Method Detail

getCurrentTime

public java.util.Date getCurrentTime()
Specified by:
getCurrentTime in interface org.jbpm.util.Clock.DateGenerator

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

getAsDouble

public static double getAsDouble(long l)
Currently we have a problem of converting the simulation time (represented as double) to a representation as long, needed for the jbpm log. We would need to know the exact scale and steps of the simulation time, to calculate the long value. And currently I am not sure about statistical effects when just multiplying the double and truncate the result to long. But at the moment I ignore this problem, because it doesn't affect the simulation run, it only affects the time seen in jBPM, and this time is only used for writing logs. It may get a problem if we start to use Timers in the simulation, which must be triggered to some simulation time. So for the moment only log this problem and be careful with judging jbpm log times. TODO: Improve the time conversion double -> long


getAsLong

public static long getAsLong(double d)


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.