コード例 #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);
  }