Commit e25be69e authored by apvrille's avatar apvrille

Update on graph management from TTool

parent 4aea4700
......@@ -22,6 +22,7 @@ BUILD_INFO = build.txt
BUILD_TO_MODIFY = src/ui/DefaultText.java
TTOOL_BINARY = ttool.jar
LAUNCHER_BINARY = launcher.jar
GRAPHSHOW_BINARY = graphshow.jar
TIFTRANSLATOR_BINARY = tiftranslator.jar
TMLTRANSLATOR_BINARY = tmltranslator.jar
GSCORE_BINARY = gs-core-1.3.jar
......@@ -34,6 +35,7 @@ RUNDSE_BINARY = rundse.jar
RUNDSE_JAR_TXT = rundse.txt
TTOOL_JAR_TXT = ttool.txt
LAUNCHER_JAR_TXT = launcher.txt
GRAPHSHOW_JAR_TXT = graphshow.txt
TIFTRANSLATOR_JAR_TXT = tiftranslator.txt
TMLTRANSLATOR_JAR_TXT = tmltranslator.txt
WEBCRAWLER_SERVER_JAR_TXT = webcrawler.txt
......@@ -96,7 +98,7 @@ RELEASE_STD_FILES_WINDIWS_EXE = ttool_windows.bat
RELEASE_STD_FILES_XML = TURTLE/manual-HW.xml AVATAR/DrinkMachineV10.xml TURTLE/WebV01.xml TURTLE/Protocol_example1.xml TURTLE/BasicExchange.xml DIPLODOCUS/SmartCardProtocol.xml TURTLE/ProtocolPatterns.xml CTTool/COCOME_V50.xml AVATAR/CoffeeMachine_Avatar.xml AVATAR/Network_Avatar.xml AVATAR/MicroWaveOven_SafetySecurity_fullMethodo.xml
RELEASE_STD_FILES_LIB = TURTLE/TClock1.lib TURTLE/TTimerv01.lib
RELEASE_STD_FILES_BIN = $(LAUNCHER_BINARY) $(TTOOL_BINARY) $(TIFTRANSLATOR_BINARY) $(TMLTRANSLATOR_BINARY) $(REMOTESIMULATOR_BINARY) $(RUNDSE_BINARY) $(WEBCRAWLER_SERVER_BINARY) $(WEBCRAWLER_CLIENT_BINARY)
RELEASE_STD_FILES_BIN = $(LAUNCHER_BINARY) $(TTOOL_BINARY) $(TIFTRANSLATOR_BINARY) $(TMLTRANSLATOR_BINARY) $(REMOTESIMULATOR_BINARY) $(RUNDSE_BINARY) $(WEBCRAWLER_SERVER_BINARY) $(WEBCRAWLER_CLIENT_BINARY) $(GRAPHSHOW_BINARY)
RELEASE_STD_FILES_LICENSES = LICENSE LICENSE_CECILL_ENG LICENSE_CECILL_FR
TEST_DIR = $(TTOOL_PATH)/tests
......@@ -110,6 +112,7 @@ define HELP_message
How to compile TTool:
---------------------
make all builds TTool and produces the jar files in bin/
make ttool builds TTool (but do not produce the jar of companion software)
Usual targets:
---------------
......@@ -143,6 +146,8 @@ help:
all: basic jar
ttool: basic jarttool
git: gitpull jar
gitpull:
......@@ -156,9 +161,11 @@ gitpull:
myrelease: basic launcher ttooljar
basic:
$(JAVAC) $(SOURCEPATH) $(TTOOL_SRC) $(CLASSPATH) $(TTOOL_CLASSPATH_BINARY) $(TTOOL_SRC)/*.java $(TTOOL_WEBCRAWLER_SRC)/*.java
$(JAVAC) $(SOURCEPATH) $(TTOOL_SRC) $(CLASSPATH) $(TTOOL_CLASSPATH_BINARY) $(TTOOL_SRC)/*.java $(TTOOL_WEBCRAWLER_SRC)/*.java
jarttool: launcher ttooljar
jar: launcher ttooljar tiftranslator tmltranslator rundse remotesimulator webcrawler
jar: launcher ttooljar tiftranslator tmltranslator rundse remotesimulator webcrawler graphshow
ttooljar:
rm -f $(TTOOL_BIN)/$(TTOOL_BINARY)
......@@ -169,6 +176,10 @@ launcher:
rm -f $(TTOOL_BIN)/$(LAUNCHER_BINARY)
cd $(TTOOL_SRC);$(JAR) cmf $(LAUNCHER_JAR_TXT) $(TTOOL_BIN)/$(LAUNCHER_BINARY) RTLLauncher.class launcher/*.class myutil/*.class
graphshow:
rm -f $(TTOOL_BIN)/$(TIFTRANSLATOR_BINARY)
cd $(TTOOL_SRC);$(JAR) cmf $(GRAPHSHOW_JAR_TXT) $(TTOOL_BIN)/$(GRAPHSHOW_BINARY) GraphShow.class myutil/*.class ui/graph/*.class ui/IconManager.class ui/file/PNGFilter.class
tiftranslator:
rm -f $(TTOOL_BIN)/$(TIFTRANSLATOR_BINARY)
cd $(TTOOL_SRC);$(JAR) cmf $(TIFTRANSLATOR_JAR_TXT) $(TTOOL_BIN)/$(TIFTRANSLATOR_BINARY) TIFTranslator.class translator/*.class translator/*/*.class myutil/*.class uppaaldesc/*.class ui/CheckingError.class compiler/tmlparser/*.class
......
/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
ludovic.apvrille AT telecom-paritech.fr
andrea.enrici AT telecom-paristech.fr
This software is a computer program whose purpose is to allow the
edition of TURTLE analysis, design and deployment diagrams, to
allow the generation of RT-LOTOS or Java code from this diagram,
and at last to allow the analysis of formal validation traces
obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
from INRIA Rhone-Alpes.
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
/**
* Class TIFTranslator
* Linecommand application for translating TIF to other languages
* Creation: 29/06/2007
* @version 1.1 30/05/2014
* @author Ludovic APVRILLE, Andrea ENRICI
* @see
*/
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import myutil.*;
import ui.graph.*;
public class GraphShow {
public static void printCopyright() {
System.out.println("GraphShow: (C) Telecom ParisTech, Ludovic APVRILLE ludovic.apvrille, andrea.enrici@telecom-paristech.fr");
System.out.println("GraphShow is released under a CECILL License. See http://www.cecill.info/index.en.html");
System.out.println("For more information on TTool related technologies, please consult http://ttool.telecom-paristech.fr/");
System.out.println("Enjoy!!!\n");
}
public static void printUsage() {
System.out.println("GraphShow: usage");
System.out.println("GraphShow <inputfile>");
System.out.println("<options> are optional. There might be : -debug");
System.out.println("<inputfile> should be in AUT format, and be readable");
}
public static boolean checkArgs(String [] args) {
return !(args.length < 1);
}
public static boolean hasDebug(String [] args) {
for (String s: args) {
if (s.equals("-debug")) {
return true;
}
}
return false;
}
public static String getInputFile(String [] args) {
return args[args.length-1];
}
public static String prepareFiles(String _inputFile) {
File inputFile = new File(_inputFile);
try {
if (!FileUtils.checkFileForOpen(inputFile)) {
System.out.println("Cannot read file: " + _inputFile);
return null;
}
return FileUtils.loadFileData(inputFile);
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
return null;
}
}
public static void main(String[] args) {
String[] tmp;
printCopyright();
if (!checkArgs(args)) {
printUsage();
return;
}
int nbOfOptions = 0;
if (hasDebug(args)) {
TraceManager.devPolicy = TraceManager.TO_CONSOLE;
} else {
TraceManager.devPolicy = TraceManager.TO_DEVNULL;
}
String graphData = prepareFiles(getInputFile(args));
if (graphData == null) {
printUsage();
return;
}
AUTGraph graph = new AUTGraph();
graph.buildGraph(graphData);
System.out.println("Graph has " + graph.getNbOfStates() + " and " + graph.getNbOfTransitions() + " transitions.");
graph.display(true);
}
} // Class GraphShow
Main-Class: GraphShow
Class-Path: ./gs-core-1.3.jar ./gs-ui-1.3.jar
......@@ -85,6 +85,13 @@ public class AUTGraph implements myutil.Graph {
//buildGraph(dataAUT);
}
public AUTGraph(ArrayList<AUTState> _st, ArrayList<AUTTransition> _tr) {
states = _st;
transitions = _tr;
nbState = states.size();
statesComputed = true;
}
public void stopBuildGraph() {
br = null;
}
......@@ -410,6 +417,12 @@ public class AUTGraph implements myutil.Graph {
return statesComputed;
}
public void setStates(ArrayList<AUTState> _states) {
states = _states;
nbState = states.size();
statesComputed = true;
}
public HashSet<String> getAllActions() {
HashSet<String> hs = new HashSet<String>();
for(AUTTransition tr: transitions) {
......@@ -455,7 +468,11 @@ public class AUTGraph implements myutil.Graph {
}
public void display() {
AUTGraphDisplay display = new AUTGraphDisplay(this);
display(false);
}
public void display(boolean exitOnClose) {
AUTGraphDisplay display = new AUTGraphDisplay(this, exitOnClose);
display.display();
}
......@@ -1210,10 +1227,65 @@ public class AUTGraph implements myutil.Graph {
TraceManager.addDev("------------------");
// Generating new graph
generateGraph(partition, alphabet);
}
// Assumes AUTElement have been added to transitions
public AUTGraph generateGraph(AUTPartition partition, HashMap<String, AUTElement> _alphabet) {
ArrayList<AUTState> sts = new ArrayList<AUTState>();
ArrayList<AUTTransition> trs = new ArrayList<AUTTransition>();
HashMap<AUTBlock, AUTState> blockToNewStates = new HashMap<AUTBlock, AUTState>();
int stID = 1;
// We create one state per block
// We look to the block that contains state 0 and we create the state id = 0
for(AUTBlock bl: partition.blocks) {
if (bl.hasState(0)) {
AUTState st0 = new AUTState(0);
blockToNewStates.put(bl, st0);
sts.add(0, st0);
} else {
AUTState st = new AUTState(stID);
stID ++;
blockToNewStates.put(bl, st);
sts.add(st);
}
}
// We now need to create the transitions
// We parse all states in blocks, and consider their transition
// We look for the destination and create a transition accordingly
for(AUTBlock bl: partition.blocks) {
AUTState newOrigin = blockToNewStates.get(bl);
for(AUTState src: bl.states) {
for(AUTTransition tr: src.outTransitions) {
AUTState newDestination = blockToNewStates.get(partition.getBlockWithState(tr.destination));
boolean foundSimilar = false;
AUTTransition newT = new AUTTransition(newOrigin.id, tr.transition, newDestination.id);
newT.elt = tr.elt;
for(AUTTransition testT: trs) {
if (testT.compareTo(newT) == 0) {
foundSimilar = true;
break;
}
}
if (!foundSimilar) {
trs.add(newT);
newOrigin.outTransitions.add(newT);
newDestination.inTransitions.add(newT);
}
}
}
}
AUTGraph newGraph = new AUTGraph(sts, trs);
TraceManager.addDev("New graph: " + newGraph.toFullString());
return newGraph;
}
private void printConfiguration(AUTPartition _part, AUTSplitter _w) {
TraceManager.addDev("P={" + _part.toString() + "}");
......
......@@ -648,6 +648,7 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
protected boolean loop;
protected MultiNode firstNode;
protected ArrayList<AbstractEdge> edges;
protected boolean exitOnClose = false;
public static String STYLE_SHEET =
"node {" +
......@@ -668,11 +669,11 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
" fill-color: green; text-color: black; size: 15px, 15px;" +
"} ";
public AUTGraphDisplay(AUTGraph _graph) {
public AUTGraphDisplay(AUTGraph _graph, boolean _exitOnClose) {
graph = _graph;
exitOnClose = _exitOnClose;
}
public void display() {
MultiNode node;
......@@ -690,6 +691,7 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
vGraph = new MultiGraph("TTool graph");
vGraph.addAttribute("ui.stylesheet", STYLE_SHEET);
int cpt = 0;
graph.computeStates();
for(AUTState state: graph.getStates()) {
node = vGraph.addNode("" + state.id);
node.addAttribute("ui.label", "" + state.id);
......@@ -727,7 +729,7 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
//View vi = viewer.addDefaultView(true);
viewer.setCloseFramePolicy(Viewer.CloseFramePolicy.CLOSE_VIEWER);
BasicFrame bf = new BasicFrame(viewer, vGraph, graph, edges);
BasicFrame bf = new BasicFrame(viewer, vGraph, graph, edges, exitOnClose);
//vi.addMouseListener(this);
......@@ -754,7 +756,7 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
// our thread
int cpt = 0;
TraceManager.addDev("Starting loop:" + cpt);
//TraceManager.addDev("Starting loop:" + cpt);
while(loop) {
try {
//TraceManager.addDev("beg of loop:" + cpt);
......@@ -765,6 +767,9 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
if (vGraph.hasAttribute("ui.viewClosed")) {
TraceManager.addDev("View was closed");
loop = false;
if (exitOnClose) {
System.exit(1);
}
} /*else if (firstNode.hasAttribute("ui.clicked")) {
TraceManager.addDev("Init node was clicked");
firstNode.removeAttribute("ui.clicked");
......@@ -794,6 +799,9 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
public void viewClosed(String id) {
TraceManager.addDev("View closed");
loop = false;
if (exitOnClose) {
System.exit(1);
}
}
......@@ -895,13 +903,16 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
protected JCheckBox readActions;
protected JCheckBox higherQuality, antialiasing;
protected JLabel help;
protected boolean exitOnClose;
public BasicFrame(Viewer viewer, MultiGraph vGraph, AUTGraph autgraph, ArrayList<AbstractEdge>_edges) {
public BasicFrame(Viewer viewer, MultiGraph vGraph, AUTGraph autgraph, ArrayList<AbstractEdge>_edges, boolean _exitOnClose) {
this.viewer = viewer;
this.vGraph = vGraph;
this.graph = autgraph;
edges = _edges;
exitOnClose = _exitOnClose;
makeComponents();
}
......@@ -950,7 +961,7 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
add(infoPanel, BorderLayout.SOUTH);
//setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(800, 600);
setSize(1000, 700);
setVisible(true);
}
......@@ -971,6 +982,9 @@ public class AUTGraphDisplay implements MouseListener, ViewerListener, Runnable
}
public void closeFrame() {
if (exitOnClose) {
System.exit(1);
}
dispose();
}
......
......@@ -93,5 +93,14 @@ public class AUTPartition {
return blocks.remove(_b);
}
public AUTBlock getBlockWithState(int id) {
for(AUTBlock b: blocks) {
if (b.hasState(id)) {
return b;
}
}
return null;
}
}
......@@ -228,10 +228,10 @@ public class AUTState implements Comparable<AUTState> {
public String toString() {
String s = "" + id + "\n";
for(AUTTransition tr: inTransitions) {
s += "\t" + tr.toString() + "\n";
s += "\t in: " + tr.toString() + "\n";
}
for(AUTTransition tr: outTransitions) {
s += "\t" + tr.toString() + "\n";
s += "\tout: " + tr.toString() + "\n";
}
return s;
}
......
......@@ -45,7 +45,7 @@
package ui.graph;
public class AUTTransition {
public class AUTTransition implements Comparable<AUTTransition> {
public int origin;
public int destination;
......@@ -65,6 +65,24 @@ public class AUTTransition {
transition = _transition;
}
public int compareTo( AUTTransition _t ) {
if (origin != _t.origin) {
return -1;
}
if (destination != _t.destination) {
return -1;
}
if(elt != null) {
if (elt != _t.elt) {
return -1;
} else {
return 0;
}
}
return transition.compareTo(_t.transition);
}
public String toString() {
return "(" + origin + " ," + transition + ", " + destination + ")";
}
......@@ -146,4 +164,6 @@ public class AUTTransition {
return tr;
}
}
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