Commit 9ca5c6ed authored by Ludovic Apvrille's avatar Ludovic Apvrille

update on simulation control

parent 86952f05
......@@ -12,7 +12,7 @@ TAR = tar
DEBUG = -g
CLASSPATH = -classpath
CLASSPATH = -sourcepath
PACKAGE = automata compiler/tmlparser nc ddtranslator launcher myutil tpndescription sddescription sdtranslator translator tmltranslator tmltranslator/toautomata tmltranslator/tosystemc tmltranslator/tomappingsystemc tmltranslator/tomappingsystemc2 tmltranslator/touppaal tmltranslator/toturtle translator/tojava translator/tosimujava translator/totpn translator/touppaal ui ui/ad ui/cd ui/oscd ui/osad ui/dd ui/file ui/graph ui/iod ui/ncdd ui/procsd ui/prosmdui/prosmd/util ui/tmlad ui/tmlcd ui/tmldd ui/tmlcomp ui/req ui/sd ui/tree ui/ucd ui/window tmltranslator tmltranslator/toturtle tmltranslator/tosystemc tmatrix uppaaldesc fr/inria/oasis/vercors/cttool/model
PACKAGE = automata compiler/tmlparser nc ddtranslator launcher myutil tpndescription sddescription sdtranslator translator tmltranslator tmltranslator/toautomata tmltranslator/tosystemc tmltranslator/tomappingsystemc tmltranslator/tomappingsystemc2 tmltranslator/touppaal tmltranslator/toturtle translator/tojava translator/tosimujava translator/totpn translator/touppaal ui ui/ad ui/cd ui/oscd ui/osad ui/dd ui/file ui/graph ui/iod ui/ncdd ui/procsd ui/prosmdui/prosmd/util ui/tmlad ui/tmlcd ui/tmldd ui/tmlcomp ui/req ui/sd ui/tree ui/ucd ui/window tmltranslator tmltranslator/toturtle tmltranslator/tosystemc tmatrix uppaaldesc fr/inria/oasis/vercors/cttool/model remotesimulation
BUILDER = builder.jar
BUILD_INFO = build.txt
BUILD_TO_MODIFY = src/ui/DefaultText.java
......@@ -20,10 +20,12 @@ TTOOL_BINARY = ttool.jar
LAUNCHER_BINARY = launcher.jar
TIFTRANSLATOR_BINARY = tiftranslator.jar
TMLTRANSLATOR_BINARY = tmltranslator.jar
REMOTESIMULATOR_BINARY = simulationcontrol.jar
TTOOL_JAR_TXT = ttool.txt
LAUNCHER_JAR_TXT = launcher.txt
TIFTRANSLATOR_JAR_TXT = tiftranslator.txt
TMLTRANSLATOR_JAR_TXT = tmltranslator.txt
REMOTESIMULATOR_JAR_TXT = simulationcontrol.txt
TTOOL_CONFIG = config.xml
TTOOL_CONFIG_SRC = config.xml
JTTOOL_JAR = jttool.jar
......@@ -60,7 +62,7 @@ TTOOL_TARGET_RELEASE = $(TTOOL_PATH)/TTool_install
RELEASE_STD_FILES_XML = manual-HW.xml DrinkMachineV10.xml WebV01.xml Protocol_example1.xml BasicExchange.xml SmartCardProtocol.xml ProtocolPatterns.xml COCOME_V50.xml
RELEASE_STD_FILES_LIB = TClock1.lib TTimerv01.lib
RELEASE_STD_FILES_BIN = $(TTOOL_CONFIG) $(LAUNCHER_BINARY) $(TTOOL_BINARY) $(TIFTRANSLATOR_BINARY) $(TMLTRANSLATOR_BINARY)
RELEASE_STD_FILES_BIN = $(TTOOL_CONFIG) $(LAUNCHER_BINARY) $(TTOOL_BINARY) $(TIFTRANSLATOR_BINARY) $(TMLTRANSLATOR_BINARY) $(REMOTESIMULATOR_BINARY)
RELEASE_STD_FILES_LICENSES = LICENSE LICENSE_CECILL_ENG LICENSE_CECILL_FR
all:
......@@ -73,7 +75,7 @@ all:
ttooljar_std:
rm -f $(TTOOL_BIN)/$(TTOOL_BINARY)
cp $(TTOOL_SRC)/ui/images/$(STD_LOGO) $(TTOOL_SRC)/ui/images/$(LOGO)
cd $(TTOOL_SRC); $(JAR) cmf $(TTOOL_JAR_TXT) $(TTOOL_BIN)/$(TTOOL_BINARY) Main.class automata/*.class compiler/tmlparser/*.class nc/*.class tmltranslator/*.class tmltranslator/toautomata/*.class tmatrix/*.class tmltranslator/toturtle/*.class tmltranslator/touppaal/*.class tmltranslator/tosystemc/*.class tmltranslator/tomappingsystemc/*.class tmltranslator/tomappingsystemc2/*.class tpndescription/*.class ddtranslator/*.class launcher/*.class myutil/*.class sddescription/*.class sdtranslator/*.class translator/*.class translator/tojava/*.class translator/tosimujava/*.class translator/touppaal/*.class translator/totpn/*.class ui/*.class ui/*/*.class ui/*/*/*.class uppaaldesc/*.class ui/images/*.* ui/images/toolbarButtonGraphics/general/*.gif ui/images/toolbarButtonGraphics/media/*.gif $(TTOOL_BIN)/$(LAUNCHER_BINARY) RTLLauncher.class launcher/*.class fr/inria/oasis/vercors/cttool/model/*.class
cd $(TTOOL_SRC); $(JAR) cmf $(TTOOL_JAR_TXT) $(TTOOL_BIN)/$(TTOOL_BINARY) Main.class automata/*.class compiler/tmlparser/*.class nc/*.class tmltranslator/*.class tmltranslator/toautomata/*.class tmatrix/*.class tmltranslator/toturtle/*.class tmltranslator/touppaal/*.class tmltranslator/tosystemc/*.class tmltranslator/tomappingsystemc/*.class tmltranslator/tomappingsystemc2/*.class tpndescription/*.class ddtranslator/*.class launcher/*.class myutil/*.class sddescription/*.class sdtranslator/*.class translator/*.class translator/tojava/*.class translator/tosimujava/*.class translator/touppaal/*.class translator/totpn/*.class ui/*.class ui/*/*.class ui/*/*/*.class uppaaldesc/*.class ui/images/*.* ui/images/toolbarButtonGraphics/general/*.gif ui/images/toolbarButtonGraphics/media/*.gif $(TTOOL_BIN)/$(LAUNCHER_BINARY) RTLLauncher.class launcher/*.class fr/inria/oasis/vercors/cttool/model/*.class remotesimulation/*.class
launcher:
......@@ -88,10 +90,14 @@ tmltranslator:
rm -f $(TTOOL_BIN)/$(TMLTRANSLATOR_BINARY)
cd $(TTOOL_SRC);$(JAR) cmf $(TMLTRANSLATOR_JAR_TXT) $(TTOOL_BIN)/$(TMLTRANSLATOR_BINARY) TMLTranslator.class tmltranslator/*.class tmltranslator/*/*.class myutil/*.class translator/*.class uppaaldesc/*.class ui/CheckingError.class compiler/tmlparser/*.class
remotesimulator:
rm -f $(TTOOL_BIN)/$(REMOTESIMULATOR_BINARY)
cd $(TTOOL_SRC);$(JAR) cmf $(REMOTESIMULATOR_JAR_TXT) $(TTOOL_BIN)/$(REMOTESIMULATOR_BINARY) RemoteSimulationControl.class remotesimulation/*.class
documentation:
$(JAVADOC) $(CLASSPATH) $(TTOOL_SRC) -d $(TTOOL_DOC_HTML) $(TTOOL_SRC)/*.java $(TTOOL_SRC)/*/*.java $(TTOOL_SRC)/*/*/*.java $(TTOOL_SRC)/fr/inria/oasis/vercors/cttool/model/*.java
release: jttooljar launcher tiftranslator tmltranslator ttooljar_std stdrelease
release: jttooljar launcher tiftranslator tmltranslator remotesimulator ttooljar_std stdrelease
echo release done
########## RELEASE
......
......@@ -58,6 +58,8 @@ public class RemoteSimulationControl extends Thread {
public static String host = "localhost";
public static RemoteConnection rc;
public static boolean mygo = true;
public boolean go = true;
public RemoteSimulationControl() {
......@@ -79,6 +81,16 @@ public class RemoteSimulationControl extends Thread {
System.out.println("port: port on which the simulator accepts commands (default: 3490). Must be a positive integer value");
}
public static void printHelp(String cmd) {
System.out.println("\nCommands supported by the simulator:");
System.out.println("-------------------------------------------------------------");
System.out.println("cmd <raw comand>: used to send a raw command to the simulator");
System.out.println("help: print that help");
System.out.println("help <command>: print the help on the given command <command>");
System.out.println("quit: quit the remote interface to simulation");
System.out.println("-------------------------------------------------------------\n");
}
public static boolean analyseArgs(String [] args) {
String tmp;
int i;
......@@ -151,7 +163,9 @@ public class RemoteSimulationControl extends Thread {
rc = new RemoteConnection(host, port);
while(true) {
mygo = true;
while(mygo) {
tryToConnect(rc);
System.out.println("Connected on host: " + host + " on port: " + port);
......@@ -159,16 +173,16 @@ public class RemoteSimulationControl extends Thread {
RemoteSimulationControl rsct = new RemoteSimulationControl();
rsct.start();
System.out.println("Reading to get commands:");
try {
while(true) {
s = rc.readOneLine();
System.out.println("From server: " + s);
}
} catch (RemoteConnectionException rce) {
System.out.println("Exception: " + rce.getMessage());
System.out.println("Could not read data from host: " + host + " on port: " + port + ". Aborting");
if (mygo) {
System.out.println("Exception: " + rce.getMessage());
System.out.println("Could not read data from host: " + host + " on port: " + port + ". Aborting");
}
}
rsct.go = false;
......@@ -176,17 +190,41 @@ public class RemoteSimulationControl extends Thread {
}
// Thread reading from keyboard
public void run() {
String input;
BufferedReader dataIn;
CommandParser cp = new CommandParser();
System.out.println("Type \"help\" for more information on commands");
System.out.println("Ready to get commands:");
try {
while(go) {
dataIn = new BufferedReader(new InputStreamReader(System.in));
input = dataIn.readLine();
rc.send(input);
if (cp.isQuitCommand(input)) {
mygo = false;
try {
rc.disconnect();
} catch (RemoteConnectionException rce) {
}
System.out.println("bye-bye");
System.exit(-1);
} else if (cp.isHelpCommand(input)) {
printHelp(input);
} else if (cp.isPicoCommand(input)) {
System.out.println("Pico has big teeth");
} else {
if (cp.isAValidCommand(input)) {
rc.send(cp.transformCommandFromUserToSimulator(input));
} else {
System.out.println("** Unknown command **");
}
}
}
} catch (IOException ioe) {
System.out.println("Exception: " + ioe.getMessage());
......
......@@ -55,5 +55,38 @@ public class CommandParser {
public CommandParser() {
}
public boolean isCommand(String cmd, String id) {
String s = cmd.trim();
if (cmd.equals(id)) {
return true;
}
return s.startsWith(id + " ");
}
public boolean isHelpCommand(String cmd) {
return isCommand(cmd, "help");
}
public boolean isQuitCommand(String cmd) {
return isCommand(cmd, "quit");
}
public boolean isPicoCommand(String cmd) {
return isCommand(cmd, "pico");
}
public boolean isAValidCommand(String cmd) {
return true;
}
public String transformCommandFromUserToSimulator(String cmd) {
return cmd;
}
}
\ No newline at end of file
......@@ -109,10 +109,16 @@ public class RemoteConnection {
} catch (Exception e) {
throw new RemoteConnectionException(SERV_NOT_RESP+host);
}
}
public void disconnect() throws RemoteConnectionException {
try {
clientSocket.close();
} catch (IOException io) {
throw new RemoteConnectionException(IO_ERROR + host);
}
}
public void send(String s) throws RemoteConnectionException {
s = s .trim();
if (s.length() == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment