From 368dccefec99a1ae1ebb0e8a54f885be4489e2af Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Tue, 2 Nov 2021 21:08:00 +0100 Subject: [PATCH] update simulation GUI (gauge process) --- Editor.py | 2 +- SimulationGUI.py | 39 ++++++++++----------------------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/Editor.py b/Editor.py index f621f9d4..1dc25a0a 100644 --- a/Editor.py +++ b/Editor.py @@ -1957,7 +1957,7 @@ def setChoices(self,block): self._choices = collections.OrderedDict([(_('New peek'),self.OnPeek), (_('New all peek'),self.OnAllPeek), (_('New poke'),self.OnPoke), (_('New hold in state'),self.OnInsertHoldInState), (_('New passivate in state'),self.OnInsertPassivateInState), (_('New passivate state'),self.OnInsertPassivateState), (_('New Phase test'),self.OnInsertPhaseIs), (_('New debugger stdout'),self.OnInsertDebug), - (_('Get state'),self.OnInsertGetState), (_('Get sigma'),self.OnInsertGetSigma), (_('Get message value'),self.OnInsertGetMsgValue)]) + (_('Get state'),self.OnInsertGetState), (_('Get sigma'),self.OnInsertGetSigma), (_('Get message value'),self.OnInsertGetMsgValue), (_('Get message time'),self.OnInsertGetMsgTime)]) else: if 'PyPDEVS' in builtins.__dict__['DEFAULT_DEVS_DIRNAME']: self._choices = collections.OrderedDict([(_("New add sub model"),self.OnAddModel),(_("New remove sub model"),self.OnRemoveModel),(_("New port connection"),self.OnDisConnectPorts),(_("New port connection"),self.OnConnectPorts),(_('New debugger stdout'),self.OnInsertDebug)]) diff --git a/SimulationGUI.py b/SimulationGUI.py index 466c15c2..1406a2af 100644 --- a/SimulationGUI.py +++ b/SimulationGUI.py @@ -490,7 +490,7 @@ def OnOk(self, event): if self.thread.end_flag: self.OnTimer(event) else: - self.timer.Start(100) + self.timer.Start() ### timer for real time if self.real_time_flag: @@ -536,24 +536,6 @@ def OnStop(self, event): if self.thread: self.thread.terminate(False) - #import signal - #import platform - - # get the current PID for safe terminate server if needed: - #PID = os.getpid() - # if platform.system() != 'Windows': - # PGID = os.getgid(PID) - - # if platform.system() != 'Windows': - # os.killpg(PGID, signal.SIGKILL) - # else: - # os.kill(PID, signal.SIGTERM) - - #main_thread = threading.currentThread() - #for t in threading.enumerate(): - # if t is not main_thread: - # pass - self.timer.Stop() wx.Bell() @@ -594,10 +576,9 @@ def OnTimer(self, event): if self.ntl: self._gauge.Pulse() else: - if not isinstance(self.thread.model.timeLast, tuple): - timeLast = self.thread.model.timeLast - else: - timeLast = self.thread.model.timeLast[0] + timeLast = self.thread.model.timeLast + if isinstance(self.thread.model.timeLast, tuple): + timeLast = timeLast[0] self.count = (timeLast/self.thread.model.FINAL_TIME)*100 @@ -630,20 +611,21 @@ def OnTimer(self, event): ### stop the timer self.timer.Stop() - ### if the simulation is suspended + ### if the simulation is not suspended elif not self.thread.thread_suspend: ### udpate the status bar - self.statusbar.SetBackgroundColour('GREY') - printOnStatusBar(self.statusbar, {0:_("Processing..."), 1:self.GetClock()}) + if self.statusbar.GetBackgroundColour() != 'GREY': + self.statusbar.SetBackgroundColour('GREY') + wx.CallAfter(printOnStatusBar,self.statusbar, {0:_("Processing..."), 1:self.GetClock()}) ### is no time limit, add some information in status bar if not self.ntl: if self.statusbar.GetFieldsCount() > 2: - printOnStatusBar(self.statusbar, {2:str(self.count)[:4]+"%"}) + wx.CallAfter(printOnStatusBar,self.statusbar, {2:str(self.count)[:4]+"%"}) #wx.Yield() - wx.YieldIfNeeded() + #wx.YieldIfNeeded() def GetClock(self): if self.real_time_flag: @@ -836,7 +818,6 @@ def __set_properties(self): icon = wx.EmptyIcon() if wx.VERSION_STRING < '4.0' else wx.Icon() icon.CopyFromBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16, "simulation.png"), wx.BITMAP_TYPE_ANY)) self.SetIcon(icon) - self.Center() def SetMaster(self, master):