Beispiel #1
0
 public PowerStateDelayer(final double[] tasklist, final State newPowerState) {
   onOffEvent = this;
   newState = newPowerState;
   tasksDue = new TDoubleLinkedList();
   tasksDue.add(tasklist);
   sendTask();
   transitionStart = Timed.getFireCount();
 }
Beispiel #2
0
    private void sendTask() {
      // Did we finish all the tasks for the state change?
      if (tasksDue.size() == 0) {
        // Mark the completion of the state change
        onOffEvent = null;
        setState(newState);
        return;
      }

      // No we did not, lets send some more to our direct consumer
      final double totalConsumption = tasksDue.removeAt(0);
      final double limit = tasksDue.removeAt(0);
      currentConsumption =
          new ResourceConsumption(
              totalConsumption, limit, directConsumer, PhysicalMachine.this, this);
      if (!currentConsumption.registerConsumption()) {
        throw new IllegalStateException(
            "PowerStateChange was not successful because resource consumption could not be registered");
      }
    }
Beispiel #3
0
 public void addFurtherTasks(final double[] tasklist) {
   tasksDue.add(tasklist);
 }