/* An omega network example using simjava */ package omega; import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.*; import eduni.simanim.*; import eduni.simjava.*; // // The simulation entities // // The main applet public class Omega extends Anim_applet implements ItemListener { Panel inputs; Label msgLabel, sizeLabel, workLabel, showMsgLabel; TextField msgField; Choice sizeChoice; Choice workChoice; Checkbox showMsgBox; public static boolean show_msg = true; public Omega() {} private int ilog2( int i ) { int l = 0; for (l=0; (i>>=1)!=0; l++) ; return l; } // initialise the gui inputs public void anim_init() { int i; inputs = new Panel(); inputs.setLayout(new GridLayout(0,2)); msgLabel = new Label("Messages:", Label.RIGHT); inputs.add(msgLabel); msgField = new TextField("5",3); inputs.add(msgField); sizeLabel = new Label("Switch size:", Label.RIGHT); inputs.add(sizeLabel); sizeChoice = new Choice(); for(i=2; i<=32; i*=2) sizeChoice.addItem(" "+i+" "); sizeChoice.select(2); sizeChoice.addItemListener(this);; inputs.add(sizeChoice); workLabel = new Label("Workload:", Label.RIGHT); inputs.add(workLabel); workChoice = new Choice(); workChoice.addItem(" One to all (broadcast) "); workChoice.addItem(" All to one (gather) "); workChoice.addItem(" All to all "); workChoice.addItem(" Random (10%) "); workChoice.addItem(" Random (50%) "); workChoice.addItem(" Random (100%) "); workChoice.select(2); inputs.add(workChoice); showMsgLabel = new Label("Show messages:", Label.RIGHT); inputs.add(showMsgLabel); showMsgBox = new Checkbox(""); showMsgBox.setState(true); inputs.add(showMsgBox); this.add("North", inputs); System.out.println("Anim init done "); } // Setup the animation public void anim_layout() { int num_msg, i, swsize; double src_hold, sink_hold; System.out.println("Laying out simulation"); num_msg = Integer.parseInt(msgField.getText()); int swlogsize = (sizeChoice.getSelectedIndex())+1; // 1,2,3 int workload = (workChoice.getSelectedIndex()); swsize = 1<