From: <ni...@us...> - 2008-11-06 17:05:47
|
Revision: 412 http://mspsim.svn.sourceforge.net/mspsim/?rev=412&view=rev Author: nifi Date: 2008-11-06 17:05:43 +0000 (Thu, 06 Nov 2008) Log Message: ----------- moved setup to generic Main Modified Paths: -------------- mspsim/Makefile mspsim/se/sics/mspsim/platform/GenericNode.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/platform/sky/TelosNode.java Added Paths: ----------- mspsim/se/sics/mspsim/Main.java Removed Paths: ------------- mspsim/se/sics/mspsim/platform/esb/Main.java mspsim/se/sics/mspsim/platform/sky/Main.java Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2008-11-06 09:35:26 UTC (rev 411) +++ mspsim/Makefile 2008-11-06 17:05:43 UTC (rev 412) @@ -68,7 +68,7 @@ BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware -PACKAGES := ${addprefix se/sics/mspsim/,core platform platform/esb platform/sky cli ui util chip extutil/highlight extutil/jfreechart} +PACKAGES := ${addprefix se/sics/mspsim/,core platform platform/esb platform/sky . cli ui util chip extutil/highlight extutil/jfreechart} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} @@ -93,7 +93,7 @@ JarManifest.txt: @echo >>$@ "Manifest-Version: 1.0" @echo >>$@ "Sealed: true" - @echo >>$@ "Main-Class: se.sics.mspsim.platform.sky.Main" + @echo >>$@ "Main-Class: se.sics.mspsim.Main" @echo >>$@ "Class-path: lib/jfreechart-1.0.9.jar lib/jcommon-1.0.12.jar" help: @@ -103,13 +103,13 @@ $(JAVA) $(JAVAARGS) se.sics.mspsim.util.IHexReader $(ARGS) $(FIRMWAREFILE) $(MAPFILE) runesb: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.Main $(ARGS) $(ESBFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ARGS) $(ESBFIRMWARE) $(MAPFILE) runsky: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.Main $(ARGS) $(SKYFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) runskyprof: compile - $(JAVA) -agentlib:yjpagent $(JAVAARGS) se.sics.mspsim.platform.sky.Main $(ARGS) $(SKYFIRMWARE) $(MAPFILE) + $(JAVA) -agentlib:yjpagent $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) runtelos: compile $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) Added: mspsim/se/sics/mspsim/Main.java =================================================================== --- mspsim/se/sics/mspsim/Main.java (rev 0) +++ mspsim/se/sics/mspsim/Main.java 2008-11-06 17:05:43 UTC (rev 412) @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * Main + * + * Authors : Joakim Eriksson, Niclas Finne + * Created : 6 nov 2008 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim; +import java.io.IOException; +import se.sics.mspsim.platform.GenericNode; +import se.sics.mspsim.util.ArgumentManager; + +/** + * + */ +public class Main { + + public static GenericNode createNode(String className) { + try { + Class<? extends GenericNode> nodeClass = Class.forName(className).asSubclass(GenericNode.class); + return nodeClass.newInstance(); + } catch (ClassNotFoundException e) { + // Can not find specified class + } catch (ClassCastException e) { + // Wrong class type + } catch (InstantiationException e) { + // Failed to instantiate + } catch (IllegalAccessException e) { + // Failed to access constructor + } + return null; + } + + public static void main(String[] args) throws IOException { + ArgumentManager config = new ArgumentManager(); + config.handleArguments(args); + + String nodeType = config.getProperty("nodeType"); + String platform = nodeType; + GenericNode node; + if (nodeType != null) { + node = createNode(nodeType); + } else { + platform = config.getProperty("platform", "sky"); + nodeType = "se.sics.mspsim.platform." + platform + '.' + + Character.toUpperCase(platform.charAt(0)) + platform.substring(1).toLowerCase() + "Node"; + node = createNode(nodeType); + if (node == null) { + nodeType = "se.sics.mspsim.platform." + platform + '.' + platform.toUpperCase() + "Node"; + node = createNode(nodeType); + } + } + if (node == null) { + System.err.println("MSPSim does not yet support the platform '" + platform + '\''); + System.exit(1); + } + node.setupArgs(config); + } + +} Property changes on: mspsim/se/sics/mspsim/Main.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-11-06 09:35:26 UTC (rev 411) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-11-06 17:05:43 UTC (rev 412) @@ -42,7 +42,6 @@ import java.io.File; import java.io.IOException; import java.net.URL; - import se.sics.mspsim.cli.CommandHandler; import se.sics.mspsim.cli.DebugCommands; import se.sics.mspsim.cli.MiscCommands; @@ -95,6 +94,14 @@ } firmwareFile = args[0]; + if (config.getProperty("nogui") == null) { + config.setProperty("nogui", "false"); + } + /* Ensure auto-run of a start script */ + if (config.getProperty("autorun") == null) { + config.setProperty("autorun", "scripts/autorun.sc"); + } + int[] memory = cpu.getMemory(); if (args[0].endsWith("ihex")) { // IHEX Reading Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-11-06 09:35:26 UTC (rev 411) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-11-06 17:05:43 UTC (rev 412) @@ -50,6 +50,7 @@ import se.sics.mspsim.extutil.jfreechart.DataChart; import se.sics.mspsim.extutil.jfreechart.DataSourceSampler; import se.sics.mspsim.platform.GenericNode; +import se.sics.mspsim.util.ArgumentManager; public class ESBNode extends GenericNode implements PortListener { @@ -184,11 +185,11 @@ return "ESB"; } - /** - * @deprecated Use se.sics.mspsim.platform.sky.Main instead. - */ public static void main(String[] args) throws IOException { - Main.main(args); + ESBNode node = new ESBNode(); + ArgumentManager config = new ArgumentManager(); + config.handleArguments(args); + node.setupArgs(config); } } Deleted: mspsim/se/sics/mspsim/platform/esb/Main.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/Main.java 2008-11-06 09:35:26 UTC (rev 411) +++ mspsim/se/sics/mspsim/platform/esb/Main.java 2008-11-06 17:05:43 UTC (rev 412) @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2008, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim - * - * $Id$ - * - * ----------------------------------------------------------------- - * - * Main - * - * Authors : Joakim Eriksson, Niclas Finne - * Created : 6 nov 2008 - * Updated : $Date$ - * $Revision$ - */ - -package se.sics.mspsim.platform.esb; -import java.io.IOException; -import se.sics.mspsim.util.ArgumentManager; - -/** - * - */ -public class Main { - - public static void main(String[] args) throws IOException { - ESBNode node = new ESBNode(); - ArgumentManager config = new ArgumentManager(); - config.handleArguments(args); - if (config.getProperty("nogui") == null) { - config.setProperty("nogui", "false"); - } - /* Ensure auto-run of a start script */ - if (config.getProperty("autorun") == null) { - config.setProperty("autorun", "scripts/autorun.sc"); - } - node.setupArgs(config); - } - -} Deleted: mspsim/se/sics/mspsim/platform/sky/Main.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/Main.java 2008-11-06 09:35:26 UTC (rev 411) +++ mspsim/se/sics/mspsim/platform/sky/Main.java 2008-11-06 17:05:43 UTC (rev 412) @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2008, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id$ - * - * ----------------------------------------------------------------- - * - * Main - * - * Authors : Joakim Eriksson, Niclas Finne - * Created : 6 nov 2008 - * Updated : $Date$ - * $Revision$ - */ - -package se.sics.mspsim.platform.sky; -import java.io.IOException; -import se.sics.mspsim.util.ArgumentManager; - -/** - * - */ -public class Main { - - public static void main(String[] args) throws IOException { - SkyNode node = new SkyNode(); - ArgumentManager config = new ArgumentManager(); - config.handleArguments(args); - if (config.getProperty("nogui") == null) { - config.setProperty("nogui", "false"); - } - /* Ensure auto-run of a start script */ - if (config.getProperty("autorun") == null) { - config.setProperty("autorun", "scripts/autorun.sc"); - } - - node.setupArgs(config); - } - -} Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-11-06 09:35:26 UTC (rev 411) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-11-06 17:05:43 UTC (rev 412) @@ -45,6 +45,7 @@ import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.USART; +import se.sics.mspsim.util.ArgumentManager; /** * Emulation of Sky Mote @@ -98,11 +99,11 @@ } } - /** - * @deprecated Use se.sics.mspsim.platform.sky.Main instead. - */ public static void main(String[] args) throws IOException { - Main.main(args); + SkyNode node = new SkyNode(); + ArgumentManager config = new ArgumentManager(); + config.handleArguments(args); + node.setupArgs(config); } } Modified: mspsim/se/sics/mspsim/platform/sky/TelosNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2008-11-06 09:35:26 UTC (rev 411) +++ mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2008-11-06 17:05:43 UTC (rev 412) @@ -104,13 +104,6 @@ TelosNode node = new TelosNode(); ArgumentManager config = new ArgumentManager(); config.handleArguments(args); - if (config.getProperty("nogui") == null) { - config.setProperty("nogui", "false"); - } - /* Ensure auto-run of a start script */ - if (config.getProperty("autorun") == null) { - config.setProperty("autorun", "scripts/autorun.sc"); - } node.setupArgs(config); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |