Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions ConnectDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def __init__(self, parent, id, title, sn="Source", snL=[None,None], tn="Target",
L1 = [function(snL,i) for i in range(len(snL))]
L2 = [function(tnL,i) for i in range(len(tnL))]

L1.append("%s"%_('All'))
L2.append("%s"%_('All'))
L1.insert(0,"%s"%_('All'))
L2.insert(0,"%s"%_('All'))

self._label_source = wx.StaticText(self, wx.NewIdRef(), '%s'%self.sn)
self._label_target = wx.StaticText(self, wx.NewIdRef(), '%s'%self.tn)
self._combo_box_sn = wx.ComboBox(self, wx.NewIdRef(), choices = L1, style = wx.CB_DROPDOWN|wx.CB_READONLY|wx.CB_SORT)
self._combo_box_tn = wx.ComboBox(self, wx.NewIdRef(), choices = L2, style = wx.CB_DROPDOWN|wx.CB_READONLY|wx.CB_SORT)
self._combo_box_sn = wx.ComboBox(self, wx.NewIdRef(), choices = L1, style = wx.CB_DROPDOWN|wx.CB_READONLY)
self._combo_box_tn = wx.ComboBox(self, wx.NewIdRef(), choices = L2, style = wx.CB_DROPDOWN|wx.CB_READONLY)
self._button_disconnect = wx.Button(self, wx.NewIdRef(), _("Disconnect"))
self._button_connect = wx.Button(self, wx.NewIdRef(), _("Connect"))

Expand Down Expand Up @@ -97,6 +97,14 @@ def EvtComboBox1(self,event):
def EvtComboBox2(self,event):
self._result[1] = event.GetSelection()

def GetSelectedIndex(self):
return self._result

def GetLabelSource(self):
return self._label_source.GetLabel()

def GetLabelTarget(self):
return self._label_target.GetLabel()
### ------------------------------------------------------------
class TestApp(wx.App):
""" Testing application
Expand Down
32 changes: 22 additions & 10 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,9 +1873,9 @@ def OnConnectTo(self, event):
sourceName = source.label

# get target model from its name
for s in [m for m in self.diagram.shapes if not isinstance(m,ConnectionShape)]:
for s in [m for m in self.diagram.shapes if not isinstance(m, ConnectionShape)]:
if s.label == targetName:
target=s
target = s
break

### init source and taget node list
Expand All @@ -1898,8 +1898,10 @@ def OnDisconnect(self, event):
""" Disconnect selected ports from connectDialog.
"""

label_source, label_target = self.dlgConnection.GetLabelSource(), self.dlgConnection.GetLabelTarget()

# dialog results
sp,tp = self.dlgConnection._result
sp,tp = self.dlgConnection.GetSelectedIndex()

### local variables
snl = len(self.sourceNodeList)
Expand All @@ -1910,14 +1912,24 @@ def OnDisconnect(self, event):

### if selected options are not 'All'
if sp == tp == 0:
for connectionShapes in self.diagram.GetConnectionShapeGenerator():
if (connectionShapes.getInput()[1] == sp-1) and (connectionShapes.getOutput()[1] == tp-1):
self.RemoveShape(connectionShapes)
for cs in list(self.diagram.GetConnectionShapeGenerator()):
if (cs.getInput()[0].label == label_source and cs.getOutput()[0].label == label_target):
self.RemoveShape(cs)
modify_flag = True
elif sp == 0:
for cs in list(self.diagram.GetConnectionShapeGenerator()):
if (cs.getInput()[0].label == label_source and cs.getOutput()[0].label == label_target and cs.getOutput()[1] == tp-1):
self.RemoveShape(cs)
modify_flag = True
elif tp == 0:
for cs in list(self.diagram.GetConnectionShapeGenerator()):
if (cs.getInput()[0].label == label_source and cs.getInput()[1] == sp-1 and cs.getOutput()[0].label == label_target):
self.RemoveShape(cs)
modify_flag = True
else:
for connectionShapes in self.diagram.GetConnectionShapeGenerator():
if (connectionShapes.getInput()[1] == sp) and (connectionShapes.getOutput()[1] == tp):
self.RemoveShape(connectionShapes)
for cs in list(self.diagram.GetConnectionShapeGenerator()):
if (cs.getInput()[1] == sp-1) and (cs.getOutput()[1] == tp-1):
self.RemoveShape(cs)
modify_flag = True

### shape has been modified
Expand All @@ -1931,7 +1943,7 @@ def OnConnect(self, event):
"""

# dialog results
sp,tp = self.dlgConnection._result
sp,tp = self.dlgConnection.GetSelectedIndex()

### local variables
snl = len(self.sourceNodeList)
Expand Down
46 changes: 23 additions & 23 deletions SimulationNoGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,19 @@ def makeSimulation(master, T, simu_name="simu", is_remote=False, json_trace=True
CPUduration = 0.0
interactionManager = None
try:
if is_remote:
# Pusher service for Simulation --> User communication
simuPusher = SimuPusher(simu_name)
else:
simuPusher = PrintPusher(simu_name)

# Pusher service for Simulation --> User communication
simuPusher = SimuPusher(simu_name) if is_remote else PrintPusher(simu_name)

### Get live stream URL if exist :
for m in [a for a in master.getComponentSet() if hasattr(a, 'plotUrl')]:
if m.plotUrl != '':
json_report['output'].append({'label':m.name, 'plotUrl':m.plotUrl})
for m in [a for a in master.getComponentSet() if hasattr(a, 'plotUrl') and a.plotUrl != '']:
json_report['output'].append({'label':m.name, 'plotUrl':m.plotUrl})

### Get live stream URL if exist :
for m in [a for a in master.getComponentSet() if hasattr(a, 'pusherChannel')]:
m.pusherChannel = simu_name
json_report['output'].append({'label':m.name, 'pusherChannel':m.pusherChannel})

# Send to user
simuPusher.push('live_streams', {'live_streams': json_report['output']})

Expand All @@ -131,21 +130,22 @@ def makeSimulation(master, T, simu_name="simu", is_remote=False, json_trace=True
first_real_time = time.time()
progress = 0

while(thread.isAlive()):
new_real_time = time.time()
CPUduration = new_real_time - first_real_time
new_progress = 100.0*(thread.model.timeLast / T)
if new_progress - progress > 5:
progress = new_progress
simuPusher.push('progress', {'progress':progress})
if not json_trace:
Printer(CPUduration)

if interactionManager != None:
interactionManager.stop()
interactionManager.join()

simuPusher.push('progress', {'progress':100})
if not builtins.__dict__['NTL']:
while(thread.isAlive()):
new_real_time = time.time()
CPUduration = new_real_time - first_real_time
new_progress = 100.0*(thread.model.timeLast / T)
if new_progress - progress > 5:
progress = new_progress
simuPusher.push('progress', {'progress':progress})
if not json_trace:
Printer(CPUduration)

if interactionManager != None:
interactionManager.stop()
interactionManager.join()

simuPusher.push('progress', {'progress':100})

except:
json_report['summary'] += " *** EXCEPTION raised in simulation ***"
Expand Down