diff --git a/solutions/RSync/src/main/scala/ttc2019/worksync/BddSyncIntegration.scala b/solutions/RSync/src/main/scala/ttc2019/worksync/BddSyncIntegration.scala index adbfdc15d81a2706d2e7cc86ac0b857a8130d3b3..219b8598cdfb888cfbec4f85343d8800876a7da2 100644 --- a/solutions/RSync/src/main/scala/ttc2019/worksync/BddSyncIntegration.scala +++ b/solutions/RSync/src/main/scala/ttc2019/worksync/BddSyncIntegration.scala @@ -15,11 +15,11 @@ object BddSyncIntegration extends IIntegrationCompartment { private var leafNodes: Map[Set[String], sync.bddg.Leaf] = Map.empty private var createdBdds: Set[sync.bddg.BDD] = Set.empty - def printManager(): Unit = { + /*def printManager(): Unit = { ModelElementLists.getElementsFromType("sync.bddg.Leaf").asInstanceOf[List[sync.bddg.Leaf]].foreach(obj => { +obj printAllManager () }) - } + }*/ def getRelationalIntegratorsForClassName(classname: Object): IIntegrator = { return null @@ -40,7 +40,6 @@ object BddSyncIntegration extends IIntegrationCompartment { } def finalEditFunction(): Unit = { - //println("++ FINISH FUNCTION") var ttNode: sync.tt.TruthTable = null createdBdds.foreach(bddNode => { @@ -56,7 +55,6 @@ object BddSyncIntegration extends IIntegrationCompartment { }) //printManager() - //println("++ END FINISH FUNCTION") } def createOutputLookSubtree(bdd: sync.bddg.BDD, truthTable: sync.tt.TruthTable, rows: Set[sync.tt.Row], finishPorts: Set[sync.tt.Port]): sync.bddg.Tree = { @@ -115,7 +113,6 @@ object BddSyncIntegration extends IIntegrationCompartment { val rowsOne = cellis.filter(_.getValue()).map(_.getOwner()) val rowsZero = cellis.filter(!_.getValue()).map(_.getOwner()) - //println("Rows (1) " + rowsOne.size + " (2) " + rowsZero.size) var treeZero: sync.bddg.Tree = null var treeOne: sync.bddg.Tree = null @@ -146,71 +143,6 @@ object BddSyncIntegration extends IIntegrationCompartment { subtree } - - def createInputLookSubtree(bdd: sync.bddg.BDD, truthTable: sync.tt.TruthTable, rows: Set[sync.tt.Row], finishPorts: Set[sync.tt.Port]): sync.bddg.Tree = { - var max = 0 - var portTT: sync.tt.Port = null - var cellis: Set[sync.tt.Cell] = Set.empty - - truthTable.getPorts().filter(p => p.isInstanceOf[sync.tt.InputPort] && !finishPorts.contains(p)).foreach(ttip => { - val newCells = ttip.getCells().filter(c => rows.contains(c.getOwner())) - if (newCells.size > max) { - max = newCells.size - portTT = ttip - cellis = newCells - } else if (newCells.size == max) { - val p1 = newCells.count(_.getValue()) - val p2 = newCells.count(!_.getValue()) - if (Math.abs(max / 2 - p1) > Math.abs(max / 2 - p2)) { - portTT = ttip - cellis = newCells - } - } - }) - //println("Used Port: " + portTT) - var portBDD: sync.bddg.InputPort = null - val oppo: PlayerSync = +portTT getRelatedClassFromName ("InputPort") - if (oppo != null) { - portBDD = oppo.asInstanceOf[sync.bddg.InputPort] - } - - val newPorts = finishPorts + portTT - val subtree = new sync.bddg.Subtree(null, null, portBDD, Set.empty, Set.empty, bdd) - bdd.addTrees(subtree) - portBDD.addSubtrees(subtree) - - val rowsOne = cellis.filter(_.getValue()).map(_.getOwner()) - val rowsZero = cellis.filter(!_.getValue()).map(_.getOwner()) - //println("Rows (1) " + rowsOne.size + " (2) " + rowsZero.size) - - var treeZero: sync.bddg.Tree = null - var treeOne: sync.bddg.Tree = null - if (rowsZero.size == 1) { - //create leaf from rows - treeZero = createLeafFromRows(bdd, rowsZero) - } else { - treeZero = createInputLookSubtree(bdd, truthTable, rowsZero, newPorts) - } - if (rowsOne.size == 1) { - //create leaf from rows - treeOne = createLeafFromRows(bdd, rowsOne) - } else { - treeOne = createInputLookSubtree(bdd, truthTable, rowsOne, newPorts) - } - //TODO: Assignment what to do for more than one output cell - - treeOne.addOwnerSubtreeForOne(subtree) - subtree.setTreeForOne(treeOne) - //connect to rows - connectTargetElementWithSourceElementes(treeOne, rowsOne.asInstanceOf[Set[PlayerSync]]) - - treeZero.addOwnerSubtreeForZero(subtree) - subtree.setTreeForZero(treeZero) - //connect to rows - connectTargetElementWithSourceElementes(treeZero, rowsZero.asInstanceOf[Set[PlayerSync]]) - - subtree - } def createLeafFromRows(bdd: sync.bddg.BDD, rows: Set[sync.tt.Row]): sync.bddg.Leaf = { val mapping = rows.head.getCells().filter(c => c.getPort().isInstanceOf[sync.tt.OutputPort]).map(c => s"${c.getPort().getName()} ${c.getValue()}") diff --git a/solutions/RSync/src/main/scala/ttc2019/worksync/BddSyncIntegrationWithoutOrder.scala b/solutions/RSync/src/main/scala/ttc2019/worksync/BddSyncIntegrationWithoutOrder.scala new file mode 100644 index 0000000000000000000000000000000000000000..58882020e7f3839d449cfe0f135e4f6335020131 --- /dev/null +++ b/solutions/RSync/src/main/scala/ttc2019/worksync/BddSyncIntegrationWithoutOrder.scala @@ -0,0 +1,234 @@ +package ttc2019.worksync + +import org.rosi_project.model_management.core.PlayerSync +import org.rosi_project.model_management.core.SynchronizationCompartment +import org.rosi_project.model_management.sync.IIntegrationCompartment +import org.rosi_project.model_management.sync.roles.IIntegrator +import org.rosi_project.model_management.sync.roles.IRoleManager + +import org.rosi_project.model_management.sync.helper.IntegrationContainer +import scala.collection.mutable.ListBuffer +import org.rosi_project.model_management.core.ModelElementLists +import util.control.Breaks._ + +object BddSyncIntegrationWithoutOrder extends IIntegrationCompartment { + + private var leafNodes: Map[Set[String], sync.bddg.Leaf] = Map.empty + private var createdBdds: Set[sync.bddg.BDD] = Set.empty + + def getRelationalIntegratorsForClassName(classname: Object): IIntegrator = { + return null + } + + def getIntegratorForClassName(classname: Object): IIntegrator = { + if (classname.isInstanceOf[sync.tt.TruthTable]) + return new TruthTableConstruct() + return null + } + + def getNextIntegratorForClassName(classname: Object): IIntegrator = { + if (classname.isInstanceOf[sync.tt.OutputPort]) + return new OutputPortConstruct() + if (classname.isInstanceOf[sync.tt.InputPort]) + return new InputPortConstruct() + return null + } + + def finalEditFunction(): Unit = { + var ttNode: sync.tt.TruthTable = null + + createdBdds.foreach(bddNode => { + val oppBDD: PlayerSync = +bddNode getRelatedClassFromName ("TruthTable") + if (oppBDD != null) { + ttNode = oppBDD.asInstanceOf[sync.tt.TruthTable] + } + val rows = ttNode.getRows() + + val tree = createOutputLookSubtree(bddNode, ttNode, rows, Set.empty) + bddNode.setRoot(tree) + connectTargetElementWithSourceElementes(tree, rows.asInstanceOf[Set[PlayerSync]]) + }) + } + + def createOutputLookSubtree(bdd: sync.bddg.BDD, truthTable: sync.tt.TruthTable, rows: Set[sync.tt.Row], finishPorts: Set[sync.tt.Port]): sync.bddg.Tree = { + var numberTrue = -1 + var numberFalse = -1 + var portTT: sync.tt.Port = null + var cellis: Set[sync.tt.Cell] = Set.empty + + breakable { + //find next inputport for subtree + truthTable.getPorts().filter(p => p.isInstanceOf[sync.tt.InputPort] && !finishPorts.contains(p)).foreach(ttip => { + val newCells = ttip.getCells().filter(c => rows.contains(c.getOwner())) + var setTrue: Set[Set[String]] = Set.empty + var setFalse: Set[Set[String]] = Set.empty + newCells.foreach(cell => { + if (cell.getValue()) { + var setPortValue: Set[String] = Set.empty + cell.getOwner().getCells().filter(_.getPort().isInstanceOf[sync.tt.OutputPort]).foreach(ocell => { + setPortValue += s"${ocell.getPort().getName()} ${ocell.getValue()}" + }) + setTrue += setPortValue + } else { + var setPortValue: Set[String] = Set.empty + cell.getOwner().getCells().filter(_.getPort().isInstanceOf[sync.tt.OutputPort]).foreach(ocell => { + setPortValue += s"${ocell.getPort().getName()} ${ocell.getValue()}" + }) + setFalse += setPortValue + } + }) + numberTrue = setTrue.size + numberFalse = setFalse.size + cellis = newCells + portTT = ttip + break + }) + } + + //println("Used Port: " + portTT) + var portBDD: sync.bddg.InputPort = null + val oppo: PlayerSync = +portTT getRelatedClassFromName ("InputPort") + if (oppo != null) { + portBDD = oppo.asInstanceOf[sync.bddg.InputPort] + } + + val newPorts = finishPorts + portTT + val subtree = new sync.bddg.Subtree(null, null, portBDD, Set.empty, Set.empty, bdd) + bdd.addTrees(subtree) + portBDD.addSubtrees(subtree) + + val rowsOne = cellis.filter(_.getValue()).map(_.getOwner()) + val rowsZero = cellis.filter(!_.getValue()).map(_.getOwner()) + + var treeZero: sync.bddg.Tree = null + var treeOne: sync.bddg.Tree = null + if (numberFalse == 1) { + //create leaf from rows + treeZero = createLeafFromRows(bdd, rowsZero) + } else { + //create new subtree from rows + treeZero = createOutputLookSubtree(bdd, truthTable, rowsZero, newPorts) + } + if (numberTrue == 1) { + //create leaf from rows + treeOne = createLeafFromRows(bdd, rowsOne) + } else { + //create new subtree from rows + treeOne = createOutputLookSubtree(bdd, truthTable, rowsOne, newPorts) + } + + treeOne.addOwnerSubtreeForOne(subtree) + subtree.setTreeForOne(treeOne) + //connect to rows + connectTargetElementWithSourceElementes(treeOne, rowsOne.asInstanceOf[Set[PlayerSync]]) + + treeZero.addOwnerSubtreeForZero(subtree) + subtree.setTreeForZero(treeZero) + //connect to rows + connectTargetElementWithSourceElementes(treeZero, rowsZero.asInstanceOf[Set[PlayerSync]]) + + subtree + } + + def createLeafFromRows(bdd: sync.bddg.BDD, rows: Set[sync.tt.Row]): sync.bddg.Leaf = { + val mapping = rows.head.getCells().filter(c => c.getPort().isInstanceOf[sync.tt.OutputPort]).map(c => s"${c.getPort().getName()} ${c.getValue()}") + + val mapped = leafNodes.get(mapping) + var leaf: sync.bddg.Leaf = null + + if (!mapped.isEmpty) { + leaf = mapped.get + } else { + leaf = new sync.bddg.Leaf(Set.empty, Set.empty, Set.empty, bdd) + bdd.addTrees(leaf) + leafNodes += (mapping -> leaf) + + rows.head.getCells().filter(c => c.getPort().isInstanceOf[sync.tt.OutputPort]).foreach(cellout => { + //Create new assignment and search all cells for it + val assignment = new sync.bddg.Assignment(cellout.getValue(), null, null) + assignment.setOwner(leaf) + leaf.addAssignments(assignment) + + val ttport: PlayerSync = +(cellout.getPort()) getRelatedClassFromName ("OutputPort") + if (ttport != null) { + val o_port = ttport.asInstanceOf[sync.bddg.OutputPort] + o_port.addAssignments(assignment) + assignment.setPort(o_port) + } + }) + } + + //connect assignments to cells + leaf.getAssignments().foreach(a => { + val cellList = rows.map(_.getCells().filter(_.getPort().getName() == a.getPort().getName()).head) + + //connect them + connectTargetElementWithSourceElementes(a, cellList.asInstanceOf[Set[PlayerSync]]) + }) + leaf + } + + class OutputPortConstruct() extends IIntegrator { + + def integrate(comp: PlayerSync): PlayerSync = { + //Step 1: Get construction values + val name: String = +this getName () + + //Step 2: Create the object in the other models + val o_port = new sync.bddg.OutputPort(Set.empty, name, null) + + //Step 3: Make Connection + connectTargetElementWithSourceElemente(o_port, comp) + + o_port + } + } + + class InputPortConstruct() extends IIntegrator { + + def integrate(comp: PlayerSync): PlayerSync = { + //Step 1: Get construction values + val name: String = +this getName () + + //Step 2: Create the object in the other models + val i_port = new sync.bddg.InputPort(Set.empty, name, null) + + //Step 3: Make Connection + connectTargetElementWithSourceElemente(i_port, comp) + + i_port + } + } + + class TruthTableConstruct() extends IIntegrator { + + def integrate(comp: PlayerSync): PlayerSync = { + //Step 1: Get construction values + val name: String = +this getName () + val ports: Set[sync.tt.Port] = +this getPorts () + + //Step 2: Create the object in the other models + val bdd = new sync.bddg.BDD(name, Set.empty, null, Set.empty) + + //Step 3: Make Connection + connectTargetElementWithSourceElemente(bdd, comp) + + ports.foreach(p => { + val integrator = getNextIntegratorForClassName(p) + val manager: IRoleManager = +p getManager () + if (manager != null) { + manager play integrator + val obj = integrator.integrate(p).asInstanceOf[sync.bddg.Port] + integrator.remove() + obj.setOwner(bdd) + bdd.addPorts(obj) + } + }) + + createdBdds += bdd + + bdd + } + } + +} \ No newline at end of file diff --git a/solutions/RSync/src/main/scala/ttc2019/worksync/BdtSyncIntegration.scala b/solutions/RSync/src/main/scala/ttc2019/worksync/BdtSyncIntegration.scala index 8a5afd3827142a43c44dde28466b9b2a73d981b7..706de0172a8a45c819474ee397e10a7b9d1eada4 100644 --- a/solutions/RSync/src/main/scala/ttc2019/worksync/BdtSyncIntegration.scala +++ b/solutions/RSync/src/main/scala/ttc2019/worksync/BdtSyncIntegration.scala @@ -14,12 +14,6 @@ object BdtSyncIntegration extends IIntegrationCompartment { private var createdBdds: Set[sync.bdd.BDD] = Set.empty - def printManager(): Unit = { - ModelElementLists.getElementsFromType("sync.bdd.Leaf").asInstanceOf[List[sync.bdd.Leaf]].foreach(obj => { - +obj printAllManager () - }) - } - def getRelationalIntegratorsForClassName(classname: Object): IIntegrator = { return null } @@ -39,7 +33,6 @@ object BdtSyncIntegration extends IIntegrationCompartment { } def finalEditFunction(): Unit = { - //println("FINISH FUNCTION") var ttNode: sync.tt.TruthTable = null createdBdds.foreach(bddNode => { @@ -49,15 +42,11 @@ object BdtSyncIntegration extends IIntegrationCompartment { } val rows = ttNode.getRows() - //val tree = createInputLookSubtree(ttNode, rows, Set.empty) val tree = createOutputLookSubtree(bddNode, ttNode, rows, Set.empty) tree.setOwnerBDD(bddNode) bddNode.setTree(tree) connectTargetElementWithSourceElementes(tree, rows.asInstanceOf[Set[PlayerSync]]) }) - - //printManager() - //println("END FINISH FUNCTION") } def createOutputLookSubtree(bdd: sync.bdd.BDD, truthTable: sync.tt.TruthTable, rows: Set[sync.tt.Row], finishPorts: Set[sync.tt.Port]): sync.bdd.Tree = { @@ -114,7 +103,6 @@ object BdtSyncIntegration extends IIntegrationCompartment { val rowsOne = cellis.filter(_.getValue()).map(_.getOwner()) val rowsZero = cellis.filter(!_.getValue()).map(_.getOwner()) - //println("Rows (1) " + rowsOne.size + " (2) " + rowsZero.size) var treeZero: sync.bdd.Tree = null var treeOne: sync.bdd.Tree = null @@ -146,70 +134,6 @@ object BdtSyncIntegration extends IIntegrationCompartment { subtree } - def createInputLookSubtree(bdd: sync.bdd.BDD, truthTable: sync.tt.TruthTable, rows: Set[sync.tt.Row], finishPorts: Set[sync.tt.Port]): sync.bdd.Tree = { - var max = 0 - var portTT: sync.tt.Port = null - var cellis: Set[sync.tt.Cell] = Set.empty - - truthTable.getPorts().filter(p => p.isInstanceOf[sync.tt.InputPort] && !finishPorts.contains(p)).foreach(ttip => { - val newCells = ttip.getCells().filter(c => rows.contains(c.getOwner())) - if (newCells.size > max) { - max = newCells.size - portTT = ttip - cellis = newCells - } else if (newCells.size == max) { - val p1 = newCells.count(_.getValue()) - val p2 = newCells.count(!_.getValue()) - if (Math.abs(max / 2 - p1) > Math.abs(max / 2 - p2)) { - portTT = ttip - cellis = newCells - } - } - }) - //println("Used Port: " + portTT) - var portBDD: sync.bdd.InputPort = null - val oppo: PlayerSync = +portTT getRelatedClassFromName ("InputPort") - if (oppo != null) { - portBDD = oppo.asInstanceOf[sync.bdd.InputPort] - } - - val newPorts = finishPorts + portTT - val subtree = new sync.bdd.Subtree(null, null, portBDD, null, null, null) - portBDD.addSubtrees(subtree) - - val rowsOne = cellis.filter(_.getValue()).map(_.getOwner()) - val rowsZero = cellis.filter(!_.getValue()).map(_.getOwner()) - //println("Rows (1) " + rowsOne.size + " (2) " + rowsZero.size) - - var treeZero: sync.bdd.Tree = null - var treeOne: sync.bdd.Tree = null - if (rowsZero.size == 1) { - //create leaf from rows - treeZero = createLeafFromRows(rowsZero) - } else { - treeZero = createInputLookSubtree(bdd, truthTable, rowsZero, newPorts) - } - if (rowsOne.size == 1) { - //create leaf from rows - treeOne = createLeafFromRows(rowsOne) - } else { - treeOne = createInputLookSubtree(bdd, truthTable, rowsOne, newPorts) - } - //TODO: Assignment what to do for more than one output cell - - treeOne.setOwnerSubtreeForOne(subtree) - subtree.setTreeForOne(treeOne) - //connect to rows - connectTargetElementWithSourceElementes(treeOne, rowsOne.asInstanceOf[Set[PlayerSync]]) - - treeZero.setOwnerSubtreeForZero(subtree) - subtree.setTreeForZero(treeZero) - //connect to rows - connectTargetElementWithSourceElementes(treeZero, rowsZero.asInstanceOf[Set[PlayerSync]]) - - subtree - } - def createLeafFromRows(rows: Set[sync.tt.Row]): sync.bdd.Leaf = { val leaf = new sync.bdd.Leaf(Set.empty, null, null, null) diff --git a/solutions/RSync/src/main/scala/ttc2019/worksync/BdtSyncIntegrationWithoutOrder.scala b/solutions/RSync/src/main/scala/ttc2019/worksync/BdtSyncIntegrationWithoutOrder.scala new file mode 100644 index 0000000000000000000000000000000000000000..483194acb05d0f207e55aad1d655df64bab4b6fe --- /dev/null +++ b/solutions/RSync/src/main/scala/ttc2019/worksync/BdtSyncIntegrationWithoutOrder.scala @@ -0,0 +1,220 @@ +package ttc2019.worksync + +import org.rosi_project.model_management.core.PlayerSync +import org.rosi_project.model_management.core.SynchronizationCompartment +import org.rosi_project.model_management.sync.IIntegrationCompartment +import org.rosi_project.model_management.sync.roles.IIntegrator +import org.rosi_project.model_management.sync.roles.IRoleManager + +import org.rosi_project.model_management.sync.helper.IntegrationContainer +import scala.collection.mutable.ListBuffer +import org.rosi_project.model_management.core.ModelElementLists +import util.control.Breaks._ + +object BdtSyncIntegrationWithoutOrder extends IIntegrationCompartment { + + private var createdBdds: Set[sync.bdd.BDD] = Set.empty + + def getRelationalIntegratorsForClassName(classname: Object): IIntegrator = { + return null + } + + def getIntegratorForClassName(classname: Object): IIntegrator = { + if (classname.isInstanceOf[sync.tt.TruthTable]) + return new TruthTableConstruct() + return null + } + + def getNextIntegratorForClassName(classname: Object): IIntegrator = { + if (classname.isInstanceOf[sync.tt.OutputPort]) + return new OutputPortConstruct() + if (classname.isInstanceOf[sync.tt.InputPort]) + return new InputPortConstruct() + return null + } + + def finalEditFunction(): Unit = { + var ttNode: sync.tt.TruthTable = null + + createdBdds.foreach(bddNode => { + val oppBDD: PlayerSync = +bddNode getRelatedClassFromName ("TruthTable") + if (oppBDD != null) { + ttNode = oppBDD.asInstanceOf[sync.tt.TruthTable] + } + val rows = ttNode.getRows() + + val tree = createOutputLookSubtree(bddNode, ttNode, rows, Set.empty) + tree.setOwnerBDD(bddNode) + bddNode.setTree(tree) + connectTargetElementWithSourceElementes(tree, rows.asInstanceOf[Set[PlayerSync]]) + }) + } + + def createOutputLookSubtree(bdd: sync.bdd.BDD, truthTable: sync.tt.TruthTable, rows: Set[sync.tt.Row], finishPorts: Set[sync.tt.Port]): sync.bdd.Tree = { + var numberTrue = -1 + var numberFalse = -1 + var portTT: sync.tt.Port = null + var cellis: Set[sync.tt.Cell] = Set.empty + + breakable { + truthTable.getPorts().filter(p => p.isInstanceOf[sync.tt.InputPort] && !finishPorts.contains(p)).foreach(ttip => { + val newCells = ttip.getCells().filter(c => rows.contains(c.getOwner())) + var setTrue: Set[Set[String]] = Set.empty + var setFalse: Set[Set[String]] = Set.empty + newCells.foreach(cell => { + if (cell.getValue()) { + var setPortValue: Set[String] = Set.empty + cell.getOwner().getCells().filter(_.getPort().isInstanceOf[sync.tt.OutputPort]).foreach(ocell => { + setPortValue += s"${ocell.getPort().getName()} ${ocell.getValue()}" + }) + setTrue += setPortValue + } else { + var setPortValue: Set[String] = Set.empty + cell.getOwner().getCells().filter(_.getPort().isInstanceOf[sync.tt.OutputPort]).foreach(ocell => { + setPortValue += s"${ocell.getPort().getName()} ${ocell.getValue()}" + }) + setFalse += setPortValue + } + }) + numberTrue = setTrue.size + numberFalse = setFalse.size + cellis = newCells + portTT = ttip + println("in row") + break + }) + } + + println("Used Port: " + portTT) + var portBDD: sync.bdd.InputPort = null + val oppo: PlayerSync = +portTT getRelatedClassFromName ("InputPort") + if (oppo != null) { + portBDD = oppo.asInstanceOf[sync.bdd.InputPort] + } + + val newPorts = finishPorts + portTT + val subtree = new sync.bdd.Subtree(null, null, portBDD, null, null, null) + portBDD.addSubtrees(subtree) + + val rowsOne = cellis.filter(_.getValue()).map(_.getOwner()) + val rowsZero = cellis.filter(!_.getValue()).map(_.getOwner()) + //println("Rows (1) " + rowsOne.size + " (2) " + rowsZero.size) + + var treeZero: sync.bdd.Tree = null + var treeOne: sync.bdd.Tree = null + if (numberFalse == 1) { + //create leaf from rows + treeZero = createLeafFromRows(rowsZero) + } else { + //create new subtree from rows + treeZero = createOutputLookSubtree(bdd, truthTable, rowsZero, newPorts) + } + if (numberTrue == 1) { + //create leaf from rows + treeOne = createLeafFromRows(rowsOne) + } else { + //create new subtree from rows + treeOne = createOutputLookSubtree(bdd, truthTable, rowsOne, newPorts) + } + + treeOne.setOwnerSubtreeForOne(subtree) + subtree.setTreeForOne(treeOne) + //connect to rows + connectTargetElementWithSourceElementes(treeOne, rowsOne.asInstanceOf[Set[PlayerSync]]) + + treeZero.setOwnerSubtreeForZero(subtree) + subtree.setTreeForZero(treeZero) + //connect to rows + connectTargetElementWithSourceElementes(treeZero, rowsZero.asInstanceOf[Set[PlayerSync]]) + + subtree + } + + def createLeafFromRows(rows: Set[sync.tt.Row]): sync.bdd.Leaf = { + val leaf = new sync.bdd.Leaf(Set.empty, null, null, null) + + rows.head.getCells().filter(c => c.getPort().isInstanceOf[sync.tt.OutputPort]).foreach(cellout => { + + //Create new assignment and search all cells for it + val assignment = new sync.bdd.Assignment(cellout.getValue(), null, null) + val cellList = rows.map(_.getCells().filter(_.getPort() == cellout.getPort()).head) + assignment.setOwner(leaf) + leaf.addAssignments(assignment) + + val ttport: PlayerSync = +(cellout.getPort()) getRelatedClassFromName ("OutputPort") + if (ttport != null) { + val o_port = ttport.asInstanceOf[sync.bdd.OutputPort] + o_port.addAssignments(assignment) + assignment.setPort(o_port) + } + + //connect them + connectTargetElementWithSourceElementes(assignment, cellList.asInstanceOf[Set[PlayerSync]]) + }) + leaf + } + + class OutputPortConstruct() extends IIntegrator { + + def integrate(comp: PlayerSync): PlayerSync = { + //Step 1: Get construction values + val name: String = +this getName () + + //Step 2: Create the object in the other models + val o_port = new sync.bdd.OutputPort(Set.empty, name, null) + + //Step 3: Make Connection + connectTargetElementWithSourceElemente(o_port, comp) + + o_port + } + } + + class InputPortConstruct() extends IIntegrator { + + def integrate(comp: PlayerSync): PlayerSync = { + //Step 1: Get construction values + val name: String = +this getName () + + //Step 2: Create the object in the other models + val i_port = new sync.bdd.InputPort(Set.empty, name, null) + + //Step 3: Make Connection + connectTargetElementWithSourceElemente(i_port, comp) + + i_port + } + } + + class TruthTableConstruct() extends IIntegrator { + + def integrate(comp: PlayerSync): PlayerSync = { + //Step 1: Get construction values + val name: String = +this getName () + val ports: Set[sync.tt.Port] = +this getPorts () + + //Step 2: Create the object in the other models + val bdt = new sync.bdd.BDD(name, null, Set.empty) + + //Step 3: Make Connection + connectTargetElementWithSourceElemente(bdt, comp) + + ports.foreach(p => { + val integrator = getNextIntegratorForClassName(p) + val manager: IRoleManager = +p getManager () + if (manager != null) { + manager play integrator + val obj = integrator.integrate(p).asInstanceOf[sync.bdd.Port] + integrator.remove() + obj.setOwner(bdt) + bdt.addPorts(obj) + } + }) + + createdBdds += bdt + + bdt + } + } + +} \ No newline at end of file