Package desmoj.extensions.crossbar

Source Code of desmoj.extensions.crossbar.Student

package desmoj.extensions.crossbar;

import java.util.Arrays;

import desmoj.core.simulator.DelayedInterruptException;
import desmoj.core.simulator.SimProcess;
import desmoj.core.simulator.TimeSpan;

public class Student extends SimProcess {

  private final Fahrtziel fahrtziel;

  public Student(MessageCrossbarExample owner, boolean showInTrace, Fahrtziel fahrtziel) {
    super(owner, "Consumer ", showInTrace);
    this.fahrtziel = fahrtziel;
  }

  @SuppressWarnings("unchecked")
  @Override
  public void lifeCycle() {
    MessageCrossbarExample model;
    String msg;

    model = (MessageCrossbarExample) getModel();

    switch (fahrtziel) {
    case SCHLUMP:
      try {
        msg = model.linie181.waitForMessage(new TimeSpan(5)).toString();
      } catch (DelayedInterruptException e) {
        msg = "KEINE Message empfangen! Vorzeitiger Warteabbruch";
      }
      break;
    case SIEMERSPLATZ:
      msg = model.linie281.waitForMessage().toString();
      break;
    case HAGENBECKS_TIERPARK:
      msg = model.bushaltestelleInformatikum.waitForMessage(Arrays.asList(model.linie181, model.linie281))
          .toString();

      break;
    default:
      throw new RuntimeException();
    }

    System.out.println(msg);

  }
}
TOP

Related Classes of desmoj.extensions.crossbar.Student

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.