Commit cd1ff966 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Merge branch 'master' of gitlab.enst.fr:mbe-tools/TTool

parents 91deca9e 2a0c7505
......@@ -67,6 +67,8 @@ public class CAMSSignal {
public final static int IN = 0;
public final static int OUT= 1;
public final static int HYBRID_IN = 2;
public final static int HYBRID_OUT= 3;
public final static int INCORRECT=-1;
private static int i=0;
......
......@@ -839,6 +839,8 @@ public class ActionPerformer {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_BRIDGENODE);
} else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_HWANODE].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_HWANODE);
} else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_CAMSNODE].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_CAMSNODE);
} else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_MEMORYNODE].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_MEMORYNODE);
} else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_DMANODE].getActionCommand())) {
......@@ -892,6 +894,13 @@ public class ActionPerformer {
} else if (command.equals(mgui.actions[TGUIAction.TMLSD_ACTION_STATE].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLSD_ACTION_STATE);
//SystemC AMS
} else if (command.equals(mgui.actions[TGUIAction.CAMS_EDIT].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.EDIT, -1);
} else if (command.equals(mgui.actions[TGUIAction.CAMS_BLOCK].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_BLOCK);
} else if (command.equals(mgui.actions[TGUIAction.CAMS_CONNECTOR].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_CONNECTOR);
// Attack Tree Diagrams
} else if (command.equals(mgui.actions[TGUIAction.ATD_BLOCK].getActionCommand())) {
......
......@@ -70,6 +70,7 @@ import ui.tmlsd.TGConnectorMessageTMLSD;
import ui.tmlsd.TMLSDControllerInstance;
import ui.tmlsd.TMLSDStorageInstance;
import ui.tmlsd.TMLSDTransferInstance;
import ui.het.*;
import java.util.*;
import java.awt.Point;
......@@ -2518,6 +2519,35 @@ public class GTMLModeling {
return map; // the data structure map is returned to CheckSyntaxTMLMapping in GTURTLEModeling
}
// public SystemCAMSPanel<TGComponent> translateToSystemCAMS() { //ajout CD 04/07 FIXME
/*tous est a changé et a créé ici*/
// tmlm = new TMLModeling<>(true);
// archi = new TMLArchitecture(); //filled by makeArchitecture
// cams = new TMLSystemCAMS<>(tmlm, archi, false);
// cams.tmlscp = tmlscp;
// checkingErrors = new LinkedList<CheckingError> ();
// warnings = new LinkedList<CheckingError> ();
// TraceManager.addDev("Making architecture");
// makeArchitecture(); //fills archi
// TraceManager.addDev("Making TML modeling");
// if (!makeTMLModeling()) {
// return null;
// }
// TraceManager.addDev("Making SystemC-AMS");
// makeMapping(); //fills cams
// cams.listE = listE;
// TraceManager.addDev("Making TMLSCPlib");
// makeTMLCPLib();
// removeActionsWithRecords();
// cams.setTMLDesignPanel(this.tmlcdp);//a ajouter
// if (cams.firewall){ // j'espère pas besoin de tous ca
// tmlscp.getMainGUI().gtm.drawFirewall(cams);
// }
// return cams;
// }
public void processAttackerScenario(){
//Scan tasks and activity diagrams for attacker read/write channels
for (TMLTask task: tmlm.getTasks()){
......
......@@ -120,6 +120,7 @@ import ui.tmlcompd.*;
import ui.tmlcp.TMLCPPanel;
import ui.tmldd.*;
import ui.tmlsd.TMLSDPanel;
import ui.het.*;
import ui.tree.GraphTree;
import ui.tree.InvariantDataTree;
import ui.tree.SearchTree;
......@@ -6051,6 +6052,37 @@ public class GTURTLEModeling {
makePostLoading(acdp, beginIndex);
}
}
} else if (tdp instanceof CAMSBlockDiagramPanel) { //ajout CD 24.07----mark
nl = doc.getElementsByTagName("CAMSBlockDiagramPanelCopy");
if (nl == null) {
return;
}
CAMSBlockDiagramPanel camsp = (CAMSBlockDiagramPanel)tdp;
for(i=0; i<nl.getLength(); i++) {
adn = nl.item(i);
if (adn.getNodeType() == Node.ELEMENT_NODE) {
elt = (Element) adn;
if (camsp == null) {
throw new MalformedModelingException();
}
decX = _decX;
decY = _decY;
makeXMLComponents(elt.getElementsByTagName("COMPONENT"), camsp);
makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), camsp);
makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), camsp);
connectConnectorsToRealPoints(camsp);
camsp.structureChanged();
makePostLoading(camsp, beginIndex);
}
}
} else if (tdp instanceof AvatarADPanel) {
nl = doc.getElementsByTagName("AvatarADPanelCopy");
......@@ -6251,6 +6283,8 @@ public class GTURTLEModeling {
loadAvatarMethodology(node);
} else if (type.compareTo("Sysmlsec Methodology") == 0) {
loadSysmlsecMethodology(node);
} else if (type.compareTo("SystemC-AMS") == 0) {
loadSystemCAMS(node);
} else if (type.compareTo("TML Design") == 0) {
loadTMLDesign(node);
} else if (type.compareTo("TML Component Design") == 0) {
......@@ -6755,6 +6789,34 @@ public class GTURTLEModeling {
}
}
public void loadSystemCAMS(Node node) throws MalformedModelingException, SAXException {
Element elt = (Element) node;
String nameTab;
NodeList diagramNl;
int indexDesign;
nameTab = elt.getAttribute("nameTab");
indexDesign = mgui.createSystemCAMS(nameTab);
diagramNl = node.getChildNodes();
for(int j=0; j<diagramNl.getLength(); j++) {
//TraceManager.addDev("Design nodes: " + j);
node = diagramNl.item(j);
if (node.getNodeType() == Node.ELEMENT_NODE) {
elt = (Element)node;
if (elt.getTagName().compareTo("SystemCAMSDiagramPanel") == 0) {
// Class diagram
TraceManager.addDev("Loading SystemC-AMS");
loadSystemCAMSDiagram(elt, indexDesign);
TraceManager.addDev("End loading SystemC-AMS");
}
}
}
}
public void loadTMLDesign(Node node) throws MalformedModelingException, SAXException {
Element elt = (Element) node;
String nameTab;
......@@ -7023,6 +7085,11 @@ public class GTURTLEModeling {
//TraceManager.addDev("Connectors...");
((AvatarADPanel)tdp).setConnectorsToFront();
}
if (tdp instanceof CAMSBlockDiagramPanel) {
//TraceManager.addDev("Connectors...");
((CAMSBlockDiagramPanel)tdp).setConnectorsToFront();
}
}
// AVATAR
......@@ -7240,6 +7307,22 @@ public class GTURTLEModeling {
loadDiagram(elt, tdp);
}
public void loadSystemCAMSDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
//ajout CD
String name;
TDiagramPanel tdp;
// class diagram name
name = elt.getAttribute("name");
mgui.setSystemCAMSDiagramName(indexDesign, name);
tdp = mgui.getMainTDiagramPanel(indexDesign);
tdp.setName(name);
//TraceManager.addDev("tdp=" + tdp.getName());
loadDiagram(elt, tdp);
}
public void loadTMLTaskDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
String name;
......@@ -8911,6 +8994,39 @@ public class GTURTLEModeling {
}
}
public boolean checkSyntaxSystemCAMS(Vector<TGComponent> blocksToTakeIntoAccount, SystemCAMSPanel scp, boolean optimize) { //ajout CD 04/07 FIXME
// List<TMLError> warningsOptimize = new ArrayList<TMLError>();
// warnings = new LinkedList<CheckingError> ();
// mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
// GTMLModeling gtmlm = new GTMLModeling(scp, true);
// // gtmlm.setBlocks(blocksToTakeIntoAccount); //simply transforms the parameter from a Vector to LinkedList
// nullifyTMLModeling();
// tmlm = null;
// tm = null;
// tmState = 1;
// // scp = gtmlm.translateToSystemCAMS();
// listE = gtmlm.getCorrespondanceTable();
// checkingErrors = gtmlm.getCheckingErrors();
// avatarspec = gtmlm.avspec;
// if ((checkingErrors != null) && (checkingErrors.size() > 0)){
// analyzeErrors();
// warnings = gtmlm.getCheckingWarnings();
// return false;
// } else {
// if (optimize) {
// warningsOptimize = tmap.optimize();
// }
// // warnings.addAll(convertToCheckingErrorTMLErrors(warningsOptimize, scp.scp));
// mgui.resetAllDIPLOIDs();
// listE.useDIPLOIDs();
// mgui.setMode(MainGUI.GEN_DESIGN_OK);
return true;
// }
}
public boolean checkSyntaxTMLMapping(Vector<TGComponent> nodesToTakeIntoAccount, TMLArchiPanel tmlap, boolean optimize) {
List<TMLError> warningsOptimize = new ArrayList<TMLError>();
warnings = new LinkedList<CheckingError> ();
......
......@@ -83,7 +83,9 @@ import ui.tmlcompd.TMLCCompositeComponent;
import ui.tmlcompd.TMLComponentTaskDiagramPanel;
import ui.tmlcp.TMLCPPanel;
import ui.tmldd.TMLArchiDiagramPanel;
import ui.tmldd.TMLArchiCAMSNode;
import ui.tmlsd.TMLSDPanel;
import ui.het.*;
import ui.tree.DiagramTreeModel;
import ui.tree.DiagramTreeRenderer;
import ui.tree.JDiagramTree;
......@@ -989,6 +991,36 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
return index;
}
public int addSystemCAMSPanel(String name, int index) { //ajout CD -----Mark
if (index == -1) {
index = tabs.size();
}
SystemCAMSPanel scp = new SystemCAMSPanel(this);
tabs.add(index, scp);
mainTabbedPane.add(scp.tabbedPane, index);
mainTabbedPane.setToolTipTextAt(index, "Open System C-AMS diagrams ");
mainTabbedPane.setTitleAt(index, name);
mainTabbedPane.setIconAt(index, IconManager.imgic60);
//mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
scp.init();
//ystem.out.println("Design added");
return index;
}
public CAMSBlockDiagramPanel addSystemCAMSPanel(String name, int index, TMLArchiCAMSNode parent) {
if (index == -1) {
index = tabs.size();
}
SystemCAMSPanel scp = new SystemCAMSPanel(this);
tabs.add(index, scp);
mainTabbedPane.add(scp.tabbedPane, index);
mainTabbedPane.setToolTipTextAt(index, "Open System C-AMS diagrams ");
mainTabbedPane.setTitleAt(index, name);
mainTabbedPane.setIconAt(index, IconManager.imgic60);
scp.init();
return scp.getCAMSBlockDiagramPanel();
}
//Return the list of all the TMLArchiDiagramPanels
public Vector<TMLArchiPanel> getTMLArchiDiagramPanels() {
......@@ -1364,6 +1396,12 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
return index;
}
public int createSystemCAMS(String name) { //ajout CD
int index = addSystemCAMSPanel(name, -1);
mainTabbedPane.setSelectedIndex(index);
return index;
}
public int createADD(String name) {
int index = addADDPanel(name, -1);
mainTabbedPane.setSelectedIndex(index);
......@@ -1737,6 +1775,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
//frame.repaint();
}
public void newSystemCAMS() {//ajout CD
//TraceManager.addDev("NEW DIPLO Architecture");
addSystemCAMSPanel("SystemC-AMS", -1);
tabs.elementAt(tabs.size()-1).tabbedPane.setSelectedIndex(0);
mainTabbedPane.setSelectedIndex(tabs.size()-1);
//paneAction(null);
//frame.repaint();
}
public void newADD() {
//TraceManager.addDev("NEW Avatar deployment");
addADDPanel("Deployment", -1);
......@@ -3286,7 +3333,44 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
}
}
}
} else if (tp instanceof TMLArchiPanel) {
} else if (tp instanceof SystemCAMSPanel) { //Ajout CD
SystemCAMSPanel camsp = (SystemCAMSPanel)tp;
JDialogSelectSystemCAMSBlock.validated = camsp.validated;
JDialogSelectSystemCAMSBlock.ignored = camsp.ignored;
Vector<TGComponent> camsBlocksToValidate = new Vector<TGComponent>();
JDialogSelectSystemCAMSBlock jdsscb = new JDialogSelectSystemCAMSBlock(frame, camsBlocksToValidate, camsp.camsbdp.getComponentList(),"Block Parameter");
if (!automatic) {
GraphicLib.centerOnParent(jdsscb);
jdsscb.setVisible(true);
} else {
jdsscb.closeDialog();
}
if (camsBlocksToValidate.size() > 0) {
camsp.validated = JDialogSelectSystemCAMSBlock.validated;
camsp.ignored = JDialogSelectSystemCAMSBlock.ignored;
if (b) {
setMode(MainGUI.GEN_SYSTEMC_OK);
setMode(MainGUI.MODEL_OK);
ret = true;
if (!automatic) {
JOptionPane.showMessageDialog(frame,
"0 error, " + getCheckingWarnings().size() + " warning(s). You can now perform verifications (safety, security, performance) or generate executable code",
"Syntax analysis successful on SystemC-AMS",
JOptionPane.INFORMATION_MESSAGE);
}
} else {
if (!automatic) {
JOptionPane.showMessageDialog(frame,
"The SystemC-AMS contains several errors",
"Syntax analysis failed",
JOptionPane.INFORMATION_MESSAGE);
}
}
}
} else if (tp instanceof TMLArchiPanel) {
tmlap = (TMLArchiPanel)tp;
JDialogSelectTMLNodes.validated = tmlap.validated;
JDialogSelectTMLNodes.ignored = tmlap.ignored;
......@@ -5689,6 +5773,11 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
tp.tabbedPane.setTitleAt(0, name);
}
public void setSystemCAMSDiagramName(int indexDesign, String name) {
TURTLEPanel tp = tabs.elementAt(indexDesign);
tp.tabbedPane.setTitleAt(0, name);
}
public void setSysmlsecMethodologyDiagramName(int indexDesign, String name) {
TURTLEPanel tp = tabs.elementAt(indexDesign);
tp.tabbedPane.setTitleAt(0, name);
......@@ -8044,7 +8133,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
private JPopupMenu menu;
private JMenuItem rename, remove, moveRight, moveLeft, newDesign, newAnalysis, newDeployment, newRequirement/*, newTMLDesign*/, newTMLComponentDesign, newTMLArchi, newProactiveDesign, newTURTLEOSDesign,
newNCDesign, sort, clone, newAttackTree, newAVATARBD, newAVATARRequirement, newMAD, newTMLCP, newTMLMethodo, newAvatarMethodo, newAVATARDD, newSysmlsecMethodo;
newNCDesign, sort, clone, newAttackTree, newAVATARBD, newAVATARRequirement, newMAD, newTMLCP, newTMLMethodo, newAvatarMethodo, newAVATARDD, newSysmlsecMethodo, newSystemCAMS;
private JMenuItem newAVATARAnalysis;
public PopupListener(MainGUI _mgui) {
......@@ -8091,6 +8180,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
newTMLComponentDesign = createMenuItem("New Partitioning - Functional view");
newTMLArchi = createMenuItem("New Partitioning - Architecture and Mapping");
newTMLCP = createMenuItem("New Partitioning - Communication Pattern");
newSystemCAMS = createMenuItem("New SystemC-AMS Block Diagram"); //ajout CD
newProactiveDesign = createMenuItem("New Proactive Design");
newTURTLEOSDesign = createMenuItem("New TURTLE-OS Design");
newNCDesign = createMenuItem("New Network Calculus Design");
......@@ -8178,6 +8268,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
menu.add(newTMLCP);
menu.add(newTMLArchi);
menu.addSeparator();
menu.add(newSystemCAMS);//ajout CD
menu.addSeparator();
}
}
......@@ -8301,7 +8393,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
mgui.newAvatarMADs();
} else if (e.getSource() == newAVATARAnalysis) {
mgui.newAvatarAnalysis();
}
} else if (e.getSource() == newSystemCAMS) { //ajout CD
mgui.newSystemCAMS();
}
}
};
}
......
......@@ -74,6 +74,7 @@ public class TAttribute {
public final static int INTEGER = 8;
public final static int TIMER = 9;
public final static int ADDRESS = 10;
public final static int DOUBLE = 11;
// Confidentiality verififcation
public final static int NOT_VERIFIED = 0;
......@@ -90,7 +91,8 @@ public class TAttribute {
private int confidentialityVerification = NOT_VERIFIED;
public boolean isAvatar;
public boolean isAvatar;
public boolean isCAMS;
private boolean set = false;
......@@ -302,6 +304,17 @@ public class TAttribute {
}
return -1;
}
public static int getCAMSType(String s) {
if (s.equals("bool")) {
return BOOLEAN;
} else if (s.equals("double")) {
return DOUBLE;
} else if (!s.equals("")) {
return OTHER;
}
return -1;
}
......@@ -348,20 +361,31 @@ public class TAttribute {
}
}
public static String getStringAvatarType(int type) {
public static String getStringAvatarType(int type) {
switch(type) {
case INTEGER:
return "int";
case BOOLEAN:
return "bool";
case TIMER:
return "Timer";
case NATURAL:
return "int";
case ADDRESS:
return "addr";
default:
return "unknown";
case INTEGER:
return "int";
case BOOLEAN:
return "bool";
case TIMER:
return "Timer";
case NATURAL:
return "int";
case ADDRESS:
return "addr";
default:
return "unknown";
}
}
public static String getStringCAMSType(int type) {
switch(type) {
case DOUBLE:
return "double";
case BOOLEAN:
return "bool";
default:
return "unknown";
}
}
......@@ -379,15 +403,15 @@ public class TAttribute {
if ((initialValue == null) || (initialValue.equals(""))) {
return getStringAccess(access) + " " + id + " : " + myType + ";";
} else {
if (type == ARRAY_NAT) {
return getStringAccess(access) + " " + id + " [" + getInitialValue() + "] : " + myType + ";";
} else {
return getStringAccess(access) + " " + id + " = " + getInitialValue() + " : " + myType + ";";
}
if (type == ARRAY_NAT) {
return getStringAccess(access) + " " + id + " [" + getInitialValue() + "] : " + myType + ";";
} else {
return getStringAccess(access) + " " + id + " = " + getInitialValue() + " : " + myType + ";";
}
}
}
public String toAvatarString() {
public String toAvatarString() {
String myType;
if (type == OTHER) {
myType = typeOther;
......@@ -398,11 +422,30 @@ public class TAttribute {
if ((initialValue == null) || (initialValue.equals(""))) {
return getStringAccess(access) + " " + id + " : " + myType + ";";
} else {
if (type == ARRAY_NAT) {
return getStringAccess(access) + " " + id + " [" + getInitialValue() + "] : " + myType + ";";
} else {
return getStringAccess(access) + " " + id + " = " + getInitialValue() + " : " + myType + ";";
}
if (type == ARRAY_NAT) {
return getStringAccess(access) + " " + id + " [" + getInitialValue() + "] : " + myType + ";";
} else {
return getStringAccess(access) + " " + id + " = " + getInitialValue() + " : " + myType + ";";
}
}
}
public String toCAMSString() {
String myType;
if (type == OTHER) {
myType = typeOther;
} else {
myType = getStringCAMSType(type);
}
if ((initialValue == null) || (initialValue.equals(""))) {
return getStringAccess(access) + " " + id + " : " + myType + ";";
} else {
if (type == ARRAY_NAT) {
return getStringAccess(access) + " " + id + " [" + getInitialValue() + "] : " + myType + ";";
} else {
return getStringAccess(access) + " " + id + " = " + getInitialValue() + " : " + myType + ";";
}
}
}
......
......@@ -62,6 +62,7 @@ import ui.tmlcd.TMLTaskOperator;
import ui.tmlcompd.TMLCCompositeComponent;
import ui.tmlcompd.TMLCPrimitiveComponent;
import ui.tmlcompd.TMLCRecordComponent;
import ui.het.*;
import ui.window.JDialogCode;
import ui.window.JDialogNote;
import ui.window.JDialogSearchBox;
......@@ -108,6 +109,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
protected List<TGComponent> componentList;
protected TGConnectingPoint selectedConnectingPoint;
protected CAMSConnectingPoint selectedCAMSConnectingPoints;
protected TGComponent componentPointed;
protected TGComponent componentPopup;
protected TToolBar ttb;
......@@ -176,6 +178,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
protected int y2;
protected Vector<Point> listPoint;
protected TGConnectingPoint p1, p2;
protected CAMSConnectingPoint cp1, cp2;
protected int type;
// For component selection
......@@ -471,6 +474,9 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
if (this.javaVisible && (tgc.hasPostJavaCode () || tgc.hasPreJavaCode ()))
tgc.drawJavaCode (g);
if (this instanceof CAMSBlockDiagramPanel) //Connecting points should always be visible in System-C AMS panels
tgc.drawTGConnectingPoint (g, this.type);
}
// Draw name of component selected
......@@ -901,6 +907,10 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
return selectedConnectingPoint;
}
public CAMSConnectingPoint getSelectedCAMSConnectingPoint(){
return selectedCAMSConnectingPoints;
}
// Adding component
public TGComponent addComponent(int x, int y, boolean swallow) {
//TraceManager.addDev("Add component");
......@@ -1040,6 +1050,47 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
listPoint = null;
}
public void addingCAMSConnector() {
listPoint = new Vector<Point>();
cp1 = getSelectedCAMSConnectingPoint();
x1 = cp1.getX(); y1 = cp1.getY();
selectedConnectingPoint.setFree(false);
}