diff --git a/bin/config.xml b/bin/config.xml index e8ab3cb1962e3c07400f5abfee5f425bf092ff6d..0dd11184e02338d09f59fa7ef9868da283165f22 100755 --- a/bin/config.xml +++ b/bin/config.xml @@ -64,7 +64,7 @@ -<LastWindowAttributes x="-1" y="27" width="1368" height="742" max="true" /> +<LastWindowAttributes x="699" y="122" width="1719" height="1201" max="true" /> </TURTLECONFIGURATION> diff --git a/src/ui/ADDPanel.java b/src/ui/ADDPanel.java new file mode 100755 index 0000000000000000000000000000000000000000..ab5f9f67a34228375daa37a841aefe6403e58981 --- /dev/null +++ b/src/ui/ADDPanel.java @@ -0,0 +1,117 @@ +/**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 ADDPanel + * Managenemt of Avatar architecture panels + * Creation: 01/07/2014 + * @version 1.0 01/07/2014 + * @author Ludovic APVRILLE + * @see MainGUI + */ + +package ui; + +import java.awt.*; +import javax.swing.*; +import javax.swing.event.*; +import java.util.*; +import ui.avatardd.*; + +public class ADDPanel extends TURTLEPanel { + public ADDDiagramPanel tmladd; + public Vector validated, ignored; + + public ADDPanel(MainGUI _mgui) { + super(_mgui); + tabbedPane = new JTabbedPane(); + cl = new ChangeListener() { + public void stateChanged(ChangeEvent e){ + mgui.paneDesignAction(e); + } + }; + tabbedPane.addChangeListener(cl); + tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui)); + } + + public void init() { + + // Class Diagram toolbar + ADDDiagramToolBar toolBar = new ADDDiagramToolBar(mgui); + toolbars.add(toolBar); + + toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + //Class diagram + tmladd = new ADDDiagramPanel(mgui, toolBar); + tmladd.setName("Avatar deployment diagram"); + tmladd.tp = this; + tdp = tmladd; + panels.add(tmladd); // Always first in list + JScrollDiagramPanel jsp = new JScrollDiagramPanel(tmladd); + tmladd.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT); + toolBarPanel.add(toolBar, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + tabbedPane.addTab("Avatar Deployment Diagram", IconManager.imgic60, toolBarPanel, "Opens Avatar deployment diagram"); + tabbedPane.setSelectedIndex(0); + + //jsp.setVisible(true); + + } + + public String saveHeaderInXml() { + return "<Modeling type=\"ADD\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; + } + + public String saveTailInXml() { + return "</Modeling>\n\n\n"; + } + + public String toString() { + return mgui.getTitleAt(this) + " (Avatar deployment diagram)"; + } + + public void renameDeployment(String oldName, String newName) { + /*if (tmladd != null) { + tmladd.renameDeployment(oldName, newName); + }*/ + } + +} \ No newline at end of file diff --git a/src/ui/ColorManager.java b/src/ui/ColorManager.java index 3556b51d04444c6ea260a05a9eadf78889be4af7..d999a5183cf0f1d51ce8dddeb2e5f435ff411db2 100755 --- a/src/ui/ColorManager.java +++ b/src/ui/ColorManager.java @@ -270,7 +270,8 @@ public class ColorManager { AVATAR_CODE = Color.black; AVATAR_SEND_SIGNAL = Color.white; AVATAR_RECEIVE_SIGNAL = Color.white; - + AVATAR_ASSUMPTION_ATTRIBUTES = Color.white; + AVATAR_ASSUMPTION_TOP = Color.white; } diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index ce74193c4d6025892a0c6895fcc8d5c9385ef9c4..b5cd8697e3faa063af39a4b5a81da0696a3efcd7 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -95,6 +95,7 @@ import ui.avatarmad.*; import ui.avatarpd.*; import ui.avatarcd.*; import ui.avatarad.*; +import ui.avatardd.*; import proverifspec.*; @@ -1151,6 +1152,22 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe return index; } + private int addADDPanel(String name, int index) { + if (index == -1) { + index = tabs.size(); + } + ADDPanel dp = new ADDPanel(this); + tabs.add(index, dp); + mainTabbedPane.add(dp.tabbedPane, index); + mainTabbedPane.setToolTipTextAt(index, "Open Avatar deployment diagram"); + mainTabbedPane.setTitleAt(index, name); + mainTabbedPane.setIconAt(index, IconManager.imgic60); + //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams"); + dp.init(); + //ystem.out.println("Design added"); + return index; + } + private int addTMLArchiPanel(String name, int index) { if (index == -1) { index = tabs.size(); @@ -1436,6 +1453,12 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe mainTabbedPane.setSelectedIndex(index); return index; } + + public int createAAD(String name) { + int index = addADDPanel(name, -1); + mainTabbedPane.setSelectedIndex(index); + return index; + } public int createTURTLEOSDesign(String name) { int index = addTURTLEOSDesignPanel(name, -1); @@ -1764,6 +1787,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe mainTabbedPane.setSelectedIndex(tabs.size()-1); //paneAction(null); //frame.repaint(); + } + + public void newADD() { + TraceManager.addDev("NEW Avatar deployment"); + addADDPanel("Avatar Deployment", -1); + ((TURTLEPanel)tabs.elementAt(tabs.size()-1)).tabbedPane.setSelectedIndex(0); + mainTabbedPane.setSelectedIndex(tabs.size()-1); + //paneAction(null); + //frame.repaint(); } public void newTURTLEOSDesign() { @@ -5142,6 +5174,11 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(indexDesign)); tp.tabbedPane.setTitleAt(0, name); } + + public void setAADName(int indexDesign, String name) { + TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(indexDesign)); + tp.tabbedPane.setTitleAt(0, name); + } public void setProacticeCSDName(int indexDesign, String name) { TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(indexDesign)); @@ -6625,6 +6662,18 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe } } + + public void renameDeployment(String oldName, String newName) { + TURTLEPanel tp; + + for(int i = 0; i<mainTabbedPane.getTabCount(); i++) { + tp = (TURTLEPanel)(tabs.elementAt(i)); + if (tp instanceof ADDPanel) { + ((ADDPanel)tp).renameDeployment(oldName, newName); + } + } + + } public boolean selectTDiagramPanel(TDiagramPanel tdp) { return (selectTab(getPoint(tdp)) == tdp); @@ -7572,6 +7621,28 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.AAD_PARTITION); } else if (command.equals(actions[TGUIAction.AAD_ALIGN_PARTITION].getActionCommand())) { alignPartitions(); + + // Avatar DD + } else if (command.equals(actions[TGUIAction.ADD_EDIT].getActionCommand())) { + actionOnButton(TGComponentManager.EDIT, -1); + } else if (command.equals(actions[TGUIAction.ADD_LINK].getActionCommand())) { + actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.ADD_CONNECTOR); + } else if (command.equals(actions[TGUIAction.ADD_CPUNODE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_CPUNODE); + } else if (command.equals(actions[TGUIAction.ADD_BUSNODE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_BUSNODE); + } else if (command.equals(actions[TGUIAction.ADD_BRIDGENODE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_BRIDGENODE); + } else if (command.equals(actions[TGUIAction.ADD_TTYNODE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_TTYNODE); + } else if (command.equals(actions[TGUIAction.ADD_RAMNODE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_RAMNODE); + } else if (command.equals(actions[TGUIAction.ADD_ROMNODE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_ROMNODE); + } else if (command.equals(actions[TGUIAction.ADD_DMANODE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_DMANODE); + } else if (command.equals(actions[TGUIAction.ADD_BLOCKARTIFACT].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ADD_ARTIFACT); } else if (command.equals(actions[TGUIAction.TCD_ASSOCIATION].getActionCommand())) { actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.CONNECTOR_ASSOCIATION); @@ -8012,7 +8083,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; + newNCDesign, sort, clone, newAttackTree, newAVATARBD, newAVATARRequirement, newMAD, newTMLCP, newTMLMethodo, newAVATARDD; private JMenuItem newAVATARAnalysis; public PopupListener(MainGUI _mgui) { @@ -8063,6 +8134,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe newAVATARRequirement = createMenuItem("New AVATAR Requirement Diagrams"); newAVATARAnalysis = createMenuItem("New AVATAR Analysis"); newAVATARBD = createMenuItem("New AVATAR Design"); + newAVATARDD = createMenuItem("New AVATAR Deployment Diagram"); menu = new JPopupMenu("TURTLE analysis, design and deployment / DIPLODOCUS design / Proactive design"); menu.add(moveLeft); @@ -8124,6 +8196,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe menu.add(newAVATARRequirement); menu.add(newAVATARAnalysis); menu.add(newAVATARBD); + if (experimentalOn) { + menu.add(newAVATARDD); + } } } @@ -8212,6 +8287,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe mgui.newNCDesign(); } else if (e.getSource() == newAVATARBD) { mgui.newAvatarBD(); + } else if (e.getSource() == newAVATARDD) { + mgui.newADD(); } else if (e.getSource() == newAVATARRequirement) { mgui.newAvatarRequirement(); } else if (e.getSource() == newMAD) { diff --git a/src/ui/TGComponent.java b/src/ui/TGComponent.java index 45d846d1ece1c1e257abc0951bd4a4c21e28e8c2..60d649a8fc5614613ac852f7cc1a22fd22dae4ba 100755 --- a/src/ui/TGComponent.java +++ b/src/ui/TGComponent.java @@ -2452,7 +2452,7 @@ public abstract class TGComponent implements CDElement, GenericTree { return null; } - // returns true if modification on component + // Returns true if modification on component public final boolean doubleClick(JFrame frame, int _x, int _y) { boolean b; if (multieditable) { diff --git a/src/ui/TGComponentManager.java b/src/ui/TGComponentManager.java index 0dda4e969c4232f4d50984f1481e532fa403cc8e..9f5cb7a7847043db118b11047195c87f2cb3aa11 100755 --- a/src/ui/TGComponentManager.java +++ b/src/ui/TGComponentManager.java @@ -82,6 +82,7 @@ import ui.ncdd.*; import ui.avatarmad.*; import ui.avatarbd.*; +import ui.avatardd.*; import ui.avatarsmd.*; import ui.avatarrd.*; import ui.avatarpd.*; @@ -383,6 +384,17 @@ public class TGComponentManager { public static final int APD_PROPERTY_CONNECTOR = 5312; public static final int APD_COMPOSITION_CONNECTOR = 5313; + // Avatar Deployment Diagrams at 5350 + public static final int ADD_CONNECTOR = 5350; + public static final int ADD_CPUNODE = 5351; + public static final int ADD_ARTIFACT = 5352; + public static final int ADD_BUSNODE = 5353; + public static final int ADD_TTYNODE = 5354; + public static final int ADD_RAMNODE = 5355; + public static final int ADD_ROMNODE = 5356; + public static final int ADD_BRIDGENODE = 5357; + public static final int ADD_DMANODE = 5358; + // AVATAR CD -> starts at 5400 public static final int ACD_BLOCK = 5400; public static final int ACD_ACTOR_STICKMAN = 5401; @@ -550,6 +562,32 @@ public class TGComponentManager { break; case AAD_PARTITION: tgc = new AvatarADPartition(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + + //AVATAR DD + case ADD_CPUNODE: + tgc = new ADDCPUNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ADD_BUSNODE: + tgc = new ADDBusNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ADD_TTYNODE: + tgc = new ADDTTYNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ADD_BRIDGENODE: + tgc = new ADDBridgeNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ADD_RAMNODE: + tgc = new ADDRAMNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ADD_ROMNODE: + tgc = new ADDROMNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ADD_DMANODE: + tgc = new ADDDMANode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case ADD_ARTIFACT: + tgc = new ADDBlockArtifact(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; // Others @@ -1059,6 +1097,8 @@ public class TGComponentManager { } else if (tgc instanceof AvatarBDPortConnector) { return AVATARBD_PORT_CONNECTOR; + + // AVATAR SMD } else if (tgc instanceof AvatarSMDStartState) { return AVATARSMD_START_STATE; @@ -1086,6 +1126,27 @@ public class TGComponentManager { return AVATARSMD_EXPIRE_TIMER; + //AVATAR DD + } else if (tgc instanceof ADDConnector) { + return ADD_CONNECTOR; + } else if (tgc instanceof ADDCPUNode) { + return ADD_CPUNODE; + } else if (tgc instanceof ADDBlockArtifact) { + return ADD_ARTIFACT; + } else if (tgc instanceof ADDBusNode) { + return ADD_BUSNODE; + } else if (tgc instanceof ADDTTYNode) { + return ADD_TTYNODE; + } else if (tgc instanceof ADDRAMNode) { + return ADD_RAMNODE; + } else if (tgc instanceof ADDROMNode) { + return ADD_ROMNODE; + } else if (tgc instanceof ADDBridgeNode) { + return ADD_BRIDGENODE; + } else if (tgc instanceof ADDDMANode) { + return ADD_DMANODE; + + // AVATAR MAD } else if (tgc instanceof AvatarMADAssumption) { return AVATARMAD_ASSUMPTION; diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index 4a21d62c64188ba0a9ae9adeb40474c1e3126d52..e3a1fbf44a77f39ce57e5bae92502e8e554068e2 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -363,6 +363,20 @@ public class TGUIAction extends AbstractAction { public static final int AMAD_IMPACT_CONNECTOR = 375; public static final int AMAD_MEET_CONNECTOR = 377; public static final int AMAD_VERSIONING_CONNECTOR = 376; + + //AVATAR Deployment diagram + public static final int ADD_EDIT = 398; + public static final int ADD_LINK = 399; + public static final int ADD_CPUNODE = 400; + public static final int ADD_BUSNODE = 401; + public static final int ADD_BLOCKARTIFACT = 402; + public static final int ADD_TTYNODE = 403; + public static final int ADD_RAMNODE = 404; + public static final int ADD_ROMNODE = 405; + public static final int ADD_DMANODE = 406; + public static final int ADD_BRIDGENODE = 407; + + // AVATAR Parametric Diagrams public static final int APD_EDIT = 307; @@ -528,7 +542,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 = 398; + public static final int NB_ACTION = 408; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -730,6 +744,19 @@ public class TGUIAction extends AbstractAction { actions[AD_ARRAY_GET] = new TAction("add-array-get", "Add array get element", IconManager.imgic230, IconManager.imgic230, "Array get element", "Add an array get element action to the currently opened activity diagram", 0); actions[AD_ARRAY_SET] = new TAction("add-array-set", "Add array set element", IconManager.imgic232, IconManager.imgic232, "Array set element", "Add an array set element action to the currently opened activity diagram", 0); + actions[ADD_EDIT] = new TAction("edit-add-diagram", "Edit AVATAR deployment diagram", IconManager.imgic100, IconManager.imgic101, "Edit AVATAR deployment diagram", "Make it possible to edit the currently opened AVATAR deployment diagram", 0); + actions[ADD_LINK] = new TAction("add-add-link", "Add a link", IconManager.imgic202, IconManager.imgic202, "Link", "Add a link between two nodes of the currently opened AVATAR deployment diagram", 0); + actions[ADD_CPUNODE] = new TAction("add-add-cpunode", "Add a CPU", IconManager.imgic1100, IconManager.imgic1100, "CPU", "Add a cpu node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_BUSNODE] = new TAction("add-add-busnode", "Add a Bus", IconManager.imgic1102, IconManager.imgic1102, "Bus", "Add a bus node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_TTYNODE] = new TAction("add-add-tty", "Add a tty node", IconManager.imgic1102, IconManager.imgic1102, "TTY", "Add a tty node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_BLOCKARTIFACT] = new TAction("add-add-blockartifact", "Map an AVATAR block", IconManager.imgic702, IconManager.imgic702, "Map an AVATAR block", "Map an AVATAR block onto a node in the currently opened AVATAR deployment diagram", 0); + actions[ADD_BRIDGENODE] = new TAction("add-tmlarchi-bridgenode", "Add a Bridge", IconManager.imgic1104, IconManager.imgic1104, "Bridge node", "Add a bridge node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_RAMNODE] = new TAction("add-add-ramnode", "Add a RAM", IconManager.imgic1106, IconManager.imgic1106, "RAM", "Add a hardware accelerator node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_ROMNODE] = new TAction("add-add-romnode", "Add a ROM", IconManager.imgic1108, IconManager.imgic1108, "ROM", "Add a memory node to the currently opened AVATAR deployment diagram", 0); + actions[ADD_DMANODE] = new TAction("add-add-dmanode", "Add a DMA", IconManager.imgic1110, IconManager.imgic1110, "DMA", "Add a DMA node to the currently opened AVATAR deployment diagram", 0); + + + actions[TCD_PARALLEL_OPERATOR] = new TAction("add-parallel-operator", "Add Parallel composition operator", IconManager.imgic112, IconManager.imgic112, "Parallel composition operator", "Add a Parallel composition operator to the currently opened class diagram", 0); actions[TCD_CONNECTOR_ATTRIBUTE] = new TAction("add-attribute-connector", "Connects an association to a composition operator", IconManager.imgic108, IconManager.imgic108, "Attributes an association with a composition operator", "Adds a connector between an association and a composition operator to the currently opened class diagram", 0); actions[TCD_SEQUENCE_OPERATOR] = new TAction("add-sequence-operator", "Add Sequence composition operator", IconManager.imgic114, IconManager.imgic114, "Sequence composition operator", "Add a Sequence composition operator to the currently opened class diagram", 0); diff --git a/src/ui/avatardd/ADDArtifact.java b/src/ui/avatardd/ADDArtifact.java new file mode 100755 index 0000000000000000000000000000000000000000..cebf2879f57e0c3a82d843899a042ca9813c9e8d --- /dev/null +++ b/src/ui/avatardd/ADDArtifact.java @@ -0,0 +1,290 @@ +/**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 ADDArtifact + * Artifact of an avatar deployment diagram + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class ADDArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int textY2 = 35; + protected int space = 5; + protected int fileX = 20; + protected int fileY = 25; + protected int cran = 5; + + protected String oldValue = ""; + protected String referenceTaskName = "referenceToBlock"; + protected String taskName = "name"; + + public ADDArtifact(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); + + width = 75; + height = 40; + minWidth = 75; + + nbConnectingPoint = 0; + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + + value = "TMLDesign::task"; + taskName = "name"; + referenceTaskName = "TMLTask"; + + makeFullValue(); + + myImageIcon = IconManager.imgic702; + } + + + public void internalDrawing(Graphics g) { + + if (oldValue.compareTo(value) != 0) { + setValue(value, g); + } + + g.drawRect(x, y, width, height); + Color c = g.getColor(); + g.setColor(ColorManager.CPU_BOX_2); + g.fillRect(x+1, y+1, width-1, height-1); + g.setColor(c); + + //g.drawRoundRect(x, y, width, height, arc, arc); + g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); + g.drawLine(x+width-space-fileX, y + space, x+width-space-cran, y+space); + g.drawLine(x+width-space-cran, y+space, x+width-space, y+space + cran); + g.drawLine(x+width-space, y+space + cran, x+width-space, y+space+fileY); + g.drawLine(x+width-space, y+space+fileY, x+width-space-fileX, y+space+fileY); + g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); + g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + + g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); + + g.drawString(value, x + textX , y + textY); + + } + + public void setValue(String val, Graphics g) { + oldValue = value; + int w = g.getFontMetrics().stringWidth(value); + int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); + + //System.out.println("width=" + width + " w1=" + w1 + " w2=" + w2 + " value=" + value); + if (w1 != width) { + width = w1; + resizeWithFather(); + } + //System.out.println("width=" + width + " w1=" + w1 + " value=" + value); + } + + public void resizeWithFather() { + if ((father != null) && ((father instanceof ADDCPUNode))) { + //System.out.println("cdRect comp"); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + //setCd(Math.min(x, father.getWidth() - getWidth()), Math.min(y, father.getHeight() - getHeight())); + setMoveCd(x, y); + } + } + + + public boolean editOndoubleClick(JFrame frame) { + String tmp; + boolean error = false; + + /*JDialogTMLTaskArtifact dialog = new JDialogTMLTaskArtifact(frame, "Setting artifact attributes", this); + dialog.setSize(400, 350); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getReferenceTaskName() == null) { + return false; + } + + if (dialog.getReferenceTaskName().length() != 0) { + tmp = dialog.getReferenceTaskName(); + referenceTaskName = tmp; + + + } + + if (dialog.getTaskName().length() != 0) { + tmp = dialog.getTaskName(); + + if (!TAttribute.isAValidId(tmp, false, false)) { + error = true; + } else { + taskName = tmp; + } + } + + priority = dialog.getPriority(); + + if (error) { + JOptionPane.showMessageDialog(frame, + "Name is non-valid", + "Error", + JOptionPane.INFORMATION_MESSAGE); + } + + makeFullValue();*/ + + return !error; + + } + + private void makeFullValue() { + value = referenceTaskName + "::" + taskName; + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.ADD_ARTIFACT; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\""); + sb.append(referenceTaskName); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String svalue = null, sname = null, sreferenceTask = null; + String prio; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + svalue = elt.getAttribute("value"); + sname = elt.getAttribute("taskName"); + sreferenceTask = elt.getAttribute("referenceTaskName"); + } + if (svalue != null) { + value = svalue; + } + if (sname != null){ + taskName = sname; + } + if (sreferenceTask != null) { + referenceTaskName = sreferenceTask; + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + makeFullValue(); + } + + public DesignPanel getDesignPanel() { + return tdp.getGUI().getDesignPanel(value); + } + + public String getReferenceTaskName() { + return referenceTaskName; + } + + public void setReferenceTaskName(String _referenceTaskName) { + referenceTaskName = _referenceTaskName; + makeFullValue(); + } + + public String getTaskName() { + return taskName; + } + + public String getAttributes() { + return ""; + } + + + + +} diff --git a/src/ui/avatardd/ADDBlockArtifact.java b/src/ui/avatardd/ADDBlockArtifact.java new file mode 100755 index 0000000000000000000000000000000000000000..51e22bdfb24c265b50e1725fdf5c13203b8967a0 --- /dev/null +++ b/src/ui/avatardd/ADDBlockArtifact.java @@ -0,0 +1,288 @@ +/**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 ADDBlockArtifact + * Artifact of an avatar deployment diagram + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class ADDBlockArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int textY2 = 35; + protected int space = 5; + protected int fileX = 20; + protected int fileY = 25; + protected int cran = 5; + + protected String oldValue = ""; + protected String referenceTaskName = "referenceToBlock"; + protected String taskName = "name"; + + public ADDBlockArtifact(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); + + width = 75; + height = 40; + minWidth = 75; + + nbConnectingPoint = 0; + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + + value = "AvatarDesign::block"; + taskName = "name"; + referenceTaskName = "AvatarBlock"; + + makeFullValue(); + + myImageIcon = IconManager.imgic702; + } + + + public void internalDrawing(Graphics g) { + + if (oldValue.compareTo(value) != 0) { + setValue(value, g); + } + + g.drawRect(x, y, width, height); + Color c = g.getColor(); + g.setColor(ColorManager.CPU_BOX_2); + g.fillRect(x+1, y+1, width-1, height-1); + g.setColor(c); + + //g.drawRoundRect(x, y, width, height, arc, arc); + g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); + g.drawLine(x+width-space-fileX, y + space, x+width-space-cran, y+space); + g.drawLine(x+width-space-cran, y+space, x+width-space, y+space + cran); + g.drawLine(x+width-space, y+space + cran, x+width-space, y+space+fileY); + g.drawLine(x+width-space, y+space+fileY, x+width-space-fileX, y+space+fileY); + g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); + g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + + g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); + + g.drawString(value, x + textX , y + textY); + + } + + public void setValue(String val, Graphics g) { + oldValue = value; + int w = g.getFontMetrics().stringWidth(value); + int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); + + //System.out.println("width=" + width + " w1=" + w1 + " w2=" + w2 + " value=" + value); + if (w1 != width) { + width = w1; + resizeWithFather(); + } + //System.out.println("width=" + width + " w1=" + w1 + " value=" + value); + } + + public void resizeWithFather() { + if ((father != null) && ((father instanceof ADDCPUNode))) { + //System.out.println("cdRect comp"); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + //setCd(Math.min(x, father.getWidth() - getWidth()), Math.min(y, father.getHeight() - getHeight())); + setMoveCd(x, y); + } + } + + + public boolean editOndoubleClick(JFrame frame) { + String tmp; + boolean error = false; + + /*JDialogTMLTaskArtifact dialog = new JDialogTMLTaskArtifact(frame, "Setting artifact attributes", this); + dialog.setSize(400, 350); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getReferenceTaskName() == null) { + return false; + } + + if (dialog.getReferenceTaskName().length() != 0) { + tmp = dialog.getReferenceTaskName(); + referenceTaskName = tmp; + + + } + + if (dialog.getTaskName().length() != 0) { + tmp = dialog.getTaskName(); + + if (!TAttribute.isAValidId(tmp, false, false)) { + error = true; + } else { + taskName = tmp; + } + } + + priority = dialog.getPriority(); + + if (error) { + JOptionPane.showMessageDialog(frame, + "Name is non-valid", + "Error", + JOptionPane.INFORMATION_MESSAGE); + } + + makeFullValue(); + */ + + return !error; + + } + + private void makeFullValue() { + value = referenceTaskName + "::" + taskName; + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.ADD_ARTIFACT; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\""); + sb.append(referenceTaskName); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String svalue = null, sname = null, sreferenceTask = null; + String prio; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + svalue = elt.getAttribute("value"); + sname = elt.getAttribute("taskName"); + sreferenceTask = elt.getAttribute("referenceTaskName"); + + } + if (svalue != null) { + value = svalue; + } + if (sname != null){ + taskName = sname; + } + if (sreferenceTask != null) { + referenceTaskName = sreferenceTask; + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + makeFullValue(); + } + + public DesignPanel getDesignPanel() { + return tdp.getGUI().getDesignPanel(value); + } + + public String getReferenceTaskName() { + return referenceTaskName; + } + + public void setReferenceTaskName(String _referenceTaskName) { + referenceTaskName = _referenceTaskName; + makeFullValue(); + } + + public String getTaskName() { + return taskName; + } + + + + +} diff --git a/src/ui/avatardd/ADDBridgeNode.java b/src/ui/avatardd/ADDBridgeNode.java new file mode 100755 index 0000000000000000000000000000000000000000..f4459ace7d22ec2d0789e46a589080887f00ca1e --- /dev/null +++ b/src/ui/avatardd/ADDBridgeNode.java @@ -0,0 +1,309 @@ +/**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 ADDBridgeNode + * Node. To be used in Avatar Deployment Diagram + * Creation: 30/06/2014 + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class ADDBridgeNode extends ADDCommunicationNode implements WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "BRIDGE"; + + + public ADDBridgeNode(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); + + width = 250; + height = 100; + minWidth = 100; + minHeight = 35; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("Bridge"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.BRIDGE_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + g.drawString(ster, x + (width - w)/2, y + textY1); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + //g.drawImage(IconManager.imgic1104.getImage(), x + width - 20, y + 4, null); + g.drawImage(IconManager.imgic1104.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + /*JDialogBridgeNode dialog = new JDialogBridgeNode(frame, "Setting bridge attributes", this); + dialog.setSize(350, 350); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + if (dialog.getBufferByteDataSize().length() != 0) { + try { + tmp = bufferByteDataSize; + bufferByteDataSize = Integer.decode(dialog.getBufferByteDataSize()).intValue(); + if (bufferByteDataSize <= 0) { + bufferByteDataSize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio <= 0) { + clockRatio = tmp; + error = true; + errors += "Clock ratio "; + } + } catch (Exception e) { + error = true; + errors += "Clock ratio "; + } + } + + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + }*/ + + return true; + } + + + public int getType() { + return TGComponentManager.ADD_BRIDGENODE; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + /*sb.append("<attributes bufferByteDataSize=\"" + bufferByteDataSize + "\" "); + sb.append(" clockRatio=\"" + clockRatio + "\" "); + sb.append("/>\n");*/ + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ + clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); + } + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + + public String getAttributes() { + String attr = ""; + //attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; + //attr += "Clock ratio = " + clockRatio + "\n"; + return attr; + } + + +} diff --git a/src/ui/avatardd/ADDBusNode.java b/src/ui/avatardd/ADDBusNode.java new file mode 100755 index 0000000000000000000000000000000000000000..9358370f199b66c69e476a7ad0c971dd13400dee --- /dev/null +++ b/src/ui/avatardd/ADDBusNode.java @@ -0,0 +1,359 @@ +/**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 ADDBusNode +* Node. To be used in Avatar Deployment Diagram +* Creation: 30/06/2014 +* @version 1.0 30/06/2014 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class ADDBusNode extends ADDCommunicationNode implements WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "VGMN"; + + private int index = 0; + private int nbAttachedInitiat = 0; + private int nbAttachedTarget = 0; + private int fifoDepth = 0; + private int minLatency = 0; + + public ADDBusNode(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); + + width = 250; + height = 50; + minWidth = 100; + minHeight = 50; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new ADDConnectingPoint(this, 0, 0, true, false, 0.0, 0.0); + connectingPoint[1] = new ADDConnectingPoint(this, 0, 0, true, false, 0.5, 0.0); + connectingPoint[2] = new ADDConnectingPoint(this, 0, 0, true, false, 1.0, 0.0); + connectingPoint[3] = new ADDConnectingPoint(this, 0, 0, true, false, 0.0, 0.5); + connectingPoint[4] = new ADDConnectingPoint(this, 0, 0, true, false, 1.0, 0.5); + connectingPoint[5] = new ADDConnectingPoint(this, 0, 0, true, false, 0.0, 1.0); + connectingPoint[6] = new ADDConnectingPoint(this, 0, 0, true, false, 0.5, 1.0); + connectingPoint[7] = new ADDConnectingPoint(this, 0, 0, true, false, 1.0, 1.0); + + connectingPoint[8] = new ADDConnectingPoint(this, 0, 0, true, false, 0.25, 0.0); + connectingPoint[9] = new ADDConnectingPoint(this, 0, 0, true, false, 0.75, 0.0); + connectingPoint[10] = new ADDConnectingPoint(this, 0, 0, true, false, 0.0, 0.25); + connectingPoint[11] = new ADDConnectingPoint(this, 0, 0, true, false, 1.0, 0.25); + connectingPoint[12] = new ADDConnectingPoint(this, 0, 0, true, false, 0.0, 0.75); + connectingPoint[13] = new ADDConnectingPoint(this, 0, 0, true, false, 1.0, 0.75); + connectingPoint[14] = new ADDConnectingPoint(this, 0, 0, true, false, 0.25, 1.0); + connectingPoint[15] = new ADDConnectingPoint(this, 0, 0, true, false, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("Vgmn"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.BUS_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + //g.drawImage(IconManager.imgic1102.getImage(), x + width - 20, y + 4, null); + g.drawImage(IconManager.imgic1102.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + /*JDialogBUSNode dialog = new JDialogBUSNode(frame, "Setting bus attributes", this); + dialog.setSize(500, 450); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + + + if (dialog.getByteDataSize().length() != 0) { + try { + tmp = byteDataSize; + byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + if (byteDataSize <= 0) { + byteDataSize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getSliceTime().length() != 0) { + try { + tmp = sliceTime; + sliceTime = Integer.decode(dialog.getSliceTime()).intValue(); + if (sliceTime <= 0) { + sliceTime = tmp; + error = true; + errors += "Slice time "; + } + } catch (Exception e) { + error = true; + errors += "Slice time "; + } + } + + if (dialog.getPipelineSize().length() != 0) { + try { + tmp = pipelineSize; + pipelineSize = Integer.decode(dialog.getPipelineSize()).intValue(); + if (pipelineSize <= 0) { + pipelineSize = tmp; + error = true; + errors += "Pipeline size "; + } + } catch (Exception e) { + error = true; + errors += "Pipeline size "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio <= 0) { + clockRatio = tmp; + error = true; + errors += "Clock ratio "; + } + } catch (Exception e) { + error = true; + errors += "Clock ratio "; + } + } + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + }*/ + + return true; + } + + + public int getType() { + return TGComponentManager.ADD_BUSNODE; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes index=\"" + index + "\" "); + sb.append(" nbAttachedInitiat=\"" + nbAttachedInitiat + "\" "); + sb.append(" nbAttachedTarget=\"" + nbAttachedTarget + "\" "); + sb.append(" minLatency=\"" + minLatency + "\" "); + sb.append(" fifoDepth=\"" + fifoDepth + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + index = Integer.decode(elt.getAttribute("index")).intValue(); + nbAttachedInitiat =Integer.decode(elt.getAttribute("nbAttachedInitiat")).intValue(); + nbAttachedTarget = Integer.decode(elt.getAttribute("nbAttachedTarget")).intValue(); + minLatency = Integer.decode(elt.getAttribute("minLatency")).intValue(); + fifoDepth = Integer.decode(elt.getAttribute("fifoDepth")).intValue(); + + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + + + + public String getAttributes() { + String attr = ""; + attr += "index = " + index + "\n"; + attr += "nbAttachedInitiat = " + nbAttachedInitiat + "\n"; + attr += "nbAttachedTarget = " + nbAttachedTarget + "\n"; + attr += "minLatency = " + minLatency + "\n"; + attr += "fifoDepth = " + fifoDepth + "\n"; + return attr; + } + + +} diff --git a/src/ui/avatardd/ADDCPUNode.java b/src/ui/avatardd/ADDCPUNode.java new file mode 100755 index 0000000000000000000000000000000000000000..d7d1e6bfe909d2e97d313324e1ad26e11b3ee0d7 --- /dev/null +++ b/src/ui/avatardd/ADDCPUNode.java @@ -0,0 +1,545 @@ +/**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 ADDCPUNode +* Node. To be used in AVATAR deployment diagrams. +* Creation: 30/06/2014 +* @version 1.0 30/06/2014 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class ADDCPUNode extends ADDNode implements SwallowTGComponent, WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "CPU"; + + private int nbOfIrq = 6; + private int iCacheWays = 0; + private int iCacheSets = 0; + private int iCacheWords = 0; + private int dCacheWays = 0; + private int dCacheSets = 0; + private int dCacheWords = 0; + + + public ADDCPUNode(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); + + width = 250; + height = 200; + minWidth = 150; + minHeight = 100; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("CPU"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.CPU_BOX_1); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + /*JDialogCPUNode dialog = new JDialogCPUNode(frame, "Setting CPU attributes", this); + dialog.setSize(500, 450); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + schedulingPolicy = dialog.getSchedulingPolicy(); + if (schedulingPolicy == HwCPU.BASIC_ROUND_ROBIN) { + stereotype = "CPURR"; + } + + if (schedulingPolicy == HwCPU.ROUND_ROBIN_PRIORITY_BASED) { + stereotype = "CPURRPB"; + } + + if (dialog.getSliceTime().length() != 0) { + try { + tmp = sliceTime; + sliceTime = Integer.decode(dialog.getSliceTime()).intValue(); + if (sliceTime <= 0) { + sliceTime = tmp; + error = true; + errors += "Slice time "; + } + } catch (Exception e) { + error = true; + errors += "Slice time "; + } + } + + if (dialog.getNbOfCores().length() != 0) { + try { + tmp = nbOfCores; + nbOfCores = Integer.decode(dialog.getNbOfCores()).intValue(); + if (nbOfCores <= 0) { + nbOfCores = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getByteDataSize().length() != 0) { + try { + tmp = byteDataSize; + byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + if (byteDataSize <= 0) { + byteDataSize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getPipelineSize().length() != 0) { + try { + tmp = pipelineSize; + pipelineSize = Integer.decode(dialog.getPipelineSize()).intValue(); + if (pipelineSize <= 0) { + pipelineSize = tmp; + error = true; + errors += "Pipeline size "; + } + } catch (Exception e) { + error = true; + errors += "Pipeline size "; + } + } + + if (dialog.getGoIdleTime().length() != 0) { + try { + tmp = goIdleTime; + goIdleTime = Integer.decode(dialog.getGoIdleTime()).intValue(); + if (goIdleTime < 0) { + goIdleTime = tmp; + error = true; + errors += "Go idle time "; + } + } catch (Exception e) { + error = true; + errors += "Go idle time "; + } + } + + if (dialog.getMaxConsecutiveIdleCycles().length() != 0) { + try { + tmp = goIdleTime; + maxConsecutiveIdleCycles = Integer.decode(dialog.getMaxConsecutiveIdleCycles()).intValue(); + if (maxConsecutiveIdleCycles < 0) { + maxConsecutiveIdleCycles = tmp; + error = true; + errors += "Max consecutive idle cycles "; + } + } catch (Exception e) { + error = true; + errors += "Max consecutive idle cycles "; + } + } + + if (dialog.getExeciTime().length() != 0) { + try { + tmp = execiTime; + execiTime = Integer.decode(dialog.getExeciTime()).intValue(); + if (execiTime < 0) { + execiTime = tmp; + error = true; + errors += "execi time "; + } + } catch (Exception e) { + error = true; + errors += "execi time "; + } + } + + if (dialog.getExeccTime().length() != 0) { + try { + tmp = execcTime; + execcTime = Integer.decode(dialog.getExeccTime()).intValue(); + if (execcTime < 0) { + execcTime = tmp; + error = true; + errors += "execc time "; + } + } catch (Exception e) { + error = true; + errors += "execc time "; + } + } + + if (dialog.getTaskSwitchingTime().length() != 0) { + try { + tmp = taskSwitchingTime; + taskSwitchingTime = Integer.decode(dialog.getTaskSwitchingTime()).intValue(); + if (taskSwitchingTime <= 0) { + taskSwitchingTime = tmp; + error = true; + errors += "Task switching time "; + } + } catch (Exception e) { + error = true; + errors += "Task switching time "; + } + } + + if (dialog.getBranchingPredictionPenalty().length() != 0) { + try { + tmp = branchingPredictionPenalty; + branchingPredictionPenalty = Integer.decode(dialog.getBranchingPredictionPenalty()).intValue(); + if ((branchingPredictionPenalty < 0) || (branchingPredictionPenalty > 100)) { + branchingPredictionPenalty = tmp; + error = true; + errors += "Mis-branching prediction "; + } + } catch (Exception e) { + error = true; + errors += "Mis-branching prediction "; + } + } + + if (dialog.getCacheMiss().length() != 0) { + try { + tmp = cacheMiss; + cacheMiss = Integer.decode(dialog.getCacheMiss()).intValue(); + if ((cacheMiss < 0) || (cacheMiss > 100)) { + cacheMiss = tmp; + error = true; + errors += "Cache-miss "; + } + } catch (Exception e) { + error = true; + errors += "Cache-miss "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio < 1) { + clockRatio = tmp; + error = true; + errors += "Clock ratio "; + } + } catch (Exception e) { + error = true; + errors += "Clock ratio "; + } + } + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + }*/ + + return true; + } + + + public int getType() { + return TGComponentManager.ADD_CPUNODE; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof ADDArtifact) { + return true; + } + + return false; + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + + //Set its coordinates + if (tgc instanceof ADDArtifact) { + tgc.setFather(this); + tgc.setDrawingZone(true); + ((ADDArtifact)tgc).resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + + return false; + + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + removeInternalComponent(tgc); + } + + + public Vector getArtifactList() { + Vector v = new Vector(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof ADDArtifact) { + v.add(tgcomponent[i]); + } + } + return v; + } + + public void hasBeenResized() { + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof ADDArtifact) { + ((ADDArtifact)tgcomponent[i]).resizeWithFather(); + } + } + + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes nbOfIrq=\"" + nbOfIrq + "\" "); + sb.append(" iCacheWays=\"" + iCacheWays + "\" "); + sb.append(" iCacheSets=\"" + iCacheSets + "\" "); + sb.append(" iCacheWords=\"" + iCacheWords + "\" "); + sb.append(" dCacheWays=\"" + iCacheWays + "\" "); + sb.append(" dCacheSets=\"" + iCacheSets + "\" "); + sb.append(" dCacheWords=\"" + iCacheWords + "\" "); + //sb.append(" clockRatio=\"" + clockRatio + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + + nbOfIrq = Integer.decode(elt.getAttribute("nbOfIrq")).intValue(); + iCacheWays =Integer.decode(elt.getAttribute("iCacheWays")).intValue(); + iCacheSets = Integer.decode(elt.getAttribute("iCacheSets")).intValue(); + iCacheWords = Integer.decode(elt.getAttribute("iCacheWords")).intValue(); + dCacheWays =Integer.decode(elt.getAttribute("dCacheWays")).intValue(); + dCacheSets = Integer.decode(elt.getAttribute("dCacheSets")).intValue(); + dCacheWords = Integer.decode(elt.getAttribute("dCacheWords")).intValue(); + + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getDefaultConnector() { + return TGComponentManager.ADD_CONNECTOR; + } + + + public String getAttributes() { + String attr = ""; + attr += "Nb of irq = " + nbOfIrq + "\n"; + attr += "iCacheWays = " + iCacheWays + "\n"; + attr += "iCacheSets = " + iCacheSets + "\n"; + attr += "iCacheWords = " + iCacheWords + "\n"; + attr += "dCacheWays = " + dCacheWays + "\n"; + attr += "dCacheSets = " + dCacheSets + "\n"; + attr += "dCacheWords = " + dCacheWords + "\n"; + + return attr; + } + +} diff --git a/src/ui/avatardd/ADDCommunicationNode.java b/src/ui/avatardd/ADDCommunicationNode.java new file mode 100755 index 0000000000000000000000000000000000000000..06736166e367d0f62cfc40b8bdab6934729b0d9e --- /dev/null +++ b/src/ui/avatardd/ADDCommunicationNode.java @@ -0,0 +1,73 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici + +ludovic.apvrille AT telecom-paristech.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 ADDCommunicationNode + * Node. To be used in TML architecture diagrams. + * Creation: 23/11/2007 + * Creation: 30/06/2014 + * @author Ludovic APVRILLE, Andrea ENRICI + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public abstract class ADDCommunicationNode extends ADDNode { + + public ADDCommunicationNode(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); + } + + + + public int getDefaultConnector() { + return TGComponentManager.ADD_CONNECTOR; + } +} diff --git a/src/ui/avatardd/ADDConnectingPoint.java b/src/ui/avatardd/ADDConnectingPoint.java new file mode 100755 index 0000000000000000000000000000000000000000..910aac4699c4dba7d97bced6fed5edabdaf9f6a9 --- /dev/null +++ b/src/ui/avatardd/ADDConnectingPoint.java @@ -0,0 +1,65 @@ +/**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 ADDConnectingPoint + * Definition of connecting points on which connectors of TMLArchi diagrams can be connected + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + + +import ui.*; + +public class ADDConnectingPoint extends TGConnectingPointWidthHeight{ + + public ADDConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + super(_container, _x, _y, _in, _out, _w, _h); + } + + public boolean isCompatibleWith(int type) { + if (type == TGComponentManager.ADD_CONNECTOR) { + return true; + } + return false; + } + +} diff --git a/src/ui/avatardd/ADDConnector.java b/src/ui/avatardd/ADDConnector.java new file mode 100755 index 0000000000000000000000000000000000000000..924baa54539828a037bfc30c017a0cf5f456f495 --- /dev/null +++ b/src/ui/avatardd/ADDConnector.java @@ -0,0 +1,107 @@ +/**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 ADDConnectorNode + * Connector used in TML Architecture diagrams + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + + + +import java.awt.*; +import java.awt.geom.*; +import javax.swing.*; +import java.util.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.cd.*; +import ui.window.*; + +public class ADDConnector extends TGConnector { + protected int arrowLength = 10; + protected int widthValue, heightValue, maxWidthValue, h; + + + public ADDConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector _listPoint) { + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; + value = "{info}"; + editable = true; + } + + public boolean editOndoubleClick(JFrame frame) { + /*JDialogTMLConnectorNode dialog = new JDialogTMLConnectorNode(frame, "Setting connector attributes", this); + dialog.setSize(350, 300); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + priority = dialog.getPriority();*/ + + return true; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + g.drawLine(x1, y1, x2, y2); + /*if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { + g.drawLine(x1, y1, x2, y2); + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + }*/ + } + + + public int getType() { + return TGComponentManager.ADD_CONNECTOR; + } + + + + +} diff --git a/src/ui/avatardd/ADDDMANode.java b/src/ui/avatardd/ADDDMANode.java new file mode 100755 index 0000000000000000000000000000000000000000..e216e64b928bad2f1b9eec38b4dc793a2d4044fc --- /dev/null +++ b/src/ui/avatardd/ADDDMANode.java @@ -0,0 +1,336 @@ +/**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 ADDDMANode + * Node. To be used in Avatar deployment diagrams. + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class ADDDMANode extends ADDCommunicationNode implements WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "DMA"; + + + public ADDDMANode(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); + + width = 200; + height = 200; + minWidth = 100; + minHeight = 50; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("DMA"); + value = "name"; + + myImageIcon = IconManager.imgic1110; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.DMA_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + w = g.getFontMetrics().stringWidth(name); + g.setFont(f); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); + g.drawImage(IconManager.imgic1108.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + /*JDialogDMANode dialog = new JDialogDMANode(frame, "Setting Memory attributes", this); + dialog.setSize(400, 300); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + if (dialog.getByteDataSize().length() != 0) { + try { + tmp = byteDataSize; + byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + if (byteDataSize <= 0) { + byteDataSize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getNbOfChannels().length() != 0) { + try { + tmp = nbOfChannels; + nbOfChannels = Integer.decode(dialog.getNbOfChannels()).intValue(); + if (nbOfChannels <= 0) { + nbOfChannels = tmp; + error = true; + errors += "nb of channels "; + } + } catch (Exception e) { + error = true; + errors += "nb of channels "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio <= 0) { + clockRatio = tmp; + error = true; + errors += "Clock ratio "; + } + } catch (Exception e) { + error = true; + errors += "Clock ratio "; + } + } + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + }*/ + + return true; + } + + + public int getType() { + return TGComponentManager.ADD_DMANODE; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + /*sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" nbOfChannels=\"" + nbOfChannels + "\""); + sb.append(" clockRatio=\"" + clockRatio + "\" "); + sb.append("/>\n");*/ + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + /*if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + nbOfChannels = Integer.decode(elt.getAttribute("nbOfChannels")).intValue(); + if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ + clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); + } + }*/ + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + + /*public int getByteDataSize(){ + return byteDataSize; + } + + public int getNbOfChannels(){ + return nbOfChannels; + }*/ + + public String getAttributes() { + String attr = ""; + /*attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Nb of channels = " + nbOfChannels + "\n";*/ + attr += "Clock ratio = " + clockRatio + "\n"; + return attr; + } + + +} diff --git a/src/ui/avatardd/ADDDiagramPanel.java b/src/ui/avatardd/ADDDiagramPanel.java new file mode 100755 index 0000000000000000000000000000000000000000..1d80858a5e4935b35f84fe10b1b2b583cbbbbfd9 --- /dev/null +++ b/src/ui/avatardd/ADDDiagramPanel.java @@ -0,0 +1,380 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici + +ludovic.apvrille AT telecom-paristech.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 ADDDiagramPanel + * Panel for drawing an avatar dd + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE, Andrea ENRICI + * @see + */ + +package ui.avatardd; + + +import org.w3c.dom.*; +import java.util.*; + +import ui.*; + +public class ADDDiagramPanel extends TDiagramPanel implements TDPWithAttributes { + private int masterClockFrequency = 200; // in MHz + + public ADDDiagramPanel(MainGUI mgui, TToolBar _ttb) { + super(mgui, _ttb); + /*TDiagramMouseManager tdmm = new TDiagramMouseManager(this); + addMouseListener(tdmm); + addMouseMotionListener(tdmm);*/ + } + + public boolean actionOnDoubleClick(TGComponent tgc) { + //System.out.println("Action"); + /*if (tgc instanceof TCDTClass) { + TCDTClass t = (TCDTClass)tgc; + return mgui.newTClassName(tp, t.oldValue, t.getValue()); + } else if (tgc instanceof TCDActivityDiagramBox) { + if (tgc.getFather() instanceof TCDTClass) { + mgui.selectTab(tp, tgc.getFather().getValue()); + } else if (tgc.getFather() instanceof TCDTObject) { + TCDTObject to = (TCDTObject)(tgc.getFather()); + TCDTClass t = to.getMasterTClass(); + if (t != null) { + mgui.selectTab(tp, t.getValue()); + } + } + return false; // because no change made on any diagram + }*/ + return false; + } + + public boolean actionOnAdd(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + TCDTClass tgcc = (TCDTClass)(tgc); + //System.out.println(" *** add tclass *** name=" + tgcc.getClassName()); + mgui.addTClass(tp, tgcc.getClassName()); + return true; + }*/ + return false; + } + + public boolean actionOnRemove(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + TCDTClass tgcc = (TCDTClass)(tgc); + mgui.removeTClass(tp, tgcc.getClassName()); + resetAllInstancesOf(tgcc); + return true; + }*/ + return false; + } + + public boolean actionOnValueChanged(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + return actionOnDoubleClick(tgc); + }*/ + return false; + } + + public int getMasterClockFrequency() { + return masterClockFrequency; + } + + public void setMasterClockFrequency(int _masterClockFrequency) { + masterClockFrequency = _masterClockFrequency; + } + + public String getXMLHead() { + return "<ADDDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + displayClock() + " >"; + } + + public String getXMLTail() { + return "</ADDDiagramPanel>"; + } + + public String getXMLSelectedHead() { + return "<ADDDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; + } + + public String getXMLSelectedTail() { + return "</ADDDiagramPanelCopy>"; + } + + public String getXMLCloneHead() { + return "<ADDDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; + } + + public String getXMLCloneTail() { + return "</ADDDiagramPanelCopy>"; + } + + public String displayParam() { + String s = " attributes=\""; + s += getAttributeState(); + s += "\""; + return s; + } + + public String displayClock() { + String s = " masterClockFrequency=\""; + s += masterClockFrequency; + s += "\""; + return s; + } + + public void loadExtraParameters(Element elt) { + String s; + //System.out.println("Extra parameter"); + try { + s = elt.getAttribute("attributes"); + //System.out.println("S=" + s); + int attr = Integer.decode(s).intValue(); + setAttributes(attr % 3); + } catch (Exception e) { + // Model was saved in an older version of TTool + //System.out.println("older format"); + setAttributes(0); + } + + try { + s = elt.getAttribute("masterClockFrequency"); + //System.out.println("S=" + s); + masterClockFrequency = Math.abs(Integer.decode(s).intValue()); + } catch (Exception e) { + // Model was saved in an older version of TTool + //System.out.println("older format"); + masterClockFrequency = 200; + } + } + + /*public boolean isFree(ArtifactTClassGate atg) { + TGConnectorLinkNode tgco; + TGComponent tgc; + Iterator iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc instanceof TGConnectorLinkNode) { + tgco = (TGConnectorLinkNode)tgc; + if (tgco.hasArtifactTClassGate(atg)) { + return false; + } + } + } + + return true; + }*/ + + /*public LinkedList getListOfNodes() { + LinkedList ll = new LinkedList(); + TGComponent tgc; + Iterator iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc instanceof TMLArchiCPUNode) { + ll.add(tgc); + } + + if (tgc instanceof TMLArchiHWANode) { + ll.add(tgc); + } + + if (tgc instanceof TMLArchiCommunicationNode) { + ll.add(tgc); + } + } + + return ll; + } + + public LinkedList getListOfLinks() { + LinkedList ll = new LinkedList(); + TGComponent tgc; + Iterator iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc instanceof TMLArchiConnectorNode) { + ll.add(tgc); + } + } + + return ll; + } + + public boolean isMapped(String _ref, String _name) { + ListIterator iterator = getListOfNodes().listIterator(); + TMLArchiNode node; + Vector v; + TMLArchiArtifact artifact; + int i; + String name = _ref + "::" + _name; + + while(iterator.hasNext()) { + node = (TMLArchiNode)(iterator.next()); + if (node instanceof TMLArchiCPUNode) { + v = ((TMLArchiCPUNode)(node)).getArtifactList(); + for(i=0; i<v.size(); i++) { + artifact = (TMLArchiArtifact)(v.get(i)); + if (artifact.getValue().equals(name)) { + return true; + } + } + } + } + + return false; + } + + public void renameMapping(String oldName, String newName) { + ListIterator iterator = getListOfNodes().listIterator(); + TMLArchiNode node; + Vector v; + TMLArchiArtifact artifact; + ArrayList<TMLArchiCommunicationArtifact> ChannelList; + ArrayList<TMLArchiEventArtifact> EventList; + int i; + + while(iterator.hasNext()) { + node = (TMLArchiNode)(iterator.next()); + + // Task mapping + + if ((node instanceof TMLArchiCPUNode) || (node instanceof TMLArchiHWANode)) { + if (node instanceof TMLArchiCPUNode) { + v = ((TMLArchiCPUNode)(node)).getArtifactList(); + //System.out.println("CPU:" + node.getName() + " v:" + v.size()); + } else { + v = ((TMLArchiHWANode)(node)).getArtifactList(); + //System.out.println("HWA:" + node.getName() + " v:" + v.size()); + } + + for(i=0; i<v.size(); i++) { + artifact = (TMLArchiArtifact)(v.get(i)); + if (artifact.getReferenceTaskName().compareTo(oldName) == 0) { + artifact.setReferenceTaskName(newName); + } + } + } + + // Channel, request mapping + if( node instanceof TMLArchiCommunicationNode ) { + ChannelList = ( (TMLArchiCommunicationNode)node ).getChannelArtifactList(); + for( TMLArchiCommunicationArtifact arti: ChannelList ) { + if( arti.getReferenceCommunicationName().compareTo( oldName ) == 0) { + arti.setReferenceCommunicationName( newName ); + } + } + //Event mapping + EventList = ((TMLArchiCommunicationNode)node).getEventArtifactList(); + for(TMLArchiEventArtifact arti: EventList) { + if( arti.getReferenceEventName().compareTo( oldName ) == 0 ) { + arti.setReferenceEventName( newName ); + } + } + } + } + } + + public void setPriority( String _name, int _priority ) { + + ListIterator iterator = getListOfNodes().listIterator(); + TMLArchiNode node; + Vector v; + TMLArchiArtifact artifact; + ArrayList<TMLArchiCommunicationArtifact> ChannelList; + ArrayList<TMLArchiEventArtifact> EventList; + int i; + + while(iterator.hasNext()) { + node = (TMLArchiNode)(iterator.next()); + + + // Channel, request mapping + if( node instanceof TMLArchiCommunicationNode ) { + ChannelList = ( (TMLArchiCommunicationNode)node ).getChannelArtifactList(); + for( TMLArchiCommunicationArtifact arti: ChannelList ) { + if( arti.getFullValue().compareTo( _name ) == 0) { + arti.setPriority(_priority); + } + } + //Event mapping + EventList = ( (TMLArchiCommunicationNode)node ).getEventArtifactList(); + for( TMLArchiEventArtifact arti: EventList ) { + if( arti.getFullValue().compareTo( _name ) == 0) { + arti.setPriority( _priority ); + } + } + } + } + } + + public int getMaxPriority( String _name ) { + + ListIterator iterator = getListOfNodes().listIterator(); + TMLArchiNode node; + Vector v; + TMLArchiArtifact artifact; + ArrayList<TMLArchiCommunicationArtifact> ChannelList; + ArrayList<TMLArchiEventArtifact> EventList; + int i; + int prio = 0; + + while(iterator.hasNext()) { + node = (TMLArchiNode)(iterator.next()); + //Channel, request mapping + if( node instanceof TMLArchiCommunicationNode ) { + ChannelList = ( (TMLArchiCommunicationNode)node ).getChannelArtifactList(); + for( TMLArchiCommunicationArtifact arti: ChannelList ) { + if( arti.getFullValue().compareTo( _name ) == 0) { + prio = Math.max(prio, arti.getPriority()); + } + } + //Event mapping + EventList = ((TMLArchiCommunicationNode)node).getEventArtifactList(); + for( TMLArchiEventArtifact arti: EventList) { + if( arti.getFullValue().compareTo( _name ) == 0) { + prio = Math.max( prio, arti.getPriority() ); + } + } + } + } + return prio; + }*/ + +}//End of class diff --git a/src/ui/avatardd/ADDDiagramToolBar.java b/src/ui/avatardd/ADDDiagramToolBar.java new file mode 100755 index 0000000000000000000000000000000000000000..6543212188ddc581d74e5bc1f0dc4297e565fd92 --- /dev/null +++ b/src/ui/avatardd/ADDDiagramToolBar.java @@ -0,0 +1,138 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici + +ludovic.apvrille AT telecom-paristech.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 ADDDiagramToolBar + * Implements the toolbar to be used in conjunction with the panel of an avatar deployment diagram + * Creation: 30/06/2014 + * @version 1.0 30/06/2014 + * @author Ludovic APVRILLE + * @see ADDDiagramPanel + */ + +package ui.avatardd; + +import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + +import ui.*; + +public class ADDDiagramToolBar extends TToolBar { + + public ADDDiagramToolBar(MainGUI _mgui) { + super(_mgui); + + } + + protected void setActive(boolean b) { + mgui.actions[TGUIAction.ADD_EDIT].setEnabled(b); + mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.CONNECTOR_COMMENT].setEnabled(b); + mgui.actions[TGUIAction.ADD_LINK].setEnabled(b); + mgui.actions[TGUIAction.ADD_CPUNODE].setEnabled(b); + mgui.actions[TGUIAction.ADD_BUSNODE].setEnabled(b); + mgui.actions[TGUIAction.ADD_BRIDGENODE].setEnabled(b); + mgui.actions[TGUIAction.ADD_BLOCKARTIFACT].setEnabled(b); + mgui.actions[TGUIAction.ADD_RAMNODE].setEnabled(b); + mgui.actions[TGUIAction.ADD_ROMNODE].setEnabled(b); + mgui.actions[TGUIAction.ADD_DMANODE].setEnabled(b); + mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b); + + mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + + /*mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); + mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); + mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b);*/ + + mgui.updateZoomInfo(); + } + + protected void setButtons() { + JButton button; + + button = this.add(mgui.actions[TGUIAction.ADD_EDIT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.UML_NOTE]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CONNECTOR_COMMENT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ADD_LINK]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ADD_CPUNODE]); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ADD_BLOCKARTIFACT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ADD_DMANODE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ADD_BUSNODE]); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ADD_BRIDGENODE]); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ADD_RAMNODE]); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.ADD_ROMNODE]); + button.addMouseListener(mgui.mouseHandler); + + + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_ATTR]); + button.addMouseListener(mgui.mouseHandler); + + + } + +} // Class diff --git a/src/ui/avatardd/ADDNode.java b/src/ui/avatardd/ADDNode.java new file mode 100755 index 0000000000000000000000000000000000000000..b04b8fae2cc6001ff6fb8f9f58a73e8d6e029d8c --- /dev/null +++ b/src/ui/avatardd/ADDNode.java @@ -0,0 +1,84 @@ +/**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 ADDNode + * Node. To be used in Avatar deploiment diagrams. + * Creation: 01/07/2014 + * @version 1.0 01/07/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public abstract class ADDNode extends TGCWithInternalComponent { + protected int clockRatio = HwNode.DEFAULT_CLOCK_RATIO; + + public ADDNode(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); + } + + public ArrayList<ADDArtifact> getAllADDArtifacts() { + ArrayList<ADDArtifact> artifacts = new ArrayList<ADDArtifact>(); + + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof ADDArtifact) { + artifacts.add((ADDArtifact)(tgcomponent[i])); + } + } + + return artifacts; + } + + public int getClockRatio(){ + return clockRatio; + } + +} diff --git a/src/ui/avatardd/ADDRAMNode.java b/src/ui/avatardd/ADDRAMNode.java new file mode 100755 index 0000000000000000000000000000000000000000..d97b9e35a14a44f94a74973664215dd2f1ef3b70 --- /dev/null +++ b/src/ui/avatardd/ADDRAMNode.java @@ -0,0 +1,316 @@ +/**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 ADDRAMNode + * Node. To be used in avatar deployment diagrams. + * Creation: 01/07/2014 + * @version 1.0 01/07/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class ADDRAMNode extends ADDCommunicationNode implements WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "RAM"; + + private int index = 0; + private int byteDataSize = HwMemory.DEFAULT_BYTE_DATA_SIZE; + + public ADDRAMNode(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); + + width = 200; + height = 200; + minWidth = 100; + minHeight = 35; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("Memory"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.MEMORY_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + w = g.getFontMetrics().stringWidth(name); + g.setFont(f); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); + g.drawImage(IconManager.imgic1108.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + /*JDialogMemoryNode dialog = new JDialogMemoryNode(frame, "Setting Memory attributes", this); + dialog.setSize(400, 300); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + if (dialog.getByteDataSize().length() != 0) { + try { + tmp = byteDataSize; + byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + if (byteDataSize <= 0) { + byteDataSize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio <= 0) { + clockRatio = tmp; + error = true; + errors += "Clock ratio "; + } + } catch (Exception e) { + error = true; + errors += "Clock ratio "; + } + } + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + }*/ + + return true; + } + + + public int getType() { + return TGComponentManager.ADD_RAMNODE; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" index=\"" + index + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + index = Integer.decode(elt.getAttribute("index")).intValue(); + + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + + public int getByteDataSize(){ + return byteDataSize; + } + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Index = " + index + "\n"; + return attr; + } + + +} diff --git a/src/ui/avatardd/ADDROMNode.java b/src/ui/avatardd/ADDROMNode.java new file mode 100755 index 0000000000000000000000000000000000000000..d698bac8e414d18469e86340dcf960d408e94703 --- /dev/null +++ b/src/ui/avatardd/ADDROMNode.java @@ -0,0 +1,316 @@ +/**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 ADDROMNode + * Node. To be used in avatar deployment diagrams. + * Creation: 01/07/2014 + * @version 1.0 01/07/2014 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class ADDROMNode extends ADDCommunicationNode implements WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "RAM"; + + private int index = 0; + private int byteDataSize = HwMemory.DEFAULT_BYTE_DATA_SIZE; + + public ADDROMNode(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); + + width = 200; + height = 200; + minWidth = 100; + minHeight = 35; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("Memory"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.MEMORY_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + w = g.getFontMetrics().stringWidth(name); + g.setFont(f); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + //g.drawImage(IconManager.imgic1108.getImage(), x + width - 20, y + 4, null); + g.drawImage(IconManager.imgic1108.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + /*JDialogMemoryNode dialog = new JDialogMemoryNode(frame, "Setting Memory attributes", this); + dialog.setSize(400, 300); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + if (dialog.getByteDataSize().length() != 0) { + try { + tmp = byteDataSize; + byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + if (byteDataSize <= 0) { + byteDataSize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio <= 0) { + clockRatio = tmp; + error = true; + errors += "Clock ratio "; + } + } catch (Exception e) { + error = true; + errors += "Clock ratio "; + } + } + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + }*/ + + return true; + } + + + public int getType() { + return TGComponentManager.ADD_ROMNODE; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" index=\"" + index + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + index = Integer.decode(elt.getAttribute("index")).intValue(); + + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + + public int getByteDataSize(){ + return byteDataSize; + } + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Index = " + index + "\n"; + return attr; + } + + +} diff --git a/src/ui/avatardd/ADDTTYNode.java b/src/ui/avatardd/ADDTTYNode.java new file mode 100755 index 0000000000000000000000000000000000000000..7322cff4d77353c6ba04eebea266a0a107658567 --- /dev/null +++ b/src/ui/avatardd/ADDTTYNode.java @@ -0,0 +1,472 @@ +/**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 ADDTTYNode +* Node. To be used in Avatar deployment diagrams. +* Creation: 01/07/2014 +* @version 1.0 01/07/2014 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.avatardd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class ADDTTYNode extends ADDNode implements WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "TTY"; + + private int index = 0; + + + public ADDTTYNode(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); + + width = 250; + height = 200; + minWidth = 150; + minHeight = 100; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new ADDConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new ADDConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new ADDConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new ADDConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new ADDConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("TTY"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.CPU_BOX_1); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + /*JDialogCPUNode dialog = new JDialogCPUNode(frame, "Setting CPU attributes", this); + dialog.setSize(500, 450); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + schedulingPolicy = dialog.getSchedulingPolicy(); + if (schedulingPolicy == HwCPU.BASIC_ROUND_ROBIN) { + stereotype = "CPURR"; + } + + if (schedulingPolicy == HwCPU.ROUND_ROBIN_PRIORITY_BASED) { + stereotype = "CPURRPB"; + } + + if (dialog.getSliceTime().length() != 0) { + try { + tmp = sliceTime; + sliceTime = Integer.decode(dialog.getSliceTime()).intValue(); + if (sliceTime <= 0) { + sliceTime = tmp; + error = true; + errors += "Slice time "; + } + } catch (Exception e) { + error = true; + errors += "Slice time "; + } + } + + if (dialog.getNbOfCores().length() != 0) { + try { + tmp = nbOfCores; + nbOfCores = Integer.decode(dialog.getNbOfCores()).intValue(); + if (nbOfCores <= 0) { + nbOfCores = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getByteDataSize().length() != 0) { + try { + tmp = byteDataSize; + byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + if (byteDataSize <= 0) { + byteDataSize = tmp; + error = true; + errors += "Data size "; + } + } catch (Exception e) { + error = true; + errors += "Data size "; + } + } + + if (dialog.getPipelineSize().length() != 0) { + try { + tmp = pipelineSize; + pipelineSize = Integer.decode(dialog.getPipelineSize()).intValue(); + if (pipelineSize <= 0) { + pipelineSize = tmp; + error = true; + errors += "Pipeline size "; + } + } catch (Exception e) { + error = true; + errors += "Pipeline size "; + } + } + + if (dialog.getGoIdleTime().length() != 0) { + try { + tmp = goIdleTime; + goIdleTime = Integer.decode(dialog.getGoIdleTime()).intValue(); + if (goIdleTime < 0) { + goIdleTime = tmp; + error = true; + errors += "Go idle time "; + } + } catch (Exception e) { + error = true; + errors += "Go idle time "; + } + } + + if (dialog.getMaxConsecutiveIdleCycles().length() != 0) { + try { + tmp = goIdleTime; + maxConsecutiveIdleCycles = Integer.decode(dialog.getMaxConsecutiveIdleCycles()).intValue(); + if (maxConsecutiveIdleCycles < 0) { + maxConsecutiveIdleCycles = tmp; + error = true; + errors += "Max consecutive idle cycles "; + } + } catch (Exception e) { + error = true; + errors += "Max consecutive idle cycles "; + } + } + + if (dialog.getExeciTime().length() != 0) { + try { + tmp = execiTime; + execiTime = Integer.decode(dialog.getExeciTime()).intValue(); + if (execiTime < 0) { + execiTime = tmp; + error = true; + errors += "execi time "; + } + } catch (Exception e) { + error = true; + errors += "execi time "; + } + } + + if (dialog.getExeccTime().length() != 0) { + try { + tmp = execcTime; + execcTime = Integer.decode(dialog.getExeccTime()).intValue(); + if (execcTime < 0) { + execcTime = tmp; + error = true; + errors += "execc time "; + } + } catch (Exception e) { + error = true; + errors += "execc time "; + } + } + + if (dialog.getTaskSwitchingTime().length() != 0) { + try { + tmp = taskSwitchingTime; + taskSwitchingTime = Integer.decode(dialog.getTaskSwitchingTime()).intValue(); + if (taskSwitchingTime <= 0) { + taskSwitchingTime = tmp; + error = true; + errors += "Task switching time "; + } + } catch (Exception e) { + error = true; + errors += "Task switching time "; + } + } + + if (dialog.getBranchingPredictionPenalty().length() != 0) { + try { + tmp = branchingPredictionPenalty; + branchingPredictionPenalty = Integer.decode(dialog.getBranchingPredictionPenalty()).intValue(); + if ((branchingPredictionPenalty < 0) || (branchingPredictionPenalty > 100)) { + branchingPredictionPenalty = tmp; + error = true; + errors += "Mis-branching prediction "; + } + } catch (Exception e) { + error = true; + errors += "Mis-branching prediction "; + } + } + + if (dialog.getCacheMiss().length() != 0) { + try { + tmp = cacheMiss; + cacheMiss = Integer.decode(dialog.getCacheMiss()).intValue(); + if ((cacheMiss < 0) || (cacheMiss > 100)) { + cacheMiss = tmp; + error = true; + errors += "Cache-miss "; + } + } catch (Exception e) { + error = true; + errors += "Cache-miss "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio < 1) { + clockRatio = tmp; + error = true; + errors += "Clock ratio "; + } + } catch (Exception e) { + error = true; + errors += "Clock ratio "; + } + } + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + }*/ + + return true; + } + + + public int getType() { + return TGComponentManager.ADD_TTYNODE; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes index=\"" + index + "\" "); + //sb.append(" clockRatio=\"" + clockRatio + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + + index = Integer.decode(elt.getAttribute("index")).intValue(); + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getDefaultConnector() { + return TGComponentManager.ADD_CONNECTOR; + } + + + public String getAttributes() { + String attr = ""; + attr += "index = " + index + "\n"; + return attr; + } + +} diff --git a/src/ui/tmlcp/TMLCPChoice.java b/src/ui/tmlcp/TMLCPChoice.java index d57b3c3f08817bc32f9791db8fe9269049dc946b..8ce4ce50147b6dfcc7bfe013aa55810206bc61e6 100755 --- a/src/ui/tmlcp/TMLCPChoice.java +++ b/src/ui/tmlcp/TMLCPChoice.java @@ -202,6 +202,8 @@ public class TMLCPChoice extends TGCWithInternalComponent { public int getDefaultConnector() { return TGComponentManager.CONNECTOR_TMLCP; } + + public TGConnectingPoint[] getConnectingPoints() { return connectingPoint;