if (type == ExactConstants.CLASS_CLOSED) {
// Closed class
key = output.addClass(name, CommonConstants.CLASS_TYPE_CLOSED, 0, new Integer((int) data), null);
} else {
// Open class
Exponential ex = new Exponential();
ex.setMean(1 / data);
key = output.addClass(name, CommonConstants.CLASS_TYPE_OPEN, 0, null, ex);
}
classKeys[i] = key;
}
routerKey = output.addStation("Router", CommonConstants.STATION_TYPE_ROUTER);
// Creates source, sink and router (if needed)
if (input.isClosed() || input.isMixed()) {
refRouterKey = output.addStation("RefStation", CommonConstants.STATION_TYPE_ROUTER);
// Makes connection between refRouter and router
output.setConnected(refRouterKey, routerKey, true);
output.setConnected(routerKey, refRouterKey, true);
// Gives warning on refStation
res
.add("A special node, called \"RefStation\" was added in order to compute correctly the System Response Time and System Throughput of closed classes."
+ " Its presence is fundamental to compute correctly number of visits at each station for closed classes.");
}
if (input.isOpen() || input.isMixed()) {
sourceKey = output.addStation("Source", CommonConstants.STATION_TYPE_SOURCE);
sinkKey = output.addStation("Sink", CommonConstants.STATION_TYPE_SINK);
//Makes connections between source, sink and router
output.setConnected(sourceKey, routerKey, true);
output.setConnected(routerKey, sinkKey, true);
}
// Convert stations
Object[] stationKeys = new Object[input.getStations()];
for (int i = 0; i < input.getStations(); i++) {
String name = input.getStationNames()[i];
int type = input.getStationTypes()[i];
int servers = input.getStationServers()[i];
double[][] serviceTimes = input.getServiceTimes()[i];
Object key = null;
switch (type) {
case ExactConstants.STATION_DELAY:
// Delay
key = output.addStation(name, CommonConstants.STATION_TYPE_DELAY);
// Sets distribution for each class
for (int j = 0; j < classKeys.length; j++) {
Exponential ex = new Exponential();
ex.setMean(serviceTimes[j][0]);
output.setServiceTimeDistribution(key, classKeys[j], ex);
}
break;
case ExactConstants.STATION_LI:
// Load independent
key = output.addStation(name, CommonConstants.STATION_TYPE_SERVER);
output.setStationNumberOfServers(new Integer(servers), key);
output.setStationQueueStrategy(key, CommonConstants.QUEUE_STRATEGY_STATION_PS);
// Sets distribution for each class
for (int j = 0; j < classKeys.length; j++) {
Exponential ex = new Exponential();
ex.setMean(serviceTimes[j][0]);
output.setServiceTimeDistribution(key, classKeys[j], ex);
}
break;
case ExactConstants.STATION_LD:
// Load dependent - this is single class only, but here
// we support multiclass too (future extensions).
key = output.addStation(name, CommonConstants.STATION_TYPE_SERVER);
output.setStationNumberOfServers(new Integer(servers), key);
output.setStationQueueStrategy(key, CommonConstants.QUEUE_STRATEGY_STATION_PS);
// Sets distribution for each class
for (int j = 0; j < classKeys.length; j++) {
LDStrategy lds = new LDStrategy();
Object rangeKey = lds.getAllRanges()[0];
for (int range = 0; range < serviceTimes[j].length; range++) {
// First range is already available
if (range > 0) {
rangeKey = lds.addRange();
}
Exponential ex = new Exponential();
ex.setMean(serviceTimes[j][range]);
lds.setRangeDistribution(rangeKey, ex);
lds.setRangeDistributionMean(rangeKey, Double.toString(serviceTimes[j][range]));
}
output.setServiceTimeDistribution(key, classKeys[j], lds);
}