LPCBeremiz.py
changeset 543 3dec6ff88620
parent 541 4d9ca788205e
child 547 5748d695beee
equal deleted inserted replaced
542:1b0f72deeb99 543:3dec6ff88620
   306                     i += 1
   306                     i += 1
   307                     group = next
   307                     group = next
   308             var_loc = loc[i:]
   308             var_loc = loc[i:]
   309             for variable in _GetModuleChildren(group):
   309             for variable in _GetModuleChildren(group):
   310                 if variable["location"] == var_loc:
   310                 if variable["location"] == var_loc:
   311                     if location["DIR"] != LOCATION_DIRS[variable["type"]]:
   311 #                    if location["DIR"] != LOCATION_DIRS[variable["type"]]:
   312                         raise Exception, "Direction conflict in variable definition"
   312 #                        raise Exception, "Direction conflict in variable definition"
   313                     if location["IEC_TYPE"] != variable["IEC_type"]:
   313 #                    if location["IEC_TYPE"] != variable["IEC_type"]:
   314                         raise Exception, "Type conflict in variable definition"
   314 #                        raise Exception, "Type conflict in variable definition"
   315                     if location["DIR"] == "Q":
   315                     if location["DIR"] == "Q":
   316                         if self.CheckLocationConflicts(location["LOC"]):
   316                         if self.CheckLocationConflicts(location["LOC"]):
   317                             raise Exception, "BYTE and BIT from the same BYTE can't be used together"
   317                             raise Exception, "BYTE and BIT from the same BYTE can't be used together"
   318                         self.AddUsedLocation(location["LOC"])
   318                         self.AddUsedLocation(location["LOC"])
   319                     vars.append({"location": location["NAME"],
   319                     vars.append({"location": location["NAME"],
   446     def SetOnlineMode(self, mode, path=None):
   446     def SetOnlineMode(self, mode, path=None):
   447         if self.OnlineMode != mode.upper():
   447         if self.OnlineMode != mode.upper():
   448             self.OnlineMode = mode.upper()
   448             self.OnlineMode = mode.upper()
   449             
   449             
   450             if self.OnlineMode != "OFF":
   450             if self.OnlineMode != "OFF":
   451                 uri = "LPC://%s" % path
   451                 uri = "LPC://%s/%s" % (self.OnlineMode,path)
   452                 try:
   452                 try:
   453                     self.LPCConnector = connectors.ConnectorFactory(uri, self)
   453                     self.LPCConnector = connectors.ConnectorFactory(uri, self)
   454                 except Exception, msg:
   454                 except Exception, msg:
   455                     self.logger.write_error(_("Exception while connecting %s!\n")%uri)
   455                     self.logger.write_error(_("Exception while connecting %s!\n")%uri)
   456                     self.logger.write_error(traceback.format_exc())
   456                     self.logger.write_error(traceback.format_exc())
   482                     status = _(self.previous_plcstate)
   482                     status = _(self.previous_plcstate)
   483                 else:
   483                 else:
   484                     status = ""
   484                     status = ""
   485                 self.logger.write(_("PLC is %s\n")%status)
   485                 self.logger.write(_("PLC is %s\n")%status)
   486                 
   486                 
   487                 if not self.StatusTimer.IsRunning():
   487                 if self.StatusTimer and not self.StatusTimer.IsRunning():
   488                     # Start the status Timer
   488                     # Start the status Timer
   489                     self.StatusTimer.Start(milliseconds=500, oneShot=False)
   489                     self.StatusTimer.Start(milliseconds=500, oneShot=False)
   490                 
   490                 
   491                 if self.previous_plcstate=="Started":
   491                 if self.previous_plcstate=="Started":
   492                     if self.DebugAvailable() and self.GetIECProgramsAndVariables():
   492                     if self.DebugAvailable() and self.GetIECProgramsAndVariables():
   493                         self.logger.write(_("Debug connect matching running PLC\n"))
   493                         self.logger.write(_("Debug connect matching running PLC\n"))
   494                         self._connect_debug()
   494                         self._connect_debug()
   495                     else:
   495                     else:
   496                         self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n"))
   496                         self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n"))
   497             
   497             
   498             elif self.StatusTimer.IsRunning():
   498             elif self.StatusTimer and self.StatusTimer.IsRunning():
   499                 self.StatusTimer.Stop()
   499                 self.StatusTimer.Stop()
   500             
   500             
   501             if self.CurrentMode == TRANSFER_MODE:
   501             if self.CurrentMode == TRANSFER_MODE:
   502                 
   502                 
   503                 if self.OnlineMode == "BOOTLOADER":
   503                 if self.OnlineMode == "BOOTLOADER":
   792         self.AbortTransferTimer.Stop()
   792         self.AbortTransferTimer.Stop()
   793         PluginsRoot._Transfer(self)
   793         PluginsRoot._Transfer(self)
   794         self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True)
   794         self.AbortTransferTimer.Start(milliseconds=5000, oneShot=True)
   795     
   795     
   796     def AbortTransfer(self, event):
   796     def AbortTransfer(self, event):
   797         self.logger.write(_("Transfer failed\n"))
   797         self.logger.write_warning(_("Timeout waiting PLC to recover\n"))
   798         
   798         
   799         self.CurrentMode = None
   799         self.CurrentMode = None
   800         self.AbortTransferTimer.Stop()
   800         self.AbortTransferTimer.Stop()
   801         self.AbortTransferTimer = None
   801         self.AbortTransferTimer = None
   802         event.Skip()
   802         event.Skip()
  1414                                        "Show": ([], 0),
  1414                                        "Show": ([], 0),
  1415                                        "Refresh": ([], 0),
  1415                                        "Refresh": ([], 0),
  1416                                        "Close": ([], 0),
  1416                                        "Close": ([], 0),
  1417                                        "Compile": ([], 0),
  1417                                        "Compile": ([], 0),
  1418                                        "SetProjectProperties": ([str, str, str, str], 0),
  1418                                        "SetProjectProperties": ([str, str, str, str], 0),
  1419                                        "SetOnlineMode": ([int, str], 1),
  1419                                        "SetOnlineMode": ([str, str], 1),
  1420                                        "AddBus": ([int, str, str], 1),
  1420                                        "AddBus": ([int, str, str], 1),
  1421                                        "RenameBus": ([int, str], 0),
  1421                                        "RenameBus": ([int, str], 0),
  1422                                        "ChangeBusIECChannel": ([int, int], 0),
  1422                                        "ChangeBusIECChannel": ([int, int], 0),
  1423                                        "RemoveBus": ([int], 0),
  1423                                        "RemoveBus": ([int], 0),
  1424                                        "AddModule": ([location, int, str, str], 1), 
  1424                                        "AddModule": ([location, int, str, str], 1),