etherlab/CommonEtherCATFunction.py
changeset 2423 2c7b7ae24d57
parent 2421 a5994ee1f6a7
child 2434 07f48018b6f5
equal deleted inserted replaced
2422:45aa510d7a2a 2423:2c7b7ae24d57
    26         pass
    26         pass
    27     try:
    27     try:
    28         return int(value.replace("#", "0"), 16)
    28         return int(value.replace("#", "0"), 16)
    29 
    29 
    30     except Exception:
    30     except Exception:
    31         raise ValueError("Invalid value for HexDecValue \"%s\"" % value)
    31         raise ValueError(_("Invalid value for HexDecValue \"%s\"") % value)
    32 
    32 
    33 
    33 
    34 def ExtractName(names, default=None):
    34 def ExtractName(names, default=None):
    35     """
    35     """
    36      Extract "name" field from XML entries.
    36      Extract "name" field from XML entries.
  1576             # Command example : "ethercat xml -p 0"
  1576             # Command example : "ethercat xml -p 0"
  1577             _error, return_val = self.Controler.RemoteExec(SLAVE_XML % (self.Controler.GetSlavePos()), return_val=None)
  1577             _error, return_val = self.Controler.RemoteExec(SLAVE_XML % (self.Controler.GetSlavePos()), return_val=None)
  1578             number_of_lines = return_val.split("\n")
  1578             number_of_lines = return_val.split("\n")
  1579             if len(number_of_lines) <= 2:  # No slave connected to the master controller
  1579             if len(number_of_lines) <= 2:  # No slave connected to the master controller
  1580                 if not cyclic_flag:
  1580                 if not cyclic_flag:
  1581                     self.CreateErrorDialog('No connected slaves')
  1581                     self.CreateErrorDialog(_('No connected slaves'))
  1582                 return False
  1582                 return False
  1583 
  1583 
  1584             elif len(number_of_lines) > 2:
  1584             elif len(number_of_lines) > 2:
  1585                 return True
  1585                 return True
  1586         else:
  1586         else:
  1587             # The master controller is not connected to Beremiz host
  1587             # The master controller is not connected to Beremiz host
  1588             if not cyclic_flag:
  1588             if not cyclic_flag:
  1589                 self.CreateErrorDialog('PLC not connected!')
  1589                 self.CreateErrorDialog(_('PLC not connected!'))
  1590             return False
  1590             return False
  1591 
  1591 
  1592     def CreateErrorDialog(self, mention):
  1592     def CreateErrorDialog(self, mention):
  1593         """
  1593         """
  1594         Create a dialog to indicate error or warning.
  1594         Create a dialog to indicate error or warning.
  1595         @param mention : Error String
  1595         @param mention : Error String
  1596         """
  1596         """
  1597         app_frame = self.Controler.GetCTRoot().AppFrame
  1597         app_frame = self.Controler.GetCTRoot().AppFrame
  1598         dlg = wx.MessageDialog(app_frame, mention,
  1598         dlg = wx.MessageDialog(app_frame, mention,
  1599                                ' Warning...',
  1599                                _(' Warning...'),
  1600                                wx.OK | wx.ICON_INFORMATION)
  1600                                wx.OK | wx.ICON_INFORMATION)
  1601         dlg.ShowModal()
  1601         dlg.ShowModal()
  1602         dlg.Destroy()
  1602         dlg.Destroy()