diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java index b945f8c401bc2f2338c6ad92848ac34b88e5337c..3c0cc72cb5908f9b89a137717286f44bdbde1aa9 100755 --- a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java @@ -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; diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index a569776e71cbc7a2a9f9dfb26400baf00fefa44e..075c8ca385e4a415994bc5bf3a318f3dd1e9d78e 100755 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -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())) { diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java index 2962737ca1255d9ea30782dd5279cb99ef6c4d96..942cf0cf56af1c5c599a23ce216f484f6c6608e8 100755 --- a/src/main/java/ui/GTMLModeling.java +++ b/src/main/java/ui/GTMLModeling.java @@ -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()){ diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index 02140d94dd873c250f5ae58ddaf4b76e0e77f763..a2216cc396d94b6f0dbf2f2ce54040b44ad72bf2 100755 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -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> (); diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index fe7f83a8485c0dc0d8bb649348d563edf8db4094..161f5118928fb8db4f7fe5215cfc92881a183086 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -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(); + } } }; } diff --git a/src/main/java/ui/TAttribute.java b/src/main/java/ui/TAttribute.java index 0e171a89a8384fe0e653b1e08c70cdc3185f89b8..41fd59deb3366b7f44678b414b3c04717d557821 100755 --- a/src/main/java/ui/TAttribute.java +++ b/src/main/java/ui/TAttribute.java @@ -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 + ";"; + } } } diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index 6243f0997d1d861c684930dec30c32831dd7f4d3..574d6351209ad9a8db4f18cfd55b8be879c2e74d 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -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); + } + + public void setAddingCAMSConnector(int _x2, int _y2) { + x2 = _x2; y2 = _y2; + } + + public void addPointToCAMSConnector(int x, int y) { + listPoint.addElement(new Point(x, y)); + x1 = x; + y1 = y; + } + + public void finishAddingConnector(CAMSConnectingPoint cp2) { + CAMSBlockConnector camsco = TGComponentManager.addCAMSConnector(cp1.getX(), cp1.getY(), mgui.getIdButtonSelected(), this, cp1, cp2, listPoint); + if (camsco != null) { + TraceManager.addDev("Adding connector"); + cp2.setFree(false); + this.componentList.add(0, camsco); + if (camsco instanceof SpecificActionAfterAdd) { + ((SpecificActionAfterAdd)camsco).specificActionAfterAdd(); + } + stopAddingConnector(false); + cp1.setFree(false); + cp1 = null; + cp2 = null; + } else { + TraceManager.addDev("Cancel adding connector"); + cp2.setFree(true); + stopAddingConnector(true); + cp1.setFree(true); + } + } + +// -------------mark + + public void setMovingHead(int _x1, int _y1, int _x2, int _y2) { x1 = _x1; y1 = _y1; x2 = _x2; y2 = _y2; @@ -2563,6 +2614,16 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { }); } + public String findCAMSBlockName(String name) { + return this.findGoodName (name, new NameChecker () { + public boolean checkCAMSBlock (CAMSBlock o, String name) { + if (o.getValue ().equals (name)) + return true; + return o.hasBlockWithName(); + } + }); + } + public String findAvatarSMDStateName(String name) { return this.findGoodName (name, new NameChecker () { public boolean checkAvatarSMDState (AvatarSMDState o, String name) { @@ -3297,4 +3358,8 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { for (TGComponent tgc: this.componentList) tgc.searchForText(text, elements); } + + public MainGUI getMainGUI(){ //Ajout CD pour creation d'un panel depuis un block + return mgui; + } } diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index 843c5c1fbe9904177670949a533b4a841eaa97fe..af58daf8ef14df88e988e756ed3a188aa6fa8030 100755 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -75,6 +75,7 @@ import ui.tmlcompd.*; import ui.tmlcp.*; import ui.tmldd.*; import ui.tmlsd.*; +import ui.het.*; import ui.ucd.*; import java.awt.*; @@ -261,6 +262,7 @@ public class TGComponentManager { public static final int TMLARCHI_BUSNODE = 1102; public static final int TMLARCHI_COMMUNICATION_ARTIFACT = 1103; public static final int TMLARCHI_HWANODE = 1104; + public static final int TMLARCHI_CAMSNODE = 1115; public static final int TMLARCHI_MEMORYNODE = 1105; public static final int TMLARCHI_BRIDGENODE = 1106; public static final int TMLARCHI_DMANODE = 1107; @@ -320,6 +322,10 @@ public class TGComponentManager { public static final int CONNECTOR_MESSAGE_ASYNC_TMLSD = 1523; public static final int TMLSD_ACTION_STATE = 1524; + // SystemC-AMS + public static final int CAMS_CONNECTOR = 1601; + public static final int CAMS_BLOCK = 1602 ; + // SMD diagram public static final int PROSMD_START_STATE = 2000; public static final int PROSMD_STOP_STATE = 2001; @@ -1172,6 +1178,9 @@ public class TGComponentManager { case TMLARCHI_HWANODE: tgc = new TMLArchiHWANode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case TMLARCHI_CAMSNODE: + tgc = new TMLArchiCAMSNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; case TMLARCHI_MEMORYNODE: tgc = new TMLArchiMemoryNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; @@ -1193,6 +1202,9 @@ public class TGComponentManager { case TMLARCHI_KEY: tgc = new TMLArchiKey(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case CAMS_BLOCK: + tgc = new CAMSBlock(x,y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; // Communication patterns + SD case TMLCP_CHOICE: @@ -1575,6 +1587,10 @@ public class TGComponentManager { } else if (tgc instanceof AvatarADAssociationConnector) { return AAD_ASSOCIATION_CONNECTOR; + //SystemC-AMS -----mark + } else if (tgc instanceof CAMSBlockConnector) { + return CAMS_CONNECTOR; + // Others } else if (tgc instanceof TADDeterministicDelay) { return TAD_DETERMINISTIC_DELAY; @@ -1889,6 +1905,8 @@ public class TGComponentManager { // return AVATAR_FIREWALL; } else if (tgc instanceof TMLArchiHWANode) { return TMLARCHI_HWANODE; + } else if (tgc instanceof TMLArchiCAMSNode) { + return TMLARCHI_CAMSNODE; } else if (tgc instanceof TMLArchiMemoryNode) { return TMLARCHI_MEMORYNODE; } else if (tgc instanceof TMLArchiDMANode) { @@ -2067,6 +2085,11 @@ public class TGComponentManager { tgc = new SysmlsecMethodologyConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); break; + // // System C-AMS + // case CAMS_CONNECTOR: + // tgc = new CAMSBlockConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); + // break; + // AVATAR MAD case AVATARMAD_COMPOSITION_CONNECTOR: tgc = new AvatarMADCompositionConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); @@ -2289,4 +2312,10 @@ public class TGComponentManager { } + public final static CAMSBlockConnector addCAMSConnector(int x, int y, int id, TDiagramPanel tdp, CAMSConnectingPoint p1, CAMSConnectingPoint p2, Vector<Point> listPoint) { + CAMSBlockConnector cbc = null; + cbc = new CAMSBlockConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); + return cbc; + } + } // Class diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index c6cd59ee3bcf0314ba660850d492e1c8a24fe530..d2124ee84ad9cb5022a35ad6aacaed27b5924fcc 100755 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -245,6 +245,7 @@ public class TGUIAction extends AbstractAction { public static final int TMLARCHI_PORT_ARTIFACT = 412; public static final int TMLARCHI_EVENT_ARTIFACT = 395; public static final int TMLARCHI_HWANODE = 223; + public static final int TMLARCHI_CAMSNODE = 461; public static final int TMLARCHI_MEMORYNODE = 224; public static final int TMLARCHI_DMANODE = 364; public static final int TMLARCHI_BRIDGENODE = 225; @@ -270,6 +271,9 @@ public class TGUIAction extends AbstractAction { public static final int TMLSD_MESSAGE_ASYNC = 390; public static final int TMLSD_EDIT = 391; + public static final int CAMS_EDIT = 458; + public static final int CAMS_BLOCK = 459; + public static final int CAMS_CONNECTOR = 460; public static final int EBRDD_EDIT = 271; public static final int EBRDD_CONNECTOR = 272; @@ -610,7 +614,7 @@ public class TGUIAction extends AbstractAction { public static final int ACT_INTERNAL_SEARCH = 415; //-- - public static final int NB_ACTION = 458; + public static final int NB_ACTION = 462; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -1022,6 +1026,7 @@ public class TGUIAction extends AbstractAction { actions[TMLARCHI_EVENT_ARTIFACT] = new TAction("add-tmlarchi-event-artifact", "Map an event / request", IconManager.imgic702, IconManager.imgic702, "Map an event/request", "Map an event or a request onto a node in the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_BRIDGENODE] = new TAction("add-tmlarchi-bridgenode", "Add a Bridge node", IconManager.imgic1104, IconManager.imgic1104, "Bridge node", "Add a bridge node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_HWANODE] = new TAction("add-tmlarchi-hwanode", "Add a hardware accelerator node", IconManager.imgic1106, IconManager.imgic1106, "Hardware accelerator node", "Add a hardware accelerator node to the currently opened DIPLODOCUS architecture diagram", 0); + actions[TMLARCHI_CAMSNODE] = new TAction("add-tmlarchi-camsnode", "Add a System C-AMS node", IconManager.imgic1106, IconManager.imgic1106, "System C-AMS node", "Add a System C-AMS node to the currently open DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_MEMORYNODE] = new TAction("add-tmlarchi-memorynode", "Add a memory node", IconManager.imgic1108, IconManager.imgic1108, "Memory node", "Add a memory node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_DMANODE] = new TAction("add-tmlarchi-dmanode", "Add a DMA node", IconManager.imgic1110, IconManager.imgic1110, "DMA node", "Add a DMA node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_KEY] = new TAction("add-tmlarchi-key", "Map a key", IconManager.imgic1118, IconManager.imgic1118, "Map a key", "Map a key onto a node in the currently opened DIPLODOCUS architecture diagram", 0); @@ -1046,6 +1051,11 @@ public class TGUIAction extends AbstractAction { actions[TMLSD_CONTROLLER_INSTANCE] = new TAction("add-controller-instance-tmlsd", "Controller instance", IconManager.imgic500, IconManager.imgic500, "Controller instance", "Add a controller instance to the currently opened communication pattern sequence diagram", 0); actions[TMLSD_ACTION_STATE] = new TAction("add-action-tmlsd", "Action state", IconManager.imgic512, IconManager.imgic512, "Action state", "Add an action state to the currently opened communication pattern sequence diagram", 0); + //System C-AMS + actions[CAMS_EDIT] = new TAction("add-action-C-AMS", "Action state", IconManager.imgic100, IconManager.imgic101, "Action state", "Add an action state to the currently opened SystemC-AMS diagram", 0); + actions[CAMS_BLOCK] = new TAction("C-AMS-block", "Add a block", IconManager.imgic5000, IconManager.imgic5000, "Block", "Add a Block to the currently opened SystemC-AMS Diagram", 0); + actions[CAMS_CONNECTOR] = new TAction("C-AMS-connector", "Add a connection", IconManager.imgic202, IconManager.imgic202, "Connector", "Connects two block of the currently opened SystemC-AMS Diagram", 0); + //ProActive State Machine Diagram actions[PROSMD_EDIT] = new TAction("edit-prosmd-diagram", "Edit ProActive state machine diagram", IconManager.imgic100, IconManager.imgic101, "Edit ProActive state machine diagram", "Make it possible to edit the currently opened ProActive state machine diagram", 0); diff --git a/src/main/java/ui/het/CAMSBlock.java b/src/main/java/ui/het/CAMSBlock.java index 39e050638069bfc098057c28166dd3be6bd3dc96..97852637283904d48b72f3e71f9ce9ff1391c7b0 100755 --- a/src/main/java/ui/het/CAMSBlock.java +++ b/src/main/java/ui/het/CAMSBlock.java @@ -72,6 +72,10 @@ public class CAMSBlock extends TGComponent { private int nbOfIn = 0; private int nbOfOut = 0; + private int nbOfHybridIn = 0; + private int nbOfHybridOut = 0; + private int totIn = 0; + private int totOut = 0; protected int index = 0; @@ -119,7 +123,7 @@ public class CAMSBlock extends TGComponent { if(this.myAttributes == null){this.myAttributes = new LinkedList<TAttribute>();} if(this.mySignals == null){this.mySignals = new LinkedList<CAMSSignal>();} - SBlock= new CAMSBlocks(name, nbOfIn, nbOfOut, myAttributes, mySignals, processCode); + SBlock= new CAMSBlocks(name, nbOfIn, nbOfOut, nbOfHybridIn, nbOfHybridOut, myAttributes, mySignals, processCode); } public void createConnectingPoints(){ @@ -132,24 +136,38 @@ public class CAMSBlock extends TGComponent { for(i=0;i<mySignals.size();i++){ if(mySignals.get(i).getInout()==0){ nbOfIn++; - } else { + } else if(mySignals.get(i).getInout()==1) { nbOfOut++; + } else if(mySignals.get(i).getInout()==2) { + nbOfHybridIn++; + } else{ + nbOfHybridOut++; } } } - nbConnectingPoint = nbOfIn + nbOfOut; + nbConnectingPoint = nbOfIn + nbOfOut + nbOfHybridIn + nbOfHybridOut; + totIn = nbOfIn + nbOfHybridIn; + totOut = nbOfOut + nbOfHybridOut; connectingPoint = new CAMSConnectingPoint[nbConnectingPoint]; - for (i = 1; i<= nbOfIn; i++){ - h = i/(nbOfIn + 1.0); - connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, 0.0, h); + for (i = 1; i<= totIn; i++){ + h = i/(totIn + 1.0); + if((i-1)<nbOfIn){ + connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, false, 0.0, h); + } else{ + connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, true, 0.0, h); + } } - for (i = 1; i<= nbOfOut; i++){ - h = i/(nbOfOut + 1.0); - connectingPoint[i+nbOfIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, 1.0, h); + for (i = 1; i<=totOut; i++){ + h = i/(totOut + 1.0); + if ((i+totIn-1)<(nbOfOut + totIn)){ + connectingPoint[i+totIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, false, 1.0, h); + } else { + connectingPoint[i+totIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, true, 1.0, h); + } } addTGConnectingPointsComment(); @@ -291,6 +309,8 @@ public class CAMSBlock extends TGComponent { SBlock.setBlockName(name); SBlock.setNbOfIn(nbOfIn); SBlock.setNbOfOut(nbOfOut); + SBlock.setNbOfHybridIn(nbOfHybridIn); + SBlock.setNbOfHybridOut(nbOfHybridOut); SBlock.setMyAttributes(myAttributes); SBlock.setMySignals(mySignals); SBlock.setProcessCode(processCode); @@ -308,8 +328,8 @@ public class CAMSBlock extends TGComponent { public String getAttributes() { String attr = ""; - attr += "Nb of in = " + nbOfIn + "\n"; - attr += "Nb of out = " + nbOfOut + "\n"; + attr += "Nb of in = " + totIn + "\n"; + attr += "Nb of out = " + totOut + "\n"; return attr; } @@ -337,13 +357,33 @@ public class CAMSBlock extends TGComponent { public void resetInOut(){ nbOfIn = 0; nbOfOut= 0; + nbOfHybridIn = 0; + nbOfHybridOut= 0; + totIn = 0; + totOut= 0; } public int getNbOfIn() { - return nbOfIn; + return totIn; } public int getNbOfOut() { + return totOut; + } + + public int getNbOfHybridIn() { + return nbOfHybridIn; + } + + public int getNbOfHybridOut() { + return nbOfHybridOut; + } + + public int getNbOfNonHybridIn() { + return nbOfIn; + } + + public int getNbOfNonHybridOut() { return nbOfOut; } diff --git a/src/main/java/ui/het/CAMSConnectingPoint.java b/src/main/java/ui/het/CAMSConnectingPoint.java index 326efe6677913b409d7f3e19d53c67ae91b49e21..7839f4d2d9577949633ba47f9f1dfea748b11e29 100755 --- a/src/main/java/ui/het/CAMSConnectingPoint.java +++ b/src/main/java/ui/het/CAMSConnectingPoint.java @@ -76,6 +76,7 @@ public class CAMSConnectingPoint extends TGConnectingPointWidthHeight { protected boolean in; protected boolean out; + protected boolean hybrid; public JDialogCAMSConnectingPoint dialog; @@ -89,33 +90,56 @@ public class CAMSConnectingPoint extends TGConnectingPointWidthHeight { protected TGConnector referenceToConnector; - public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out,boolean _hybrid, double _w, double _h) { super(_container, _x, _y, _in, _out, _w, _h); - - if (_in) { - if (_out) { - myColor = INOUT; - } else { - myColor = IN; - } - } else { - if (_out) { - myColor = OUT; + hybrid = _hybrid; + + //color selection + if (_in) { + if (_out) { + myColor = INOUT; + } else { + myColor = IN; + } + } else { + if (_out) { + myColor = OUT; } else { - myColor = NO; - } - } + myColor = NO; + } + } id = TGComponent.getGeneralId(); TGComponent.setGeneralId(id + 1); } + + // public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + // super(_container, _x, _y, _in, _out, _w, _h); + // CAMSConnectingPoint camsco = new CAMSConnectingPoint (_container, _x, _y, _in, _out, false, _w, _h); + // } public void draw(Graphics g) { int mx = getX(); int my = getY(); g.setColor(myColor); - g.fillRect(mx - width, my - width, width*2, height*2); + + //taking into account hybrid connectors + if(this.hybrid==false){ + g.fillRect(mx - width, my - width, width*2, height*2); + }else if (this.in==true){ + System.out.println("test"); + g.setColor(Color.white); + g.fillRect(mx - width, my - width, width*2, height*2); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width, height*2); + }else { + g.setColor(Color.white); + g.fillRect(mx - width, my - width, width*2, height*2); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width, height*2); + } + GraphicLib.doubleColorRect(g, mx - width, my - width, width*2, height*2, Color.white, Color.black); } diff --git a/src/main/java/ui/window/JDialogCAMSBlocks.java b/src/main/java/ui/window/JDialogCAMSBlocks.java index 7ca2bce390de7a8508009c3f8aab87be4c836ff5..9ae2084b9ac86042887dee4ccd06a7dcdc109d0d 100755 --- a/src/main/java/ui/window/JDialogCAMSBlocks.java +++ b/src/main/java/ui/window/JDialogCAMSBlocks.java @@ -348,9 +348,11 @@ public class JDialogCAMSBlocks extends javax.swing.JDialog implements ActionList // second line panel5 c5.gridwidth = 1; c5.fill = GridBagConstraints.HORIZONTAL; - String[] v = new String[2]; + String[] v = new String[4]; v[0] = "in"; v[1] = "out"; + v[2] = "hybrid in"; + v[3] = "hybrid out"; signalInOutBox = new JComboBox<String>(v); panel5.add(signalInOutBox, c5); signalText = new JTextField(); @@ -641,6 +643,10 @@ public class JDialogCAMSBlocks extends javax.swing.JDialog implements ActionList inout=0; }else if(signalInOutBox.getSelectedIndex()==1){ inout=1; + }else if(signalInOutBox.getSelectedIndex()==2){ + inout=2; + }else if(signalInOutBox.getSelectedIndex()==3){ + inout=3; }else{ inout=-1; }