objdictgen/subindextable.py
changeset 747 4725d8f909ff
parent 741 b1a73ddc514b
child 748 18ed0f3b030a
equal deleted inserted replaced
746:3e16d9a121b8 747:4725d8f909ff
    92     {"minIndex" : 0x1C00, "maxIndex" : 0x1FFF, "name" : "Other Communication Parameters"},
    92     {"minIndex" : 0x1C00, "maxIndex" : 0x1FFF, "name" : "Other Communication Parameters"},
    93     {"minIndex" : 0x2000, "maxIndex" : 0x5FFF, "name" : "Manufacturer Specific"},
    93     {"minIndex" : 0x2000, "maxIndex" : 0x5FFF, "name" : "Manufacturer Specific"},
    94     {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"},
    94     {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"},
    95     {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}]
    95     {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}]
    96 
    96 
       
    97 IECTypeConversion = {
       
    98     "BOOLEAN": "BOOL",
       
    99     "INTEGER8": "SINT",
       
   100     "INTEGER16": "INT",
       
   101     "INTEGER32": "DINT",
       
   102     "UNSIGNED8": "USINT",
       
   103     "UNSIGNED16": "UINT",
       
   104     "UNSIGNED32": "UDINT",
       
   105     "REAL32": "REAL",
       
   106     "VISIBLE_STRING": "STRING",
       
   107     "OCTET_STRING": "STRING",
       
   108     "UNICODE_STRING": "WSTRING",
       
   109     "DOMAIN": "STRING",
       
   110     "INTEGER24": "DINT",
       
   111     "REAL64": "LREAL",
       
   112     "INTEGER40": "LINT",
       
   113     "INTEGER48": "LINT",
       
   114     "INTEGER56": "LINT",
       
   115     "INTEGER64": "LINT",
       
   116     "UNSIGNED24": "UDINT",
       
   117     "UNSIGNED40": "ULINT",
       
   118     "UNSIGNED48": "ULINT",
       
   119     "UNSIGNED56": "ULINT",
       
   120     "UNSIGNED64": "ULINT",
       
   121 }
    97 SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"}
   122 SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"}
    98 
   123 
    99 class SubindexTable(wx.grid.PyGridTableBase):
   124 class SubindexTable(wx.grid.PyGridTableBase):
   100     
   125     
   101     """
   126     """
   525                         typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
   550                         typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
   526                         if typeinfos:
   551                         if typeinfos:
   527                             bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
   552                             bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
   528                             var_name = "master_%04x_%02x" % (index, subindex)
   553                             var_name = "master_%04x_%02x" % (index, subindex)
   529                             size = typeinfos["size"]
   554                             size = typeinfos["size"]
   530                             data = wx.TextDataObject(str(("%s%s.%d.%d"%(SizeConversion[size], bus_id, index, subindex), "location", None, var_name, "")))
   555                             data = wx.TextDataObject(str(
       
   556                                 ("%s%s.%d.%d"%(SizeConversion[size], bus_id, index, subindex), 
       
   557                                  "location", 
       
   558                                  IECTypeConversion.get(typeinfos["name"]), 
       
   559                                  var_name, "")))
   531                             dragSource = wx.DropSource(self.SubindexGrid)
   560                             dragSource = wx.DropSource(self.SubindexGrid)
   532                             dragSource.SetData(data)
   561                             dragSource.SetData(data)
   533                             dragSource.DoDragDrop()
   562                             dragSource.DoDragDrop()
   534             elif col == 0:
   563             elif col == 0:
   535                 selected = self.IndexList.GetSelection()
   564                 selected = self.IndexList.GetSelection()
   543                         if subentry_infos["pdo"] and typeinfos:
   572                         if subentry_infos["pdo"] and typeinfos:
   544                             bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
   573                             bus_id = '.'.join(map(str, self.ParentWindow.GetBusId()))
   545                             node_id = self.ParentWindow.GetCurrentNodeId()
   574                             node_id = self.ParentWindow.GetCurrentNodeId()
   546                             var_name = "%s_%04x_%02x" % (self.Manager.GetSlaveName(node_id), index, subindex)
   575                             var_name = "%s_%04x_%02x" % (self.Manager.GetSlaveName(node_id), index, subindex)
   547                             size = typeinfos["size"]
   576                             size = typeinfos["size"]
   548                             data = wx.TextDataObject(str(("%s%s.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location", None, var_name, "")))
   577                             data = wx.TextDataObject(str(
       
   578                                 ("%s%s.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), 
       
   579                                  "location", 
       
   580                                  IECTypeConversion.get(typeinfos["name"]), 
       
   581                                  var_name, "")))
   549                             dragSource = wx.DropSource(self.SubindexGrid)
   582                             dragSource = wx.DropSource(self.SubindexGrid)
   550                             dragSource.SetData(data)
   583                             dragSource.SetData(data)
   551                             dragSource.DoDragDrop()
   584                             dragSource.DoDragDrop()
   552         event.Skip()
   585         event.Skip()
   553 
   586