127 |
127 |
128 Otherwise default to the default renderer. |
128 Otherwise default to the default renderer. |
129 """ |
129 """ |
130 for row in range(self.GetNumberRows()): |
130 for row in range(self.GetNumberRows()): |
131 row_highlights = self.Highlights.get(row, {}) |
131 row_highlights = self.Highlights.get(row, {}) |
132 access = self.GetValueByName(row, "Access") |
132 pdo_mapping = self.GetValueByName(row, "PDOMapping") |
133 for col in range(self.GetNumberCols()): |
133 for col in range(self.GetNumberCols()): |
134 colname = self.GetColLabelValue(col, False) |
134 colname = self.GetColLabelValue(col, False) |
135 |
135 |
136 if colname in ["PDO index", "PDO name", "PDO type"] and access == "": |
136 if colname in ["PDO index", "PDO name", "PDO type"] and pdo_mapping == "": |
137 highlight_colours = (wx.LIGHT_GREY, wx.WHITE) |
137 highlight_colours = (wx.LIGHT_GREY, wx.WHITE) |
138 else: |
138 else: |
139 highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] |
139 highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] |
140 grid.SetReadOnly(row, col, True) |
140 grid.SetReadOnly(row, col, True) |
141 grid.SetCellEditor(row, col, None) |
141 grid.SetCellEditor(row, col, None) |
260 |
260 |
261 def __init__(self, parent, controler): |
261 def __init__(self, parent, controler): |
262 self._init_ctrls(parent) |
262 self._init_ctrls(parent) |
263 |
263 |
264 self.Controler = controler |
264 self.Controler = controler |
|
265 self.Slave = None |
|
266 self.Type = None |
265 |
267 |
266 self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames()) |
268 self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames()) |
267 self.SyncManagersGrid.SetTable(self.SyncManagersTable) |
269 self.SyncManagersGrid.SetTable(self.SyncManagersTable) |
268 self.SyncManagersGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
270 self.SyncManagersGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
269 wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT] |
271 wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT] |
288 attr.SetAlignment(self.VariablesGridColAlignements[col], wx.ALIGN_CENTRE) |
290 attr.SetAlignment(self.VariablesGridColAlignements[col], wx.ALIGN_CENTRE) |
289 self.VariablesGrid.SetColAttr(col, attr) |
291 self.VariablesGrid.SetColAttr(col, attr) |
290 self.VariablesGrid.SetColMinimalWidth(col, self.VariablesGridColSizes[col]) |
292 self.VariablesGrid.SetColMinimalWidth(col, self.VariablesGridColSizes[col]) |
291 self.VariablesGrid.AutoSizeColumn(col, False) |
293 self.VariablesGrid.AutoSizeColumn(col, False) |
292 |
294 |
293 def SetSlaveInfos(self, slave_infos): |
295 def SetSlaveInfos(self, slave_pos, slave_infos): |
|
296 self.Slave = slave_pos |
294 if slave_infos is not None: |
297 if slave_infos is not None: |
|
298 self.Type = slave_infos["device_type"] |
295 self.Vendor.SetValue(slave_infos["vendor"]) |
299 self.Vendor.SetValue(slave_infos["vendor"]) |
296 self.ProductCode.SetValue(slave_infos["product_code"]) |
300 self.ProductCode.SetValue(slave_infos["product_code"]) |
297 self.RevisionNumber.SetValue(slave_infos["revision_number"]) |
301 self.RevisionNumber.SetValue(slave_infos["revision_number"]) |
298 self.Physics.SetValue(slave_infos["physics"]) |
302 self.Physics.SetValue(slave_infos["physics"]) |
299 self.SyncManagersTable.SetData(slave_infos["sync_managers"]) |
303 self.SyncManagersTable.SetData(slave_infos["sync_managers"]) |
300 self.SyncManagersTable.ResetView(self.SyncManagersGrid) |
304 self.SyncManagersTable.ResetView(self.SyncManagersGrid) |
301 self.VariablesTable.SetData(slave_infos["entries"]) |
305 self.VariablesTable.SetData(slave_infos["entries"]) |
302 self.VariablesTable.ResetView(self.VariablesGrid) |
306 self.VariablesTable.ResetView(self.VariablesGrid) |
303 else: |
307 else: |
|
308 self.Type = None |
304 self.Vendor.SetValue("") |
309 self.Vendor.SetValue("") |
305 self.ProductCode.SetValue("") |
310 self.ProductCode.SetValue("") |
306 self.RevisionNumber.SetValue("") |
311 self.RevisionNumber.SetValue("") |
307 self.Physics.SetValue("") |
312 self.Physics.SetValue("") |
308 self.SyncManagersTable.SetData([]) |
313 self.SyncManagersTable.SetData([]) |
312 |
317 |
313 def OnVariablesGridCellLeftClick(self, event): |
318 def OnVariablesGridCellLeftClick(self, event): |
314 row = event.GetRow() |
319 row = event.GetRow() |
315 |
320 |
316 data_type = self.VariablesTable.GetValueByName(row, "Type") |
321 data_type = self.VariablesTable.GetValueByName(row, "Type") |
317 access = self.VariablesTable.GetValueByName(row, "Access") |
322 pdo_mapping = self.VariablesTable.GetValueByName(row, "PDOMapping") |
318 if (event.GetCol() == 0 and access != "" and |
323 if (event.GetCol() == 0 and pdo_mapping != "" and |
319 self.Controler.GetSizeOfType(data_type) is not None): |
324 self.Controler.GetSizeOfType(data_type) is not None): |
320 |
325 |
321 entry_index = self.Controler.ExtractHexDecValue(self.VariablesTable.GetValueByName(row, "Index")) |
326 entry_index = self.Controler.ExtractHexDecValue(self.VariablesTable.GetValueByName(row, "Index")) |
322 entry_subindex = self.Controler.ExtractHexDecValue(self.VariablesTable.GetValueByName(row, "SubIndex")) |
327 entry_subindex = self.Controler.ExtractHexDecValue(self.VariablesTable.GetValueByName(row, "SubIndex")) |
323 var_name = "%s_%4.4x_%2.2x" % (self.Type.GetValue(), entry_index, entry_subindex) |
328 var_name = "%s_%4.4x_%2.2x" % (self.Type, entry_index, entry_subindex) |
324 if access in ["ro"]: |
329 if pdo_mapping in ["R"]: |
325 dir = "%I" |
330 dir = "%I" |
326 else: |
331 else: |
327 dir = "%Q" |
332 dir = "%Q" |
328 location = "%s%s" % (dir, self.Controler.GetSizeOfType(data_type)) + \ |
333 location = "%s%s" % (dir, self.Controler.GetSizeOfType(data_type)) + \ |
329 ".".join(map(lambda x:str(x), self.Controler.GetCurrentLocation() + self.Slave + (entry_index, entry_subindex))) |
334 ".".join(map(lambda x:str(x), self.Controler.GetCurrentLocation() + self.Slave + (entry_index, entry_subindex))) |
466 if slave_infos is not None: |
471 if slave_infos is not None: |
467 self.Type.SetValue(slave_infos["device_type"]) |
472 self.Type.SetValue(slave_infos["device_type"]) |
468 else: |
473 else: |
469 type_infos = self.Controler.GetSlaveType(self.Slave) |
474 type_infos = self.Controler.GetSlaveType(self.Slave) |
470 self.Type.SetValue(type_infos["device_type"]) |
475 self.Type.SetValue(type_infos["device_type"]) |
471 self.SlaveInfosPanel.SetSlaveInfos(slave_infos) |
476 self.SlaveInfosPanel.SetSlaveInfos(self.Slave, slave_infos) |
472 |
477 |
473 def OnAliasChanged(self, event): |
478 def OnAliasChanged(self, event): |
474 alias = self.Alias.GetValue() |
479 alias = self.Alias.GetValue() |
475 if alias != self.Slave[0]: |
480 if alias != self.Slave[0]: |
476 result = self.Controler.SetSlavePos(self.Slave[:2], alias = alias) |
481 result = self.Controler.SetSlavePos(self.Slave[:2], alias = alias) |