Пример #1
0
 /**
  * Set the current state of the light
  *
  * @param value True if lighted
  */
 public void set(boolean value) {
   payload.set(value);
 }
Пример #2
0
  public RuntimeMonitor() {
    this.name = "RuntimeMonitor";

    // set up network inputs
    mDesiredFloor =
        new DesiredFloorCanPayloadTranslator(
            CanMailbox.getReadableCanMailbox(MessageDictionary.DESIRED_FLOOR_CAN_ID));
    canInterface.registerTimeTriggered(mDesiredFloor.getReadablePayload());
    // dummy calls to make sure the translator has the methods needed for monitoring.
    int dummyFloor = mDesiredFloor.getFloor();
    Hallway dummyHallway = mDesiredFloor.getHallway();
    Direction dummyDirection = mDesiredFloor.getDirection();

    // drive and car info (unreplicated)
    carLevelPosition = CarLevelPositionPayload.getReadablePayload();
    physicalInterface.registerEventTriggered(carLevelPosition);

    carPositionIndicator = CarPositionIndicatorPayload.getReadablePayload();
    physicalInterface.registerEventTriggered(carPositionIndicator);

    carWeightPayload = CarWeightPayload.getReadablePayload();
    physicalInterface.registerEventTriggered(carWeightPayload);

    carWeightAlarmPayload = CarWeightAlarmPayload.getReadablePayload();
    physicalInterface.registerEventTriggered(carWeightAlarmPayload);

    driveCommandedSpeed = DrivePayload.getReadablePayload();
    physicalInterface.registerEventTriggered(driveCommandedSpeed);

    driveActualSpeed = DriveSpeedPayload.getReadablePayload();
    physicalInterface.registerEventTriggered(driveActualSpeed);

    emergencyBrake = EmergencyBrakePayload.getReadablePayload();
    physicalInterface.registerEventTriggered(emergencyBrake);

    // car lanterns
    // hoistway limits
    for (Direction d : Direction.replicationValues) {
      carLanterns[d.ordinal()] = CarLanternPayload.getReadablePayload(d);
      physicalInterface.registerEventTriggered(carLanterns[d.ordinal()]);
    }

    // door values
    for (Hallway h : Hallway.replicationValues) {
      for (Side s : Side.values()) {
        int index = ReplicationComputer.computeReplicationId(h, s);

        doorMotors[h.ordinal()][s.ordinal()] = DoorMotorPayload.getReadablePayload(h, s);
        physicalInterface.registerEventTriggered(doorMotors[h.ordinal()][s.ordinal()]);

        doorOpeneds[h.ordinal()][s.ordinal()] = DoorOpenPayload.getReadablePayload(h, s);
        physicalInterface.registerEventTriggered(doorOpeneds[h.ordinal()][s.ordinal()]);

        doorCloseds[h.ordinal()][s.ordinal()] = DoorClosedPayload.getReadablePayload(h, s);
        physicalInterface.registerEventTriggered(doorCloseds[h.ordinal()][s.ordinal()]);

        doorReversals[h.ordinal()][s.ordinal()] = DoorReversalPayload.getReadablePayload(h, s);
        physicalInterface.registerEventTriggered(doorReversals[h.ordinal()][s.ordinal()]);
      }
    }

    // landing values
    for (int i = 0; i < Elevator.numFloors; ++i) {
      for (Hallway h : Hallway.replicationValues) {
        int floor = i + 1;
        atFloors[i][h.ordinal()] = AtFloorPayload.getReadablePayload(floor, h);
        physicalInterface.registerEventTriggered(atFloors[i][h.ordinal()]);

        carCalls[i][h.ordinal()] = CarCallPayload.getReadablePayload(floor, h);
        physicalInterface.registerEventTriggered(carCalls[i][h.ordinal()]);

        carLights[i][h.ordinal()] = CarLightPayload.getReadablePayload(floor, h);
        physicalInterface.registerEventTriggered(carLights[i][h.ordinal()]);

        for (Direction d : Direction.replicationValues) {
          hallCalls[i][h.ordinal()][d.ordinal()] = HallCallPayload.getReadablePayload(floor, h, d);
          physicalInterface.registerEventTriggered(hallCalls[i][h.ordinal()][d.ordinal()]);

          hallLights[i][h.ordinal()][d.ordinal()] =
              HallLightPayload.getReadablePayload(floor, h, d);
          physicalInterface.registerEventTriggered(hallLights[i][h.ordinal()][d.ordinal()]);
        }
      }
    }
  }
Пример #3
0
 @Override
 public Payload clone() {
   CarLanternPayload c = new CarLanternPayload(direction);
   c.copyFrom(this);
   return c;
 }