etherlab/ConfigEditor.py
author Laurent Bessard
Wed, 30 Jan 2013 23:46:58 +0100
changeset 2095 6733a7c5c897
parent 2089 3f5c41f3d47f
child 2097 58d07e039896
permissions -rw-r--r--
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
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
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    44
    CONFNODEEDITOR_TABS = [
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    45
        (_("Ethercat node"), "_create_EthercatNodeEditor")]
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    46
    
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    47
    def _init_coll_MainSizer_Items(self, parent):
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    48
        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
    49
        parent.AddWindow(self.SyncManagersLabel, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    50
        parent.AddWindow(self.SyncManagersGrid, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    51
        parent.AddWindow(self.VariablesLabel, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.GROW)
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    52
        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
    53
        
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    54
    def _init_coll_MainSizer_Growables(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    55
        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
    56
        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
    57
        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
    58
        
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    59
    def _init_coll_SlaveInfosDetailsSizer_Items(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    60
        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
    61
        parent.AddWindow(self.Vendor, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    62
        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
    63
        parent.AddWindow(self.ProductCode, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    64
        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
    65
        parent.AddWindow(self.RevisionNumber, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    66
        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
    67
        parent.AddWindow(self.Physics, 0, border=0, flag=wx.GROW)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    68
        
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    69
    def _init_coll_SlaveInfosDetailsSizer_Growables(self, parent):
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    70
        parent.AddGrowableCol(1)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    71
        parent.AddGrowableCol(3)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    72
    
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    73
    def _init_sizers(self):
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
    74
        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
    75
        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
    76
        
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    77
        self._init_coll_MainSizer_Growables(self.MainSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    78
        self._init_coll_MainSizer_Items(self.MainSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    79
        self._init_coll_SlaveInfosDetailsSizer_Growables(self.SlaveInfosDetailsSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    80
        self._init_coll_SlaveInfosDetailsSizer_Items(self.SlaveInfosDetailsSizer)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    81
        
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    82
        self.EthercatNodeEditor.SetSizer(self.MainSizer)
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    83
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    84
    def _create_EthercatNodeEditor(self, prnt):
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    85
        self.EthercatNodeEditor = wx.ScrolledWindow(id=-1, name='SlavePanel', parent=prnt,
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
    86
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    87
        self.EthercatNodeEditor.Bind(wx.EVT_SIZE, self.OnEthercatNodeEditorResize)
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
    88
        
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
        self.VendorLabel = wx.StaticText(id=ID_NODEEDITORVENDORLABEL,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    90
              label=_('Vendor:'), name='VendorLabel', parent=self.EthercatNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    91
              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
    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.Vendor = wx.TextCtrl(id=ID_NODEEDITORVENDOR, value='',
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    94
              name='Vendor', parent=self.EthercatNodeEditor, 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
    95
              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
    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.ProductCodeLabel = wx.StaticText(id=ID_NODEEDITORPRODUCTCODELABEL,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
    98
              label=_('Product code:'), name='ProductCodeLabel', parent=self.EthercatNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
    99
              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
   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.ProductCode = wx.TextCtrl(id=ID_NODEEDITORPRODUCTCODE, value='',
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   102
              name='ProductCode', parent=self.EthercatNodeEditor, 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
   103
              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
   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.RevisionNumberLabel = wx.StaticText(id=ID_NODEEDITORREVISIONNUMBERLABEL,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   106
              label=_('Revision number:'), name='RevisionNumberLabel', parent=self.EthercatNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   107
              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
   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.RevisionNumber = wx.TextCtrl(id=ID_NODEEDITORREVISIONNUMBER, value='',
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   110
              name='RevisionNumber', parent=self.EthercatNodeEditor, 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
   111
              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
   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.PhysicsLabel = wx.StaticText(id=ID_NODEEDITORPHYSICSLABEL,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   114
              label=_('Physics:'), name='PhysicsLabel', parent=self.EthercatNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   115
              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
   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.Physics = wx.TextCtrl(id=ID_NODEEDITORPHYSICS, value='',
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   118
              name='Physics', parent=self.EthercatNodeEditor, 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
   119
              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
   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.SyncManagersLabel =  wx.StaticText(id=ID_NODEEDITORSYNCMANAGERSLABEL,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   122
              label=_('Sync managers:'), name='SyncManagersLabel', parent=self.EthercatNodeEditor,
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   123
              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
   124
        
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.SyncManagersGrid = CustomGrid(id=ID_NODEEDITORSYNCMANAGERSGRID,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   126
              name='SyncManagersGrid', parent=self.EthercatNodeEditor, 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
   127
              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
   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.VariablesLabel =  wx.StaticText(id=ID_NODEEDITORVARIABLESLABEL,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   130
              label=_('Variable entries:'), name='VariablesLabel', parent=self.EthercatNodeEditor,
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   131
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   132
        
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   133
        self.VariablesGrid = wx.gizmos.TreeListCtrl(id=ID_NODEEDITORVARIABLESGRID,
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   134
              name='VariablesGrid', parent=self.EthercatNodeEditor, 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
   135
              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
   136
                                          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
   137
                                          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
   138
                                          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
   139
                                          wx.TR_FULL_ROW_HIGHLIGHT)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   140
        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
   141
                
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   142
        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
   143
    
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   144
        return self.EthercatNodeEditor
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   145
    
2041
ce3727171207 Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents: 2040
diff changeset
   146
    def __init__(self, parent, controler, window):
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   147
        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
   148
    
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
   149
        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
   150
        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
   151
        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
   152
                                               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
   153
        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
   154
        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
   155
        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
   156
            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
   157
            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
   158
            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
   159
            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
   160
            self.SyncManagersGrid.AutoSizeColumn(col, False)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   161
        
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   162
        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
   163
                                              [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
   164
                                              [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
   165
                                               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
   166
                                               wx.ALIGN_LEFT, wx.ALIGN_LEFT]):
2072
b7477ba593ba Fix bug variable entries table column headers not translated
Laurent Bessard
parents: 2071
diff changeset
   167
            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
   168
        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
   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 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
   171
        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
   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 RefreshView(self):
2060
c7a2c9362d63 Fixing bug on ConfNodeEditors refresh
Laurent Bessard
parents: 2058
diff changeset
   174
        ConfTreeNodeEditor.RefreshView(self)
2067
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   175
    
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   176
        self.RefreshSlaveInfos()
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   177
        
04cc0295e2c4 Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents: 2060
diff changeset
   178
    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
   179
        slave_infos = self.Controler.GetSlaveInfos()
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   180
        if slave_infos is not None:
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   181
            self.Vendor.SetValue(slave_infos["vendor"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   182
            self.ProductCode.SetValue(slave_infos["product_code"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   183
            self.RevisionNumber.SetValue(slave_infos["revision_number"])
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   184
            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
   185
            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
   186
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   187
            self.RefreshVariablesGrid(slave_infos["entries"])
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   188
        else:
2034
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   189
            self.Vendor.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   190
            self.ProductCode.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   191
            self.RevisionNumber.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   192
            self.Physics.SetValue("")
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   193
            self.SyncManagersTable.SetData([])
ae8fecf082a1 Adding support for MCL
laurent
parents: 2030
diff changeset
   194
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   195
            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
   196
    
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   197
    def RefreshVariablesGrid(self, entries):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   198
        root = self.VariablesGrid.GetRootItem()
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   199
        if not root.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   200
            root = self.VariablesGrid.AddRoot("Slave entries")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   201
        self.GenerateVariablesGridBranch(root, entries, GetVariablesTableColnames())
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   202
        self.VariablesGrid.Expand(root)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   203
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   204
    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
   205
        if wx.VERSION >= (2, 6, 0):
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)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   207
        else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   208
            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
   209
        
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   210
        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
   211
        for entry in entries:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   212
            idx += 1
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   213
            if no_more_items:
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   214
                item = self.VariablesGrid.AppendItem(root, "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   215
            for col, colname in enumerate(colnames):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   216
                if col == 0:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   217
                    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
   218
                else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   219
                    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
   220
            if entry["PDOMapping"] == "":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   221
                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
   222
            self.VariablesGrid.SetItemPyData(item, entry)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   223
            idx = self.GenerateVariablesGridBranch(item, entry["children"], colnames, idx)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   224
            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
   225
                item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
2056
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   226
                no_more_items = not item.IsOk()
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   227
        
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   228
        if not no_more_items:
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   229
            to_delete = []
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   230
            while item.IsOk():
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   231
                to_delete.append(item)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   232
                item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie)
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   233
            for item in to_delete:
0a23fe9594e0 Fix bug with VariablesList on Windows
laurent
parents: 2055
diff changeset
   234
                self.VariablesGrid.Delete(item)
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   235
        
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   236
        return idx
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   237
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   238
    def OnVariablesGridLeftClick(self, event):
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   239
        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
   240
        if item.IsOk():
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   241
            entry = self.VariablesGrid.GetItemPyData(item)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   242
            data_type = entry.get("Type", "")
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   243
            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
   244
            
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   245
            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
   246
                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
   247
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   248
                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
   249
                entry_subindex = self.Controler.ExtractHexDecValue(entry.get("SubIndex", "0"))
2048
5726f2bbdace reflected changes in beremiz extension mechanism
Edouard Tisserant
parents: 2043
diff changeset
   250
                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
   251
                if pdo_mapping == "R":
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   252
                    dir = "%I"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   253
                else:
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   254
                    dir = "%Q"
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   255
                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
   256
                           ".".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
   257
                
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   258
                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
   259
                dragSource = wx.DropSource(self.VariablesGrid)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   260
                dragSource.SetData(data)
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   261
                dragSource.DoDragDrop()
2089
3f5c41f3d47f Fix bug when Drag'n Dropping located variables on Windows
Laurent Bessard
parents: 2072
diff changeset
   262
                return
2038
6f78c4ac22f9 Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents: 2037
diff changeset
   263
            
2022
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   264
        event.Skip()
c2295d311402 First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff changeset
   265
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   266
    def OnEthercatNodeEditorResize(self, event):
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   267
        self.EthercatNodeEditor.GetBestSize()
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   268
        xstart, ystart = self.EthercatNodeEditor.GetViewStart()
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   269
        window_size = self.EthercatNodeEditor.GetClientSize()
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   270
        maxx, maxy = self.EthercatNodeEditor.GetMinSize()
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   271
        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
   272
        posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))
2095
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   273
        self.EthercatNodeEditor.Scroll(posx, posy)
6733a7c5c897 Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 2089
diff changeset
   274
        self.EthercatNodeEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, 
2058
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   275
                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
   276
        event.Skip()
b3bc00dae385 Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents: 2056
diff changeset
   277
2053
5998beb54a6c refactoring
laurent
parents: 2048
diff changeset
   278
CIA402NodeEditor = NodeEditor