etherlab/ConfigEditor.py
author Laurent Bessard
Thu, 25 Oct 2012 19:55:02 +0200
changeset 2086 8e4992e0f147
parent 2072 b7477ba593ba
child 2089 3f5c41f3d47f
permissions -rw-r--r--
Adding block library for SDO download and SDO upload
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
2053
5998beb54a6c refactoring
laurent
parents: 2048
diff changeset
     5
from controls import CustomGrid, CustomTable
2071
37d603e91a43 Fix import after integration of plcopeneditor into Beremiz
Laurent Bessard
parents: 2067
diff changeset
     6
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor, SCROLLBAR_UNIT
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     7
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     8
[ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
     9
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    10
def AppendMenu(parent, help, id, kind, text):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    11
    if wx.VERSION >= (2, 6, 0):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    12
        parent.Append(help=help, id=id, kind=kind, text=text)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    13
    else:
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    14
        parent.Append(helpString=help, id=id, kind=kind, item=text)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    15
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
    16
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
    17
    _ = 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
    18
    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
    19
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
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
    21
    
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
    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
    23
        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
    24
            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
    25
                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
    26
            return self.data[row].get(self.GetColLabelValue(col, False), "")
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    27
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    28
def GetVariablesTableColnames():
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    29
    _ = lambda x : x
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
    30
    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
    31
2041
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_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
    33
 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
    34
 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
    35
 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
    36
 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
    37
 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
    38
 ID_NODEEDITORVARIABLESGRID, 
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    39
] = [wx.NewId() for _init_ctrls in range(13)]
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    40
2053
5998beb54a6c refactoring
laurent
parents: 2048
diff changeset
    41
class NodeEditor(ConfTreeNodeEditor):
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    42
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    43
    ID = ID_NODEEDITOR
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    44
    
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    45
    def _init_coll_MainSizer_Items(self, parent):
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    46
        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
    47
        parent.AddWindow(self.SyncManagersLabel, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    48
        parent.AddWindow(self.SyncManagersGrid, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    49
        parent.AddWindow(self.VariablesLabel, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    50
        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
    51
        
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    52
    def _init_coll_MainSizer_Growables(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    53
        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
    54
        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
    55
        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
    56
        
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    57
    def _init_coll_SlaveInfosDetailsSizer_Items(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    58
        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
    59
        parent.AddWindow(self.Vendor, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    60
        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
    61
        parent.AddWindow(self.ProductCode, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    62
        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
    63
        parent.AddWindow(self.RevisionNumber, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    64
        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
    65
        parent.AddWindow(self.Physics, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    66
        
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    67
    def _init_coll_SlaveInfosDetailsSizer_Growables(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    68
        parent.AddGrowableCol(1)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    69
        parent.AddGrowableCol(3)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    70
    
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    71
    def _init_sizers(self):
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    72
        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
    73
        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
    74
        
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    75
        self._init_coll_MainSizer_Growables(self.MainSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    76
        self._init_coll_MainSizer_Items(self.MainSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    77
        self._init_coll_SlaveInfosDetailsSizer_Growables(self.SlaveInfosDetailsSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    78
        self._init_coll_SlaveInfosDetailsSizer_Items(self.SlaveInfosDetailsSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    79
        
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
    80
        self.ConfNodeEditor.SetSizer(self.MainSizer)
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
    81
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
    82
    def _init_ConfNodeEditor(self, prnt):
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
    83
        self.ConfNodeEditor = wx.ScrolledWindow(id=-1, name='SlavePanel', parent=prnt,
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
    84
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
    85
        self.ConfNodeEditor.Bind(wx.EVT_SIZE, self.OnConfNodeEditorResize)
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    86
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    87
        self.VendorLabel = wx.StaticText(id=ID_NODEEDITORVENDORLABEL,
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
    88
              label=_('Vendor:'), name='VendorLabel', parent=self.ConfNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    89
              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
    90
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    91
        self.Vendor = wx.TextCtrl(id=ID_NODEEDITORVENDOR, value='',
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
    92
              name='Vendor', parent=self.ConfNodeEditor, pos=wx.Point(0, 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
    93
              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
    94
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    95
        self.ProductCodeLabel = wx.StaticText(id=ID_NODEEDITORPRODUCTCODELABEL,
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
    96
              label=_('Product code:'), name='ProductCodeLabel', parent=self.ConfNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    97
              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
    98
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    99
        self.ProductCode = wx.TextCtrl(id=ID_NODEEDITORPRODUCTCODE, value='',
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   100
              name='ProductCode', parent=self.ConfNodeEditor, pos=wx.Point(0, 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
   101
              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
   102
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   103
        self.RevisionNumberLabel = wx.StaticText(id=ID_NODEEDITORREVISIONNUMBERLABEL,
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   104
              label=_('Revision number:'), name='RevisionNumberLabel', parent=self.ConfNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   105
              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
   106
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   107
        self.RevisionNumber = wx.TextCtrl(id=ID_NODEEDITORREVISIONNUMBER, value='',
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   108
              name='RevisionNumber', parent=self.ConfNodeEditor, pos=wx.Point(0, 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
   109
              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
   110
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   111
        self.PhysicsLabel = wx.StaticText(id=ID_NODEEDITORPHYSICSLABEL,
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   112
              label=_('Physics:'), name='PhysicsLabel', parent=self.ConfNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   113
              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
   114
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   115
        self.Physics = wx.TextCtrl(id=ID_NODEEDITORPHYSICS, value='',
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   116
              name='Physics', parent=self.ConfNodeEditor, pos=wx.Point(0, 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
   117
              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
   118
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   119
        self.SyncManagersLabel =  wx.StaticText(id=ID_NODEEDITORSYNCMANAGERSLABEL,
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   120
              label=_('Sync managers:'), name='SyncManagersLabel', parent=self.ConfNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   121
              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
   122
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   123
        self.SyncManagersGrid = CustomGrid(id=ID_NODEEDITORSYNCMANAGERSGRID,
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   124
              name='SyncManagersGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), 
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   125
              size=wx.Size(0, 200), style=wx.VSCROLL)
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
   126
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   127
        self.VariablesLabel =  wx.StaticText(id=ID_NODEEDITORVARIABLESLABEL,
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   128
              label=_('Variable entries:'), name='VariablesLabel', parent=self.ConfNodeEditor,
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   129
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   130
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   131
        self.VariablesGrid = wx.gizmos.TreeListCtrl(id=ID_NODEEDITORVARIABLESGRID,
2055
d845f2c546a6 refactoring
laurent
parents: 2053
diff changeset
   132
              name='VariablesGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), 
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   133
              size=wx.Size(0, 400), style=wx.TR_DEFAULT_STYLE |
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   134
                                          wx.TR_ROW_LINES |
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   135
                                          wx.TR_COLUMN_LINES |
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   136
                                          wx.TR_HIDE_ROOT |
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   137
                                          wx.TR_FULL_ROW_HIGHLIGHT)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   138
        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
   139
                
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   140
        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
   141
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   142
    def __init__(self, parent, controler, window):
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   143
        ConfTreeNodeEditor.__init__(self, parent, controler, window)
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   144
    
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
   145
        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
   146
        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
   147
        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
   148
                                               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
   149
        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
   150
        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
   151
        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
   152
            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
   153
            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
   154
            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
   155
            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
   156
            self.SyncManagersGrid.AutoSizeColumn(col, False)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   157
        
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   158
        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
   159
                                              [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
   160
                                              [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
   161
                                               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
   162
                                               wx.ALIGN_LEFT, wx.ALIGN_LEFT]):
2072
b7477ba593ba Fix bug variable entries table column headers not translated
Laurent Bessard
parents: 2071
diff changeset
   163
            self.VariablesGrid.AddColumn(_(colname), colsize, colalign)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   164
        self.VariablesGrid.SetMainColumn(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
   165
    
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   166
    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
   167
        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
   168
        
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   169
    def RefreshView(self):
2060
c7a2c9362d63 Fixing bug on ConfNodeEditors refresh
Laurent Bessard
parents: 2058
diff changeset
   170
        ConfTreeNodeEditor.RefreshView(self)
2067
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   171
    
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   172
        self.RefreshSlaveInfos()
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   173
        
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   174
    def RefreshSlaveInfos(self):
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   175
        slave_infos = self.Controler.GetSlaveInfos()
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   176
        if slave_infos is not None:
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   177
            self.Vendor.SetValue(slave_infos["vendor"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   178
            self.ProductCode.SetValue(slave_infos["product_code"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   179
            self.RevisionNumber.SetValue(slave_infos["revision_number"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   180
            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
   181
            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
   182
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   183
            self.RefreshVariablesGrid(slave_infos["entries"])
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   184
        else:
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   185
            self.Vendor.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   186
            self.ProductCode.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   187
            self.RevisionNumber.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   188
            self.Physics.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   189
            self.SyncManagersTable.SetData([])
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   190
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   191
            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
   192
    
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   193
    def RefreshVariablesGrid(self, entries):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   194
        root = self.VariablesGrid.GetRootItem()
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   195
        if not root.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   196
            root = self.VariablesGrid.AddRoot("Slave entries")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   197
        self.GenerateVariablesGridBranch(root, entries, GetVariablesTableColnames())
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   198
        self.VariablesGrid.Expand(root)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   199
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   200
    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
   201
        if wx.VERSION >= (2, 6, 0):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   202
            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
   203
        else:
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, 0)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   205
        
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   206
        no_more_items = not item.IsOk()
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   207
        for entry in entries:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   208
            idx += 1
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   209
            if no_more_items:
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   210
                item = self.VariablesGrid.AppendItem(root, "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   211
            for col, colname in enumerate(colnames):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   212
                if col == 0:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   213
                    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
   214
                else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   215
                    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
   216
            if entry["PDOMapping"] == "":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   217
                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
   218
            self.VariablesGrid.SetItemPyData(item, entry)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   219
            idx = self.GenerateVariablesGridBranch(item, entry["children"], colnames, idx)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   220
            if not no_more_items:
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
                item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   222
                no_more_items = not item.IsOk()
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   223
        
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   224
        if not no_more_items:
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   225
            to_delete = []
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   226
            while item.IsOk():
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   227
                to_delete.append(item)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   228
                item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   229
            for item in to_delete:
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   230
                self.VariablesGrid.Delete(item)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   231
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   232
        return idx
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   233
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   234
    def OnVariablesGridLeftClick(self, event):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   235
        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
   236
        if item.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   237
            entry = self.VariablesGrid.GetItemPyData(item)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   238
            data_type = entry.get("Type", "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   239
            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
   240
            
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   241
            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
   242
                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
   243
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   244
                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
   245
                entry_subindex = self.Controler.ExtractHexDecValue(entry.get("SubIndex", "0"))
2048
5726f2bbdace reflected changes in beremiz extension mechanism
Edouard Tisserant
parents: 2043
diff changeset
   246
                var_name = "%s_%4.4x_%2.2x" % (self.Controler.CTNName(), entry_index, entry_subindex)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   247
                if pdo_mapping == "R":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   248
                    dir = "%I"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   249
                else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   250
                    dir = "%Q"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   251
                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
   252
                           ".".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
   253
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   254
                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
   255
                dragSource = wx.DropSource(self.VariablesGrid)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   256
                dragSource.SetData(data)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   257
                dragSource.DoDragDrop()
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   258
            
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   259
        event.Skip()
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   260
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   261
    def OnConfNodeEditorResize(self, event):
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   262
        self.ConfNodeEditor.GetBestSize()
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   263
        xstart, ystart = self.ConfNodeEditor.GetViewStart()
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   264
        window_size = self.ConfNodeEditor.GetClientSize()
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   265
        maxx, maxy = self.ConfNodeEditor.GetMinSize()
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   266
        posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT))
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   267
        posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   268
        self.ConfNodeEditor.Scroll(posx, posy)
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   269
        self.ConfNodeEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, 
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   270
                maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy)
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   271
        event.Skip()
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   272
2053
5998beb54a6c refactoring
laurent
parents: 2048
diff changeset
   273
CIA402NodeEditor = NodeEditor