package desmoj.extensions.crossbar;
import desmoj.core.simulator.SimProcess;
import desmoj.core.simulator.TimeSpan;
import desmoj.extensions.crossbar.CrossbarMessage.DistributionMode;
public class BusZyklus extends SimProcess {
private final MessageChannel<Student> line;
private final int initialDelay;
private final int interval;
public BusZyklus(MessageCrossbarExample owner, boolean showInTrace, MessageChannel<Student> line, int initialDelay,
int interval) {
super(owner, "Producer ", showInTrace);
this.line = line;
this.initialDelay = initialDelay;
this.interval = interval;
}
@Override
public void lifeCycle() {
hold(new TimeSpan(initialDelay));
while (true) {
line.send(new CrossbarMessage(getModel(), "Bus der " + line.getName(),
DistributionMode.DISTRIBUTE_BY_REFERENCE));
hold(new TimeSpan(interval));
}
}
}