예제 #1
0
 /** Stop the stopwatch and add the interval to the accumulated total */
 public void stop() {
   if (isRunning) {
     SimTime offset = SimTime.subtract(Harness.getTime(), startTime);
     accumulatedTime = SimTime.add(accumulatedTime, offset);
     startTime = null;
     isRunning = false;
   }
 }
 /**
  * @param dropPercentage A value in the range [0,100] that indicates how many messages should be
  *     dropped.
  */
 public DropMessagesFaultModel(double dropPercentage) {
   super("DropMessageFaultModel");
   if (dropPercentage < 0 || dropPercentage > 100) {
     throw new RuntimeException("Drop percentage out of range [0,100]: " + dropPercentage);
   }
   this.dropPercentage = dropPercentage / 100; // store as a value in the range [0.1]
   this.random = Harness.getRandomSource().getRandom();
 }
예제 #3
0
 /** Start the stopwatch */
 public void start() {
   if (!isRunning) {
     startTime = Harness.getTime();
     isRunning = true;
   }
 }