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);
}
}