1
0
mirror of https://github.com/sethm/symon.git synced 2025-01-03 19:30:32 +00:00

allow for selecting the emulated machien type with the "-machine" parameter. The default is the Symon machine model, the Multicomp machine can be selected with "-machine multicomp".

This commit is contained in:
Maik Merten 2014-07-21 17:39:20 +02:00
parent a49c0d40d8
commit bd2337ae65

View File

@ -39,6 +39,8 @@ import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -123,8 +125,8 @@ public class Simulator {
*/
private static final String[] STEPS = {"1", "5", "10", "20", "50", "100"};
public Simulator() throws Exception {
this.machine = new MulticompMachine();
public Simulator(Class machineClass) throws Exception {
this.machine = (Machine) machineClass.getConstructors()[0].newInstance();
}
/**
@ -383,12 +385,25 @@ public class Simulator {
* @param args
*/
public static void main(String args[]) {
Class machineClass = SymonMachine.class;
for(int i = 0; i < args.length; ++i) {
String arg = args[i].toLowerCase(Locale.ENGLISH);
if(arg.equals("-machine") && (i+1) < args.length) {
String machine = args[i+1].trim().toLowerCase(Locale.ENGLISH);
if(machine.equals("multicomp")) {
machineClass = MulticompMachine.class;
}
}
}
final Class mClass = machineClass;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// Create the main UI window
Simulator simulator = new Simulator();
Simulator simulator = new Simulator(mClass);
simulator.createAndShowUi();
// Reset the simulator.
simulator.handleReset();