LPCManager.py
changeset 37 6e36ecf3f622
parent 35 cb9da964a178
child 39 38a01052693f
equal deleted inserted replaced
35:cb9da964a178 37:6e36ecf3f622
   693             self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus")]
   693             self.CTNChildrenTypes += [("LPCBus", LPCBus, "LPC bus")]
   694         self.CTNType = "LPC"
   694         self.CTNType = "LPC"
   695         
   695         
   696         self.OnlineMode = "OFF"
   696         self.OnlineMode = "OFF"
   697         self.LPCConnector = None
   697         self.LPCConnector = None
       
   698         self.ConnectorPath = None
   698         
   699         
   699         self.CurrentMode = None
   700         self.CurrentMode = None
   700         self.previous_mode = None
   701         self.previous_mode = None
   701         
   702         
   702         self.SimulationBuildPath = None
   703         self.SimulationBuildPath = None
   756     def SetOnlineMode(self, mode, path=None):
   757     def SetOnlineMode(self, mode, path=None):
   757         if self.OnlineMode != mode.upper():
   758         if self.OnlineMode != mode.upper():
   758             self.OnlineMode = mode.upper()
   759             self.OnlineMode = mode.upper()
   759             
   760             
   760             if self.OnlineMode != "OFF":
   761             if self.OnlineMode != "OFF":
       
   762                 self.ConnectorPath = path
   761                 uri = "LPC://%s/%s" % (self.OnlineMode,path)
   763                 uri = "LPC://%s/%s" % (self.OnlineMode,path)
   762                 try:
   764                 try:
   763                     self.LPCConnector = connectors.ConnectorFactory(uri, self)
   765                     self.LPCConnector = connectors.ConnectorFactory(uri, self)
   764                 except Exception, msg:
   766                 except Exception, msg:
   765                     self.logger.write_error(_("Exception while connecting %s!\n")%uri)
   767                     self.logger.write_error(_("Exception while connecting %s!\n")%uri)
   770                     # Oups.
   772                     # Oups.
   771                     self.logger.write_error(_("Connection failed to %s!\n")%uri)
   773                     self.logger.write_error(_("Connection failed to %s!\n")%uri)
   772                 
   774                 
   773             else:
   775             else:
   774                 self.LPCConnector = None
   776                 self.LPCConnector = None
       
   777                 self.ConnectorPath = None
   775             
   778             
   776             self.ApplyOnlineMode()
   779             self.ApplyOnlineMode()
   777 
   780 
   778     def ApplyOnlineMode(self):
   781     def ApplyOnlineMode(self):
   779         if self.CurrentMode != SIMULATION_MODE:
   782         if self.CurrentMode != SIMULATION_MODE:
   960                 self.ShowMethod(*args)
   963                 self.ShowMethod(*args)
   961             self.previous_plcstate = status
   964             self.previous_plcstate = status
   962             self.previous_mode = self.CurrentMode
   965             self.previous_mode = self.CurrentMode
   963             if self.AppFrame is not None:
   966             if self.AppFrame is not None:
   964                 self.AppFrame.RefreshStatusToolBar()
   967                 self.AppFrame.RefreshStatusToolBar()
       
   968                 connection_text = _("Connected to: ")
       
   969                 status_text = ""
       
   970                 if simulating:
       
   971                     connection_text += _("Simulation")
       
   972                     status_text += _("ON")
       
   973                 if status == "Disconnected":
       
   974                     if not simulating:
       
   975                         self.AppFrame.ConnectionStatusBar.SetStatusText(_(status), 1)
       
   976                         self.AppFrame.ConnectionStatusBar.SetStatusText('', 2)
       
   977                     else:
       
   978                         self.AppFrame.ConnectionStatusBar.SetStatusText(connection_text, 1)
       
   979                         self.AppFrame.ConnectionStatusBar.SetStatusText(status_text, 2)
       
   980                 else:
       
   981                     if simulating:
       
   982                         connection_text += " (%s)"
       
   983                         status_text += " (%s)"
       
   984                     else:
       
   985                         connection_text += "%s"
       
   986                         status_text += "%s"
       
   987                     self.AppFrame.ConnectionStatusBar.SetStatusText(connection_text % self.ConnectorPath, 1)
       
   988                     self.AppFrame.ConnectionStatusBar.SetStatusText(status_text % _(status), 2)
   965             return True
   989             return True
   966         return False
   990         return False
   967 
   991 
   968     def Generate_plc_declare_locations(self):
   992     def Generate_plc_declare_locations(self):
   969         """
   993         """
  1110             #or list of strings
  1134             #or list of strings
  1111             elif type(CTNLDFLAGS)==type(list()):
  1135             elif type(CTNLDFLAGS)==type(list()):
  1112                 self.LDFLAGS=CTNLDFLAGS[:]
  1136                 self.LDFLAGS=CTNLDFLAGS[:]
  1113         else:
  1137         else:
  1114             self.LDFLAGS=[]
  1138             self.LDFLAGS=[]
       
  1139         
       
  1140         # Header file for extensions
       
  1141         open(os.path.join(buildpath,"beremiz.h"), "w").write(targets.GetHeader())
  1115         
  1142         
  1116         # Template based part of C code generation
  1143         # Template based part of C code generation
  1117         # files are stacked at the beginning, as files of confnode tree root
  1144         # files are stacked at the beginning, as files of confnode tree root
  1118         for generator, filename, name in [
  1145         for generator, filename, name in [
  1119            # debugger code
  1146            # debugger code
  1891         
  1918         
  1892         def Show(self):
  1919         def Show(self):
  1893             global frame
  1920             global frame
  1894             if frame is not None:
  1921             if frame is not None:
  1895                 self.CTR.SetAppFrame(frame, frame.Log)
  1922                 self.CTR.SetAppFrame(frame, frame.Log)
       
  1923                 self.CTR.UpdateMethodsFromPLCStatus()
  1896                 frame.Show()
  1924                 frame.Show()
  1897                 frame.Raise()
  1925                 frame.Raise()
  1898                 self.restore_last_state = True
  1926                 self.restore_last_state = True
  1899             self.RestartTimer()
  1927             self.RestartTimer()
  1900         
  1928