def GenerateRequests(self):
     generator = self.generators[self.sender()]
     data = generator.GetSettings()
     d = ParamsDialog(data, self,
                      generator.GetName() == "Tightly coupled",
                      generator.GetName() == "Tightly coupled")
     d.exec_()
     if d.result() == QDialog.Accepted:
         generator.UpdateSettings(d.data)
         #TODO: populate the table with new demands
         self.project.demands = generator.Generate(self.project.resources)
         self.ui.demands.clear()
         self.demands = {}
         for demand in self.project.demands:
             it = QTreeWidgetItem(
                 self.ui.demands,
                 QStringList([
                     demand.id,
                     str(demand.startTime),
                     str(demand.endTime),
                     self.tr("No"),
                     self.tr("No")
                 ]))
             cb = QComboBox()
             cb.addItems([self.tr("No"), self.tr("Yes")])
             self.ui.demands.setItemWidget(it, 3, cb)
             QObject.connect(cb, SIGNAL("currentIndexChanged(int)"),
                             it.emitDataChanged)
             it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled
                         | Qt.ItemIsSelectable)
             self.demands[it] = demand
 def Generate(self):
     d = FilesGenerator()
     for generator in self.parent().generators.values():
         d.ui.generators.addItem(generator.GetName())
     d.exec_()
     if not d.result():
         return
     resources = ResourceGraph()
     if not d.result():
         return
     if d.ui.topologies.currentIndex()==0:
         d1 = TreeDialog(1)
     elif d.ui.topologies.currentIndex()==1:
         d1 = TreeDialog(2)
     elif d.ui.topologies.currentIndex()==2:
         d1 = TreeDialog(3)
     d1.exec_()
     if not d1.result():
         return
     dict = d1.GetResult()
     if dict["type"]==1:
         resources.GenerateCommonStructure(dict)
     elif dict["type"]==2:
         resources.GenerateTree2(dict)
     elif dict["type"]==3:
         resources.GenerateTree3(dict)
     generator = self.parent().generators.values()[d.ui.generators.currentIndex()]
     data = generator.GetSettings()
     d2 = ParamsDialog(data, self)
     d2.setWindowTitle("Demand Params Lower Bound")
     d2.exec_()
     if d2.result() != QDialog.Accepted:
         return
     lower = d2.data
     d3 = ParamsDialog(data, self)
     d3.setWindowTitle("Demand Params Upper Bound")
     d3.exec_()
     if d3.result() != QDialog.Accepted:
         return
     upper = d3.data   
     count = int(d.ui.num.text())         
     for j in range(count):
         params = [v for v in lower]
         for i in range(len(params)):
             params[i][1] = lower[i][1] + (upper[i][1] - lower[i][1]) / count
         generator.UpdateSettings(params)
         project = Project()
         project.demands = generator.Generate(resources)
         project.resources = resources
         name = "Project" + str(j) + ".dcxml"
         project.Save(name)
         it = QTreeWidgetItem(self.ui.projects, [name])
         self.projects[it] = name
     self.changed = True
Exemple #3
0
 def Generate(self):
     d = FilesGenerator()
     for generator in self.parent().generators.values():
         d.ui.generators.addItem(generator.GetName())
     d.exec_()
     if not d.result():
         return
     resources = ResourceGraph()
     if not d.result():
         return
     if d.ui.topologies.currentIndex()==0:
         d1 = TreeDialog(1)
     elif d.ui.topologies.currentIndex()==1:
         d1 = TreeDialog(2)
     elif d.ui.topologies.currentIndex()==2:
         d1 = TreeDialog(3)
     d1.exec_()
     if not d1.result():
         return
     dict = d1.GetResult()
     if dict["type"]==1:
         resources.GenerateCommonStructure(dict)
     elif dict["type"]==2:
         resources.GenerateTree2(dict)
     elif dict["type"]==3:
         resources.GenerateTree3(dict)
     generator = self.parent().generators.values()[d.ui.generators.currentIndex()]
     data = generator.GetSettings()
     d2 = ParamsDialog(data, self)
     d2.setWindowTitle("Demand Params Lower Bound")
     d2.exec_()
     if d2.result() != QDialog.Accepted:
         return
     lower = d2.data
     d3 = ParamsDialog(data, self)
     d3.setWindowTitle("Demand Params Upper Bound")
     d3.exec_()
     if d3.result() != QDialog.Accepted:
         return
     upper = d3.data   
     count = int(d.ui.num.text())         
     for j in range(count):
         params = [v for v in lower]
         for i in range(len(params)):
             params[i][1] = lower[i][1] + (upper[i][1] - lower[i][1]) / count
         generator.UpdateSettings(params)
         project = Project()
         project.demands = generator.Generate(resources)
         project.resources = resources
         name = "Project" + str(j) + ".dcxml"
         project.Save(name)
         it = QTreeWidgetItem(self.ui.projects, [name])
         self.projects[it] = name
     self.changed = True
 def GenerateRequests(self):
     generator = self.generators[self.sender()]
     data = generator.GetSettings()
     d = ParamsDialog(data, self, generator.GetName()=="Tightly coupled", generator.GetName()=="Tightly coupled")
     d.exec_()
     if d.result() == QDialog.Accepted:
         generator.UpdateSettings(d.data)
         #TODO: populate the table with new demands
         self.project.demands = generator.Generate(self.project.resources)
         self.ui.demands.clear()
         self.demands = {}
         for demand in self.project.demands:
             it = QTreeWidgetItem(self.ui.demands, QStringList([demand.id, str(demand.startTime), str(demand.endTime), self.tr("No"), self.tr("No")]))
             cb = QComboBox()
             cb.addItems([self.tr("No"),self.tr("Yes")])
             self.ui.demands.setItemWidget(it,3,cb)
             QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged)
             it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
             self.demands[it] = demand