diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index 8550f8bdd14d4db218aa550b54ee959719496337..d9ad4ea3531d977dd8362f54c08ff2efbcbd8efd 100644 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -857,7 +857,10 @@ public class ActionPerformer { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_CPUNODE); } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_FPGANODE].getActionCommand())) { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_FPGANODE); - } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_BUSNODE].getActionCommand())) { + } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_ANALOGNODE].getActionCommand())) { + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_ANALOGNODE); + } + else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_BUSNODE].getActionCommand())) { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_BUSNODE); } else if (command.equals(mgui.actions[TGUIAction.TMLARCHI_CPNODE].getActionCommand())) { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_CPNODE); diff --git a/src/main/java/ui/GTMLModeling.java b/src/main/java/ui/GTMLModeling.java index 4dc0892986058de1d611b0cbc0959768c5a057f4..fde5a7fe9e9a1350e0b95b13f2ff411a11a49b0d 100644 --- a/src/main/java/ui/GTMLModeling.java +++ b/src/main/java/ui/GTMLModeling.java @@ -89,6 +89,7 @@ import ui.tmldd.TMLArchiCrossbarNode; import ui.tmldd.TMLArchiDMANode; import ui.tmldd.TMLArchiEventArtifact; import ui.tmldd.TMLArchiFPGANode; +import ui.tmldd.TMLArchiAnalogNode; import ui.tmldd.TMLArchiFirewallNode; import ui.tmldd.TMLArchiHWANode; import ui.tmldd.TMLArchiKey; @@ -2780,6 +2781,7 @@ public class GTMLModeling { TMLArchiCPUNode node; TMLArchiFPGANode fpgaNode; + TMLArchiAnalogNode analogNode; TMLArchiHWANode hwanode; TMLArchiBUSNode busnode; TMLArchiVGMNNode vgmnnode; @@ -2791,6 +2793,7 @@ public class GTMLModeling { TMLArchiRouterNode routerNode; HwCPU cpu; HwFPGA fpga; + HwAnalog analog; HwA hwa; HwBus bus; HwVGMN vgmn; @@ -2867,6 +2870,36 @@ public class GTMLModeling { } } + if (tgc instanceof TMLArchiAnalogNode) { + analogNode = (TMLArchiAnalogNode) tgc; + if (nameInUse(names, analogNode.getName())) { + // Node with the same name + UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Two nodes have the same name: " + analogNode.getName()); + ce.setTDiagramPanel(tmlap.tmlap); + ce.setTGComponent(analogNode); + checkingErrors.add(ce); + } else { + names.add(analogNode.getName()); + analog = new HwAnalog(analogNode.getName()); + analog.capacity = analogNode.getCapacity(); + analog.byteDataSize = analogNode.getByteDataSize(); + analog.mappingPenalty = analogNode.getMappingPenalty(); + analog.goIdleTime = analogNode.getGoIdleTime(); + analog.maxConsecutiveIdleCycles = analogNode.getMaxConsecutiveIdleCycles(); + analog.reconfigurationTime = analogNode.getReconfigurationTime(); + analog.execiTime = analogNode.getExeciTime(); + analog.execcTime = analogNode.getExeccTime(); + analog.clockRatio = analogNode.getClockRatio(); + analog.setOperation(analogNode.getOperation()); + analog.setScheduling(analogNode.getScheduling()); + + listE.addCor(analog, analogNode); + archi.addHwNode(analog); + //TraceManager.addDev("Analog node added: " + analogNode.getName()); + } + } + + if (tgc instanceof TMLArchiHWANode) { hwanode = (TMLArchiHWANode) tgc; if (nameInUse(names, hwanode.getName())) { diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index a42b1b98b344837368c62a07dc44f7d99a42d9f1..a9b2441d42717ddb0178960d7e1ad160d4ba0cc6 100644 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -280,6 +280,7 @@ public class TGComponentManager { public static final int TMLARCHI_CROSSBARNODE = 1113; public static final int TMLARCHI_FIREWALL = 1114; public static final int TMLARCHI_FPGANODE = 1116; + public static final int TMLARCHI_ANALOGNODE = 5720; public static final int TMLARCHI_ROUTERNODE = 1117; public static final int TMLCTD_CCOMPONENT = 1200; @@ -1240,6 +1241,9 @@ public class TGComponentManager { case TMLARCHI_FPGANODE: tgc = new TMLArchiFPGANode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case TMLARCHI_ANALOGNODE: + tgc = new TMLArchiAnalogNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; case TMLARCHI_BUSNODE: tgc = new TMLArchiBUSNode(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; @@ -2160,6 +2164,8 @@ public class TGComponentManager { return TMLARCHI_CPUNODE; } else if (tgc instanceof TMLArchiFPGANode) { return TMLARCHI_FPGANODE; + } else if (tgc instanceof TMLArchiAnalogNode) { + return TMLARCHI_ANALOGNODE; } else if (tgc instanceof TMLArchiBUSNode) { return TMLARCHI_BUSNODE; } else if (tgc instanceof TMLArchiVGMNNode) { diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index d0940e93e1202bc33bf2cb0d0fde34502f6fae9c..dc580d18e71d991f867a965d10b0cdbdb2dc73df 100644 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -251,7 +251,8 @@ public class TGUIAction extends AbstractAction { public static final int TMLARCHI_KEY = 435; public static final int TMLARCHI_FIREWALL = 436; public static final int TMLARCHI_FPGANODE = 474; - + public static final int TMLARCHI_ANALOGNODE = 519; + public static final int TMLCP_EDIT = 378; public static final int TMLCP_CONNECTOR = 379; public static final int TMLCP_REF_SD = 380; @@ -673,7 +674,7 @@ public class TGUIAction extends AbstractAction { public static final int MOVE_ENABLED = 463; public static final int FIRST_DIAGRAM = 464; - public static final int NB_ACTION = 519; + public static final int NB_ACTION = 520; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -1137,6 +1138,7 @@ public class TGUIAction extends AbstractAction { actions[TMLARCHI_LINK] = new TAction("add-tmlarchi-link", "Add a link", IconManager.imgic202, IconManager.imgic202, "Link", "Add a link between two nodes of the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_CPUNODE] = new TAction("add-tmlarchi-cpunode", "Add a CPU node", IconManager.imgic1100, IconManager.imgic1100, "CPU node", "Add a cpu node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_FPGANODE] = new TAction("add-tmlarchi-fpganode", "Add a FPGA node", IconManager.imgic1120, IconManager.imgic1120, "FPGA node", "Add a fpga node to the currently opened DIPLODOCUS architecture diagram", 0); + actions[TMLARCHI_ANALOGNODE] = new TAction("add-tmlarchi-analognode", "Add an analog node", IconManager.imgic8006, IconManager.imgic8006, "Analog node", "Add an analog node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_BUSNODE] = new TAction("add-tmlarchi-busnode", "Add a Bus node", IconManager.imgic1102, IconManager.imgic1102, "Bus node", "Add a bus node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_CPNODE] = new TAction("add-tmlarchi-cpnode", "Add a Communication pattern node", IconManager.imgic1102, IconManager.imgic1102, "CP node", "Add a communication pattern node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_ARTIFACT] = new TAction("add-tmlarchi-artifact", "Map a task", IconManager.imgic702, IconManager.imgic702, "Map a task", "Map a task onto a node in the currently opened DIPLODOCUS architecture diagram", 0); diff --git a/src/main/java/ui/tmldd/TMLArchiAnalogNode.java b/src/main/java/ui/tmldd/TMLArchiAnalogNode.java new file mode 100755 index 0000000000000000000000000000000000000000..839af5165c0c883e3bc68238560c1b34567eca23 --- /dev/null +++ b/src/main/java/ui/tmldd/TMLArchiAnalogNode.java @@ -0,0 +1,585 @@ +/* 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. + */ + + + + +package ui.tmldd; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import tmltranslator.HwAnalog; +//import tmltranslator.modelcompiler.ArchUnitMEC; +import ui.*; +import ui.util.IconManager; +import ui.window.JDialogAnalogNode; + +import javax.swing.*; +import java.awt.*; +import java.util.Vector; + +/** + * Class TMLAnalogNode + * Node. To be used in TML architecture diagrams. + * Creation: 07/02/2018 + * @version 1.1 07/02/2018 + * @author Ludovic APVRILLE, Matteo BERTOLINO + */ +public class TMLArchiAnalogNode extends TMLArchiNode implements SwallowTGComponent, WithAttributes, TMLArchiElementInterface { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "Analog"; + + private int byteDataSize = HwAnalog.DEFAULT_BYTE_DATA_SIZE; + private int goIdleTime = HwAnalog.DEFAULT_GO_IDLE_TIME; + private int maxConsecutiveIdleCycles = HwAnalog.DEFAULT_MAX_CONSECUTIVE_IDLE_CYCLES; + private int execiTime = HwAnalog.DEFAULT_EXECI_TIME; + private int execcTime = HwAnalog.DEFAULT_EXECC_TIME; + private int capacity = HwAnalog.DEFAULT_CAPACITY; + private int mappingPenalty = HwAnalog.DEFAULT_MAPPING_PENALTY; + private int reconfigurationTime = HwAnalog.DEFAULT_RECONFIGURATION_TIME; + + private String operation = ""; + + private String scheduling = ""; + + + public TMLArchiAnalogNode(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 TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("Analog"); + value = "name"; + + myImageIcon = IconManager.imgic700;//DG ToDo image + } + + 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.imgic1120.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 getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + JDialogAnalogNode dialog = new JDialogAnalogNode(frame, "Setting Analog attributes", this); + dialog.setSize(500, 450); + GraphicLib.centerOnParent(dialog, 500, 450 ); + // dialog.show(); // blocked until dialog has been closed + dialog.setVisible( true ); + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getNodeName().length() != 0) { + tmpName = dialog.getNodeName(); + tmpName = tmpName.trim(); + if (!TAttribute.isAValidId(tmpName, false, false, false)) { + error = true; + errors += "Name of the node "; + } else { + name = tmpName; + } + } + + + if (dialog.getCapacity().length() != 0) { + try { + tmp = capacity; + capacity = Integer.decode(dialog.getCapacity()).intValue(); + if (capacity <= 0) { + capacity = tmp; + error = true; + errors += "Capacity "; + } + } catch (Exception e) { + error = true; + errors += "Capacity "; + } + } + + if (dialog.getMappingPenalty().length() != 0) { + try { + tmp = mappingPenalty; + mappingPenalty = Integer.decode(dialog.getMappingPenalty()).intValue(); + if (mappingPenalty < 0) { + mappingPenalty = tmp; + error = true; + errors += "Mapping penalty "; + } + } catch (Exception e) { + error = true; + errors += "Mapping penalty "; + } + } + + if (dialog.getReconfigurationTime().length() != 0) { + try { + tmp = reconfigurationTime; + reconfigurationTime = Integer.decode(dialog.getReconfigurationTime()).intValue(); + if (reconfigurationTime <= 0) { + reconfigurationTime = tmp; + error = true; + errors += "Reconfiguration time "; + } + } catch (Exception e) { + error = true; + errors += "Reconfiguration time "; + } + } + + 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.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.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio < 1) { + clockRatio = tmp; + error = true; + errors += "Clock divider "; + } + } catch (Exception e) { + error = true; + errors += "Clock divider "; + } + } + + operation = dialog.getOperation().trim(); + scheduling = dialog.getScheduling().trim(); + + + 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.TMLARCHI_ANALOGNODE; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + return tgc instanceof TMLArchiArtifact; + + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + + //Set its coordinates + if (tgc instanceof TMLArchiArtifact) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + + return false; + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + removeInternalComponent(tgc); + } + + public Vector<TMLArchiArtifact> getArtifactList() { + Vector<TMLArchiArtifact> v = new Vector<TMLArchiArtifact>(); + + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLArchiArtifact) { + v.add( (TMLArchiArtifact) tgcomponent[i] ); + } + } + return v; + } + + public void hasBeenResized() { + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLArchiArtifact) { + 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 capacity=\"" + capacity + "\" byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" mappingPenalty=\"" + mappingPenalty + "\" "); + sb.append(" reconfigurationTime=\"" + reconfigurationTime + "\" "); + sb.append(" goIdleTime=\"" + goIdleTime + "\" "); + sb.append(" maxConsecutiveIdleCycles=\"" + maxConsecutiveIdleCycles + "\" "); + sb.append(" execiTime=\"" + execiTime + "\""); + sb.append(" execcTime=\"" + execcTime + "\""); + sb.append(" clockRatio=\"" + clockRatio + "\""); + sb.append(" operation =\"" + operation + "\" "); + sb.append(" scheduling =\"" + scheduling + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + @Override + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + // + try { + + NodeList nli; + Node n1, n2; + Element elt; + // int t1id; + String sstereotype = null, snodeName = null; + String operationTypesTmp; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + // + + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + + // Issue #17 copy-paste error on j index + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + // + 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")) { + try { + // the "try" statement is for retro compatibility + capacity = Integer.decode(elt.getAttribute("capacity")).intValue(); + } catch (Exception e) { + } + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + mappingPenalty =Integer.decode(elt.getAttribute("mappingPenalty")).intValue(); + goIdleTime = Integer.decode(elt.getAttribute("goIdleTime")).intValue(); + reconfigurationTime = Integer.decode(elt.getAttribute("reconfigurationTime")).intValue(); + + if ((elt.getAttribute("execiTime") != null) && (elt.getAttribute("execiTime").length() > 0)){ + execiTime = Integer.decode(elt.getAttribute("execiTime")).intValue(); + } + if ((elt.getAttribute("execcTime") != null) && (elt.getAttribute("execcTime").length() > 0)){ + execcTime = Integer.decode(elt.getAttribute("execcTime")).intValue(); + } + if ((elt.getAttribute("maxConsecutiveIdleCycles") != null) && (elt.getAttribute("maxConsecutiveIdleCycles").length() > 0)){ + maxConsecutiveIdleCycles = Integer.decode(elt.getAttribute("maxConsecutiveIdleCycles")).intValue(); + } + if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ + clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); + } + /*if ((elt.getAttribute("MECType") != null) && (elt.getAttribute("MECType").length() > 0)){ + if( elt.getAttribute("MECType").length() > 1 ) { //old format + MECType = ArchUnitMEC.Types.get(0); + } + else { + MECType = ArchUnitMEC.Types.get( Integer.valueOf( elt.getAttribute("MECType") ) ); + } + }*/ + operation = elt.getAttribute("operation"); + if (operation == null) { + operation = ""; + } + + scheduling = elt.getAttribute("scheduling"); + if (scheduling == null) { + scheduling = ""; + } + + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_NODE_TMLARCHI; + } + + public int getCapacity(){ + return capacity; + } + + public int getByteDataSize(){ + return byteDataSize; + } + + public int getReconfigurationTime(){ + return reconfigurationTime; + } + + public int getGoIdleTime(){ + return goIdleTime; + } + + public int getMaxConsecutiveIdleCycles(){ + return maxConsecutiveIdleCycles; + } + + public int getExeciTime(){ + return execiTime; + } + + public int getExeccTime(){ + return execcTime; + } + + public int getMappingPenalty(){ + return mappingPenalty; + } + + public String getOperation() { + return operation; + } + + public String getScheduling() { + return scheduling; + } + + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Capacity = " + capacity + "\n"; + attr += "Mapping penalty (percentage) = " + mappingPenalty + "\n"; + attr += "Reconfiguration time = " + reconfigurationTime + "\n"; + attr += "Go in idle mode (in cycle) = " + goIdleTime + "\n"; + attr += "Idle cycles to go idle = " + maxConsecutiveIdleCycles + "\n"; + attr += "EXECI exec. time (in cycle) = " + execiTime + "\n"; + attr += "EXECC exec. time (in cycle) = " + execcTime + "\n"; + attr += "Operation = " + operation + "\n"; + attr += "Scheduling = " + scheduling + "\n"; + attr += "Clock divider = " + clockRatio + "\n"; + return attr; + + } + + public int getComponentType() { + return CONTROLLER; + } + +} diff --git a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java index bafabffb53668394b36c7fac7107305590de9e32..ec03387239b388616181c8b798786aee508b3c43 100755 --- a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java +++ b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java @@ -77,6 +77,7 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener mgui.actions[TGUIAction.TMLARCHI_LINK].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_CPUNODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_FPGANODE].setEnabled(b); + mgui.actions[TGUIAction.TMLARCHI_ANALOGNODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_HWANODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_BUSNODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_CPNODE].setEnabled(b); @@ -133,7 +134,11 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener button = this.add(mgui.actions[TGUIAction.TMLARCHI_FPGANODE]); button.addMouseListener(mgui.mouseHandler); } - + + if (mgui.isExperimentalOn()) { + button = this.add(mgui.actions[TGUIAction.TMLARCHI_ANALOGNODE]); + button.addMouseListener(mgui.mouseHandler); + } button = this.add(mgui.actions[TGUIAction.TMLARCHI_ARTIFACT]); button.addMouseListener(mgui.mouseHandler); diff --git a/src/main/java/ui/window/JDialogAnalogNode.java b/src/main/java/ui/window/JDialogAnalogNode.java new file mode 100644 index 0000000000000000000000000000000000000000..7e86c34178de2850da16082edc60ca24cb50f9fe --- /dev/null +++ b/src/main/java/ui/window/JDialogAnalogNode.java @@ -0,0 +1,300 @@ +/* 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. + */ + + +package ui.window; + +import myutil.GraphicLib; +import tmltranslator.modelcompiler.ArchUnitMEC; +import ui.ColorManager; +import ui.interactivesimulation.SimulationTransaction; +import ui.tmldd.TMLArchiAnalogNode; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.math.BigDecimal; +import java.util.*; + +/** + * Class JDialogAnalog + * Dialog for managing attributes of cpu nodes + * Creation: 07/02/2018 + * + * @author Ludovic APVRILLE + * @version 2.0 05/03/2019 + */ +public class JDialogAnalogNode extends JDialogBase implements ActionListener { + + private boolean regularClose; + + private JPanel panel2, panel4, panel5; + // private Frame frame; + private TMLArchiAnalogNode node; + + + protected JTextField nodeName; + + // Panel2 + protected JTextField byteDataSize, goIdleTime, maxConsecutiveIdleCycles, clockRatio, execiTime, execcTime, + capacity, mappingPenalty, reconfigurationTime, operation, scheduling; + + // Tabbed pane for panel1 and panel2 + //private JTabbedPane tabbedPane; + + + /* + * Creates new form + */ + public JDialogAnalogNode(Frame _frame, String _title, TMLArchiAnalogNode _node) { + super(_frame, _title, true); + // frame = _frame; + node = _node; + initComponents(); + // myInitComponents(); + pack(); + } +// +// private void myInitComponents() { +// } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagLayout gridbag4 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + //GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + GridBagConstraints c4 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("Attributes")); + panel2.setPreferredSize(new Dimension(400, 300)); + + // Issue #41 Ordering of tabbed panes + //tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane(); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("CPU name:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + nodeName = new JTextField(node.getNodeName(), 30); + nodeName.setEditable(true); + nodeName.setFont(new Font("times", Font.PLAIN, 12)); + panel2.add(nodeName, c2); + + + c2.gridwidth = 1; + panel2.add(new JLabel("Data size (in byte):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + byteDataSize = new JTextField("" + node.getByteDataSize(), 15); + panel2.add(byteDataSize, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Overall mapping capacity:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + capacity = new JTextField("" + node.getCapacity(), 15); + panel2.add(capacity, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Mapping penalty:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + mappingPenalty = new JTextField("" + node.getMappingPenalty(), 15); + panel2.add(mappingPenalty, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Reconfiguration time:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + reconfigurationTime = new JTextField("" + node.getReconfigurationTime(), 15); + panel2.add(reconfigurationTime, c2); + + + c2.gridwidth = 1; + panel2.add(new JLabel("Go idle time (in cycle):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + goIdleTime = new JTextField("" + node.getGoIdleTime(), 15); + panel2.add(goIdleTime, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Max consecutive cycles before idle (in cycle):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + maxConsecutiveIdleCycles = new JTextField("" + node.getMaxConsecutiveIdleCycles(), 15); + panel2.add(maxConsecutiveIdleCycles, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("EXECI execution time (in cycle):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + execiTime = new JTextField("" + node.getExeciTime(), 15); + panel2.add(execiTime, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("EXECC execution time (in cycle):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + execcTime = new JTextField("" + node.getExeccTime(), 15); + panel2.add(execcTime, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Operation:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + operation = new JTextField(""+node.getOperation(), 15); + panel2.add(operation, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Scheduling:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + scheduling = new JTextField(""+node.getScheduling(), 15); + panel2.add(scheduling, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Clock divider:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + clockRatio = new JTextField("" + node.getClockRatio(), 15); + panel2.add(clockRatio, c2); + + + // main panel; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c0.fill = GridBagConstraints.BOTH; + c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + + initButtons(c0, c, this); + } + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + +// if (evt.getSource() == tracemode) { +// selectedTracemode = tracemode.getSelectedIndex(); +// } + + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + } + + public void closeDialog() { + regularClose = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public String getNodeName() { + return nodeName.getText(); + } + + public String getCapacity() { + return capacity.getText(); + } + + public String getByteDataSize() { + return byteDataSize.getText(); + } + + public String getReconfigurationTime() { + return reconfigurationTime.getText(); + } + + public String getMappingPenalty() { + return mappingPenalty.getText(); + } + + public String getGoIdleTime() { + return goIdleTime.getText(); + } + + public String getMaxConsecutiveIdleCycles() { + return maxConsecutiveIdleCycles.getText(); + } + + public String getExeciTime() { + return execiTime.getText(); + } + + public String getExeccTime() { + return execcTime.getText(); + } + + public String getOperation() { + return operation.getText(); + } + + public String getScheduling() { + return scheduling.getText(); + } + + + public String getClockRatio() { + return clockRatio.getText(); + } + + +}