Beremiz.py
changeset 451 73b3913b6d9c
parent 446 1edde533db19
child 456 dbcf4a13926d
equal deleted inserted replaced
450:18583d13f0fa 451:73b3913b6d9c
   245             dc.DrawBitmap(self._bitmap, 0, 0, True)
   245             dc.DrawBitmap(self._bitmap, 0, 0, True)
   246 
   246 
   247                         
   247                         
   248 class LogPseudoFile:
   248 class LogPseudoFile:
   249     """ Base class for file like objects to facilitate StdOut for the Shell."""
   249     """ Base class for file like objects to facilitate StdOut for the Shell."""
   250     def __init__(self, output):
   250     def __init__(self, output, risecall):
   251         self.red_white = wx.TextAttr("RED", "WHITE")
   251         self.red_white = wx.TextAttr("RED", "WHITE")
   252         self.red_yellow = wx.TextAttr("RED", "YELLOW")
   252         self.red_yellow = wx.TextAttr("RED", "YELLOW")
   253         self.black_white = wx.TextAttr("BLACK", "WHITE")
   253         self.black_white = wx.TextAttr("BLACK", "WHITE")
   254         self.default_style = None
   254         self.default_style = None
   255         self.output = output
   255         self.output = output
       
   256         self.risecall = risecall
   256         # to prevent rapid fire on rising log panel
   257         # to prevent rapid fire on rising log panel
   257         self.rising_timer = 0
   258         self.rising_timer = 0
   258 
   259 
   259     def write(self, s, style = None):
   260     def write(self, s, style = None):
   260         if style is None : style=self.black_white
   261         if style is None : style=self.black_white
   266         self.output.ScrollLines(s.count('\n')+1)
   267         self.output.ScrollLines(s.count('\n')+1)
   267         self.output.ShowPosition(self.output.GetLastPosition())
   268         self.output.ShowPosition(self.output.GetLastPosition())
   268         self.output.Thaw()
   269         self.output.Thaw()
   269         newtime = time.time()
   270         newtime = time.time()
   270         if newtime - self.rising_timer > 1:
   271         if newtime - self.rising_timer > 1:
   271             self.output.Rise()
   272             self.risecall()
   272         self.rising_timer = newtime 
   273         self.rising_timer = newtime 
   273 
   274 
   274     def write_warning(self, s):
   275     def write_warning(self, s):
   275         self.write(s,self.red_white)
   276         self.write(s,self.red_white)
   276 
   277 
   381         self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True)
   382         self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True)
   382         
   383         
   383         self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='',
   384         self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='',
   384                   name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0),
   385                   name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0),
   385                   size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2)
   386                   size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2)
   386         self.LogConsole.Rise = self.RiseLogConsole 
   387         self.LogConsole.SetRise(self.RiseLogConsole)
   387         self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick)
   388         self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick)
   388         self.BottomNoteBook.AddPage(self.LogConsole, _("Log Console"))
   389         self.BottomNoteBook.AddPage(self.LogConsole, _("Log Console"))
   389         
   390         
   390         self._init_beremiz_sizers()
   391         self._init_beremiz_sizers()
   391 
   392 
   392     def __init__(self, parent, projectOpen=None, buildpath=None, plugin_root=None, debug=True):
   393     def __init__(self, parent, projectOpen=None, buildpath=None, plugin_root=None, debug=True):
   393         IDEFrame.__init__(self, parent, debug)
   394         IDEFrame.__init__(self, parent, debug)
   394         self.Config = wx.ConfigBase.Get()
   395         self.Config = wx.ConfigBase.Get()
   395         
   396         self.Log = LogPseudoFile(self.LogConsole,self.RiseLogConsole)
   396         self.Log = LogPseudoFile(self.LogConsole)
       
   397         
   397         
   398         self.local_runtime = None
   398         self.local_runtime = None
   399         self.runtime_port = None
   399         self.runtime_port = None
   400         self.local_runtime_tmpdir = None
   400         self.local_runtime_tmpdir = None
   401         
   401