Exemplo n.º 1
0
  public CarPositionControl(SimTime period, boolean verbose) {
    super("CarPositionControl", verbose);

    this.period = period;
    this.floor = 0;

    // log construction
    log("Created CarPositionControl");

    // initialize physical state
    // create carpositionindicator payload object
    localCarPositionIndicator = CarPositionIndicatorPayload.getWriteablePayload();

    // register the payload with the physical interface as output
    physicalInterface.sendTimeTriggered(localCarPositionIndicator, period);

    // initialize network interface
    // create CAN mailboxe for mCarPositionIndicator
    networkCarPositionIndicatorOut =
        CanMailbox.getWriteableCanMailbox(MessageDictionary.CAR_POSITION_CAN_ID);
    mCarPositionIndicator = new IntegerCanPayloadTranslator(networkCarPositionIndicatorOut);
    canInterface.sendTimeTriggered(networkCarPositionIndicatorOut, period);

    // create the AtFloor mailboxes
    for (int i = 0; i < mAtFloors.length; i++) {
      networkAtFloorIns[i] =
          CanMailbox.getReadableCanMailbox(
              MessageDictionary.AT_FLOOR_BASE_CAN_ID
                  + ReplicationComputer.computeReplicationId(AtFloorFloors[i], AtFloorHallways[i]));
      mAtFloors[i] =
          new AtFloorCanPayloadTranslator(
              networkAtFloorIns[i], AtFloorFloors[i], AtFloorHallways[i]);
      canInterface.registerTimeTriggered(networkAtFloorIns[i]);
    }
    timer.start(period);
  }
Exemplo n.º 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()]);
        }
      }
    }
  }