diff --git a/src/tmltranslator/TMLArchiTextSpecification.java b/src/tmltranslator/TMLArchiTextSpecification.java index d9f6fb6c5daf262382cbab0f5f64a13a1df6d6a6..7de4d8557e742c411f4d48685301e502aef7657b 100755 --- a/src/tmltranslator/TMLArchiTextSpecification.java +++ b/src/tmltranslator/TMLArchiTextSpecification.java @@ -1,48 +1,48 @@ /**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 TMLArchiTextSpecification -* Import and export of TML architecture textual specifications -* Creation: 21/09/2007 -* @version 1.0 21/09/2007 -* @author Ludovic APVRILLE -* @see -*/ + * + * 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 TMLArchiTextSpecification + * Import and export of TML architecture textual specifications + * Creation: 21/09/2007 + * @version 1.0 21/09/2007 + * @author Ludovic APVRILLE + * @see + */ package tmltranslator; @@ -52,794 +52,794 @@ import java.io.*; import myutil.*; public class TMLArchiTextSpecification { - public final static String CR = "\n"; - public final static String SP = " "; - public final static String CR2 = "\n\n"; - public final static String SC = ";"; - + public final static String CR = "\n"; + public final static String SP = " "; + public final static String CR2 = "\n\n"; + public final static String SC = ";"; + private String spec; - private String title; - - private TMLArchitecture tmla; - private ArrayList<TMLTXTError> errors; - private ArrayList<TMLTXTError> warnings; - - private String keywords[] = {"NODE", "CPU", "SET", "BUS", "LINK", "BRIDGE", "MEMORY", "MASTERCLOCKFREQUENCY", "DMA"}; - private String nodetypes[] = {"CPU", "BUS", "LINK", "BRIDGE", "MEMORY", "HWA", "DMA"}; - private String cpuparameters[] = {"nbOfCores", "byteDataSize", "pipelineSize", "goIdleTime", "maxConsecutiveIdleCycles", "taskSwitchingTime", "branchingPredictionPenalty", "cacheMiss", "schedulingPolicy", "sliceTime", "execiTime", "execcTime"}; - private String linkparameters[] = {"bus", "node", "priority"}; - private String hwaparameters[] = {"byteDataSize", "execiTime"}; - private String busparameters[] = {"byteDataSize", "pipelineSize", "arbitration"}; - private String bridgeparameters[] = {"bufferByteSize"}; - private String memoryparameters[] = {"byteDataSize"}; - private String dmaparameters[] = {"byteDataSize", "nbOfChannels"}; - - - - /*private String keywords[] = {"BOOL", "INT", "NAT", "CHANNEL", "EVENT", "REQUEST", "BRBW", "NBRNBW", - "BRNBW", "INF", "NIB", "NINB", "TASK", "ENDTASK", "IF", "ELSE", "ELSEIF", "ENDIF", "FOR", "ENDFOR", - "SELECTEVT", "CASE", "ENDSELECTEVT", "ENDCASE", "WRITE", "READ", "WAIT", "NOTIFY", "NOTIFIED", "RAND", "CASERAND", "ENDRAND", "ENDCASERAND", "EXECI"}; - - private String channeltypes[] = {"BRBW", "NBRNBW", "BRNBW"}; - private String eventtypes[] = {"INF", "NIB", "NINB"}; - - private String beginArray[] = {"TASK", "FOR", "IF", "ELSE", "ELSEIF", "SELECTEVT", "CASE", "RAND", "CASERAND"}; - private String endArray[] = {"ENDTASK", "ENDFOR", "ENDIF", "ELSE", "ELSEIF", "ENDSELECTEVT", "ENDCASE", "ENDRAND", "ENDCASERAND"}; - */ - - public TMLArchiTextSpecification(String _title) { - title = _title; + private String title; + + private TMLArchitecture tmla; + private ArrayList<TMLTXTError> errors; + private ArrayList<TMLTXTError> warnings; + + private String keywords[] = {"NODE", "CPU", "SET", "BUS", "LINK", "BRIDGE", "MEMORY", "MASTERCLOCKFREQUENCY", "DMA"}; + private String nodetypes[] = {"CPU", "BUS", "LINK", "BRIDGE", "MEMORY", "HWA", "DMA"}; + private String cpuparameters[] = {"nbOfCores", "byteDataSize", "pipelineSize", "goIdleTime", "maxConsecutiveIdleCycles", "taskSwitchingTime", "branchingPredictionPenalty", "cacheMiss", "schedulingPolicy", "sliceTime", "execiTime", "execcTime"}; + private String linkparameters[] = {"bus", "node", "priority"}; + private String hwaparameters[] = {"byteDataSize", "execiTime"}; + private String busparameters[] = {"byteDataSize", "pipelineSize", "arbitration"}; + private String bridgeparameters[] = {"bufferByteSize"}; + private String memoryparameters[] = {"byteDataSize"}; + private String dmaparameters[] = {"byteDataSize", "nbOfChannels"}; + + + + /*private String keywords[] = {"BOOL", "INT", "NAT", "CHANNEL", "EVENT", "REQUEST", "BRBW", "NBRNBW", + "BRNBW", "INF", "NIB", "NINB", "TASK", "ENDTASK", "IF", "ELSE", "ELSEIF", "ENDIF", "FOR", "ENDFOR", + "SELECTEVT", "CASE", "ENDSELECTEVT", "ENDCASE", "WRITE", "READ", "WAIT", "NOTIFY", "NOTIFIED", "RAND", "CASERAND", "ENDRAND", "ENDCASERAND", "EXECI"}; + + private String channeltypes[] = {"BRBW", "NBRNBW", "BRNBW"}; + private String eventtypes[] = {"INF", "NIB", "NINB"}; + + private String beginArray[] = {"TASK", "FOR", "IF", "ELSE", "ELSEIF", "SELECTEVT", "CASE", "RAND", "CASERAND"}; + private String endArray[] = {"ENDTASK", "ENDFOR", "ENDIF", "ELSE", "ELSEIF", "ENDSELECTEVT", "ENDCASE", "ENDRAND", "ENDCASERAND"}; + */ + + public TMLArchiTextSpecification(String _title) { + title = _title; } - - public void saveFile(String path, String filename) throws FileException { - System.out.println("Saving architecture spec file in " + path + filename); + + public void saveFile(String path, String filename) throws FileException { + System.out.println("Saving architecture spec file in " + path + filename); FileUtils.saveFile(path + filename, spec); } - - public TMLArchitecture getTMLArchitecture() { - return tmla; - } - - public String getSpec() { - return spec; - } - - public ArrayList<TMLTXTError> getErrors() { - return errors; - } - - public ArrayList<TMLTXTError> getWarnings() { - return warnings; - } - - - public String toString() { - return spec; - } - - public String toTextFormat(TMLArchitecture _tmla) { - tmla = _tmla; - - spec = "// Master clock frequency - in MHz" + CR; - spec += "MASTERCLOCKFREQUENCY " + tmla.getMasterClockFrequency() + CR + CR; - - spec += makeNodes(tmla); - spec += makeLinks(tmla); - return spec; - //indent(); - } - - public String makeNodes(TMLArchitecture tmla) { - String code = ""; - String name; - String set; - ArrayList<HwNode> hwnodes = tmla.getHwNodes(); - HwCPU cpu; - HwA hwa; - HwBus bus; - HwBridge bridge; - HwMemory memory; - HwDMA dma; - - for(HwNode node: hwnodes) { - - // CPU - if (node instanceof HwCPU) { - cpu = (HwCPU)node; - name = prepareString(node.getName()); - set = "SET " + name + " "; - code += "NODE CPU " + name + CR; - code += set + "nbOfCores " + cpu.nbOfCores + CR; - code += set + "byteDataSize " + cpu.byteDataSize + CR; - code += set + "pipelineSize " + cpu.pipelineSize + CR; - code += set + "goIdleTime " + cpu.goIdleTime + CR; - code += set + "maxConsecutiveIdleCycles " + cpu.maxConsecutiveIdleCycles + CR; - code += set + "taskSwitchingTime " + cpu.taskSwitchingTime + CR; - code += set + "branchingPredictionPenalty " + cpu.branchingPredictionPenalty + CR; - code += set + "cacheMiss " + cpu.cacheMiss + CR; - code += set + "schedulingPolicy " + cpu.schedulingPolicy + CR; - code += set + "sliceTime " + cpu.sliceTime + CR; - code += set + "execiTime " + cpu.execiTime + CR; - code += set + "execcTime " + cpu.execcTime + CR; - } - - //HWA - if (node instanceof HwA) { - hwa = (HwA)node; - name = prepareString(node.getName()); - set = "SET " + name + " "; - code += "NODE HWA " + name + CR; - code += set + "byteDataSize " + hwa.byteDataSize + CR; - code += set + "execiTime " + hwa.execiTime + CR; - code += set + "execcTime " + hwa.execcTime + CR; - } - - // BUS - if (node instanceof HwBus) { - bus = (HwBus)node; - name = prepareString(node.getName()); - set = "SET " + name + " "; - code += "NODE BUS " + name + CR; - code += set + "byteDataSize " + bus.byteDataSize + CR; - code += set + "pipelineSize " + bus.pipelineSize + CR; - code += set + "arbitration " + bus.arbitration + CR; - } - - - // Bridge - if (node instanceof HwBridge) { - bridge = (HwBridge)node; - name = prepareString(node.getName()); - set = "SET " + name + " "; - code += "NODE BRIDGE " + name + CR; - code += set + "bufferByteSize " + bridge.bufferByteSize + CR; - } - - // Memory - if (node instanceof HwMemory) { - memory = (HwMemory)node; - name = prepareString(node.getName()); - set = "SET " + name + " "; - code += "NODE MEMORY " + name + CR; - code += set + "byteDataSize " + memory.byteDataSize + CR; - } - - // DMA - if (node instanceof HwDMA) { - dma = (HwDMA)node; - name = prepareString(node.getName()); - set = "SET " + name + " "; - code += "NODE DMA " + name + CR; - code += set + "byteDataSize " + dma.byteDataSize + CR; - code += set + "nbOfChannels " + dma.nbOfChannels + CR; - } - - code += CR; - - } - return code; - } - - public String makeLinks(TMLArchitecture tmla) { - String code = ""; - String name; - String set; - ArrayList<HwLink> hwlinks = tmla.getHwLinks(); - - //System.out.println("Making links"); - for(HwLink link: hwlinks) { - //System.out.println("Link"); - if (link instanceof HwLink) { - if ((link.hwnode != null) && (link.bus != null)) { - name = prepareString(link.getName()); - set = "SET " + name + " "; - code += "NODE LINK " + name + CR; - code += set + "node " + prepareString(link.hwnode.getName()) + CR; - code += set + "bus " + prepareString(link.bus.getName()) + CR; - code += set + "priority " + link.getPriority() + CR; - } - } - } - //System.out.println("Links:done"); - - return code; - } - - - - - // FROM Text file to TML ARCHITECTURE - - public boolean makeTMLArchitecture(String _spec) { - spec = _spec; - tmla = new TMLArchitecture(); - errors = new ArrayList<TMLTXTError>(); - warnings = new ArrayList<TMLTXTError>(); - - spec = Conversion.removeComments(spec); - //System.out.println(spec); - browseCode(); - - return (errors.size() == 0); - } - - public String printErrors() { - String ret = ""; - for(TMLTXTError error: errors) { - ret += "ERROR at line " + error.lineNb + ": " + error.message + CR; - try { - ret += "->" + spec.split("\n")[error.lineNb] + CR2; - } catch (Exception e) { - ret += "(Code line not accessible)" + CR; - } - } - return ret; - } - - public String printWarnings() { - String ret = ""; - for(TMLTXTError error: warnings) { - ret += "WARNING at line " + error.lineNb + CR; - ret += error.message + CR; - } - return ret; - } - - public String printSummary() { - String ret = ""; - if (errors.size() == 0) { - ret += printWarnings(); - ret += "Compilation successful" + CR; - ret += "No error, " + warnings.size() + " warning(s)" + CR; - } else { - ret += printErrors() + CR + printWarnings() + CR; - ret += "Compilation failed" + CR; - ret += errors.size() + " error(s), "+ warnings.size() + " warning(s)" + CR; - } - - return ret; - } - - public void browseCode() { - // Browse lines of code one after the other - // Build accordinlgy the TMLModeling and updates errors and warnings - // In case of fatal error, immedialty quit code bowsing - - StringReader sr = new StringReader(spec); + + public TMLArchitecture getTMLArchitecture() { + return tmla; + } + + public String getSpec() { + return spec; + } + + public ArrayList<TMLTXTError> getErrors() { + return errors; + } + + public ArrayList<TMLTXTError> getWarnings() { + return warnings; + } + + + public String toString() { + return spec; + } + + public String toTextFormat(TMLArchitecture _tmla) { + tmla = _tmla; + + spec = "// Master clock frequency - in MHz" + CR; + spec += "MASTERCLOCKFREQUENCY " + tmla.getMasterClockFrequency() + CR + CR; + + spec += makeNodes(tmla); + spec += makeLinks(tmla); + return spec; + //indent(); + } + + public String makeNodes(TMLArchitecture tmla) { + String code = ""; + String name; + String set; + ArrayList<HwNode> hwnodes = tmla.getHwNodes(); + HwCPU cpu; + HwA hwa; + HwBus bus; + HwBridge bridge; + HwMemory memory; + HwDMA dma; + + for(HwNode node: hwnodes) { + + // CPU + if (node instanceof HwCPU) { + cpu = (HwCPU)node; + name = prepareString(node.getName()); + set = "SET " + name + " "; + code += "NODE CPU " + name + CR; + code += set + "nbOfCores " + cpu.nbOfCores + CR; + code += set + "byteDataSize " + cpu.byteDataSize + CR; + code += set + "pipelineSize " + cpu.pipelineSize + CR; + code += set + "goIdleTime " + cpu.goIdleTime + CR; + code += set + "maxConsecutiveIdleCycles " + cpu.maxConsecutiveIdleCycles + CR; + code += set + "taskSwitchingTime " + cpu.taskSwitchingTime + CR; + code += set + "branchingPredictionPenalty " + cpu.branchingPredictionPenalty + CR; + code += set + "cacheMiss " + cpu.cacheMiss + CR; + code += set + "schedulingPolicy " + cpu.schedulingPolicy + CR; + code += set + "sliceTime " + cpu.sliceTime + CR; + code += set + "execiTime " + cpu.execiTime + CR; + code += set + "execcTime " + cpu.execcTime + CR; + } + + //HWA + if (node instanceof HwA) { + hwa = (HwA)node; + name = prepareString(node.getName()); + set = "SET " + name + " "; + code += "NODE HWA " + name + CR; + code += set + "byteDataSize " + hwa.byteDataSize + CR; + code += set + "execiTime " + hwa.execiTime + CR; + code += set + "execcTime " + hwa.execcTime + CR; + } + + // BUS + if (node instanceof HwBus) { + bus = (HwBus)node; + name = prepareString(node.getName()); + set = "SET " + name + " "; + code += "NODE BUS " + name + CR; + code += set + "byteDataSize " + bus.byteDataSize + CR; + code += set + "pipelineSize " + bus.pipelineSize + CR; + code += set + "arbitration " + bus.arbitration + CR; + } + + + // Bridge + if (node instanceof HwBridge) { + bridge = (HwBridge)node; + name = prepareString(node.getName()); + set = "SET " + name + " "; + code += "NODE BRIDGE " + name + CR; + code += set + "bufferByteSize " + bridge.bufferByteSize + CR; + } + + // Memory + if (node instanceof HwMemory) { + memory = (HwMemory)node; + name = prepareString(node.getName()); + set = "SET " + name + " "; + code += "NODE MEMORY " + name + CR; + code += set + "byteDataSize " + memory.byteDataSize + CR; + } + + // DMA + if (node instanceof HwDMA) { + dma = (HwDMA)node; + name = prepareString(node.getName()); + set = "SET " + name + " "; + code += "NODE DMA " + name + CR; + code += set + "byteDataSize " + dma.byteDataSize + CR; + code += set + "nbOfChannels " + dma.nbOfChannels + CR; + } + + code += CR; + + } + return code; + } + + public String makeLinks(TMLArchitecture tmla) { + String code = ""; + String name; + String set; + ArrayList<HwLink> hwlinks = tmla.getHwLinks(); + + //System.out.println("Making links"); + for(HwLink link: hwlinks) { + //System.out.println("Link"); + if (link instanceof HwLink) { + if ((link.hwnode != null) && (link.bus != null)) { + name = prepareString(link.getName()); + set = "SET " + name + " "; + code += "NODE LINK " + name + CR; + code += set + "node " + prepareString(link.hwnode.getName()) + CR; + code += set + "bus " + prepareString(link.bus.getName()) + CR; + code += set + "priority " + link.getPriority() + CR; + } + } + } + //System.out.println("Links:done"); + + return code; + } + + + + + // FROM Text file to TML ARCHITECTURE + + public boolean makeTMLArchitecture(String _spec) { + spec = _spec; + tmla = new TMLArchitecture(); + errors = new ArrayList<TMLTXTError>(); + warnings = new ArrayList<TMLTXTError>(); + + spec = Conversion.removeComments(spec); + //System.out.println(spec); + browseCode(); + + return (errors.size() == 0); + } + + public String printErrors() { + String ret = ""; + for(TMLTXTError error: errors) { + ret += "ERROR at line " + error.lineNb + ": " + error.message + CR; + try { + ret += "->" + spec.split("\n")[error.lineNb] + CR2; + } catch (Exception e) { + ret += "(Code line not accessible)" + CR; + } + } + return ret; + } + + public String printWarnings() { + String ret = ""; + for(TMLTXTError error: warnings) { + ret += "WARNING at line " + error.lineNb + CR; + ret += error.message + CR; + } + return ret; + } + + public String printSummary() { + String ret = ""; + if (errors.size() == 0) { + ret += printWarnings(); + ret += "Compilation successful" + CR; + ret += "No error, " + warnings.size() + " warning(s)" + CR; + } else { + ret += printErrors() + CR + printWarnings() + CR; + ret += "Compilation failed" + CR; + ret += errors.size() + " error(s), "+ warnings.size() + " warning(s)" + CR; + } + + return ret; + } + + public void browseCode() { + // Browse lines of code one after the other + // Build accordinlgy the TMLModeling and updates errors and warnings + // In case of fatal error, immedialty quit code bowsing + + StringReader sr = new StringReader(spec); BufferedReader br = new BufferedReader(sr); String s; - String s1; - String [] split; - int lineNb = 0; - - String instruction; - + String s1; + String [] split; + int lineNb = 0; + + String instruction; + try { while((s = br.readLine()) != null) { - if (s != null) { - s = s.trim(); - //System.out.println("s=" + s); - s = removeUndesiredWhiteSpaces(s, lineNb); - s1 = Conversion.replaceAllString(s, "\t", " "); - s1 = Conversion.replaceRecursiveAllString(s1, " ", " "); - //System.out.println("s1=" + s1); - if (s1 != null) { - split = s1.split("\\s"); - if (split.length > 0) { - //System.out.println("analyse"); - analyseInstruction(s, lineNb, split); - //System.out.println("end analyse"); - } - } - - lineNb++; - } + if (s != null) { + s = s.trim(); + //System.out.println("s=" + s); + s = removeUndesiredWhiteSpaces(s, lineNb); + s1 = Conversion.replaceAllString(s, "\t", " "); + s1 = Conversion.replaceRecursiveAllString(s1, " ", " "); + //System.out.println("s1=" + s1); + if (s1 != null) { + split = s1.split("\\s"); + if (split.length > 0) { + //System.out.println("analyse"); + analyseInstruction(s, lineNb, split); + //System.out.println("end analyse"); + } + } + + lineNb++; + } } } catch (Exception e) { System.out.println("Exception when reading specification: " + e.getMessage()); - addError(0, lineNb, 0, "Exception when reading specification"); + addError(0, lineNb, 0, "Exception when reading specification"); } - } - - public void addError(int _type, int _lineNb, int _charNb, String _msg) { - TMLTXTError error = new TMLTXTError(_type); - error.lineNb = _lineNb; - error.charNb = _charNb; - error.message = _msg; - errors.add(error); - } - - public int analyseInstruction(String _line, int _lineNb, String[] _split) { - String error; - String params; - String id; - int value; - - - // Master clock frequency - if(isInstruction("MASTERCLOCKFREQUENCY", _split[0])) { - - if (_split.length != 2) { - error = "A master clock frequency must be declared with 1 parameter, and not " + (_split.length - 1) ; - addError(0, _lineNb, 0, error); - return -1; - } - - if (!checkParameter("NODE", _split, 1, 1, _lineNb)) { - error = "A master clock frequency must be provided as a positive int number"; - addError(0, _lineNb, 0, error); - return -1; - } - - try { - value = Integer.decode(_split[1]).intValue(); - } catch (Exception e) { - error = "A master clock frequency must be provided as a positive int number"; - addError(0, _lineNb, 0, error); - return -1; - } - - if (value < 0) { - error = "A master clock frequency must be provided as a positive int number"; - addError(0, _lineNb, 0, error); - return -1; - } - - //System.out.println("Master clock frequency = " + value); - tmla.setMasterClockFrequency(value); - - // NODE - } else if(isInstruction("NODE", _split[0])) { - - if (_split.length != 3) { - error = "A node must be declared with 3 parameters, and not " + (_split.length - 1) ; - addError(0, _lineNb, 0, error); - return -1; - } - - if (!checkParameter("NODE", _split, 1, 2, _lineNb)) { - return -1; - } - - if (!checkParameter("NODE", _split, 2, 0, _lineNb)) { - return -1; - } - - if (_split[1].equals("CPU")) { - HwCPU cpu = new HwCPU(_split[2]); - tmla.addHwNode(cpu); - } else if (_split[1].equals("BUS")) { - HwBus bus = new HwBus(_split[2]); - tmla.addHwNode(bus); - } else if (_split[1].equals("MEMORY")) { - HwMemory memory = new HwMemory(_split[2]); - tmla.addHwNode(memory); - } else if (_split[1].equals("DMA")) { - HwDMA dma = new HwDMA(_split[2]); - tmla.addHwNode(dma); - } else if (_split[1].equals("BRIDGE")) { - HwBridge bridge = new HwBridge(_split[2]); - tmla.addHwNode(bridge); - } else if (_split[1].equals("HWA")) { - HwA hwa = new HwA(_split[2]); - tmla.addHwNode(hwa); - } else if (_split[1].equals("LINK")) { - HwLink link = new HwLink(_split[2]); - tmla.addHwLink(link); - } - - } // NODE - - // SET - if(isInstruction("SET", _split[0])) { - - if (_split.length != 4) { - error = "A set instruction must be used with 3 parameters, and not " + (_split.length - 1) ; - addError(0, _lineNb, 0, error); - return -1; - } - - if (!checkParameter("SET", _split, 1, 0, _lineNb)) { - return -1; - } - - HwNode node = tmla.getHwNodeByName(_split[1]); - HwLink link; - - if (node == null) { - link = tmla.getHwLinkByName(_split[1]); - if (link == null) { - error = "Unknown node: " + _split[1] ; - addError(0, _lineNb, 0, error); - return -1; - } else { - // Link node - if (link instanceof HwLink) { - if (!checkParameter("SET", _split, 2, 8, _lineNb)) { - return -1; - } - - if (!checkParameter("SET", _split, 3, 7, _lineNb)) { - return -1; - } - - if (_split[2].toUpperCase().equals("NODE")) { - HwNode node0 = tmla.getHwNodeByName(_split[3]); - if (node0 == null) { - error = "Unknown node: " + _split[3] ; - addError(0, _lineNb, 0, error); - return -1; - } else { - link.hwnode = node0; - } - } - - if (_split[2].toUpperCase().equals("BUS")) { - HwBus bus0 = tmla.getHwBusByName(_split[3]); - if (bus0 == null) { - error = "Unknown bus: " + _split[3] ; - addError(0, _lineNb, 0, error); - return -1; - } else { - link.bus = bus0; - } - } - - if (_split[2].toUpperCase().equals("PRIORITY")) { - link.setPriority(Integer.decode(_split[3]).intValue()); - } - } - } - } else { - if (node instanceof HwCPU) { - HwCPU cpu = (HwCPU)node; - - if (!checkParameter("SET", _split, 2, 3, _lineNb)) { - return -1; - } - - if (!checkParameter("SET", _split, 3, 1, _lineNb)) { - return -1; - } - - if (_split[2].toUpperCase().equals("NBOFCORES")) { - cpu.nbOfCores = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { - cpu.byteDataSize = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("PIPELINESIZE")) { - cpu.pipelineSize = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("GOIDLETIME")) { - cpu.goIdleTime = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("MAXCONSECUTIVEIDLECYCLES")) { - cpu.maxConsecutiveIdleCycles = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("TASKSWITCHINGTIME")) { - cpu.taskSwitchingTime = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("BRANCHINGPREDICTIONPENALTY")) { - cpu.branchingPredictionPenalty = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("CACHEMISS")) { - cpu.cacheMiss = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("SCHEDULINGPOLICY")) { - cpu.schedulingPolicy = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("SLICETIME")) { - cpu.sliceTime = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("EXECITIME")) { - cpu.execiTime = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("EXECCTIME")) { - cpu.execcTime = Integer.decode(_split[3]).intValue(); - } - } - - if (node instanceof HwA) { - HwA hwa = (HwA)node; - - if (!checkParameter("SET", _split, 2, 10, _lineNb)) { - return -1; - } - - if (!checkParameter("SET", _split, 3, 1, _lineNb)) { - return -1; - } - - if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { - hwa.byteDataSize = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("EXECITIME")) { - hwa.execiTime = Integer.decode(_split[3]).intValue(); - } - } - - if (node instanceof HwBus) { - HwBus bus = (HwBus)node; - - if (!checkParameter("SET", _split, 2, 9, _lineNb)) { - return -1; - } - - if (!checkParameter("SET", _split, 3, 1, _lineNb)) { - return -1; - } - - if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { - bus.byteDataSize = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("PIPELINESIZE")) { - bus.pipelineSize = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("ARBITRATION")) { - bus.arbitration = Integer.decode(_split[3]).intValue(); - } - } - - if (node instanceof HwBridge) { - HwBridge bridge = (HwBridge)node; - - if (!checkParameter("SET", _split, 2, 11, _lineNb)) { - return -1; - } - - if (!checkParameter("SET", _split, 3, 1, _lineNb)) { - return -1; - } - - if (_split[2].toUpperCase().equals("BUFFERBYTESIZE")) { - bridge.bufferByteSize = Integer.decode(_split[3]).intValue(); - } - } - - if (node instanceof HwMemory) { - HwMemory memory = (HwMemory)node; - - if (!checkParameter("SET", _split, 2, 12, _lineNb)) { - return -1; - } - - if (!checkParameter("SET", _split, 3, 1, _lineNb)) { - return -1; - } - - if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { - memory.byteDataSize = Integer.decode(_split[3]).intValue(); - } - } - - if (node instanceof HwDMA) { - HwDMA dma = (HwDMA)node; - - if (!checkParameter("SET", _split, 2, 12, _lineNb)) { - return -1; - } - - if (!checkParameter("SET", _split, 3, 1, _lineNb)) { - return -1; - } - - if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { - dma.byteDataSize = Integer.decode(_split[3]).intValue(); - } - - if (_split[2].toUpperCase().equals("NBOFCHANNELS")) { - dma.nbOfChannels = Integer.decode(_split[3]).intValue(); - } - } - } - - } // SET - - // Other command - //System.out.println("ERROR hm hm"); - if((_split[0].length() > 0) && (!(isInstruction(_split[0])))) { - error = "Syntax error: unrecognized instruction: " + _split[0]; - addError(0, _lineNb, 0, error); - return -1; - - } // Other command - - return 0; - } - - // Type 0: id - // Type 1: numeral - // Type 2: Node type - // Type 3: CPU parameter - // Type 5: '=' - // Type 6: attribute value - // Type 7: id or numeral - // Type 8: LINK parameter - // Type 9: BUS parameter - // Type 10: HWA parameter - // Type 11: BRIDGE parameter - // Type 12: MEMORY parameter - - public boolean checkParameter(String _inst, String[] _split, int _parameter, int _type, int _lineNb) { - boolean err = false; - String error; - - if(_parameter < _split.length) { - switch(_type) { - case 0: - if (!isAValidId(_split[_parameter])) { - err = true; - } - break; - case 1: - if (!isANumeral(_split[_parameter])) { - err = true; - } - break; - case 2: - if (!isIncluded(_split[_parameter], nodetypes)) { - err = true; - } - break; - case 3: - if (!isIncluded(_split[_parameter], cpuparameters)) { - err = true; - } - break; - case 4: - if (!isAValidId(getEvtId(_split[_parameter]))) { - err = true; - //System.out.println("Unvalid id"); - } else if (!TMLEvent.isAValidListOfParams(getParams(_split[_parameter]))) { - //System.out.println("Unvalid param"); - err = true; - } - break; - case 5: - if (!(_split[_parameter].equals("="))) { - System.out.println("Error of ="); - err = true; - } - break; - case 6: - if (_inst.equals("BOOL")) { - String tmp = _split[_parameter].toUpperCase(); - if (!(tmp.equals("TRUE") || tmp.equals("FALSE"))) { - err = true; - } - } else { - if (!isANumeral(_split[_parameter])) { - err = true; - } - } - break; - case 7: - if (!isAValidId(_split[_parameter]) && !isANumeral(_split[_parameter])) { - err = true; - } - break; - case 8: - if (!isIncluded(_split[_parameter], linkparameters)) { - err = true; - } - break; - case 9: - if (!isIncluded(_split[_parameter], busparameters)) { - err = true; - } - break; - case 10: - if (!isIncluded(_split[_parameter], hwaparameters)) { - err = true; - } - break; - case 11: - if (!isIncluded(_split[_parameter], bridgeparameters)) { - err = true; - } - break; - case 12: - if (!isIncluded(_split[_parameter], memoryparameters)) { - err = true; - } - break; - } - } else { - err = true; - } - if (err) { - error = "Unvalid parameter #" + _parameter + " ->" + _split[_parameter] + "<- in " + _inst + " instruction"; - addError(0, _lineNb, 0, error); - return false; - } - return true; - } - - public boolean isInstruction(String instcode, String inst) { - return (inst.toUpperCase().compareTo(instcode) == 0); - } - - public boolean isInstruction(String instcode) { - return (!checkKeywords(instcode)); - } - - public boolean isAValidId(String _id) { - if ((_id == null) || (_id.length() == 0)) { - return false; - } - - boolean b1 = (_id.substring(0,1)).matches("[a-zA-Z]"); + } + + public void addError(int _type, int _lineNb, int _charNb, String _msg) { + TMLTXTError error = new TMLTXTError(_type); + error.lineNb = _lineNb; + error.charNb = _charNb; + error.message = _msg; + errors.add(error); + } + + public int analyseInstruction(String _line, int _lineNb, String[] _split) { + String error; + String params; + String id; + int value; + + + // Master clock frequency + if(isInstruction("MASTERCLOCKFREQUENCY", _split[0])) { + + if (_split.length != 2) { + error = "A master clock frequency must be declared with 1 parameter, and not " + (_split.length - 1) ; + addError(0, _lineNb, 0, error); + return -1; + } + + if (!checkParameter("NODE", _split, 1, 1, _lineNb)) { + error = "A master clock frequency must be provided as a positive int number"; + addError(0, _lineNb, 0, error); + return -1; + } + + try { + value = Integer.decode(_split[1]).intValue(); + } catch (Exception e) { + error = "A master clock frequency must be provided as a positive int number"; + addError(0, _lineNb, 0, error); + return -1; + } + + if (value < 0) { + error = "A master clock frequency must be provided as a positive int number"; + addError(0, _lineNb, 0, error); + return -1; + } + + //System.out.println("Master clock frequency = " + value); + tmla.setMasterClockFrequency(value); + + // NODE + } else if(isInstruction("NODE", _split[0])) { + + if (_split.length != 3) { + error = "A node must be declared with 3 parameters, and not " + (_split.length - 1) ; + addError(0, _lineNb, 0, error); + return -1; + } + + if (!checkParameter("NODE", _split, 1, 2, _lineNb)) { + return -1; + } + + if (!checkParameter("NODE", _split, 2, 0, _lineNb)) { + return -1; + } + + if (_split[1].equals("CPU")) { + HwCPU cpu = new HwCPU(_split[2]); + tmla.addHwNode(cpu); + } else if (_split[1].equals("BUS")) { + HwBus bus = new HwBus(_split[2]); + tmla.addHwNode(bus); + } else if (_split[1].equals("MEMORY")) { + HwMemory memory = new HwMemory(_split[2]); + tmla.addHwNode(memory); + } else if (_split[1].equals("DMA")) { + HwDMA dma = new HwDMA(_split[2]); + tmla.addHwNode(dma); + } else if (_split[1].equals("BRIDGE")) { + HwBridge bridge = new HwBridge(_split[2]); + tmla.addHwNode(bridge); + } else if (_split[1].equals("HWA")) { + HwA hwa = new HwA(_split[2]); + tmla.addHwNode(hwa); + } else if (_split[1].equals("LINK")) { + HwLink link = new HwLink(_split[2]); + tmla.addHwLink(link); + } + + } // NODE + + // SET + if(isInstruction("SET", _split[0])) { + + if (_split.length != 4) { + error = "A set instruction must be used with 3 parameters, and not " + (_split.length - 1) ; + addError(0, _lineNb, 0, error); + return -1; + } + + if (!checkParameter("SET", _split, 1, 0, _lineNb)) { + return -1; + } + + HwNode node = tmla.getHwNodeByName(_split[1]); + HwLink link; + + if (node == null) { + link = tmla.getHwLinkByName(_split[1]); + if (link == null) { + error = "Unknown node: " + _split[1] ; + addError(0, _lineNb, 0, error); + return -1; + } else { + // Link node + if (link instanceof HwLink) { + if (!checkParameter("SET", _split, 2, 8, _lineNb)) { + return -1; + } + + if (!checkParameter("SET", _split, 3, 7, _lineNb)) { + return -1; + } + + if (_split[2].toUpperCase().equals("NODE")) { + HwNode node0 = tmla.getHwNodeByName(_split[3]); + if (node0 == null) { + error = "Unknown node: " + _split[3] ; + addError(0, _lineNb, 0, error); + return -1; + } else { + link.hwnode = node0; + } + } + + if (_split[2].toUpperCase().equals("BUS")) { + HwBus bus0 = tmla.getHwBusByName(_split[3]); + if (bus0 == null) { + error = "Unknown bus: " + _split[3] ; + addError(0, _lineNb, 0, error); + return -1; + } else { + link.bus = bus0; + } + } + + if (_split[2].toUpperCase().equals("PRIORITY")) { + link.setPriority(Integer.decode(_split[3]).intValue()); + } + } + } + } else { + if (node instanceof HwCPU) { + HwCPU cpu = (HwCPU)node; + + if (!checkParameter("SET", _split, 2, 3, _lineNb)) { + return -1; + } + + if (!checkParameter("SET", _split, 3, 1, _lineNb)) { + return -1; + } + + if (_split[2].toUpperCase().equals("NBOFCORES")) { + cpu.nbOfCores = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { + cpu.byteDataSize = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("PIPELINESIZE")) { + cpu.pipelineSize = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("GOIDLETIME")) { + cpu.goIdleTime = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("MAXCONSECUTIVEIDLECYCLES")) { + cpu.maxConsecutiveIdleCycles = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("TASKSWITCHINGTIME")) { + cpu.taskSwitchingTime = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("BRANCHINGPREDICTIONPENALTY")) { + cpu.branchingPredictionPenalty = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("CACHEMISS")) { + cpu.cacheMiss = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("SCHEDULINGPOLICY")) { + cpu.schedulingPolicy = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("SLICETIME")) { + cpu.sliceTime = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("EXECITIME")) { + cpu.execiTime = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("EXECCTIME")) { + cpu.execcTime = Integer.decode(_split[3]).intValue(); + } + } + + if (node instanceof HwA) { + HwA hwa = (HwA)node; + + if (!checkParameter("SET", _split, 2, 10, _lineNb)) { + return -1; + } + + if (!checkParameter("SET", _split, 3, 1, _lineNb)) { + return -1; + } + + if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { + hwa.byteDataSize = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("EXECITIME")) { + hwa.execiTime = Integer.decode(_split[3]).intValue(); + } + } + + if (node instanceof HwBus) { + HwBus bus = (HwBus)node; + + if (!checkParameter("SET", _split, 2, 9, _lineNb)) { + return -1; + } + + if (!checkParameter("SET", _split, 3, 1, _lineNb)) { + return -1; + } + + if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { + bus.byteDataSize = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("PIPELINESIZE")) { + bus.pipelineSize = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("ARBITRATION")) { + bus.arbitration = Integer.decode(_split[3]).intValue(); + } + } + + if (node instanceof HwBridge) { + HwBridge bridge = (HwBridge)node; + + if (!checkParameter("SET", _split, 2, 11, _lineNb)) { + return -1; + } + + if (!checkParameter("SET", _split, 3, 1, _lineNb)) { + return -1; + } + + if (_split[2].toUpperCase().equals("BUFFERBYTESIZE")) { + bridge.bufferByteSize = Integer.decode(_split[3]).intValue(); + } + } + + if (node instanceof HwMemory) { + HwMemory memory = (HwMemory)node; + + if (!checkParameter("SET", _split, 2, 12, _lineNb)) { + return -1; + } + + if (!checkParameter("SET", _split, 3, 1, _lineNb)) { + return -1; + } + + if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { + memory.byteDataSize = Integer.decode(_split[3]).intValue(); + } + } + + if (node instanceof HwDMA) { + HwDMA dma = (HwDMA)node; + + if (!checkParameter("SET", _split, 2, 12, _lineNb)) { + return -1; + } + + if (!checkParameter("SET", _split, 3, 1, _lineNb)) { + return -1; + } + + if (_split[2].toUpperCase().equals("BYTEDATASIZE")) { + dma.byteDataSize = Integer.decode(_split[3]).intValue(); + } + + if (_split[2].toUpperCase().equals("NBOFCHANNELS")) { + dma.nbOfChannels = Integer.decode(_split[3]).intValue(); + } + } + } + + } // SET + + // Other command + //System.out.println("ERROR hm hm"); + if((_split[0].length() > 0) && (!(isInstruction(_split[0])))) { + error = "Syntax error: unrecognized instruction: " + _split[0]; + addError(0, _lineNb, 0, error); + return -1; + + } // Other command + + return 0; + } + + // Type 0: id + // Type 1: numeral + // Type 2: Node type + // Type 3: CPU parameter + // Type 5: '=' + // Type 6: attribute value + // Type 7: id or numeral + // Type 8: LINK parameter + // Type 9: BUS parameter + // Type 10: HWA parameter + // Type 11: BRIDGE parameter + // Type 12: MEMORY parameter + + public boolean checkParameter(String _inst, String[] _split, int _parameter, int _type, int _lineNb) { + boolean err = false; + String error; + + if(_parameter < _split.length) { + switch(_type) { + case 0: + if (!isAValidId(_split[_parameter])) { + err = true; + } + break; + case 1: + if (!isANumeral(_split[_parameter])) { + err = true; + } + break; + case 2: + if (!isIncluded(_split[_parameter], nodetypes)) { + err = true; + } + break; + case 3: + if (!isIncluded(_split[_parameter], cpuparameters)) { + err = true; + } + break; + case 4: + if (!isAValidId(getEvtId(_split[_parameter]))) { + err = true; + //System.out.println("Unvalid id"); + } else if (!TMLEvent.isAValidListOfParams(getParams(_split[_parameter]))) { + //System.out.println("Unvalid param"); + err = true; + } + break; + case 5: + if (!(_split[_parameter].equals("="))) { + System.out.println("Error of ="); + err = true; + } + break; + case 6: + if (_inst.equals("BOOL")) { + String tmp = _split[_parameter].toUpperCase(); + if (!(tmp.equals("TRUE") || tmp.equals("FALSE"))) { + err = true; + } + } else { + if (!isANumeral(_split[_parameter])) { + err = true; + } + } + break; + case 7: + if (!isAValidId(_split[_parameter]) && !isANumeral(_split[_parameter])) { + err = true; + } + break; + case 8: + if (!isIncluded(_split[_parameter], linkparameters)) { + err = true; + } + break; + case 9: + if (!isIncluded(_split[_parameter], busparameters)) { + err = true; + } + break; + case 10: + if (!isIncluded(_split[_parameter], hwaparameters)) { + err = true; + } + break; + case 11: + if (!isIncluded(_split[_parameter], bridgeparameters)) { + err = true; + } + break; + case 12: + if (!isIncluded(_split[_parameter], memoryparameters)) { + err = true; + } + break; + } + } else { + err = true; + } + if (err) { + error = "Unvalid parameter #" + _parameter + " ->" + _split[_parameter] + "<- in " + _inst + " instruction"; + addError(0, _lineNb, 0, error); + return false; + } + return true; + } + + public boolean isInstruction(String instcode, String inst) { + return (inst.toUpperCase().compareTo(instcode) == 0); + } + + public boolean isInstruction(String instcode) { + return (!checkKeywords(instcode)); + } + + public boolean isAValidId(String _id) { + if ((_id == null) || (_id.length() == 0)) { + return false; + } + + boolean b1 = (_id.substring(0,1)).matches("[a-zA-Z]"); boolean b2 = _id.matches("\\w*"); - boolean b3 = checkKeywords(_id); - - return (b1 && b2 && b3); - } - - public boolean isANumeral(String _num) { - return _num.matches("\\d*"); - } - - public boolean checkKeywords(String _id) { - String id = _id.toUpperCase(); - for(int i=0; i<keywords.length; i++) { - if (id.compareTo(keywords[i]) == 0) { - return false; - } - } - return true; - } - - public boolean isIncluded(String _id, String[] _list) { - String id = _id.toUpperCase(); - for(int i=0; i<_list.length; i++) { - if (id.compareTo(_list[i].toUpperCase()) == 0) { - return true; - } - } - return false; - } - - public String removeUndesiredWhiteSpaces(String _input, int _lineNb) { - String error, tmp; - int index0, index1, index2; - - return _input; - } - - private String getEvtId(String _input) { - int index = _input.indexOf('('); - if (index == -1) { - return _input; - } - return _input.substring(0, index); - } - - private String getParams(String _input) { - //System.out.println("input=" + _input); - int index0 = _input.indexOf('('); - int index1 = _input.indexOf(')'); - if ((index0 == -1) || (index1 == -1)) { - return _input; - } - return _input.substring(index0 + 1, index1); - } - - private String prepareString(String s) { - return s.replaceAll("\\s", ""); - } -} \ No newline at end of file + boolean b3 = checkKeywords(_id); + + return (b1 && b2 && b3); + } + + public boolean isANumeral(String _num) { + return _num.matches("\\d*"); + } + + public boolean checkKeywords(String _id) { + String id = _id.toUpperCase(); + for(int i=0; i<keywords.length; i++) { + if (id.compareTo(keywords[i]) == 0) { + return false; + } + } + return true; + } + + public boolean isIncluded(String _id, String[] _list) { + String id = _id.toUpperCase(); + for(int i=0; i<_list.length; i++) { + if (id.compareTo(_list[i].toUpperCase()) == 0) { + return true; + } + } + return false; + } + + public String removeUndesiredWhiteSpaces(String _input, int _lineNb) { + String error, tmp; + int index0, index1, index2; + + return _input; + } + + private String getEvtId(String _input) { + int index = _input.indexOf('('); + if (index == -1) { + return _input; + } + return _input.substring(0, index); + } + + private String getParams(String _input) { + //System.out.println("input=" + _input); + int index0 = _input.indexOf('('); + int index1 = _input.indexOf(')'); + if ((index0 == -1) || (index1 == -1)) { + return _input; + } + return _input.substring(index0 + 1, index1); + } + + private String prepareString(String s) { + return s.replaceAll("\\s", ""); + } +} diff --git a/src/ui/tmldd/TMLArchiBUSNode.java b/src/ui/tmldd/TMLArchiBUSNode.java index 0980f74eb1755c85989e98a186516d1f94a6e692..5c72cfa14e4c578e87a70c596efdf76fc0abc983 100755 --- a/src/ui/tmldd/TMLArchiBUSNode.java +++ b/src/ui/tmldd/TMLArchiBUSNode.java @@ -1,48 +1,48 @@ /**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 TMLArchiBUSNode -* Node. To be used in TML architecture diagrams. -* Creation: 31/10/2007 -* @version 1.0 31/10/2007 -* @author Ludovic APVRILLE -* @see -*/ + 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 TMLArchiBUSNode + * Node. To be used in TML architecture diagrams. + * Creation: 31/10/2007 + * @version 1.0 31/10/2007 + * @author Ludovic APVRILLE + * @see + */ package ui.tmldd; @@ -59,363 +59,363 @@ import ui.window.*; import tmltranslator.*; public class TMLArchiBUSNode extends TMLArchiCommunicationNode implements SwallowTGComponent, WithAttributes { - private int textY1 = 15; - private int textY2 = 30; - private int derivationx = 2; - private int derivationy = 3; - private String stereotype = "BUS"; - - private int byteDataSize = HwBus.DEFAULT_BYTE_DATA_SIZE; - private int pipelineSize = HwBus.DEFAULT_PIPELINE_SIZE; - private int arbitrationPolicy = HwBus.DEFAULT_ARBITRATION; - private int sliceTime = HwBus.DEFAULT_SLICE_TIME; - private int privacy = HwBus.BUS_PUBLIC; - public TMLArchiBUSNode(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 TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.0); - connectingPoint[1] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.5, 0.0); - connectingPoint[2] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.0); - connectingPoint[3] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.5); - connectingPoint[4] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.5); - connectingPoint[5] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 1.0); - connectingPoint[6] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.5, 1.0); - connectingPoint[7] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 1.0); - - connectingPoint[8] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.25, 0.0); - connectingPoint[9] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.75, 0.0); - connectingPoint[10] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.25); - connectingPoint[11] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.25); - connectingPoint[12] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.75); - connectingPoint[13] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.75); - connectingPoint[14] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.25, 1.0); - connectingPoint[15] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.75, 1.0); - - addTGConnectingPointsComment(); - - nbInternalTGComponent = 0; - - moveable = true; - editable = true; - removable = true; - userResizable = true; - - name = tdp.findNodeName("Bus"); - 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); - - c = g.getColor(); - - //Draw bus privacy - if (privacy== HwBus.BUS_PUBLIC){ - - } - else { - int[] xps = new int[]{x+4, x+7, x+10, x+13, x+16, x+19, x+22, x+22, x+13, x+4}; - int[] yps = new int[]{y+18, y+22, y+22, y+18, y+22, y+22,y+18, y+35, y+43, y+35}; - g.setColor(Color.green); - g.fillPolygon(xps, yps,10); - - // g.drawOval(x+6, y+19, 12, 18); - - // g.fillRect(x+4, y+25, 18, 14); - g.setColor(c); - g.drawPolygon(xps, yps,10); - // g.drawRect(x+4, y+25, 18, 14); - } - } - - 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; - } - } - - arbitrationPolicy = dialog.getArbitrationPolicy(); - privacy = dialog.getPrivacy(); - if (arbitrationPolicy == HwBus.BASIC_ROUND_ROBIN) { - stereotype = "BUS-RR"; - } - - if (arbitrationPolicy == HwBus.PRIORITY_BASED) { - stereotype = "BUS-PB"; - } - - if (arbitrationPolicy == HwBus.CAN) { - stereotype = "BUS-CAN"; - } - - if (arbitrationPolicy == HwBus.CROSSBAR) { - stereotype = "CROSSBAR"; - } - - 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.TMLARCHI_BUSNODE; - } - - 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(" arbitrationPolicy=\"" + arbitrationPolicy + "\" "); - sb.append(" sliceTime=\"" + sliceTime + "\" "); - sb.append(" pipelineSize=\"" + pipelineSize + "\" "); - sb.append(" clockRatio=\"" + clockRatio + "\" "); - sb.append(" privacy=\"" + privacy + "\" "); - 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(); - arbitrationPolicy =Integer.decode(elt.getAttribute("arbitrationPolicy")).intValue(); pipelineSize = Integer.decode(elt.getAttribute("pipelineSize")).intValue(); - if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ - clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); - } - if ((elt.getAttribute("sliceTime") != null) && (elt.getAttribute("sliceTime").length() > 0)){ - sliceTime = Integer.decode(elt.getAttribute("sliceTime")).intValue(); - } - if ((elt.getAttribute("privacy") != null) && (elt.getAttribute("privacy").length() > 0)){ - privacy = Integer.decode(elt.getAttribute("privacy")).intValue(); - } - } - } - } - } - } - - } catch (Exception e) { - throw new MalformedModelingException(); - } - } - - - public int getByteDataSize(){ - return byteDataSize; - } - - public int getPipelineSize(){ - return pipelineSize; - } - - public int getSliceTime(){ - return sliceTime; - } - - public int getArbitrationPolicy(){ - return arbitrationPolicy; - } - public int getPrivacy(){ - return privacy; - } - - public String getAttributes() { - String attr = ""; - attr += "Data size (in byte) = " + byteDataSize + "\n"; - attr += "Pipeline size = " + pipelineSize + "\n"; - if (arbitrationPolicy == HwBus.DEFAULT_ARBITRATION) { - attr += "Arbitration policy = basic Round Robin\n"; - } else if (arbitrationPolicy == HwBus.PRIORITY_BASED) { - attr += "Arbitration policy = priority based\n"; - } - attr += "Slice time (in microseconds) = " + sliceTime + "\n"; - attr += "Clock ratio = " + clockRatio + "\n"; - return attr; - } - - public int getComponentType() { - return TRANSFER; - } - + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "BUS"; + + private int byteDataSize = HwBus.DEFAULT_BYTE_DATA_SIZE; + private int pipelineSize = HwBus.DEFAULT_PIPELINE_SIZE; + private int arbitrationPolicy = HwBus.DEFAULT_ARBITRATION; + private int sliceTime = HwBus.DEFAULT_SLICE_TIME; + private int privacy = HwBus.BUS_PUBLIC; + public TMLArchiBUSNode(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 TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.0); + connectingPoint[1] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.5, 0.0); + connectingPoint[2] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.0); + connectingPoint[3] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.5); + connectingPoint[4] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.5); + connectingPoint[5] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 1.0); + connectingPoint[6] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.5, 1.0); + connectingPoint[7] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 1.0); + + connectingPoint[8] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.25, 0.0); + connectingPoint[9] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.75, 0.0); + connectingPoint[10] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.25); + connectingPoint[11] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.25); + connectingPoint[12] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.0, 0.75); + connectingPoint[13] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 1.0, 0.75); + connectingPoint[14] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.25, 1.0); + connectingPoint[15] = new TMLArchiConnectingPoint(this, 0, 0, true, false, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("Bus"); + 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); + + c = g.getColor(); + + //Draw bus privacy + if (privacy== HwBus.BUS_PUBLIC){ + + } + else { + int[] xps = new int[]{x+4, x+7, x+10, x+13, x+16, x+19, x+22, x+22, x+13, x+4}; + int[] yps = new int[]{y+18, y+22, y+22, y+18, y+22, y+22,y+18, y+35, y+43, y+35}; + g.setColor(Color.green); + g.fillPolygon(xps, yps,10); + + // g.drawOval(x+6, y+19, 12, 18); + + // g.fillRect(x+4, y+25, 18, 14); + g.setColor(c); + g.drawPolygon(xps, yps,10); + // g.drawRect(x+4, y+25, 18, 14); + } + } + + 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; + } + } + + arbitrationPolicy = dialog.getArbitrationPolicy(); + privacy = dialog.getPrivacy(); + if (arbitrationPolicy == HwBus.BASIC_ROUND_ROBIN) { + stereotype = "BUS-RR"; + } + + if (arbitrationPolicy == HwBus.PRIORITY_BASED) { + stereotype = "BUS-PB"; + } + + if (arbitrationPolicy == HwBus.CAN) { + stereotype = "BUS-CAN"; + } + + if (arbitrationPolicy == HwBus.CROSSBAR) { + stereotype = "CROSSBAR"; + } + + 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 diviser "; + } + } catch (Exception e) { + error = true; + errors += "Clock diviser "; + } + } + + 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_BUSNODE; + } + + 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(" arbitrationPolicy=\"" + arbitrationPolicy + "\" "); + sb.append(" sliceTime=\"" + sliceTime + "\" "); + sb.append(" pipelineSize=\"" + pipelineSize + "\" "); + sb.append(" clockRatio=\"" + clockRatio + "\" "); + sb.append(" privacy=\"" + privacy + "\" "); + 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(); + arbitrationPolicy =Integer.decode(elt.getAttribute("arbitrationPolicy")).intValue(); pipelineSize = Integer.decode(elt.getAttribute("pipelineSize")).intValue(); + if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ + clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); + } + if ((elt.getAttribute("sliceTime") != null) && (elt.getAttribute("sliceTime").length() > 0)){ + sliceTime = Integer.decode(elt.getAttribute("sliceTime")).intValue(); + } + if ((elt.getAttribute("privacy") != null) && (elt.getAttribute("privacy").length() > 0)){ + privacy = Integer.decode(elt.getAttribute("privacy")).intValue(); + } + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + + public int getByteDataSize(){ + return byteDataSize; + } + + public int getPipelineSize(){ + return pipelineSize; + } + + public int getSliceTime(){ + return sliceTime; + } + + public int getArbitrationPolicy(){ + return arbitrationPolicy; + } + public int getPrivacy(){ + return privacy; + } + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Pipeline size = " + pipelineSize + "\n"; + if (arbitrationPolicy == HwBus.DEFAULT_ARBITRATION) { + attr += "Arbitration policy = basic Round Robin\n"; + } else if (arbitrationPolicy == HwBus.PRIORITY_BASED) { + attr += "Arbitration policy = priority based\n"; + } + attr += "Slice time (in microseconds) = " + sliceTime + "\n"; + attr += "Clock diviser = " + clockRatio + "\n"; + return attr; + } + + public int getComponentType() { + return TRANSFER; + } + } diff --git a/src/ui/tmldd/TMLArchiBridgeNode.java b/src/ui/tmldd/TMLArchiBridgeNode.java index e643a8ae1728b8e18802480e99c5853a33be99f1..7dd06a06dc2ed03e47aa5a883a31982ba66af3e7 100755 --- a/src/ui/tmldd/TMLArchiBridgeNode.java +++ b/src/ui/tmldd/TMLArchiBridgeNode.java @@ -1,48 +1,48 @@ /**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 TMLArchiBridgeNode - * Node. To be used in TML architecture diagrams. - * Creation: 23/11/2007 - * @version 1.0 23/11/2007 - * @author Ludovic APVRILLE - * @see - */ + 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 TMLArchiBridgeNode + * Node. To be used in TML architecture diagrams. + * Creation: 23/11/2007 + * @version 1.0 23/11/2007 + * @author Ludovic APVRILLE + * @see + */ package ui.tmldd; @@ -64,20 +64,20 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa private int derivationx = 2; private int derivationy = 3; private String stereotype = "BRIDGE"; - - private int bufferByteDataSize = HwBridge.DEFAULT_BUFFER_BYTE_DATA_SIZE; - + + private int bufferByteDataSize = HwBridge.DEFAULT_BUFFER_BYTE_DATA_SIZE; + public TMLArchiBridgeNode(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 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); @@ -86,7 +86,7 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa 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); @@ -95,55 +95,55 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa 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("Bridge"); - value = "name"; - + value = "name"; + myImageIcon = IconManager.imgic700; } - + public void internalDrawing(Graphics g) { - Color c = g.getColor(); - g.draw3DRect(x, y, width, height, true); - + 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); - + + // 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); + + // 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); @@ -154,113 +154,113 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa 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); + 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)) { + + 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; - } - + 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 diviser "; + } + } catch (Exception e) { + error = true; + errors += "Clock diviser "; + } + } + + + 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_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("<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); @@ -277,42 +277,42 @@ public class TMLArchiBridgeNode extends TMLArchiCommunicationNode implements Swa } if (sstereotype != null) { stereotype = sstereotype; - } + } if (snodeName != null){ name = snodeName; } - - if (elt.getTagName().equals("attributes")) { + + if (elt.getTagName().equals("attributes")) { bufferByteDataSize = Integer.decode(elt.getAttribute("bufferByteDataSize")).intValue(); - if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ - clockRatio = Integer.decode(elt.getAttribute("clockRatio")).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 getBufferByteDataSize(){ - return bufferByteDataSize; - } - - public String getAttributes() { - String attr = ""; - attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; - attr += "Clock ratio = " + clockRatio + "\n"; - return attr; - } - - public int getComponentType() { - return TRANSFER; - } - - + + + public int getBufferByteDataSize(){ + return bufferByteDataSize; + } + + public String getAttributes() { + String attr = ""; + attr += "Buffer size (in byte) = " + bufferByteDataSize + "\n"; + attr += "Clock diviser = " + clockRatio + "\n"; + return attr; + } + + public int getComponentType() { + return TRANSFER; + } + + } diff --git a/src/ui/tmldd/TMLArchiCPUNode.java b/src/ui/tmldd/TMLArchiCPUNode.java index 1f7ce0b2c4c2e1d4593b0af7c77dfb9b7e027be3..737b33b6423eec1a4c0475f256e20a2361671846 100755 --- a/src/ui/tmldd/TMLArchiCPUNode.java +++ b/src/ui/tmldd/TMLArchiCPUNode.java @@ -192,7 +192,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, dialog.setSize(500, 450); GraphicLib.centerOnParent(dialog); dialog.show(); // blocked until dialog has been closed - MECType = dialog.getMECType(); + MECType = dialog.getMECType(); if (!dialog.isRegularClose()) { return false; @@ -390,14 +390,14 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, if (clockRatio < 1) { clockRatio = tmp; error = true; - errors += "Clock ratio "; + errors += "Clock diviser "; } } catch (Exception e) { error = true; - errors += "Clock ratio "; + errors += "Clock diviser "; } } - encryption = dialog.getEncryption(); + encryption = dialog.getEncryption(); if (error) { JOptionPane.showMessageDialog(frame, "Invalid value for the following attributes: " + errors, @@ -477,8 +477,8 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, sb.append(" execiTime=\"" + execiTime + "\""); sb.append(" execcTime=\"" + execcTime + "\""); sb.append(" clockRatio=\"" + clockRatio + "\""); - sb.append(" MECType=\"" + MECType.getIndex() + "\""); - sb.append(" encryption=\"" + encryption + "\""); + sb.append(" MECType=\"" + MECType.getIndex() + "\""); + sb.append(" encryption=\"" + encryption + "\""); sb.append("/>\n"); sb.append("</extraparam>\n"); return new String(sb); @@ -543,17 +543,17 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, 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") ) ); - } - } + if( elt.getAttribute("MECType").length() > 1 ) { //old format + MECType = ArchUnitMEC.Types.get(0); + } + else { + MECType = ArchUnitMEC.Types.get( Integer.valueOf( elt.getAttribute("MECType") ) ); + } + } if ((elt.getAttribute("sliceTime") != null) && (elt.getAttribute("sliceTime").length() > 0)){ sliceTime = Integer.decode(elt.getAttribute("sliceTime")).intValue(); } - if ((elt.getAttribute("encryption") != null) && (elt.getAttribute("encryption").length() > 0)){ + if ((elt.getAttribute("encryption") != null) && (elt.getAttribute("encryption").length() > 0)){ encryption = Integer.decode(elt.getAttribute("encryption")).intValue(); } } @@ -619,7 +619,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, return sliceTime; } public int getEncryption(){ - return encryption; + return encryption; } public String getAttributes() { String attr = ""; @@ -637,9 +637,9 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, attr += "EXECC exec. time (in cycle) = " + execcTime + "\n"; attr += "Branch. pred. misrate (in %) = " + branchingPredictionPenalty + "\n"; attr += "Cache miss (in %) = " + cacheMiss + "\n"; - attr += "Clock ratio = " + clockRatio + "\n"; - attr += "MECType = " + MECType.getIndex() + "\n"; - attr += "encryption = " + encryption+ "\n"; + attr += "Clock diviser = " + clockRatio + "\n"; + attr += "MECType = " + MECType.getIndex() + "\n"; + attr += "encryption = " + encryption+ "\n"; return attr; } diff --git a/src/ui/tmldd/TMLArchiDMANode.java b/src/ui/tmldd/TMLArchiDMANode.java index 5aabbf57e9be1618482f7f5fc6515a40f8111d8a..f7047c81005c5939c7cc6bc3a9670740348fddba 100755 --- a/src/ui/tmldd/TMLArchiDMANode.java +++ b/src/ui/tmldd/TMLArchiDMANode.java @@ -1,48 +1,48 @@ /**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 TMLArchiDMANode - * Node. To be used in TML architecture diagrams. - * Creation: 26/09/2011 - * @version 1.0 26/09/2011 - * @author Ludovic APVRILLE - * @see - */ + 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 TMLArchiDMANode + * Node. To be used in TML architecture diagrams. + * Creation: 26/09/2011 + * @version 1.0 26/09/2011 + * @author Ludovic APVRILLE + * @see + */ package ui.tmldd; @@ -64,21 +64,21 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo private int derivationx = 2; private int derivationy = 3; private String stereotype = "DMA"; - - private int byteDataSize = HwDMA.DEFAULT_BYTE_DATA_SIZE; - private int nbOfChannels = HwDMA.DEFAULT_NB_OF_CHANNELS; - + + private int byteDataSize = HwDMA.DEFAULT_BYTE_DATA_SIZE; + private int nbOfChannels = HwDMA.DEFAULT_NB_OF_CHANNELS; + public TMLArchiDMANode(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 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); @@ -87,7 +87,7 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo 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); @@ -96,58 +96,58 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo 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("DMA"); - value = "name"; - + + 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); - + 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); - + + // 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)); + 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.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); + + // 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); @@ -158,127 +158,127 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo 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 DMA attributes", this); - dialog.setSize(400, 300); + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + JDialogDMANode dialog = new JDialogDMANode(frame, "Setting DMA 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)) { + + 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; - } - + 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 diviser "; + } + } catch (Exception e) { + error = true; + errors += "Clock diviser "; + } + } + + 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_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("<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); @@ -295,47 +295,47 @@ public class TMLArchiDMANode extends TMLArchiCommunicationNode implements Swallo } if (sstereotype != null) { stereotype = sstereotype; - } + } if (snodeName != null){ name = snodeName; } - - if (elt.getTagName().equals("attributes")) { + + 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(); - } + 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; - } - - public int getComponentType() { - return TRANSFER; - } - + + + 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 diviser = " + clockRatio + "\n"; + return attr; + } + + public int getComponentType() { + return TRANSFER; + } + } diff --git a/src/ui/tmldd/TMLArchiHWANode.java b/src/ui/tmldd/TMLArchiHWANode.java index c40b333123efc883ecb76a89500c2c060e4bf62f..3d9a7efd0387631b43352f827986991cff1b319f 100755 --- a/src/ui/tmldd/TMLArchiHWANode.java +++ b/src/ui/tmldd/TMLArchiHWANode.java @@ -1,48 +1,48 @@ /**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 TMLArchiHWANode - * Node. To be used in TML architecture diagrams. - * Creation: 23/11/2007 - * @version 1.0 23/11/2007 - * @author Ludovic APVRILLE - * @see - */ + 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 TMLArchiHWANode + * Node. To be used in TML architecture diagrams. + * Creation: 23/11/2007 + * @version 1.0 23/11/2007 + * @author Ludovic APVRILLE + * @see + */ package ui.tmldd; @@ -64,21 +64,21 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, private int derivationx = 2; private int derivationy = 3; private String stereotype = "HWA"; - - private int byteDataSize = HwCPU.DEFAULT_BYTE_DATA_SIZE; - private int execiTime = HwCPU.DEFAULT_EXECI_TIME; - + + private int byteDataSize = HwCPU.DEFAULT_BYTE_DATA_SIZE; + private int execiTime = HwCPU.DEFAULT_EXECI_TIME; + public TMLArchiHWANode(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 = 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); @@ -87,7 +87,7 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, 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); @@ -96,58 +96,58 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, 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("HWA"); - value = "name"; - + value = "name"; + myImageIcon = IconManager.imgic700; } - + public void internalDrawing(Graphics g) { - Color c = g.getColor(); - g.draw3DRect(x, y, width, height, true); - - + 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.HWA_BOX); - g.fill3DRect(x+1, y+1, width-1, height-1, true); - g.setColor(c); - + + // Filling color + g.setColor(ColorManager.HWA_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)); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); g.drawString(ster, x + (width - w)/2, y + textY1); - g.setFont(f); + g.setFont(f); w = g.getFontMetrics().stringWidth(name); g.drawString(name, x + (width - w)/2, y + textY2); - - // Icon - g.drawImage(IconManager.imgic1106.getImage(), x + 4, y + 4, null); - g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + + // Icon + g.drawImage(IconManager.imgic1106.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); @@ -158,131 +158,131 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, 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; - - JDialogHwANode dialog = new JDialogHwANode(frame, "Setting HWA attributes", this); - dialog.setSize(500, 450); + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + JDialogHwANode dialog = new JDialogHwANode(frame, "Setting HWA 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)) { + + 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.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 += "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.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.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; - } - + errors += "execi time "; + } + } + + if (dialog.getClockRatio().length() != 0) { + try { + tmp = clockRatio; + clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + if (clockRatio <= 0) { + clockRatio = tmp; + error = true; + errors += "Clock diviser "; + } + } catch (Exception e) { + error = true; + errors += "Clock diviser "; + } + } + + 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_HWANODE; } - - public boolean acceptSwallowedTGComponent(TGComponent tgc) { - if ((tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0)){ - return true; - } - - return false; - } - + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if ((tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0)){ + return true; + } + + return false; + } + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { if ((tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0)){ - tgc.setFather(this); - tgc.setDrawingZone(true); + tgc.setFather(this); + tgc.setDrawingZone(true); ((TMLArchiArtifact)tgc).resizeWithFather(); - addInternalComponent(tgc, 0); - return true; + 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++) { @@ -292,38 +292,38 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, } return v; } - + public void hasBeenResized() { for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] instanceof TMLArchiArtifact) { ((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 byteDataSize=\"" + byteDataSize + "\" "); - sb.append(" execiTime=\"" + execiTime + "\" "); - sb.append(" clockRatio=\"" + clockRatio + "\" "); + sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" execiTime=\"" + execiTime + "\" "); + 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); @@ -340,51 +340,51 @@ public class TMLArchiHWANode extends TMLArchiNode implements SwallowTGComponent, } if (sstereotype != null) { stereotype = sstereotype; - } + } if (snodeName != null){ name = snodeName; } - - if (elt.getTagName().equals("attributes")) { + + if (elt.getTagName().equals("attributes")) { byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); execiTime = Integer.decode(elt.getAttribute("execiTime")).intValue(); - if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ - clockRatio = Integer.decode(elt.getAttribute("clockRatio")).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 getDefaultConnector() { + + public int getDefaultConnector() { return TGComponentManager.CONNECTOR_NODE_TMLARCHI; - } - - public int getByteDataSize(){ - return byteDataSize; - } - - public int getExeciTime(){ - return execiTime; - } - - - public String getAttributes() { - String attr = ""; - attr += "Data size (in byte) = " + byteDataSize + "\n"; - attr += "Execi execution time (in cycle) = " + execiTime + "\n"; - attr += "Clock ratio = " + clockRatio + "\n"; - return attr; - } - - public int getComponentType() { - return CONTROLLER; - } - + } + + public int getByteDataSize(){ + return byteDataSize; + } + + public int getExeciTime(){ + return execiTime; + } + + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Execi execution time (in cycle) = " + execiTime + "\n"; + attr += "Clock diviser = " + clockRatio + "\n"; + return attr; + } + + public int getComponentType() { + return CONTROLLER; + } + } diff --git a/src/ui/tmldd/TMLArchiMemoryNode.java b/src/ui/tmldd/TMLArchiMemoryNode.java index bb52eea01cfc6ee71a5b980cc309a623b2490b44..bedc254e027a26b5d1e4a772a92c767e1bdb2457 100755 --- a/src/ui/tmldd/TMLArchiMemoryNode.java +++ b/src/ui/tmldd/TMLArchiMemoryNode.java @@ -1,48 +1,48 @@ /**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 TMLArchiMemoryNode - * Node. To be used in TML architecture diagrams. - * Creation: 23/11/2007 - * @version 1.0 23/11/2007 - * @author Ludovic APVRILLE - * @see - */ + 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 TMLArchiMemoryNode + * Node. To be used in TML architecture diagrams. + * Creation: 23/11/2007 + * @version 1.0 23/11/2007 + * @author Ludovic APVRILLE + * @see + */ package ui.tmldd; @@ -65,21 +65,21 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa private int derivationx = 2; private int derivationy = 3; private String stereotype = "MEMORY"; - private int bufferType = 0; - - private int byteDataSize = HwMemory.DEFAULT_BYTE_DATA_SIZE; - + private int bufferType = 0; + + private int byteDataSize = HwMemory.DEFAULT_BYTE_DATA_SIZE; + public TMLArchiMemoryNode(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 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); @@ -88,7 +88,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa 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); @@ -97,58 +97,58 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa 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("Memory"); - value = "name"; - + + 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); - + 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); - + + // 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)); + 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.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); + + // 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); @@ -159,114 +159,114 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa 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, bufferType ); - dialog.setSize(400, 300); - GraphicLib.centerOnParent(dialog); - dialog.show(); // blocked until dialog has been closed - bufferType = dialog.getBufferType(); - - if (!dialog.isRegularClose()) { - return false; - } - - if (dialog.getNodeName().length() != 0) { - tmpName = dialog.getNodeName(); - tmpName = tmpName.trim(); - if (!TAttribute.isAValidId(tmpName, false, false)) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + JDialogMemoryNode dialog = new JDialogMemoryNode(frame, "Setting Memory attributes", this, bufferType ); + dialog.setSize(400, 300); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + bufferType = dialog.getBufferType(); + + 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; - } - + 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 diviser "; + } + } catch (Exception e) { + error = true; + errors += "Clock diviser "; + } + } + + 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_MEMORYNODE; } - + 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(" clockRatio=\"" + clockRatio + "\" "); - sb.append(" bufferType=\"" + bufferType + "\" "); + sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" clockRatio=\"" + clockRatio + "\" "); + sb.append(" bufferType=\"" + bufferType + "\" "); 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); @@ -283,48 +283,48 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa } if (sstereotype != null) { stereotype = sstereotype; - } + } if (snodeName != null){ name = snodeName; } - - if (elt.getTagName().equals("attributes")) { - byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); - if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ - clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); - } - if ((elt.getAttribute("bufferType") != null) && (elt.getAttribute("bufferType").length() > 0)){ - bufferType = Integer.decode(elt.getAttribute("bufferType")).intValue(); - } + + if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ + clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); + } + if ((elt.getAttribute("bufferType") != null) && (elt.getAttribute("bufferType").length() > 0)){ + bufferType = Integer.decode(elt.getAttribute("bufferType")).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 += "Clock ratio = " + clockRatio + "\n"; - return attr; - } - - public int getComponentType() { - return STORAGE; - } - - public int getBufferType() { - return bufferType; - } - + + + public int getByteDataSize(){ + return byteDataSize; + } + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Clock diviser = " + clockRatio + "\n"; + return attr; + } + + public int getComponentType() { + return STORAGE; + } + + public int getBufferType() { + return bufferType; + } + } diff --git a/src/ui/window/JDialogBUSNode.java b/src/ui/window/JDialogBUSNode.java index 8513a611db51046f0a5724c6580dc630113c1bde..9467905b23f6e43f528b0ad9d33e24c0bc782734 100755 --- a/src/ui/window/JDialogBUSNode.java +++ b/src/ui/window/JDialogBUSNode.java @@ -58,41 +58,41 @@ import ui.tmldd.*; public class JDialogBUSNode extends javax.swing.JDialog implements ActionListener { - + private boolean regularClose; - + private JPanel panel2; private Frame frame; private TMLArchiBUSNode node; - - + + // Panel1 protected JTextField nodeName; - - // Panel2 + + // Panel2 protected JTextField byteDataSize, pipelineSize, clockRatio; - protected JComboBox arbitrationPolicy, privacy; + protected JComboBox arbitrationPolicy, privacy; protected JTextField sliceTime; - - + + // Main Panel private JButton closeButton; private JButton cancelButton; - + /** Creates new form */ public JDialogBUSNode(Frame _frame, String _title, TMLArchiBUSNode _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(); @@ -101,19 +101,19 @@ public class JDialogBUSNode extends javax.swing.JDialog implements ActionListene GridBagConstraints c0 = new GridBagConstraints(); GridBagConstraints c1 = new GridBagConstraints(); GridBagConstraints c2 = 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("BUS attributes")); panel2.setPreferredSize(new Dimension(400, 200)); - - c1.gridwidth = 1; + + c1.gridwidth = 1; c1.gridheight = 1; c1.weighty = 1.0; c1.weightx = 1.0; @@ -123,64 +123,64 @@ public class JDialogBUSNode extends javax.swing.JDialog implements ActionListene nodeName = new JTextField(node.getNodeName(), 30); nodeName.setEditable(true); nodeName.setFont(new Font("times", Font.PLAIN, 12)); - panel2.add(nodeName, c1); - + panel2.add(nodeName, c1); + c2.gridwidth = 1; c2.gridheight = 1; c2.weighty = 1.0; c2.weightx = 1.0; c2.fill = GridBagConstraints.HORIZONTAL; panel2.add(new JLabel("Arbitration policy:"), c2); - + c2.gridwidth = GridBagConstraints.REMAINDER; //end row arbitrationPolicy = new JComboBox(); arbitrationPolicy.addItem("Round Robin"); - arbitrationPolicy.addItem("Priority Based"); - arbitrationPolicy.addItem("CAN"); - arbitrationPolicy.addItem("Crossbar"); - arbitrationPolicy.setSelectedIndex(node.getArbitrationPolicy()); + arbitrationPolicy.addItem("Priority Based"); + arbitrationPolicy.addItem("CAN"); + arbitrationPolicy.addItem("Crossbar"); + arbitrationPolicy.setSelectedIndex(node.getArbitrationPolicy()); panel2.add(arbitrationPolicy, 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; + + c2.gridwidth = 1; panel2.add(new JLabel("Pipeline size (num. stages):"), c2); c2.gridwidth = GridBagConstraints.REMAINDER; //end row pipelineSize = new JTextField(""+node.getPipelineSize(), 15); panel2.add(pipelineSize, c2); - + c2.gridwidth = 1; - panel2.add(new JLabel("Slice time (in microseconds):"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - sliceTime = new JTextField(""+node.getSliceTime(), 15); - panel2.add(sliceTime, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Clock ratio:"), c2); + panel2.add(new JLabel("Slice time (in microseconds):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + sliceTime = new JTextField(""+node.getSliceTime(), 15); + panel2.add(sliceTime, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Clock diviser:"), c2); c2.gridwidth = GridBagConstraints.REMAINDER; //end row clockRatio = new JTextField(""+node.getClockRatio(), 15); panel2.add(clockRatio, c2); - c2.gridwidth = 1; + c2.gridwidth = 1; panel2.add(new JLabel("Bus Privacy:"), c2); c2.gridwidth = GridBagConstraints.REMAINDER; //end row privacy = new JComboBox(); - privacy.addItem("Public"); - privacy.addItem("Private"); - privacy.setSelectedIndex(node.getPrivacy()); + privacy.addItem("Public"); + privacy.addItem("Private"); + privacy.setSelectedIndex(node.getPrivacy()); panel2.add(privacy, c2); - + // main panel; c0.gridheight = 10; c0.weighty = 1.0; c0.weightx = 1.0; c0.gridwidth = GridBagConstraints.REMAINDER; //end row c.add(panel2, c0); - + c0.gridwidth = 1; c0.gridheight = 1; c0.fill = GridBagConstraints.HORIZONTAL; @@ -193,17 +193,17 @@ public class JDialogBUSNode extends javax.swing.JDialog implements ActionListene cancelButton.addActionListener(this); c.add(cancelButton, c0); } - - public void actionPerformed(ActionEvent evt) { - /* if (evt.getSource() == typeBox) { - boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); - initialValue.setEnabled(b); - return; - }*/ - - + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + String command = evt.getActionCommand(); - + // Compare the action command to the known actions. if (command.equals("Save and Close")) { closeDialog(); @@ -211,47 +211,47 @@ public class JDialogBUSNode extends javax.swing.JDialog implements ActionListene cancelDialog(); } } - + public void closeDialog() { regularClose = true; dispose(); } - + public void cancelDialog() { dispose(); } - + public boolean isRegularClose() { return regularClose; } - - public String getNodeName() { + + public String getNodeName() { return nodeName.getText(); } - + public String getByteDataSize() { return byteDataSize.getText(); } - - public String getPipelineSize(){ - return pipelineSize.getText(); - } - - public String getClockRatio(){ - return clockRatio.getText(); - } - + + public String getPipelineSize(){ + return pipelineSize.getText(); + } + + public String getClockRatio(){ + return clockRatio.getText(); + } + public int getArbitrationPolicy() { return arbitrationPolicy.getSelectedIndex(); } - - + + public int getPrivacy(){ - return privacy.getSelectedIndex(); + return privacy.getSelectedIndex(); } public String getSliceTime() { - return sliceTime.getText(); - } - - + return sliceTime.getText(); + } + + } diff --git a/src/ui/window/JDialogBridgeNode.java b/src/ui/window/JDialogBridgeNode.java index 605851486d64a1484383efa49bf184563b479c61..6b0d255d96110f188af0e077c757a113531ed4e8 100755 --- a/src/ui/window/JDialogBridgeNode.java +++ b/src/ui/window/JDialogBridgeNode.java @@ -58,39 +58,39 @@ import ui.tmldd.*; public class JDialogBridgeNode extends javax.swing.JDialog implements ActionListener { - + private boolean regularClose; - + private JPanel panel2; private Frame frame; private TMLArchiBridgeNode node; - - + + // Panel1 protected JTextField nodeName; - - // Panel2 + + // Panel2 protected JTextField bufferByteDataSize, clockRatio; - - + + // Main Panel private JButton closeButton; private JButton cancelButton; - + /** Creates new form */ public JDialogBridgeNode(Frame _frame, String _title, TMLArchiBridgeNode _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(); @@ -99,19 +99,19 @@ public class JDialogBridgeNode extends javax.swing.JDialog implements ActionList GridBagConstraints c0 = new GridBagConstraints(); GridBagConstraints c1 = new GridBagConstraints(); GridBagConstraints c2 = 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("Bridge attributes")); panel2.setPreferredSize(new Dimension(300, 200)); - - c1.gridwidth = 1; + + c1.gridwidth = 1; c1.gridheight = 1; c1.weighty = 1.0; c1.weightx = 1.0; @@ -121,8 +121,8 @@ public class JDialogBridgeNode extends javax.swing.JDialog implements ActionList nodeName = new JTextField(node.getNodeName(), 30); nodeName.setEditable(true); nodeName.setFont(new Font("times", Font.PLAIN, 12)); - panel2.add(nodeName, c1); - + panel2.add(nodeName, c1); + c2.gridwidth = 1; c2.gridheight = 1; c2.weighty = 1.0; @@ -132,20 +132,20 @@ public class JDialogBridgeNode extends javax.swing.JDialog implements ActionList c2.gridwidth = GridBagConstraints.REMAINDER; //end row bufferByteDataSize = new JTextField(""+node.getBufferByteDataSize(), 15); panel2.add(bufferByteDataSize, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Clock ratio:"), c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Clock diviser:"), 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 c.add(panel2, c0); - + c0.gridwidth = 1; c0.gridheight = 1; c0.fill = GridBagConstraints.HORIZONTAL; @@ -158,17 +158,17 @@ public class JDialogBridgeNode extends javax.swing.JDialog implements ActionList cancelButton.addActionListener(this); c.add(cancelButton, c0); } - - public void actionPerformed(ActionEvent evt) { - /* if (evt.getSource() == typeBox) { - boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); - initialValue.setEnabled(b); - return; - }*/ - - + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + String command = evt.getActionCommand(); - + // Compare the action command to the known actions. if (command.equals("Save and Close")) { closeDialog(); @@ -176,30 +176,30 @@ public class JDialogBridgeNode extends javax.swing.JDialog implements ActionList cancelDialog(); } } - + public void closeDialog() { regularClose = true; dispose(); } - + public void cancelDialog() { dispose(); } - + public boolean isRegularClose() { return regularClose; } - - public String getNodeName() { + + public String getNodeName() { return nodeName.getText(); } - + public String getBufferByteDataSize() { return bufferByteDataSize.getText(); } - - public String getClockRatio() { + + public String getClockRatio() { return clockRatio.getText(); } - + } diff --git a/src/ui/window/JDialogCPUNode.java b/src/ui/window/JDialogCPUNode.java index d517dcee5690088cabd6c86ea0ce5baabc8af752..90dc419cc7b420250a3e4a65c2b6f467f29c5382 100755 --- a/src/ui/window/JDialogCPUNode.java +++ b/src/ui/window/JDialogCPUNode.java @@ -1,48 +1,48 @@ /**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 JDialogCPUNode -* Dialog for managing attributes of cpu nodes -* Creation: 19/09/2007 -* @version 1.0 19/09/2007 -* @author Ludovic APVRILLE -* @see -*/ + * + * 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 JDialogCPUNode + * Dialog for managing attributes of cpu nodes + * Creation: 19/09/2007 + * @version 1.0 19/09/2007 + * @author Ludovic APVRILLE + * @see + */ package ui.window; @@ -59,324 +59,324 @@ import ui.tmldd.*; import myutil.*; public class JDialogCPUNode extends javax.swing.JDialog implements ActionListener { - - private boolean regularClose; - - private JPanel panel2, panel4; - private Frame frame; - private TMLArchiCPUNode node; - - private ArchUnitMEC MECType; - - - // Panel1 - protected JTextField nodeName; - - // Panel2 - protected JTextField sliceTime, nbOfCores, byteDataSize, pipelineSize, goIdleTime, maxConsecutiveIdleCycles, taskSwitchingTime, branchingPredictionPenalty, cacheMiss, clockRatio, execiTime, execcTime; - protected JComboBox schedulingPolicy, MECTypeCB, encryption; - - // Tabbed pane for panel1 and panel2 - private JTabbedPane tabbedPane; - - // Main Panel - private JButton closeButton; - private JButton cancelButton; - - /** Creates new form */ - public JDialogCPUNode(Frame _frame, String _title, TMLArchiCPUNode _node, ArchUnitMEC _MECType) { - super(_frame, _title, true); - frame = _frame; - node = _node; - MECType = _MECType; - - 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("CPU attributes")); - panel2.setPreferredSize(new Dimension(400, 300)); - - tabbedPane = 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; - c2.gridheight = 1; - c2.weighty = 1.0; - c2.weightx = 1.0; - c2.fill = GridBagConstraints.HORIZONTAL; - panel2.add(new JLabel("Scheduling policy:"), c2); - - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - schedulingPolicy = new JComboBox(); - schedulingPolicy.addItem("Round Robin"); - schedulingPolicy.addItem("Round Robin - Priority Based"); - schedulingPolicy.setSelectedIndex(node.getSchedulingPolicy()); - panel2.add(schedulingPolicy, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Slice time (in microseconds):"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - sliceTime = new JTextField(""+node.getSliceTime(), 15); - panel2.add(sliceTime, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Nb of cores:"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - nbOfCores = new JTextField(""+node.getNbOfCores(), 15); - panel2.add(nbOfCores, 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("Pipeline size (num. stages):"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - pipelineSize = new JTextField(""+node.getPipelineSize(), 15); - panel2.add(pipelineSize, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Task switching time (in cycle):"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - taskSwitchingTime = new JTextField(""+node.getTaskSwitchingTime(), 15); - panel2.add(taskSwitchingTime, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Mis-Branching prediction (in %):"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - branchingPredictionPenalty = new JTextField(""+node.getBranchingPredictionPenalty(), 15); - panel2.add(branchingPredictionPenalty, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Cache-miss (in %):"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - cacheMiss = new JTextField(""+node.getCacheMiss(), 15); - panel2.add(cacheMiss, 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("Clock ratio:"), c2); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - clockRatio = new JTextField(""+node.getClockRatio(), 15); - panel2.add(clockRatio, c2); - - // Code generation - panel4 = new JPanel(); - panel4.setLayout( gridbag4 ); - panel4.setBorder( new javax.swing.border.TitledBorder("Code generation") ); - panel4.setPreferredSize( new Dimension(400, 300) ); - c4.gridwidth = 1; - c4.gridheight = 1; - c4.weighty = 1.0; - c4.weightx = 1.0; - c4.fill = GridBagConstraints.HORIZONTAL; - /*c4.fill = GridBagConstraints.BOTH; - c4.gridheight = 3; - panel4.add( new JLabel(" "), c4 ); - c4.gridwidth = 1; - c4.fill = GridBagConstraints.HORIZONTAL; - c4.anchor = GridBagConstraints.CENTER;*/ - panel4.add(new JLabel("Encryption:"), c4); - c4.gridwidth = GridBagConstraints.REMAINDER; - encryption = new JComboBox(); - encryption.addItem("None"); - encryption.addItem("Software Encryption"); - encryption.addItem("Hardware Security Module"); - encryption.setSelectedIndex(node.getEncryption()); - panel4.add(encryption, c4); - c4.gridwidth = 1; - panel4.add(new JLabel("CPU Extension Construct:"), c4); - c4.gridwidth = GridBagConstraints.REMAINDER; //end row - MECTypeCB = new JComboBox( ArchUnitMEC.stringTypes ); - if( MECType == null ) { - MECTypeCB.setSelectedIndex( 0 ); - } - else { - MECTypeCB.setSelectedIndex( MECType.getIndex() ); - } - MECTypeCB.addActionListener(this); - panel4.add( MECTypeCB, c4); - - tabbedPane.addTab( "Simulation", panel2 ); - tabbedPane.addTab( "Code generation", panel4 ); - tabbedPane.setSelectedIndex(0); - - // 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); - c.add(panel4, c0);*/ - c.add( tabbedPane, c0 ); - - c0.gridwidth = 1; - c0.gridheight = 1; - c0.fill = GridBagConstraints.HORIZONTAL; - closeButton = new JButton("Save and Close", IconManager.imgic25); - //closeButton.setPreferredSize(new Dimension(600, 50)); - closeButton.addActionListener(this); - c.add(closeButton, c0); - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - cancelButton = new JButton("Cancel", IconManager.imgic27); - cancelButton.addActionListener(this); - c.add(cancelButton, c0); - } - - public void actionPerformed(ActionEvent evt) { - /* if (evt.getSource() == typeBox) { - boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); - initialValue.setEnabled(b); - return; - }*/ - - - 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; - MECType = ArchUnitMEC.Types.get( MECTypeCB.getSelectedIndex() ); - dispose(); - } - - public void cancelDialog() { - dispose(); - } - - public boolean isRegularClose() { - return regularClose; - } - - public String getNodeName() { - return nodeName.getText(); - } - - public String getSliceTime() { - return sliceTime.getText(); - } - - public String getNbOfCores() { - return nbOfCores.getText(); - } - - public String getByteDataSize() { - return byteDataSize.getText(); - } - - public String getPipelineSize(){ - return pipelineSize.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 getTaskSwitchingTime(){ - return taskSwitchingTime.getText(); - } - - public String getBranchingPredictionPenalty(){ - return branchingPredictionPenalty.getText(); - } - - public String getCacheMiss(){ - return cacheMiss.getText(); - } - - public String getClockRatio(){ - return clockRatio.getText(); - } - - public int getSchedulingPolicy() { - return schedulingPolicy.getSelectedIndex(); - } - - public int getEncryption(){ - return encryption.getSelectedIndex(); - } - public ArchUnitMEC getMECType() { - return MECType; - } - - + + private boolean regularClose; + + private JPanel panel2, panel4; + private Frame frame; + private TMLArchiCPUNode node; + + private ArchUnitMEC MECType; + + + // Panel1 + protected JTextField nodeName; + + // Panel2 + protected JTextField sliceTime, nbOfCores, byteDataSize, pipelineSize, goIdleTime, maxConsecutiveIdleCycles, taskSwitchingTime, branchingPredictionPenalty, cacheMiss, clockRatio, execiTime, execcTime; + protected JComboBox schedulingPolicy, MECTypeCB, encryption; + + // Tabbed pane for panel1 and panel2 + private JTabbedPane tabbedPane; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogCPUNode(Frame _frame, String _title, TMLArchiCPUNode _node, ArchUnitMEC _MECType) { + super(_frame, _title, true); + frame = _frame; + node = _node; + MECType = _MECType; + + 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("CPU attributes")); + panel2.setPreferredSize(new Dimension(400, 300)); + + tabbedPane = 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; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("Scheduling policy:"), c2); + + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + schedulingPolicy = new JComboBox(); + schedulingPolicy.addItem("Round Robin"); + schedulingPolicy.addItem("Round Robin - Priority Based"); + schedulingPolicy.setSelectedIndex(node.getSchedulingPolicy()); + panel2.add(schedulingPolicy, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Slice time (in microseconds):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + sliceTime = new JTextField(""+node.getSliceTime(), 15); + panel2.add(sliceTime, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Nb of cores:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + nbOfCores = new JTextField(""+node.getNbOfCores(), 15); + panel2.add(nbOfCores, 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("Pipeline size (num. stages):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + pipelineSize = new JTextField(""+node.getPipelineSize(), 15); + panel2.add(pipelineSize, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Task switching time (in cycle):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + taskSwitchingTime = new JTextField(""+node.getTaskSwitchingTime(), 15); + panel2.add(taskSwitchingTime, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Mis-Branching prediction (in %):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + branchingPredictionPenalty = new JTextField(""+node.getBranchingPredictionPenalty(), 15); + panel2.add(branchingPredictionPenalty, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Cache-miss (in %):"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + cacheMiss = new JTextField(""+node.getCacheMiss(), 15); + panel2.add(cacheMiss, 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("Clock diviser:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + clockRatio = new JTextField(""+node.getClockRatio(), 15); + panel2.add(clockRatio, c2); + + // Code generation + panel4 = new JPanel(); + panel4.setLayout( gridbag4 ); + panel4.setBorder( new javax.swing.border.TitledBorder("Code generation") ); + panel4.setPreferredSize( new Dimension(400, 300) ); + c4.gridwidth = 1; + c4.gridheight = 1; + c4.weighty = 1.0; + c4.weightx = 1.0; + c4.fill = GridBagConstraints.HORIZONTAL; + /*c4.fill = GridBagConstraints.BOTH; + c4.gridheight = 3; + panel4.add( new JLabel(" "), c4 ); + c4.gridwidth = 1; + c4.fill = GridBagConstraints.HORIZONTAL; + c4.anchor = GridBagConstraints.CENTER;*/ + panel4.add(new JLabel("Encryption:"), c4); + c4.gridwidth = GridBagConstraints.REMAINDER; + encryption = new JComboBox(); + encryption.addItem("None"); + encryption.addItem("Software Encryption"); + encryption.addItem("Hardware Security Module"); + encryption.setSelectedIndex(node.getEncryption()); + panel4.add(encryption, c4); + c4.gridwidth = 1; + panel4.add(new JLabel("CPU Extension Construct:"), c4); + c4.gridwidth = GridBagConstraints.REMAINDER; //end row + MECTypeCB = new JComboBox( ArchUnitMEC.stringTypes ); + if( MECType == null ) { + MECTypeCB.setSelectedIndex( 0 ); + } + else { + MECTypeCB.setSelectedIndex( MECType.getIndex() ); + } + MECTypeCB.addActionListener(this); + panel4.add( MECTypeCB, c4); + + tabbedPane.addTab( "Simulation", panel2 ); + tabbedPane.addTab( "Code generation", panel4 ); + tabbedPane.setSelectedIndex(0); + + // 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); + c.add(panel4, c0);*/ + c.add( tabbedPane, c0 ); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + + 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; + MECType = ArchUnitMEC.Types.get( MECTypeCB.getSelectedIndex() ); + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public String getNodeName() { + return nodeName.getText(); + } + + public String getSliceTime() { + return sliceTime.getText(); + } + + public String getNbOfCores() { + return nbOfCores.getText(); + } + + public String getByteDataSize() { + return byteDataSize.getText(); + } + + public String getPipelineSize(){ + return pipelineSize.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 getTaskSwitchingTime(){ + return taskSwitchingTime.getText(); + } + + public String getBranchingPredictionPenalty(){ + return branchingPredictionPenalty.getText(); + } + + public String getCacheMiss(){ + return cacheMiss.getText(); + } + + public String getClockRatio(){ + return clockRatio.getText(); + } + + public int getSchedulingPolicy() { + return schedulingPolicy.getSelectedIndex(); + } + + public int getEncryption(){ + return encryption.getSelectedIndex(); + } + public ArchUnitMEC getMECType() { + return MECType; + } + + } diff --git a/src/ui/window/JDialogDMANode.java b/src/ui/window/JDialogDMANode.java index 5c241a539c0a9ca69e1c4c7cf605a757e34e3947..dfa5bf8d6d05e9912a7de3af314ef05f4290379d 100644 --- a/src/ui/window/JDialogDMANode.java +++ b/src/ui/window/JDialogDMANode.java @@ -141,7 +141,7 @@ public class JDialogDMANode extends javax.swing.JDialog implements ActionListene panel2.add(nbOfChannels, c2); c2.gridwidth = 1; - panel2.add(new JLabel("Clock ratio:"), c2); + panel2.add(new JLabel("Clock diviser:"), c2); c2.gridwidth = GridBagConstraints.REMAINDER; //end row clockRatio = new JTextField(""+node.getClockRatio(), 15); panel2.add(clockRatio, c2); diff --git a/src/ui/window/JDialogHwANode.java b/src/ui/window/JDialogHwANode.java index a35c4ab709aee268062eb3b4a90e9c63bdcc2478..2d87ec667e7fee79ec995ae9ed667aa2f33f93d6 100755 --- a/src/ui/window/JDialogHwANode.java +++ b/src/ui/window/JDialogHwANode.java @@ -58,38 +58,38 @@ import ui.tmldd.*; public class JDialogHwANode extends javax.swing.JDialog implements ActionListener { - + private boolean regularClose; - + private JPanel panel2; private Frame frame; private TMLArchiHWANode node; - - + + // Panel1 protected JTextField nodeName; - - // Panel2 + + // Panel2 protected JTextField byteDataSize, execiTime, clockRatio; - + // Main Panel private JButton closeButton; private JButton cancelButton; - + /** Creates new form */ public JDialogHwANode(Frame _frame, String _title, TMLArchiHWANode _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(); @@ -98,19 +98,19 @@ public class JDialogHwANode extends javax.swing.JDialog implements ActionListene GridBagConstraints c0 = new GridBagConstraints(); GridBagConstraints c1 = new GridBagConstraints(); GridBagConstraints c2 = 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("CPU attributes")); panel2.setPreferredSize(new Dimension(400, 300)); - - c1.gridwidth = 1; + + c1.gridwidth = 1; c1.gridheight = 1; c1.weighty = 1.0; c1.weightx = 1.0; @@ -120,39 +120,39 @@ public class JDialogHwANode extends javax.swing.JDialog implements ActionListene nodeName = new JTextField(node.getNodeName(), 30); nodeName.setEditable(true); nodeName.setFont(new Font("times", Font.PLAIN, 12)); - panel2.add(nodeName, c1); - + panel2.add(nodeName, c1); + c2.gridwidth = 1; c2.gridheight = 1; c2.weighty = 1.0; c2.weightx = 1.0; c2.fill = GridBagConstraints.HORIZONTAL; - + 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; + + 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("Clock ratio:"), c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Clock diviser:"), 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 c.add(panel2, c0); - + c0.gridwidth = 1; c0.gridheight = 1; c0.fill = GridBagConstraints.HORIZONTAL; @@ -165,17 +165,17 @@ public class JDialogHwANode extends javax.swing.JDialog implements ActionListene cancelButton.addActionListener(this); c.add(cancelButton, c0); } - - public void actionPerformed(ActionEvent evt) { - /* if (evt.getSource() == typeBox) { - boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); - initialValue.setEnabled(b); - return; - }*/ - - + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + String command = evt.getActionCommand(); - + // Compare the action command to the known actions. if (command.equals("Save and Close")) { closeDialog(); @@ -183,34 +183,34 @@ public class JDialogHwANode extends javax.swing.JDialog implements ActionListene cancelDialog(); } } - + public void closeDialog() { regularClose = true; dispose(); } - + public void cancelDialog() { dispose(); } - + public boolean isRegularClose() { return regularClose; } - - public String getNodeName() { + + public String getNodeName() { return nodeName.getText(); } - + public String getByteDataSize() { return byteDataSize.getText(); } - - public String getExeciTime(){ - return execiTime.getText(); - } - - public String getClockRatio(){ - return clockRatio.getText(); - } - + + public String getExeciTime(){ + return execiTime.getText(); + } + + public String getClockRatio(){ + return clockRatio.getText(); + } + } diff --git a/src/ui/window/JDialogMemoryNode.java b/src/ui/window/JDialogMemoryNode.java index 9c719e62035a57daf43a609f385a1596fd1ade03..2239d605fa61b721de13690e823a0d6b582110ad 100755 --- a/src/ui/window/JDialogMemoryNode.java +++ b/src/ui/window/JDialogMemoryNode.java @@ -58,45 +58,45 @@ import tmltranslator.ctranslator.*; public class JDialogMemoryNode extends javax.swing.JDialog implements ActionListener { - + private boolean regularClose; - + private JPanel panel2, panel3; private Frame frame; private TMLArchiMemoryNode node; - - + + // Panel1 protected JTextField nodeName; - - // Panel2 + + // Panel2 protected JTextField byteDataSize, monitored, clockRatio; - //Panel3: code generation - protected int bufferType = 0; //it is the index in the ArrayList of String - protected JComboBox bufferTypesCB; - - private JTabbedPane tabbedPane; - + //Panel3: code generation + protected int bufferType = 0; //it is the index in the ArrayList of String + protected JComboBox bufferTypesCB; + + private JTabbedPane tabbedPane; + // Main Panel private JButton closeButton; private JButton cancelButton; - + /** Creates new form */ public JDialogMemoryNode( Frame _frame, String _title, TMLArchiMemoryNode _node, int _bufferType ) { super(_frame, _title, true); frame = _frame; node = _node; - bufferType = _bufferType; - + bufferType = _bufferType; + initComponents(); myInitComponents(); pack(); } - + private void myInitComponents() { } - + private void initComponents() { Container c = getContentPane(); GridBagLayout gridbag0 = new GridBagLayout(); @@ -107,14 +107,14 @@ public class JDialogMemoryNode extends javax.swing.JDialog implements ActionList GridBagConstraints c1 = new GridBagConstraints(); GridBagConstraints c2 = new GridBagConstraints(); GridBagConstraints c3 = new GridBagConstraints(); - + setFont(new Font("Helvetica", Font.PLAIN, 14)); c.setLayout(gridbag0); - + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - tabbedPane = new JTabbedPane(); - + + tabbedPane = new JTabbedPane(); + panel2 = new JPanel(); panel2.setLayout(gridbag2); panel2.setBorder(new javax.swing.border.TitledBorder("Memory attributes")); @@ -124,8 +124,8 @@ public class JDialogMemoryNode extends javax.swing.JDialog implements ActionList panel3.setLayout(gridbag3); panel3.setBorder(new javax.swing.border.TitledBorder("Code generation")); panel3.setPreferredSize(new Dimension(300, 200)); - - c1.gridwidth = 1; + + c1.gridwidth = 1; c1.gridheight = 1; c1.weighty = 1.0; c1.weightx = 1.0; @@ -135,57 +135,57 @@ public class JDialogMemoryNode extends javax.swing.JDialog implements ActionList nodeName = new JTextField(node.getNodeName(), 30); nodeName.setEditable(true); nodeName.setFont(new Font("times", Font.PLAIN, 12)); - panel2.add(nodeName, c1); - + panel2.add(nodeName, c1); + c2.gridheight = 1; c2.weighty = 1.0; c2.weightx = 1.0; c2.fill = GridBagConstraints.HORIZONTAL; - + 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; + c2.gridwidth = 1; panel2.add(new JLabel("Monitored :"), c2); c2.gridwidth = GridBagConstraints.REMAINDER; //end row //monitored = new JTextField(""+node.getMonitored(), 15);//DG 19.04. - monitored = new JTextField("", 15); + monitored = new JTextField("", 15); panel2.add(monitored, c2); - - c2.gridwidth = 1; - panel2.add(new JLabel("Clock ratio:"), c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Clock diviser:"), c2); c2.gridwidth = GridBagConstraints.REMAINDER; //end row clockRatio = new JTextField(""+node.getClockRatio(), 15); panel2.add(clockRatio, c2); - //code generation - c3.gridwidth = 1; + //code generation + c3.gridwidth = 1; c3.gridheight = 1; c3.weighty = 1.0; c3.weightx = 1.0; - panel3.add(new JLabel("<html>Memory Extension<br>Construct:</html>"), c3); - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - bufferTypesCB = new JComboBox( new Vector<String>( Arrays.asList( Buffer.memoryTypesList ) ) ); - bufferTypesCB.setSelectedIndex( bufferType ); - panel3.add( bufferTypesCB, c3 ); - + panel3.add(new JLabel("<html>Memory Extension<br>Construct:</html>"), c3); + c3.gridwidth = GridBagConstraints.REMAINDER; //end row + bufferTypesCB = new JComboBox( new Vector<String>( Arrays.asList( Buffer.memoryTypesList ) ) ); + bufferTypesCB.setSelectedIndex( bufferType ); + panel3.add( bufferTypesCB, c3 ); + // main panel; c0.gridheight = 10; c0.weighty = 1.0; c0.weightx = 1.0; c0.gridwidth = GridBagConstraints.REMAINDER; //end row - c0.fill = GridBagConstraints.BOTH; + c0.fill = GridBagConstraints.BOTH; - tabbedPane.addTab( "Simulation", panel2 ); - tabbedPane.addTab( "Code generation", panel3 ); - tabbedPane.setSelectedIndex(0); + tabbedPane.addTab( "Simulation", panel2 ); + tabbedPane.addTab( "Code generation", panel3 ); + tabbedPane.setSelectedIndex(0); /*c.add(panel2, c0); - c.add(panel3, c0);*/ - c.add( tabbedPane, c0 ); - + c.add(panel3, c0);*/ + c.add( tabbedPane, c0 ); + c0.gridwidth = 1; c0.gridheight = 1; c0.fill = GridBagConstraints.HORIZONTAL; @@ -198,17 +198,17 @@ public class JDialogMemoryNode extends javax.swing.JDialog implements ActionList cancelButton.addActionListener(this); c.add(cancelButton, c0); } - - public void actionPerformed(ActionEvent evt) { - /* if (evt.getSource() == typeBox) { - boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); - initialValue.setEnabled(b); - return; - }*/ - - + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + String command = evt.getActionCommand(); - + // Compare the action command to the known actions. if (command.equals("Save and Close")) { closeDialog(); @@ -216,38 +216,38 @@ public class JDialogMemoryNode extends javax.swing.JDialog implements ActionList cancelDialog(); } } - + public void closeDialog() { regularClose = true; - bufferType = bufferTypesCB.getSelectedIndex(); + bufferType = bufferTypesCB.getSelectedIndex(); dispose(); } - + public void cancelDialog() { dispose(); } - + public boolean isRegularClose() { return regularClose; } - - public String getNodeName() { + + public String getNodeName() { return nodeName.getText(); } - + public String getByteDataSize() { return byteDataSize.getText(); } public String getMonitored() { return monitored.getText(); - } - public String getClockRatio() { + } + public String getClockRatio() { return clockRatio.getText(); } - - public int getBufferType() { - return bufferType; - } - + + public int getBufferType() { + return bufferType; + } + }