etherlab/ConfigEditor.py
author laurent
Wed, 21 Mar 2012 11:15:47 +0100
changeset 2043 27d4cb689a79
parent 2041 ce3727171207
child 2048 5726f2bbdace
permissions -rw-r--r--
Adding plugin icons and replacing reference to DS402 by CIA402
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     1
import wx
2026
65ecbfe9a6f9 Adding support for drag'n dropping located variables from topology panel to configurations and resources variable panel for declaring global located variables
laurent
parents: 2023
diff changeset
     2
import wx.grid
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
     3
import wx.gizmos
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     4
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     5
from controls import CustomGrid, CustomTable, EditorPanel
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     6
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     7
[ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     8
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     9
def AppendMenu(parent, help, id, kind, text):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    10
    if wx.VERSION >= (2, 6, 0):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    11
        parent.Append(help=help, id=id, kind=kind, text=text)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    12
    else:
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    13
        parent.Append(helpString=help, id=id, kind=kind, item=text)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    14
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    15
def GetSyncManagersTableColnames():
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    16
    _ = lambda x : x
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    17
    return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")]
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    18
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    19
class SyncManagersTable(CustomTable):
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    20
    
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    21
    def GetValue(self, row, col):
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    22
        if row < self.GetNumberRows():
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    23
            if col == 0:
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    24
                return row
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    25
            return self.data[row].get(self.GetColLabelValue(col, False), "")
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    26
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    27
def GetVariablesTableColnames():
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    28
    _ = lambda x : x
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    29
    return ["#", _("Name"), _("Index"), _("SubIndex"), _("Type"), _("PDO index"), _("PDO name"), _("PDO type")]
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    30
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    31
[ID_NODEEDITOR, ID_NODEEDITORVENDORLABEL, 
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    32
 ID_NODEEDITORVENDOR, ID_NODEEDITORPRODUCTCODELABEL, 
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    33
 ID_NODEEDITORPRODUCTCODE, ID_NODEEDITORREVISIONNUMBERLABEL, 
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    34
 ID_NODEEDITORREVISIONNUMBER, ID_NODEEDITORPHYSICSLABEL, 
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    35
 ID_NODEEDITORPHYSICS, ID_NODEEDITORSYNCMANAGERSLABEL, 
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    36
 ID_NODEEDITORSYNCMANAGERSGRID, ID_NODEEDITORVARIABLESLABEL, 
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    37
 ID_NODEEDITORVARIABLESGRID, 
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    38
] = [wx.NewId() for _init_ctrls in range(13)]
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    39
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    40
class NodeEditor(EditorPanel):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    41
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    42
    ID = ID_NODEEDITOR
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    43
    
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    44
    def _init_coll_MainSizer_Items(self, parent):
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    45
        parent.AddSizer(self.SlaveInfosDetailsSizer, 0, border=5, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    46
        parent.AddWindow(self.SyncManagersLabel, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    47
        parent.AddWindow(self.SyncManagersGrid, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    48
        parent.AddWindow(self.VariablesLabel, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    49
        parent.AddWindow(self.VariablesGrid, 0, border=5, flag=wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    50
        
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    51
    def _init_coll_MainSizer_Growables(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    52
        parent.AddGrowableCol(0)
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    53
        parent.AddGrowableRow(2, 1)
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
    54
        parent.AddGrowableRow(4, 2)
2023
f9f884cf3033 Adding support for not configuring pdos when not mandatory and not needed by locations defined in PLC program. Adding support for displaying locations tree in Topology panel and BrowseLocationsDialog. Merging pdos grid and variables grid into one single grid in slave infos panel.
laurent
parents: 2022
diff changeset
    55
        
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    56
    def _init_coll_SlaveInfosDetailsSizer_Items(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    57
        parent.AddWindow(self.VendorLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    58
        parent.AddWindow(self.Vendor, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    59
        parent.AddWindow(self.ProductCodeLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    60
        parent.AddWindow(self.ProductCode, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    61
        parent.AddWindow(self.RevisionNumberLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    62
        parent.AddWindow(self.RevisionNumber, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    63
        parent.AddWindow(self.PhysicsLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    64
        parent.AddWindow(self.Physics, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    65
        
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    66
    def _init_coll_SlaveInfosDetailsSizer_Growables(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    67
        parent.AddGrowableCol(1)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    68
        parent.AddGrowableCol(3)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    69
    
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    70
    def _init_sizers(self):
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    71
        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5)
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    72
        self.SlaveInfosDetailsSizer = wx.FlexGridSizer(cols=4, hgap=5, rows=2, vgap=5)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    73
        
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    74
        self._init_coll_MainSizer_Growables(self.MainSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    75
        self._init_coll_MainSizer_Items(self.MainSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    76
        self._init_coll_SlaveInfosDetailsSizer_Growables(self.SlaveInfosDetailsSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    77
        self._init_coll_SlaveInfosDetailsSizer_Items(self.SlaveInfosDetailsSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    78
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    79
        self.Editor.SetSizer(self.MainSizer)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    80
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    81
    def _init_Editor(self, prnt):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    82
        self.Editor = wx.Panel(id=-1, name='SlavePanel', parent=prnt,
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    83
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    84
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    85
        self.VendorLabel = wx.StaticText(id=ID_NODEEDITORVENDORLABEL,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    86
              label=_('Vendor:'), name='VendorLabel', parent=self.Editor,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    87
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    88
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    89
        self.Vendor = wx.TextCtrl(id=ID_NODEEDITORVENDOR, value='',
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    90
              name='Vendor', parent=self.Editor, pos=wx.Point(0, 0),
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    91
              size=wx.Size(0, 24), style=wx.TE_READONLY)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    92
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    93
        self.ProductCodeLabel = wx.StaticText(id=ID_NODEEDITORPRODUCTCODELABEL,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    94
              label=_('Product code:'), name='ProductCodeLabel', parent=self.Editor,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    95
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    96
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    97
        self.ProductCode = wx.TextCtrl(id=ID_NODEEDITORPRODUCTCODE, value='',
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    98
              name='ProductCode', parent=self.Editor, pos=wx.Point(0, 0),
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    99
              size=wx.Size(0, 24), style=wx.TE_READONLY)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   100
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   101
        self.RevisionNumberLabel = wx.StaticText(id=ID_NODEEDITORREVISIONNUMBERLABEL,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   102
              label=_('Revision number:'), name='RevisionNumberLabel', parent=self.Editor,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   103
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   104
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   105
        self.RevisionNumber = wx.TextCtrl(id=ID_NODEEDITORREVISIONNUMBER, value='',
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   106
              name='RevisionNumber', parent=self.Editor, pos=wx.Point(0, 0),
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   107
              size=wx.Size(0, 24), style=wx.TE_READONLY)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   108
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   109
        self.PhysicsLabel = wx.StaticText(id=ID_NODEEDITORPHYSICSLABEL,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   110
              label=_('Physics:'), name='PhysicsLabel', parent=self.Editor,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   111
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   112
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   113
        self.Physics = wx.TextCtrl(id=ID_NODEEDITORPHYSICS, value='',
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   114
              name='Physics', parent=self.Editor, pos=wx.Point(0, 0),
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   115
              size=wx.Size(0, 24), style=wx.TE_READONLY)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   116
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   117
        self.SyncManagersLabel =  wx.StaticText(id=ID_NODEEDITORSYNCMANAGERSLABEL,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   118
              label=_('Sync managers:'), name='SyncManagersLabel', parent=self.Editor,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   119
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   120
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   121
        self.SyncManagersGrid = CustomGrid(id=ID_NODEEDITORSYNCMANAGERSGRID,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   122
              name='SyncManagersGrid', parent=self.Editor, pos=wx.Point(0, 0), 
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   123
              size=wx.Size(0, 0), style=wx.VSCROLL)
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   124
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   125
        self.VariablesLabel =  wx.StaticText(id=ID_NODEEDITORVARIABLESLABEL,
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   126
              label=_('Variable entries:'), name='VariablesLabel', parent=self,
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   127
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   128
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   129
        self.VariablesGrid = wx.gizmos.TreeListCtrl(id=ID_NODEEDITORVARIABLESGRID,
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   130
              name='VariablesGrid', parent=self.Editor, pos=wx.Point(0, 0), 
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   131
              size=wx.Size(0, 0), style=wx.TR_DEFAULT_STYLE |
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   132
                                        wx.TR_ROW_LINES |
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   133
                                        wx.TR_COLUMN_LINES |
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   134
                                        wx.TR_HIDE_ROOT |
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   135
                                        wx.TR_FULL_ROW_HIGHLIGHT)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   136
        self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, self.OnVariablesGridLeftClick)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   137
                
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   138
        self._init_sizers()
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   139
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   140
    def __init__(self, parent, controler, window):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   141
        EditorPanel.__init__(self, parent, "", window, controler)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   142
    
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   143
        self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames())
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   144
        self.SyncManagersGrid.SetTable(self.SyncManagersTable)
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   145
        self.SyncManagersGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   146
                                               wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT]
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   147
        self.SyncManagersGridColSizes = [40, 150, 100, 100, 100, 100]
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   148
        self.SyncManagersGrid.SetRowLabelSize(0)
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   149
        for col in range(self.SyncManagersTable.GetNumberCols()):
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   150
            attr = wx.grid.GridCellAttr()
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   151
            attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTRE)
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   152
            self.SyncManagersGrid.SetColAttr(col, attr)
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   153
            self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col])
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   154
            self.SyncManagersGrid.AutoSizeColumn(col, False)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   155
            
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   156
        for colname, colsize, colalign in zip(GetVariablesTableColnames(),
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   157
                                              [40, 150, 100, 100, 150, 100, 150, 100],
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   158
                                              [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   159
                                               wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   160
                                               wx.ALIGN_LEFT, wx.ALIGN_LEFT]):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   161
            self.VariablesGrid.AddColumn(colname, colsize, colalign)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   162
        self.VariablesGrid.SetMainColumn(1)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   163
        
2043
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   164
        img = wx.Bitmap(self.Controler.GetIconPath("Slave.png"), wx.BITMAP_TYPE_PNG).ConvertToImage()
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   165
        self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16)))
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   166
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   167
    def __del__(self):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   168
        self.Controler.OnCloseEditor(self)
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   169
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   170
    def GetTitle(self):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   171
        return self.Controler.PlugFullName()
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   172
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   173
    def GetBufferState(self):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   174
        return False, False
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   175
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   176
    def RefreshView(self):
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   177
        slave_infos = self.Controler.GetSlaveInfos()
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   178
        if slave_infos is not None:
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   179
            self.Vendor.SetValue(slave_infos["vendor"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   180
            self.ProductCode.SetValue(slave_infos["product_code"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   181
            self.RevisionNumber.SetValue(slave_infos["revision_number"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   182
            self.Physics.SetValue(slave_infos["physics"])
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   183
            self.SyncManagersTable.SetData(slave_infos["sync_managers"])
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   184
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   185
            self.RefreshVariablesGrid(slave_infos["entries"])
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   186
        else:
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   187
            self.Vendor.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   188
            self.ProductCode.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   189
            self.RevisionNumber.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   190
            self.Physics.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   191
            self.SyncManagersTable.SetData([])
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   192
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   193
            self.RefreshVariablesGrid([])
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   194
    
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   195
    def RefreshVariablesGrid(self, entries):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   196
        root = self.VariablesGrid.GetRootItem()
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   197
        if not root.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   198
            root = self.VariablesGrid.AddRoot("Slave entries")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   199
        self.GenerateVariablesGridBranch(root, entries, GetVariablesTableColnames())
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   200
        self.VariablesGrid.Expand(root)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   201
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   202
    def GenerateVariablesGridBranch(self, root, entries, colnames, idx=0):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   203
        if wx.VERSION >= (2, 6, 0):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   204
            item, root_cookie = self.VariablesGrid.GetFirstChild(root)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   205
        else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   206
            item, root_cookie = self.VariablesGrid.GetFirstChild(root, 0)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   207
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   208
        for entry in entries:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   209
            idx += 1
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   210
            create_new = not item.IsOk()
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   211
            if create_new:
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   212
                item = self.VariablesGrid.AppendItem(root, "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   213
            for col, colname in enumerate(colnames):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   214
                if col == 0:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   215
                    self.VariablesGrid.SetItemText(item, str(idx), 0)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   216
                else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   217
                    self.VariablesGrid.SetItemText(item, entry.get(colname, ""), col)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   218
            if entry["PDOMapping"] == "":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   219
                self.VariablesGrid.SetItemBackgroundColour(item, wx.LIGHT_GREY)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   220
            self.VariablesGrid.SetItemPyData(item, entry)
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   221
            if create_new and wx.Platform != '__WXMSW__':
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   222
                item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   223
            idx = self.GenerateVariablesGridBranch(item, entry["children"], colnames, idx)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   224
            item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   225
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   226
        to_delete = []
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   227
        while item.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   228
            to_delete.append(item)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   229
            item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   230
        for item in to_delete:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   231
            self.VariablesGrid.Delete(item)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   232
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   233
        return idx
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   234
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   235
    def OnVariablesGridLeftClick(self, event):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   236
        item, flags, col = self.VariablesGrid.HitTest(event.GetPosition())
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   237
        if item.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   238
            entry = self.VariablesGrid.GetItemPyData(item)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   239
            data_type = entry.get("Type", "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   240
            pdo_mapping = entry.get("PDOMapping", "")
2029
7c848efa21c6 Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents: 2026
diff changeset
   241
            
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   242
            if (col == -1 and pdo_mapping != "" and
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   243
                self.Controler.GetSizeOfType(data_type) is not None):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   244
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   245
                entry_index = self.Controler.ExtractHexDecValue(entry.get("Index", "0"))
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   246
                entry_subindex = self.Controler.ExtractHexDecValue(entry.get("SubIndex", "0"))
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   247
                var_name = "%s_%4.4x_%2.2x" % (self.Controler.PlugName(), entry_index, entry_subindex)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   248
                if pdo_mapping == "R":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   249
                    dir = "%I"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   250
                else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   251
                    dir = "%Q"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   252
                location = "%s%s" % (dir, self.Controler.GetSizeOfType(data_type)) + \
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   253
                           ".".join(map(lambda x:str(x), self.Controler.GetCurrentLocation() + (self.Controler.GetSlavePos(), entry_index, entry_subindex)))
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   254
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   255
                data = wx.TextDataObject(str((location, "location", data_type, var_name, "")))
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   256
                dragSource = wx.DropSource(self.VariablesGrid)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   257
                dragSource.SetData(data)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   258
                dragSource.DoDragDrop()
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   259
            
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   260
        event.Skip()
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   261
2043
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   262
class CIA402NodeEditor(NodeEditor):
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   263
    
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   264
    def __init__(self, parent, controler, window):
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   265
        NodeEditor.__init__(self, parent, controler, window)
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   266
        
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   267
        img = wx.Bitmap(self.Controler.GetIconPath("CIA402Slave.png"), wx.BITMAP_TYPE_PNG).ConvertToImage()
27d4cb689a79 Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents: 2041
diff changeset
   268
        self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16)))