etherlab/ConfigEditor.py
changeset 2379 015b724c30a5
parent 2375 cfa68a06a24d
child 2381 1c40e3976cc2
equal deleted inserted replaced
2378:7aa47c09f8f5 2379:015b724c30a5
   422             if values[1] == "location":
   422             if values[1] == "location":
   423                 result = LOCATION_MODEL.match(values[0])
   423                 result = LOCATION_MODEL.match(values[0])
   424                 if result is not None:
   424                 if result is not None:
   425                     location = map(int, result.group(1).split('.'))
   425                     location = map(int, result.group(1).split('.'))
   426                 master_location = self.ParentWindow.GetMasterLocation()
   426                 master_location = self.ParentWindow.GetMasterLocation()
   427                 if (master_location == tuple(location[:len(master_location)]) and
   427                 if master_location == tuple(location[:len(master_location)]) and \
   428                     len(location) - len(master_location) == 3):
   428                    len(location) - len(master_location) == 3:
   429                     values = tuple(location[len(master_location):])
   429                     values = tuple(location[len(master_location):])
   430                     var_type = self.ParentWindow.Controler.GetSlaveVariableDataType(*values)
   430                     var_type = self.ParentWindow.Controler.GetSlaveVariableDataType(*values)
   431                     if col == 2:
   431                     if col == 2:
   432                         other_values = self.ParentWindow.ProcessVariablesTable.GetValueByName(row, "WriteTo")
   432                         other_values = self.ParentWindow.ProcessVariablesTable.GetValueByName(row, "WriteTo")
   433                     else:
   433                     else:
   489             elif values[1] == "variable":
   489             elif values[1] == "variable":
   490                 location = values[0]
   490                 location = values[0]
   491                 access = values[2]
   491                 access = values[2]
   492             if location is not None:
   492             if location is not None:
   493                 master_location = self.ParentWindow.GetMasterLocation()
   493                 master_location = self.ParentWindow.GetMasterLocation()
   494                 if (master_location == tuple(location[:len(master_location)]) and
   494                 if master_location == tuple(location[:len(master_location)]) and \
   495                     len(location) - len(master_location) == 3):
   495                    len(location) - len(master_location) == 3:
   496                     if access in ["wo", "rw"]:
   496                     if access in ["wo", "rw"]:
   497                         self.ParentWindow.AddStartupCommand(*location[len(master_location):])
   497                         self.ParentWindow.AddStartupCommand(*location[len(master_location):])
   498                     else:
   498                     else:
   499                         message = _("Entry can't be write through SDO")
   499                         message = _("Entry can't be write through SDO")
   500                 else:
   500                 else:
   902         if self.CurrentNodesFilter is not None:
   902         if self.CurrentNodesFilter is not None:
   903             self.ProcessVariables = self.Controler.GetProcessVariables()
   903             self.ProcessVariables = self.Controler.GetProcessVariables()
   904             slaves = self.Controler.GetSlaves(**self.CurrentNodesFilter)
   904             slaves = self.Controler.GetSlaves(**self.CurrentNodesFilter)
   905             data = []
   905             data = []
   906             for variable in self.ProcessVariables:
   906             for variable in self.ProcessVariables:
   907                 if (variable["ReadFrom"] == "" or variable["ReadFrom"][0] in slaves or
   907                 if variable["ReadFrom"] == "" or variable["ReadFrom"][0] in slaves or \
   908                     variable["WriteTo"] == "" or variable["WriteTo"][0] in slaves):
   908                    variable["WriteTo"] == "" or variable["WriteTo"][0] in slaves:
   909                     data.append(variable)
   909                     data.append(variable)
   910             self.ProcessVariablesTable.SetData(data)
   910             self.ProcessVariablesTable.SetData(data)
   911             self.ProcessVariablesTable.ResetView(self.ProcessVariablesGrid)
   911             self.ProcessVariablesTable.ResetView(self.ProcessVariablesGrid)
   912             self.ProcessVariablesGrid.RefreshButtons()
   912             self.ProcessVariablesGrid.RefreshButtons()
   913 
   913 
  1012     def OnProcessVariablesGridKeyDown(self, event):
  1012     def OnProcessVariablesGridKeyDown(self, event):
  1013         keycode = event.GetKeyCode()
  1013         keycode = event.GetKeyCode()
  1014         col = self.ProcessVariablesGrid.GetGridCursorCol()
  1014         col = self.ProcessVariablesGrid.GetGridCursorCol()
  1015         row = self.ProcessVariablesGrid.GetGridCursorRow()
  1015         row = self.ProcessVariablesGrid.GetGridCursorRow()
  1016         colname = self.ProcessVariablesTable.GetColLabelValue(col, False)
  1016         colname = self.ProcessVariablesTable.GetColLabelValue(col, False)
  1017         if (keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE) and
  1017         if keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE) and \
  1018             (colname.startswith("Read from") or colname.startswith("Write to"))):
  1018            (colname.startswith("Read from") or colname.startswith("Write to")):
  1019             self.ProcessVariablesTable.SetValue(row, col, "")
  1019             self.ProcessVariablesTable.SetValue(row, col, "")
  1020             self.SaveProcessVariables()
  1020             self.SaveProcessVariables()
  1021             wx.CallAfter(self.ProcessVariablesTable.ResetView, self.ProcessVariablesGrid)
  1021             wx.CallAfter(self.ProcessVariablesTable.ResetView, self.ProcessVariablesGrid)
  1022         else:
  1022         else:
  1023             event.Skip()
  1023             event.Skip()