package fbench;
import java.io.FileReader;
import java.io.IOException;
import fb.rt.FBInstance;
import fb.rt.tools.FBLogger;
import fb.rt.tools.SystemLogger;
import fb.rt.tools.SystemManager;
import fb.tools.FBEDataConn;
import fb.tools.FBEDevice;
import fb.tools.FBEDeviceType;
import fb.tools.FBEInstance;
import fb.tools.FBELibrarySpec;
import fb.tools.FBEResource;
import fb.tools.FBESpec;
import fb.tools.FBESystem;
import fb.tools.FileLibrary;
import fb.tools.swing.editor.FBJPreferences;
import fb.xml.XMLException;
/**
* A FBSystemManager that supports debugging. Use the -d switch to specify debug
* host & ip
*
* @author DG
*
*/
public class FBenchSystemManager extends SystemManager {
private static boolean debugEnabled = false;
public FBenchSystemManager(FBLogger logger) {
super(logger);
}
public static void main(String args[]) {
// if (args.length <= 0) {
// System.out
// .println("FBenchSystemManager usage: java -classpath ./rt;./fbrt.jar; [-d host:ip] <libraryElementPath>");
// System.exit(-1);
// }
if(args.length == 0){
args = new String[] { "-d", "192.168.0.1:61502", "src\\ita\\FLASHER_TESTR.sys" };
}
for (int i = 0; i < args.length - 1; i++) {
if (args[i].equals("-d")) {
debugEnabled = true;
String host = args[++i];
System.out.println("Debug host: " + host);
FBInstance.debugHost = host;
}
}
FBJPreferences.loadPrefs("launcher.ini");
FileLibrary.initStatic();
FBELibrarySpec.library = new FileLibrary();
SystemLogger logger = new SystemLogger();
SystemManager mgr = new FBenchSystemManager(logger);
try {
FBELibrarySpec spec = FBELibrarySpec.load(new FileReader(args[args.length - 1]), true);
mgr.launch(spec, FBJPreferences.getBounds());
} catch (Exception e) {
logger.log(e);
System.exit(-1);
}
}
public void create(FBESystem spc) throws XMLException, IOException {
super.create(spc);
}
public void create(FBEResource res, String element) throws XMLException {
super.create(res, element);
// if (debugEnabled && FBELibrarySpec.get(res.getType(), true).isRemoteDevice()) {
// System.out.println("Creating DEBUGGER BLOCK: " + FBInstance.debugHost);
// FBEInstance fb = new FBEInstance();
// fb.setName("DEBUGHOST");
// fb.setType("DEBUG");
// createFB("", "DEBUGHOST", "DEBUG", fb);
// connectParameter("", "\"" + FBInstance.debugHost + "\"", "DEBUGHOST", "HOST", new FBEDataConn("DEBUGHOST.HOST", "DEBUG"));
// }
}
public void createFB(String element, String fbName, String fbType, FBESpec src) throws XMLException {
super.createFB(element, fbName, fbType, src);
}
}