diff --git a/src/tmltranslator/TMLArchitecture.java b/src/tmltranslator/TMLArchitecture.java index 4179e88ffb9f775733501630914409d9e90f4fb3..18fd447dd03b472df69dba9f4c39d0886e74e610 100755 --- a/src/tmltranslator/TMLArchitecture.java +++ b/src/tmltranslator/TMLArchitecture.java @@ -1,47 +1,47 @@ /**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 TMLArchitecture -* Creation: 05/09/2007 -* @version 1.1 19/05/2008 -* @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 TMLArchitecture + * Creation: 05/09/2007 + * @version 1.1 19/05/2008 + * @author Ludovic APVRILLE + * @see + */ package tmltranslator; @@ -51,316 +51,327 @@ import myutil.*; public class TMLArchitecture { private ArrayList<HwNode> hwnodes; - private ArrayList<HwLink> hwlinks; // Between buses and other component - - private int masterClockFrequency = 200; // in MHz - - private int hashCode; - private boolean hashCodeComputed = false; - - + private ArrayList<HwLink> hwlinks; // Between buses and other component + + private int masterClockFrequency = 200; // in MHz + + private int hashCode; + private boolean hashCodeComputed = false; + + public TMLArchitecture() { init(); } - + private void init() { hwnodes = new ArrayList<HwNode>(); - hwlinks = new ArrayList<HwLink>(); - } - - private void computeHashCode() { - TMLArchiTextSpecification architxt = new TMLArchiTextSpecification("spec.tarchi"); - String s = architxt.toTextFormat(this); - hashCode = s.hashCode(); - //System.out.println("TARCHI hashcode = " + hashCode); - } - - public int getHashCode() { - if (!hashCodeComputed) { - computeHashCode(); - hashCodeComputed = true; - } - return hashCode; - } - - public void setMasterClockFrequency(int value) { - masterClockFrequency = value; - } - - public int getMasterClockFrequency() { - return masterClockFrequency; - } - - + hwlinks = new ArrayList<HwLink>(); + } + + private void computeHashCode() { + TMLArchiTextSpecification architxt = new TMLArchiTextSpecification("spec.tarchi"); + String s = architxt.toTextFormat(this); + hashCode = s.hashCode(); + //System.out.println("TARCHI hashcode = " + hashCode); + } + + public int getHashCode() { + if (!hashCodeComputed) { + computeHashCode(); + hashCodeComputed = true; + } + return hashCode; + } + + public void setMasterClockFrequency(int value) { + masterClockFrequency = value; + } + + public int getMasterClockFrequency() { + return masterClockFrequency; + } + + public void addHwNode(HwNode _node) { hwnodes.add(_node); } - - public ArrayList<HwNode> getHwNodes() { - return hwnodes; - } - - public HwCPU getFirstCPU() { - for(HwNode node: hwnodes) { - if (node instanceof HwCPU) { - return (HwCPU)node; - } - } - return null; - } - - public HwBus getFirstBus() { - for(HwNode node: hwnodes) { - if (node instanceof HwBus) { - return (HwBus)node; - } - } - return null; - } - - public HwMemory getFirstMemory() { - for(HwNode node: hwnodes) { - if (node instanceof HwMemory) { - return (HwMemory)node; - } - } - return null; - } - - - - public boolean hasCPU() { - for(HwNode node: hwnodes) { - if (node instanceof HwCPU) { - return true; - } - } - return false; - } - - public boolean hasBus() { - for(HwNode node: hwnodes) { - if (node instanceof HwBus) { - return true; - } - } - return false; - } - - public int getNbOfBusses() { - int cpt = 0; - for(HwNode node: hwnodes) { - if (node instanceof HwBus) { - cpt ++; - } - } - return cpt; - } - - public boolean hasMemory() { - for(HwNode node: hwnodes) { - if (node instanceof HwMemory) { - return true; - } - } - return false; - } - - public int getNbOfMemories() { - int cpt = 0; - for(HwNode node: hwnodes) { - if (node instanceof HwMemory) { - cpt ++; - } - } - return cpt; - } - - public String[] getCPUIDs() { - String [] list = new String[getNbOfCPU()]; - int cpt = 0; - - for(HwNode node: hwnodes) { - if (node instanceof HwCPU) { - list[cpt] = node.getName() + " (" + node.getID() + ")"; - cpt ++; - } - } + + public ArrayList<HwNode> getHwNodes() { + return hwnodes; + } + + public HwCPU getFirstCPU() { + for(HwNode node: hwnodes) { + if (node instanceof HwCPU) { + return (HwCPU)node; + } + } + return null; + } + + public HwBus getFirstBus() { + for(HwNode node: hwnodes) { + if (node instanceof HwBus) { + return (HwBus)node; + } + } + return null; + } + + public HwMemory getFirstMemory() { + for(HwNode node: hwnodes) { + if (node instanceof HwMemory) { + return (HwMemory)node; + } + } + return null; + } + + + + public boolean hasCPU() { + for(HwNode node: hwnodes) { + if (node instanceof HwCPU) { + return true; + } + } + return false; + } + + public boolean hasBus() { + for(HwNode node: hwnodes) { + if (node instanceof HwBus) { + return true; + } + } + return false; + } + + public int getNbOfBusses() { + int cpt = 0; + for(HwNode node: hwnodes) { + if (node instanceof HwBus) { + cpt ++; + } + } + return cpt; + } + + public boolean hasMemory() { + for(HwNode node: hwnodes) { + if (node instanceof HwMemory) { + return true; + } + } + return false; + } + + public int getNbOfMemories() { + int cpt = 0; + for(HwNode node: hwnodes) { + if (node instanceof HwMemory) { + cpt ++; + } + } + return cpt; + } + + public String[] getCPUIDs() { + String [] list = new String[getNbOfCPU()]; + int cpt = 0; + + for(HwNode node: hwnodes) { + if (node instanceof HwCPU) { + list[cpt] = node.getName() + " (" + node.getID() + ")"; + cpt ++; + } + } return list; - } - - public String[] getCPUandHwAIDs() { - String [] list = new String[getNbOfCPUandHwA()]; - int cpt = 0; - - for(HwNode node: hwnodes) { - if ((node instanceof HwCPU) || (node instanceof HwA)) { - list[cpt] = node.getName() + " (" + node.getID() + ")"; - cpt ++; - } - } + } + + public String[] getCPUandHwAIDs() { + String [] list = new String[getNbOfCPUandHwA()]; + int cpt = 0; + + for(HwNode node: hwnodes) { + if ((node instanceof HwCPU) || (node instanceof HwA)) { + list[cpt] = node.getName() + " (" + node.getID() + ")"; + cpt ++; + } + } return list; - } - - public String[] getBusIDs() { - String [] list = new String[getNbOfBus()]; - int cpt = 0; - - for(HwNode node: hwnodes) { - if (node instanceof HwBus) { - list[cpt] = node.getName() + " (" + node.getID() + ")"; - cpt ++; - } - } + } + + public String[] getBusIDs() { + String [] list = new String[getNbOfBus()]; + int cpt = 0; + + for(HwNode node: hwnodes) { + if (node instanceof HwBus) { + list[cpt] = node.getName() + " (" + node.getID() + ")"; + cpt ++; + } + } return list; - } - - public String[] getMemIDs() { - String [] list = new String[getNbOfMem()]; - int cpt = 0; - - for(HwNode node: hwnodes) { - if (node instanceof HwMemory) { - list[cpt] = node.getName() + " (" + node.getID() + ")"; - cpt ++; - } - } + } + + public String[] getMemIDs() { + String [] list = new String[getNbOfMem()]; + int cpt = 0; + + for(HwNode node: hwnodes) { + if (node instanceof HwMemory) { + list[cpt] = node.getName() + " (" + node.getID() + ")"; + cpt ++; + } + } return list; - } - - - - public int getNbOfCPU() { - int cpt = 0; - for(HwNode node: hwnodes) { - if (node instanceof HwCPU) { - cpt ++; - } - } - return cpt; - } - - public int getNbOfCPUandHwA() { - int cpt = 0; - for(HwNode node: hwnodes) { - if ((node instanceof HwCPU) || (node instanceof HwA)) { - cpt ++; - } - } - return cpt; - } - - public int getNbOfBus() { - int cpt = 0; - for(HwNode node: hwnodes) { - if (node instanceof HwBus) { - cpt ++; - } - } - return cpt; - } - - public int getNbOfMem() { - int cpt = 0; - for(HwNode node: hwnodes) { - if (node instanceof HwMemory) { - cpt ++; - } - } - return cpt; - } - - public void addHwLink(HwLink _link) { + } + + + + public int getNbOfCPU() { + int cpt = 0; + for(HwNode node: hwnodes) { + if (node instanceof HwCPU) { + cpt ++; + } + } + return cpt; + } + + public int getNbOfCPUandHwA() { + int cpt = 0; + for(HwNode node: hwnodes) { + if ((node instanceof HwCPU) || (node instanceof HwA)) { + cpt ++; + } + } + return cpt; + } + + public int getNbOfBus() { + int cpt = 0; + for(HwNode node: hwnodes) { + if (node instanceof HwBus) { + cpt ++; + } + } + return cpt; + } + + public int getNbOfMem() { + int cpt = 0; + for(HwNode node: hwnodes) { + if (node instanceof HwMemory) { + cpt ++; + } + } + return cpt; + } + + public void addHwLink(HwLink _link) { hwlinks.add(_link); } - - public ArrayList<HwLink> getHwLinks() { - return hwlinks; - } - - public HwNode getHwNodeByName(String _name) { - for(HwNode node: hwnodes) { - if (node.getName().equals(_name)) { - return node; - } - } - return null; - } - - public HwBus getHwBusByName(String _name) { - for(HwNode node: hwnodes) { - if (node.getName().equals(_name)) { - if (node instanceof HwBus) { - return (HwBus)node; - } - } - } - return null; - } - - public HwLink getHwLinkByName(String _name) { - for(HwLink link: hwlinks) { - if (link.getName().equals(_name)) { - return link; - } - } - return null; - } - - public ArrayList<HwLink> getLinkByHwNode(HwNode node){ - ArrayList<HwLink> tempList=new ArrayList<HwLink>(); - for(HwLink link: hwlinks) { - if (link.hwnode==node) tempList.add(link); - } - return tempList; - } - - public HwLink getHwLinkByHwNode(HwNode node){ - for(HwLink link: hwlinks) { - if (link.hwnode==node) { - return link; - } - } - return null; - } - - public boolean isNodeConnectedToBus(HwNode node, HwBus bus){ - for(HwLink link: hwlinks) { - if (node==link.hwnode && bus==link.bus) return true; - } - return false; - } - - public ArrayList<HwLink> getLinkByBus(HwBus bus){ - ArrayList<HwLink> tempList=new ArrayList<HwLink>(); - for(HwLink link: hwlinks) { - if (link.bus==bus) tempList.add(link); - } - return tempList; - } - - public int getArchitectureComplexity() { - // CPU complexity depends on its data size - // Bus complexity depends on its data size - int complexity = 0; - - for(HwNode node: hwnodes) { - if (node instanceof HwCPU) { - HwCPU cpu = (HwCPU)node; - complexity += cpu.nbOfCores * cpu.byteDataSize * cpu.pipelineSize; - TraceManager.addDev("complexity CPU= " + complexity); - } - - if (node instanceof HwBus) { - HwBus bus = (HwBus)node; - complexity += bus.byteDataSize * bus.pipelineSize; - TraceManager.addDev("complexity bus= " + complexity); - } - } - - TraceManager.addDev("Complexity = " + complexity); - - return complexity; - } - -} \ No newline at end of file + + public ArrayList<HwLink> getHwLinks() { + return hwlinks; + } + + public HwNode getHwNodeByName(String _name) { + for(HwNode node: hwnodes) { + if (node.getName().equals(_name)) { + return node; + } + } + return null; + } + + public HwBus getHwBusByName(String _name) { + for(HwNode node: hwnodes) { + if (node.getName().equals(_name)) { + if (node instanceof HwBus) { + return (HwBus)node; + } + } + } + return null; + } + + public HwMemory getHwMemoryByName(String _name) { + for(HwNode node: hwnodes) { + if (node.getName().equals(_name)) { + if (node instanceof HwMemory) { + return (HwMemory)node; + } + } + } + return null; + } + + public HwLink getHwLinkByName(String _name) { + for(HwLink link: hwlinks) { + if (link.getName().equals(_name)) { + return link; + } + } + return null; + } + + public ArrayList<HwLink> getLinkByHwNode(HwNode node){ + ArrayList<HwLink> tempList=new ArrayList<HwLink>(); + for(HwLink link: hwlinks) { + if (link.hwnode==node) tempList.add(link); + } + return tempList; + } + + public HwLink getHwLinkByHwNode(HwNode node){ + for(HwLink link: hwlinks) { + if (link.hwnode==node) { + return link; + } + } + return null; + } + + public boolean isNodeConnectedToBus(HwNode node, HwBus bus){ + for(HwLink link: hwlinks) { + if (node==link.hwnode && bus==link.bus) return true; + } + return false; + } + + public ArrayList<HwLink> getLinkByBus(HwBus bus){ + ArrayList<HwLink> tempList=new ArrayList<HwLink>(); + for(HwLink link: hwlinks) { + if (link.bus==bus) tempList.add(link); + } + return tempList; + } + + public int getArchitectureComplexity() { + // CPU complexity depends on its data size + // Bus complexity depends on its data size + int complexity = 0; + + for(HwNode node: hwnodes) { + if (node instanceof HwCPU) { + HwCPU cpu = (HwCPU)node; + complexity += cpu.nbOfCores * cpu.byteDataSize * cpu.pipelineSize; + TraceManager.addDev("complexity CPU= " + complexity); + } + + if (node instanceof HwBus) { + HwBus bus = (HwBus)node; + complexity += bus.byteDataSize * bus.pipelineSize; + TraceManager.addDev("complexity bus= " + complexity); + } + } + + TraceManager.addDev("Complexity = " + complexity); + + return complexity; + } + +} diff --git a/src/tmltranslator/TMLCPLib.java b/src/tmltranslator/TMLCPLib.java index 8ae6fd3de1f0421b0eac7d58a48fc6ba9c3c6dd2..e6e53a9348c37af1043cd4eeb33f92f9e4646d49 100755 --- a/src/tmltranslator/TMLCPLib.java +++ b/src/tmltranslator/TMLCPLib.java @@ -100,6 +100,10 @@ public class TMLCPLib extends TMLElement { return typeName.compareTo("Double_DMA_transfer") == 0; } + public boolean isMemoryCopy() { + return typeName.compareTo("CP_Memory_Copy") == 0; + } + public String getUnitByName(String id) { id = "." + id + " : "; for(String s: mappedUnits) { diff --git a/src/tmltranslator/TMLMapping.java b/src/tmltranslator/TMLMapping.java index 93fa56a7a60292f95e322e60e85f21a8c2f4c12e..be3319acef29e847d43e5bca9bf7643a819c18be 100755 --- a/src/tmltranslator/TMLMapping.java +++ b/src/tmltranslator/TMLMapping.java @@ -343,6 +343,14 @@ public class TMLMapping { mappedcommelts.add(_elt); } + public void removeCommMapping(TMLElement _elt) { + int index; + while((index = mappedcommelts.indexOf(_elt)) > -1) { + oncommnodes.remove(index); + mappedcommelts.remove(index); + } + } + public TMLModeling getTMLModeling() { return tmlm; } @@ -654,34 +662,31 @@ public class TMLMapping { public void handleCPs() { // Remove the CPLib with new tasks, channels, HW components - - - handleCPDMA(); - - // Handle ports of forks / joins not mapped on local memories - // - - mappedCPLibs = new ArrayList<TMLCPLib>(); - - - } - - private void handleCPDMA() { - TraceManager.addDev("\n\n**** HANDLING CPs:"); + TraceManager.addDev("\n\n**** HANDLING CPs:"); for(TMLCPLib cp: mappedCPLibs) { //TraceManager.addDev(" Found cp:" + cp.getName() + " ref=" + cp.getTypeName()); if (cp.isDMATransfer()) { - TraceManager.addDev(" Found cp store:" + cp.getName() + "::" + cp.getTypeName()); + TraceManager.addDev(" Found cp DMA:" + cp.getName() + "::" + cp.getTypeName()); handleCPDMA(cp); } if (cp.isDoubleDMATransfer()) { - TraceManager.addDev(" Found cp store:" + cp.getName() + "::" + cp.getTypeName()); + TraceManager.addDev(" Found cp Double DMA:" + cp.getName() + "::" + cp.getTypeName()); handleCPDoubleDMA(cp); } + if (cp.isMemoryCopy()) { + TraceManager.addDev(" Found cp Memory Copy:" + cp.getName() + "::" + cp.getTypeName()); + handleCPMemoryCopy(cp); + } } + + // Remove CPs + mappedCPLibs = new ArrayList<TMLCPLib>(); + + } + private void handleCPDMA(TMLCPLib _cp) { for(TMLCPLibArtifact arti: _cp.getArtifacts()) { handleCPDMAArtifact(_cp, arti); @@ -695,6 +700,12 @@ public class TMLMapping { } } + private void handleCPMemoryCopy(TMLCPLib _cp) { + for(TMLCPLibArtifact arti: _cp.getArtifacts()) { + handleCPMemoryCopyArtifact(_cp, arti); + } + } + private void handleCPDMAArtifact(TMLCPLib _cp, TMLCPLibArtifact _arti) { // Find all the channel with the artifact TMLChannel chan = tmlm.getChannelByDestinationPortName(_arti.portName); @@ -1077,6 +1088,148 @@ public class TMLMapping { // Remove olf channel from TMLModeling //tmlm.removeChannel(chan); chan.removeComplexInformation(); + } + + private void handleCPMemoryCopyArtifact(TMLCPLib _cp, TMLCPLibArtifact _arti) { + // Find all the channel with the artifact + TMLChannel chan = tmlm.getChannelByDestinationPortName(_arti.portName); + if (chan == null) { + TraceManager.addDev("MemCPY/ Unknown channel with in port=" + _arti.portName); + return; + } + + TraceManager.addDev("MemCPY/ Found channel=" + chan); + + if (chan.getNbOfDestinationPorts() > 1) { + TraceManager.addDev("MemCPY/ Channel has too many ports (must have only one)"); + return; + } + + if (!(chan.isBasicChannel())) { + TraceManager.addDev("MemCPY/ Only basic channel is accepted"); + return; + } + + // CPU + String CPUController = _cp.getUnitByName("CPU_Controller"); + if (CPUController == null) { + TraceManager.addDev("MemCPY/ Unknown CPU controller in CP"); + return; + } + TraceManager.addDev("CPU controller=|" + CPUController + "|"); + HwExecutionNode node = getHwExecutionNodeByName(CPUController); + if (node == null) { + TraceManager.addDev("MemCPY/ Unknown Hw Execution Node: " + CPUController); + return; + } + + // SRC MEM + String SrcStorageInstance = _cp.getUnitByName("Src_Storage_Instance"); + if (SrcStorageInstance == null) { + TraceManager.addDev("MemCPY/ Unknown SrcStorageInstance in CP"); + return; + } + HwMemory mem1 = tmla.getHwMemoryByName(SrcStorageInstance); + if (mem1 == null) { + TraceManager.addDev("MemCPY/ Unknown Hw Execution Node: " + SrcStorageInstance); + return; + } + + // DST MEM + String DstStorageInstance = _cp.getUnitByName("Dst_Storage_Instance"); + if (DstStorageInstance == null) { + TraceManager.addDev("MemCPY/ Unknown DstStorageInstance in CP"); + return; + } + HwMemory mem2 = tmla.getHwMemoryByName(DstStorageInstance); + if (mem2 == null) { + TraceManager.addDev("MemCPY/ Unknown Hw Execution Node: " + DstStorageInstance); + return; + } + + // The current chan is unmapped, and mapped to the destination memory + removeCommMapping(chan); + addCommToHwCommNode(chan, mem2); + + + // We create a new Task mapped on CPUController, with a new channel + TMLTask origin = chan.getOriginTask(); + TMLTask ctrl = new TMLTask("MemCpyController__" + chan.getName(), chan, null); + tmlm.addTask(ctrl); + addTaskToHwExecutionNode(ctrl, node); + TMLChannel fromOriginToCTRL = new TMLChannel("toCTRL__" + chan.getName(), chan); + addCommToHwCommNode(fromOriginToCTRL, mem1); + fromOriginToCTRL.setType(TMLChannel.NBRNBW); + fromOriginToCTRL.setSize(chan.getSize()); + fromOriginToCTRL.setTasks(chan.getOriginTask(), ctrl); + tmlm.addChannel(fromOriginToCTRL); + + // Reworking chan + chan.setTasks(ctrl, chan.getDestinationTask()); + + // Reworking origin task + origin.replaceWriteChannelWith(chan, fromOriginToCTRL); + TMLEvent toCTRL = new TMLEvent("toCTRL__" + chan.getName(), chan, 1, false); + tmlm.addEvent(toCTRL); + toCTRL.addParam(new TMLType(TMLType.NATURAL)); + toCTRL.setTasks(origin, ctrl); + origin.addSendEventAfterWriteIn(fromOriginToCTRL, toCTRL, "size"); + + // We need to create the CTRL task-> infinite loop, waiting for the origin signal, and then making the mem cpy + TMLActivity activity = ctrl.getActivityDiagram(); + TMLStartState start = new TMLStartState("startOfCTRL", null); + activity.setFirst(start); + TMLStopState mainStop = new TMLStopState("mainStopOfCTRL", null); + activity.addElement(mainStop); + TMLStopState stop = new TMLStopState("stopOfCTRL", null); + activity.addElement(stop); + TMLStopState stopWrite = new TMLStopState("stopOfWrite", null); + activity.addElement(stopWrite); + TMLWaitEvent wait = new TMLWaitEvent("waitEvtInCTRL", null); + wait.setEvent(toCTRL); + wait.addParam("size"); + activity.addElement(wait); + TMLForLoop mainLoop = new TMLForLoop("mainLoopOfCTRL", null); + mainLoop.setInit("i=0"); + mainLoop.setCondition("i==1"); + mainLoop.setIncrement("i=i"); + activity.addElement(mainLoop); + TMLForLoop loop = new TMLForLoop("loopOfCTRL", null); + loop.setInit("j=size"); + loop.setCondition("j==0"); + loop.setIncrement("j = j-1"); + activity.addElement(loop); + TMLAttribute attri = new TMLAttribute("i", "i", new TMLType(TMLType.NATURAL), "0"); + ctrl.addAttribute(attri); + TMLAttribute attrj = new TMLAttribute("j", "j", new TMLType(TMLType.NATURAL), "0"); + ctrl.addAttribute(attrj); + TMLAttribute attrsize = new TMLAttribute("size", "size", new TMLType(TMLType.NATURAL), "0"); + ctrl.addAttribute(attrsize); + + TMLWriteChannel write = new TMLWriteChannel("WriteOfCTRL", null); + activity.addElement(write); + write.addChannel(chan); + write.setNbOfSamples("1"); + TMLReadChannel read = new TMLReadChannel("ReadOfCTRL", null); + read.addChannel(fromOriginToCTRL); + read.setNbOfSamples("1"); + activity.addElement(read); + + activity.setFirst(start); + start.addNext(mainLoop); + mainLoop.addNext(wait); + mainLoop.addNext(mainStop); + wait.addNext(loop); + loop.addNext(read); + loop.addNext(stop); + read.addNext(write); + write.addNext(stopWrite); + + + + + + } }