From 95b8868a0cd53335b6ca13de5e00cf3e20012db8 Mon Sep 17 00:00:00 2001 From: Andrea Enrici <andrea.enrici@nokia.com> Date: Fri, 6 Feb 2015 17:42:03 +0000 Subject: [PATCH] added button for C code generation. Started to add dataFlowType and more features for the mapping of ports onto CPs --- src/ui/ConfigurationTTool.java | 19 +++++- src/ui/GTMLModeling.java | 12 ++-- src/ui/GTURTLEModeling.java | 63 +++++++++++++++---- src/ui/JMenuBarTurtle.java | 3 + src/ui/JToolBarMainTurtle.java | 14 ++++- src/ui/MainGUI.java | 19 ++++++ src/ui/TGUIAction.java | 4 +- src/ui/tmlcd/TMLDataFlowType.java | 70 ++++++++++++++++++++++ src/ui/tmlcompd/TMLCPrimitivePort.java | 8 ++- src/ui/tmldd/TMLArchiDiagramToolBar.java | 2 + src/ui/tmldd/TMLArchiPortArtifact.java | 5 +- src/ui/window/JDialogPortArtifact.java | 47 +++++++++++++-- src/ui/window/JDialogTMLCompositePort.java | 39 +++++++++++- 13 files changed, 271 insertions(+), 34 deletions(-) create mode 100755 src/ui/tmlcd/TMLDataFlowType.java diff --git a/src/ui/ConfigurationTTool.java b/src/ui/ConfigurationTTool.java index be8715f441..7f6422f586 100755 --- a/src/ui/ConfigurationTTool.java +++ b/src/ui/ConfigurationTTool.java @@ -98,6 +98,7 @@ public class ConfigurationTTool { public static String NCDirectory = ""; public static String SystemCCodeDirectory = ""; public static String TMLCodeDirectory = ""; + public static String CcodeDirectory = ""; public static String SystemCCodeCompileCommand = ""; public static String SystemCCodeExecuteCommand = ""; public static String SystemCCodeInteractiveExecuteCommand = ""; @@ -368,6 +369,9 @@ public class ConfigurationTTool { // TML sb.append("TMLCodeDirectory" + TMLCodeDirectory + "\n"); + + //Application C code + sb.append("CcodeDirectory" + CcodeDirectory + "\n"); // VCD sb.append("VCDPath: " + VCDPath + "\n"); @@ -579,6 +583,10 @@ public class ConfigurationTTool { nl = doc.getElementsByTagName("TMLCodeDirectory"); if (nl.getLength() > 0) TMLCodeDirectory(nl); + + nl = doc.getElementsByTagName("CcodeDirectory"); + if (nl.getLength() > 0) + CcodeDirectory(nl); nl = doc.getElementsByTagName("VCDPath"); if (nl.getLength() > 0) @@ -1022,6 +1030,15 @@ public class ConfigurationTTool { throw new MalformedConfigurationException(e.getMessage()); } } + + private static void CcodeDirectory(NodeList nl) throws MalformedConfigurationException { + try { + Element elt = (Element)(nl.item(0)); + CcodeDirectory = elt.getAttribute("data"); + } catch (Exception e) { + throw new MalformedConfigurationException(e.getMessage()); + } + } private static void VCDPath(NodeList nl) throws MalformedConfigurationException { try { @@ -1275,4 +1292,4 @@ public class ConfigurationTTool { return ((s != null) && (s.trim().length() > 0)); } -} // \ No newline at end of file +} // diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java index 870a27f457..4c658eefdf 100755 --- a/src/ui/GTMLModeling.java +++ b/src/ui/GTMLModeling.java @@ -2207,16 +2207,16 @@ public class GTMLModeling { //tmlcp.generateNexts(); // Add nexts elements to CPElements //tmlcp.removeADConnectors(); // Remove connectors since nexts have been filled tmlcp.splitADs(); // Splitting ADs so as to remove junctions -> new ADs are introduced for each junction inside an AD - TraceManager.addDev( "After splitting ADs. OriginalCP:" + tmlcp.toString() ); - TraceManager.addDev( "After splitting ADs. The list of ADs contains: " + tmlcp.getCPActivityDiagrams().toString() ); + TraceManager.addDev( "After splitting ADs. OriginalCP:" + tmlcp.toString() ); + TraceManager.addDev( "After splitting ADs. The list of ADs contains: " + tmlcp.getMainCP().toString() + tmlcp.getCPActivityDiagrams().toString() ); - for( TMLCPSequenceDiagram seqDiag: tmlcp.getCPSequenceDiagrams() ) { + /*for( TMLCPSequenceDiagram seqDiag: tmlcp.getCPSequenceDiagrams() ) { TraceManager.addDev( "**********" ); + TraceManager.addDev( "DIAGRAM " + seqDiag.getName() ); for( tmltranslator.tmlcp.TMLSDInstance instance: seqDiag.getInstances() ) { - TraceManager.addDev( "PRINTING EVENTS: " + instance.getEvents() ); + TraceManager.addDev( "INSTANCE: " + instance.getName() + "\n" + instance.getAttributes() ); } - TraceManager.addDev( "**********" ); - } + }*/ } //End of method diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index 380c2f489b..ca6150fd3f 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -128,6 +128,8 @@ import proverifspec.*; import req.ebrdd.*; +import Ctranslator.*; + //Communication Pattern javaCC parser //import compiler.tmlCPparser.*; @@ -406,19 +408,64 @@ public class GTURTLEModeling { return null; } } + + public boolean generateCcode( String _title ) { + + CwmMEC myCwm = new CwmMEC(); + + TMLMappingTextSpecification spec = new TMLMappingTextSpecification( _title ); + spec.toTextFormat( tmap ); //TMLMapping + + try { + myCwm.saveFile( ConfigurationTTool.CcodeDirectory + File.separator, "application.c" ); + } + catch( Exception e ) { + TraceManager.addError( "Application C files could not be saved: " + e.getMessage() ); + return false; + } + return true; /* temporary, just to check functionality */ + } public boolean generateTMLTxt( String _title ) { if( tmlcp != null ) { //Use the data structure filled by translateToTML... and pass it to the appropriate toTextFormat() TraceManager.addError( "About to generate the TMLText for CPs" ); TMLCPTextSpecification specCP = new TMLCPTextSpecification( _title ); - specCP.toTextFormat( tmlcp ); //TMLCP.TMLCPGraphicalCP + + //get the architecture panel and the nodes + TMLArchiDiagramPanel tmlap = mgui.getTMLArchiDiagramPanels().get(0).tmlap; + LinkedList components = tmlap.getComponentList(); + ListIterator iterator = components.listIterator(); + TGComponent tgc; + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc instanceof TMLArchiCPNode) { + TMLArchiCPNode node = (TMLArchiCPNode) tgc; + TraceManager.addDev( "Found CP node: " + node.getName() ); + TraceManager.addDev( "with mapping info: " + node.getMappedUnits() ); + } + } + + ArrayList<TMLCommunicationPatternPanel> tmlcpPanelsList = new ArrayList<TMLCommunicationPatternPanel>(); + //get the TMLCommunicationPatternPanels :) + for( int i = 0; i < mgui.tabs.size(); i++ ) { + TURTLEPanel panel = (TURTLEPanel)( mgui.tabs.get(i) ); + if( panel instanceof TMLCommunicationPatternPanel ) { + tmlcpPanelsList.add( (TMLCommunicationPatternPanel) panel ); + TraceManager.addDev( "Found TMLCommunicationPatternPanel: " + ((TMLCommunicationPatternPanel)panel).toString() ); + } + } + + specCP.toTextFormat( tmlcp ); // the data structure tmlcp is filled with the info concerning the CP panel + // from which the button is pressed. If there are multiple CP panels this operation must be repeated for each panel. It + // should be no difficult to implement. try { - specCP.saveFile( ConfigurationTTool.TMLCodeDirectory + File.separator, "spec.tmlcp" ); + specCP.saveFile( ConfigurationTTool.TMLCodeDirectory + File.separator, "spec.tmlcp" ); } catch( Exception e ) { - TraceManager.addError( "Writing TMLText for CPs, file could not be saved: " + e.getMessage() ); - return false; + TraceManager.addError( "Writing TMLText for CPs, file could not be saved: " + e.getMessage() ); + return false; } } else { @@ -440,11 +487,8 @@ public class GTURTLEModeling { else { TMLMappingTextSpecification spec = new TMLMappingTextSpecification( _title ); spec.toTextFormat( tmap ); //TMLMapping - // TMLCPTextSpecification specCP = new TMLCPTextSpecification( _title ); - // specCP.toTextFormat( tmap ); //TMLCP try { spec.saveFile( ConfigurationTTool.TMLCodeDirectory + File.separator, "spec" ); - // specCP.saveFile( ConfigurationTTool.TMLCodeDirectory + File.separator, "spec.tmlcp" ); } catch( Exception e ) { TraceManager.addError( "Files could not be saved: " + e.getMessage() ); @@ -455,11 +499,6 @@ public class GTURTLEModeling { return true; //temporary, just to check functionality } - /*public void setUPPAALData(String _uppaal, RelationTIFUPPAAL _uppaalTable) { - uppaal = _uppaal; - uppaalTable = _uppaalTable; - }*/ - public boolean generateUPPAALFromTIF(String path, boolean debug, int nb, boolean choices, boolean variables) { TURTLE2UPPAAL turtle2uppaal = new TURTLE2UPPAAL(tm); turtle2uppaal.setChoiceDeterministic(choices); diff --git a/src/ui/JMenuBarTurtle.java b/src/ui/JMenuBarTurtle.java index daf938d917..ccb68c6c34 100755 --- a/src/ui/JMenuBarTurtle.java +++ b/src/ui/JMenuBarTurtle.java @@ -491,6 +491,9 @@ public class JMenuBarTurtle extends JMenuBar { menuItem.addMouseListener(mgui.mouseHandler); menuItem = codeG.add(mgui.actions[TGUIAction.ACT_GEN_TMLTXT]); + menuItem.addMouseListener(mgui.mouseHandler); + + menuItem = codeG.add(mgui.actions[TGUIAction.ACT_GEN_CCODE]); menuItem.addMouseListener(mgui.mouseHandler); } diff --git a/src/ui/JToolBarMainTurtle.java b/src/ui/JToolBarMainTurtle.java index 73d6108e95..f414dfe788 100755 --- a/src/ui/JToolBarMainTurtle.java +++ b/src/ui/JToolBarMainTurtle.java @@ -64,7 +64,7 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener // Other JButton genrtlotos, genlotos, genuppaal, gendesign; JButton checkcode, simulation, validation; - JButton oneClickrtlotos, onclicklotos, gensystemc, simusystemc, gentml, genjava, nc; + JButton oneClickrtlotos, onclicklotos, gensystemc, simusystemc, gentml, genC, genjava, nc; JTextField search; @@ -225,6 +225,10 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener gentml = add(mgui.actions[TGUIAction.ACT_GEN_TMLTXT]); gentml.addMouseListener(mgui.mouseHandler); addSeparator(); + + genC = add(mgui.actions[TGUIAction.ACT_GEN_CCODE]); + genC.addMouseListener(mgui.mouseHandler); + addSeparator(); } addSeparator(); @@ -326,6 +330,10 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener gentml.setVisible(!b); } + if (genC != null) { + genC.setVisible(!b); + } + if (genjava != null) { genjava.setVisible(!b); } @@ -395,6 +403,10 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener gentml.setVisible(b); } + if (genC != null) { + genC.setVisible(b); + } + if (genjava != null) { genjava.setVisible(!b); } diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 2462535806..f902a5ec9e 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -645,6 +645,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe case GEN_SYSTEMC_OK: actions[TGUIAction.ACT_GEN_SYSTEMC].setEnabled(true); actions[TGUIAction.ACT_GEN_TMLTXT].setEnabled(true); + actions[TGUIAction.ACT_GEN_CCODE].setEnabled(true); actions[TGUIAction.ACT_GEN_AUT].setEnabled(true); actions[TGUIAction.ACT_GEN_AUTS].setEnabled(true); actions[TGUIAction.ACT_GEN_UPPAAL].setEnabled(true); @@ -683,6 +684,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe actions[TGUIAction.ACT_GEN_DESIGN].setEnabled(false); actions[TGUIAction.ACT_GEN_SYSTEMC].setEnabled(false); actions[TGUIAction.ACT_GEN_TMLTXT].setEnabled(false); + actions[TGUIAction.ACT_GEN_CCODE].setEnabled(false); actions[TGUIAction.ACT_GEN_AUT].setEnabled(false); actions[TGUIAction.ACT_GEN_AUTS].setEnabled(false); actions[TGUIAction.ACT_GEN_UPPAAL].setEnabled(false); @@ -708,6 +710,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe actions[TGUIAction.ACT_GEN_DESIGN].setEnabled(false); actions[TGUIAction.ACT_GEN_SYSTEMC].setEnabled(false); actions[TGUIAction.ACT_GEN_TMLTXT].setEnabled(false); + actions[TGUIAction.ACT_GEN_CCODE].setEnabled(false); actions[TGUIAction.ACT_GEN_UPPAAL].setEnabled(false); actions[TGUIAction.ACT_GEN_PROVERIF].setEnabled(false); actions[TGUIAction.ACT_GEN_AUT].setEnabled(false); @@ -723,6 +726,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe actions[TGUIAction.ACT_GEN_DESIGN].setEnabled(false); actions[TGUIAction.ACT_GEN_SYSTEMC].setEnabled(false); actions[TGUIAction.ACT_GEN_TMLTXT].setEnabled(false); + actions[TGUIAction.ACT_GEN_CCODE].setEnabled(false); actions[TGUIAction.ACT_GEN_AUT].setEnabled(false); actions[TGUIAction.ACT_GEN_AUTS].setEnabled(false); actions[TGUIAction.ACT_GEN_UPPAAL].setEnabled(false); @@ -4019,6 +4023,19 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe //TraceManager.addDev("Done"); } + public String generateCcode() { + String path = ConfigurationTTool.FILEPath; + if( file != null ) { + path = file.getAbsolutePath(); + } + TraceManager.addDev("Generating C code: " + path ); + if( gtm.generateCcode( path ) ) { + return ConfigurationTTool.CcodeDirectory; + } + return null; + //TraceManager.addDev("Done"); + } + public void generateDesign() { if (gtm.getTURTLEModelingState() == 1) { if (generateTURTLEModelingFromState(gtm.getTURTLEModelingState(), false, DESIGN) == -1) { @@ -7495,6 +7512,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe interactiveSimulationSystemC(); } else if (command.equals(actions[TGUIAction.ACT_GEN_TMLTXT].getActionCommand())) { generateTMLTxt(); + } else if (command.equals(actions[TGUIAction.ACT_GEN_CCODE].getActionCommand())) { + generateCcode(); } else if (command.equals(actions[TGUIAction.ACT_GEN_DESIGN].getActionCommand())) { generateDesign(); } else if (command.equals(actions[TGUIAction.ACT_CHECKCODE].getActionCommand())) { diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index f6fc4ca8d5..b1496c8006 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -435,6 +435,7 @@ public class TGUIAction extends AbstractAction { public static final int ACT_GEN_SYSTEMC = 148; public static final int ACT_SIMU_SYSTEMC = 263; public static final int ACT_GEN_TMLTXT = 215; + public static final int ACT_GEN_CCODE = 413; public static final int ACT_GEN_AUT = 157; public static final int ACT_GEN_AUTS = 202; public static final int ACT_GEN_DESIGN = 103; @@ -547,7 +548,7 @@ public class TGUIAction extends AbstractAction { //Action for the help button created by Solange public static final int PRUEBA_1 = 205; - public static final int NB_ACTION = 413; + public static final int NB_ACTION = 414; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -656,6 +657,7 @@ public class TGUIAction extends AbstractAction { actions[ACT_GEN_SYSTEMC] = new TAction("gen_systemc-command", "Generate simulation code", IconManager.imgic61, IconManager.imgic61, "Generate code for simulation", "Generates code for simulation", 0); actions[ACT_SIMU_SYSTEMC] = new TAction("simu_systemc", "Interactive Simulation", IconManager.imgic61, IconManager.imgic61, "Interactive simulation", "Interactive simulation ", 0); actions[ACT_GEN_TMLTXT] = new TAction("gen_tmltxt-command", "Generate TML / TMAP in text format", IconManager.imgic66, IconManager.imgic66, "Generate TML / TMAP in text format", "Generates TML / TMAP code in text format from TML Design diagrams", 0); + actions[ACT_GEN_CCODE] = new TAction("gen_Ccode-command", "Generate C code", IconManager.imgic66, IconManager.imgic66, "Generate C code", "Generate C code from Design diagrams", 0); actions[ACT_GEN_AUT] = new TAction("gen_aut-command", "Generate automata", IconManager.imgic64, IconManager.imgic64, "Generate automata", "Generates automata from TML Design diagrams", 0); actions[ACT_GEN_AUTS] = new TAction("gen_auts-command", "Generate automata via LOTOS", IconManager.imgic64, IconManager.imgic64, "Generate automata via LOTOS", "Generates automata from TML Design diagrams, using LOTOS", 0); actions[ACT_GEN_DESIGN] = new TAction("gen_design-command", "Generate Design", IconManager.imgic58, IconManager.imgic59, "Generate Design from analysis", "Generates a TURTLE design from a TURTLE analysis", 0); diff --git a/src/ui/tmlcd/TMLDataFlowType.java b/src/ui/tmlcd/TMLDataFlowType.java new file mode 100755 index 0000000000..252f620eb6 --- /dev/null +++ b/src/ui/tmlcd/TMLDataFlowType.java @@ -0,0 +1,70 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.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 TMLDataFlowType + * To be used in class diagrams + * Creation: 06/02/2015 + * @version 1.0 06/02/2015 + * @author Andrea ENRICI + * @see + */ + +package ui.tmlcd; + +import java.awt.*; +import javax.swing.*; +import java.util.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public abstract class TMLDataFlowType { + + public static final String UINT_16 = "uint_16"; + public static final String UINT_32 = "uint_32"; + public static final String UINT_64 = "uint_64"; + public static final String INT_16 = "int_16"; + public static final String INT_32 = "int_32"; + public static final String INT_64 = "int_64"; + public static final String CPX_32 = "cpx_32"; + public static final String CPX_64 = "cpx_64"; + +} diff --git a/src/ui/tmlcompd/TMLCPrimitivePort.java b/src/ui/tmlcompd/TMLCPrimitivePort.java index ab8657e899..bae9920fea 100755 --- a/src/ui/tmlcompd/TMLCPrimitivePort.java +++ b/src/ui/tmlcompd/TMLCPrimitivePort.java @@ -84,7 +84,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent protected boolean conflict = false; protected String conflictMessage; - + protected String dataFlowType = "VOID"; public TMLCPrimitivePort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -415,10 +415,12 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent otherTypes = tgc.getAllRecords(); } - JDialogTMLCompositePort jda = new JDialogTMLCompositePort(commName, typep, list[0], list[1], list[2], list[3], list[4], isOrigin, isFinite, isBlocking, ""+maxSamples, ""+widthSamples, isLossy, lossPercentage, maxNbOfLoss, frame, "Port properties", otherTypes); + JDialogTMLCompositePort jda = new JDialogTMLCompositePort(commName, typep, list[0], list[1], list[2], list[3], list[4], isOrigin, isFinite, isBlocking, ""+maxSamples, ""+widthSamples, isLossy, lossPercentage, maxNbOfLoss, frame, "Port properties", otherTypes, dataFlowType ); jda.setSize(350, 700); GraphicLib.centerOnParent(jda); jda.show(); // blocked until dialog has been closed + dataFlowType = jda.getDataFlowType(); + TraceManager.addDev( "The Data flow type is: " + dataFlowType ); if (jda.hasNewData()) { try { @@ -485,6 +487,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent sb.append("\" isLossy=\"" + isLossy); sb.append("\" lossPercentage=\"" + lossPercentage); sb.append("\" maxNbOfLoss=\"" + maxNbOfLoss); + sb.append("\" dataFlowType=\"" + dataFlowType); sb.append("\" />\n"); for(int i=0; i<nbMaxAttribute; i++) { //System.out.println("Attribute:" + i); @@ -560,6 +563,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent try { lossPercentage = Integer.decode(elt.getAttribute("lossPercentage")).intValue(); maxNbOfLoss = Integer.decode(elt.getAttribute("maxNbOfLoss")).intValue(); + dataFlowType = elt.getAttribute("dataFlowType"); isLossy = (elt.getAttribute("isLossy").compareTo("true") ==0); } catch (Exception e) { lossPercentage = 0; diff --git a/src/ui/tmldd/TMLArchiDiagramToolBar.java b/src/ui/tmldd/TMLArchiDiagramToolBar.java index 001cb57f81..0acea92cea 100755 --- a/src/ui/tmldd/TMLArchiDiagramToolBar.java +++ b/src/ui/tmldd/TMLArchiDiagramToolBar.java @@ -140,6 +140,8 @@ public class TMLArchiDiagramToolBar extends TToolBar { button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]); button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]); + button.addMouseListener(mgui.mouseHandler); this.addSeparator(); diff --git a/src/ui/tmldd/TMLArchiPortArtifact.java b/src/ui/tmldd/TMLArchiPortArtifact.java index 0c25f4fae6..a8decbb3fb 100644 --- a/src/ui/tmldd/TMLArchiPortArtifact.java +++ b/src/ui/tmldd/TMLArchiPortArtifact.java @@ -65,7 +65,7 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements protected int fileX = 20; protected int fileY = 25; protected int cran = 5; - + protected String mappedMemory = "VOID"; protected String oldValue = ""; protected String referenceCommunicationName = "TMLCommunication"; protected String portName = "name"; @@ -161,10 +161,11 @@ public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements String tmp; boolean error = false; - JDialogPortArtifact dialog = new JDialogPortArtifact(frame, "Setting port artifact attributes", this); + JDialogPortArtifact dialog = new JDialogPortArtifact(frame, "Setting port artifact attributes", this, mappedMemory ); dialog.setSize(700, 600); GraphicLib.centerOnParent(dialog); dialog.show(); // blocked until dialog has been closed + mappedMemory = dialog.getMappedMemory(); if (!dialog.isRegularClose()) { return false; diff --git a/src/ui/window/JDialogPortArtifact.java b/src/ui/window/JDialogPortArtifact.java index 90fa667323..1f27cc0887 100755 --- a/src/ui/window/JDialogPortArtifact.java +++ b/src/ui/window/JDialogPortArtifact.java @@ -67,18 +67,20 @@ public class JDialogPortArtifact extends javax.swing.JDialog implements ActionLi private JPanel panel2; private Frame frame; private TMLArchiPortArtifact artifact; - - protected JComboBox referenceCommunicationName, priority; + private String mappedMemory = "VOID"; + protected JComboBox referenceCommunicationName, priority, memory; + protected JTextField startAddress, endAddress; // Main Panel private JButton closeButton; private JButton cancelButton; /** Creates new form */ - public JDialogPortArtifact(Frame _frame, String _title, TMLArchiPortArtifact _artifact) { + public JDialogPortArtifact(Frame _frame, String _title, TMLArchiPortArtifact _artifact, String _mappedMemory ) { super(_frame, _title, true); frame = _frame; artifact = _artifact; + mappedMemory = _mappedMemory; //System.out.println("New window"); @@ -152,11 +154,11 @@ public class JDialogPortArtifact extends javax.swing.JDialog implements ActionLi TraceManager.addDev("Got communications"); - referenceCommunicationName = new JComboBox(portsList); + referenceCommunicationName = new JComboBox(portsList); referenceCommunicationName.setSelectedIndex(index); referenceCommunicationName.addActionListener(this); - //referenceTaskName.setEditable(true); - //referenceTaskName.setFont(new Font("times", Font.PLAIN, 12)); + //referenceTaskName.setEditable(true); + //referenceTaskName.setFont(new Font("times", Font.PLAIN, 12)); panel2.add(referenceCommunicationName, c1); list = new Vector<String>(); @@ -165,8 +167,36 @@ public class JDialogPortArtifact extends javax.swing.JDialog implements ActionLi } priority = new JComboBox(list); priority.setSelectedIndex(artifact.getPriority()); + panel2.add( new JLabel( "Priority: "), c2 ); panel2.add(priority, c1); + //Make the list of memories + LinkedList componentList = artifact.getTDiagramPanel().getComponentList(); + Vector<String> memoryList = new Vector<String>(); + for( int k = 0; k < componentList.size(); k++ ) { + if( componentList.get(k) instanceof TMLArchiMemoryNode ) { + memoryList.add( ( (TMLArchiMemoryNode) componentList.get(k) ).getName() ); + } + } + + memory = new JComboBox( memoryList ); + if( mappedMemory.equals( "VOID" ) || mappedMemory.equals( "" ) ) { + memory.setSelectedIndex( 0 ); + } + else { + memory.setSelectedIndex( memoryList.indexOf( mappedMemory ) ); + } + panel2.add( new JLabel( "Memory: "), c2 ); + panel2.add( memory, c1 ); + + startAddress = new JTextField("", 5 ); + panel2.add( new JLabel( "Start address = "), c2 ); + c1.gridwidth = GridBagConstraints.REMAINDER; + panel2.add( startAddress, c1 ); + + endAddress = new JTextField("", 5 ); + panel2.add( new JLabel( "End address = "), c2 ); + panel2.add( endAddress, c1 ); /*c1.gridwidth = 1; c1.gridheight = 1; c1.weighty = 1.0; @@ -230,8 +260,13 @@ public class JDialogPortArtifact extends javax.swing.JDialog implements ActionLi public void closeDialog() { regularClose = true; + mappedMemory = (String) memory.getItemAt( memory.getSelectedIndex() ); dispose(); } + + public String getMappedMemory() { + return mappedMemory; + } public void cancelDialog() { dispose(); diff --git a/src/ui/window/JDialogTMLCompositePort.java b/src/ui/window/JDialogTMLCompositePort.java index c243e0b34c..f6fe94bdd5 100755 --- a/src/ui/window/JDialogTMLCompositePort.java +++ b/src/ui/window/JDialogTMLCompositePort.java @@ -50,6 +50,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import ui.*; +import ui.tmlcd.*; import java.util.*; import myutil.*; @@ -60,6 +61,7 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti private Frame frame; private String name; + private String dataFlowType = "VOID"; private TType type1, type2, type3, type4, type5; private boolean isFinite, isBlocking, isOrigin; private String maxInFIFO, widthSamples; @@ -75,7 +77,7 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti // Panel1 private JTextField nameText, maxText, widthText; private JComboBox typePort, typeList1, typeList2, typeList3, typeList4, typeList5; - private JComboBox origin, finite, blocking; + private JComboBox origin, finite, blocking, dfType; private JLabel lossPercentageLabel, maxNbOfLossLabel; private int portIndex; private Vector origins, finites, blockings, portTypes, types1, types2, types3, types4, types5; @@ -90,7 +92,7 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti private JButton closeButton; private JButton cancelButton; - public JDialogTMLCompositePort(String _name, int _portIndex, TType _type1, TType _type2, TType _type3, TType _type4, TType _type5, boolean _isOrigin, boolean _isFinite, boolean _isBlocking, String _maxInFIFO, String _widthSamples, boolean _isLossy, int _lossPercentage, int _maxNbOfLoss, Frame f, String title, Vector<String> _types) { + public JDialogTMLCompositePort(String _name, int _portIndex, TType _type1, TType _type2, TType _type3, TType _type4, TType _type5, boolean _isOrigin, boolean _isFinite, boolean _isBlocking, String _maxInFIFO, String _widthSamples, boolean _isLossy, int _lossPercentage, int _maxNbOfLoss, Frame f, String title, Vector<String> _types, String _dataFlowType ) { super(f, title, true); frame = f; @@ -102,6 +104,7 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti data = false; + dataFlowType = _dataFlowType; maxInFIFO = _maxInFIFO; widthSamples = _widthSamples; isOrigin = _isOrigin; @@ -174,6 +177,16 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti private void initComponents() { int i; + Vector<String> dataFlowTypes = new Vector<String>(); + dataFlowTypes.add( TMLDataFlowType.UINT_16 ); + dataFlowTypes.add( TMLDataFlowType.UINT_32 ); + dataFlowTypes.add( TMLDataFlowType.UINT_64 ); + dataFlowTypes.add( TMLDataFlowType.INT_16 ); + dataFlowTypes.add( TMLDataFlowType.INT_32 ); + dataFlowTypes.add( TMLDataFlowType.INT_64 ); + dataFlowTypes.add( TMLDataFlowType.CPX_32 ); + dataFlowTypes.add( TMLDataFlowType.CPX_64 ); + Container c = getContentPane(); GridBagLayout gridbag0 = new GridBagLayout(); GridBagLayout gridbag1 = new GridBagLayout(); @@ -355,6 +368,21 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti } } panel2.add(typeList5, c2); + + c2.gridwidth = 1; + c2.fill = GridBagConstraints.HORIZONTAL; + c2.anchor = GridBagConstraints.CENTER; + panel2.add(new JLabel("Dataflow type"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + dfType = new JComboBox( dataFlowTypes ); + if( dataFlowType.equals( "VOID" ) || dataFlowType.equals( "" ) ) { + dfType.setSelectedIndex( 0 ); + } + else { + dfType.setSelectedIndex( dataFlowTypes.indexOf( dataFlowType ) ); + } + dfType.addActionListener(this); + panel2.add( dfType, c2); c2.gridwidth = 1; c2.fill = GridBagConstraints.HORIZONTAL; @@ -486,8 +514,13 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti public void closeDialog() { data = true; + dataFlowType = (String)dfType.getItemAt( dfType.getSelectedIndex() ); dispose(); } + + public String getDataFlowType() { + return dataFlowType; + } public void cancelDialog() { dispose(); @@ -641,4 +674,4 @@ public class JDialogTMLCompositePort extends javax.swing.JDialog implements Acti return -1; } } -} \ No newline at end of file +} -- GitLab