author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Mon, 30 May 2022 15:30:51 +0200 | |
branch | wxPython4 |
changeset 3491 | 88c4b18453d5 |
parent 3303 | 0ffb41625592 |
child 3572 | b46af5b80c7d |
permissions | -rw-r--r-- |
2165
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
1 |
#!/usr/bin/env python |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
3 |
|
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
4 |
# This file is part of Beremiz |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
5 |
# |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
6 |
# Copyright (C) 2011-2014: Laurent BESSARD, Edouard TISSERANT |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
7 |
# RTES Lab : CRKim, JBLee, youcu |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
8 |
# Higen Motor : Donggu Kang |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
9 |
# |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2152
diff
changeset
|
11 |
|
2405
af050469fc5c
clean etherlab: pylint, W1618 # (no-absolute-import) import missing `from __future__ import absolute_import`
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2395
diff
changeset
|
12 |
from __future__ import absolute_import |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
13 |
from __future__ import division |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
14 |
import os |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
15 |
import re |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
16 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
17 |
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
|
18 |
import wx.grid |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
19 |
import wx.adv |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
20 |
import wx.lib.buttons |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
21 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
22 |
from plcopen.structures import IEC_KEYWORDS, TestIdentifier |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
23 |
from controls import CustomGrid, CustomTable, FolderTree |
2392
aad985da14f7
clean etherlab: pylint, C0412 # (ungrouped-imports) Imports from package X are not grouped
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
24 |
from controls.CustomStyledTextCtrl import NAVIGATION_KEYS |
2071
37d603e91a43
Fix import after integration of plcopeneditor into Beremiz
Laurent Bessard
parents:
2067
diff
changeset
|
25 |
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor, SCROLLBAR_UNIT |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
26 |
from util.BitmapLibrary import GetBitmap |
2392
aad985da14f7
clean etherlab: pylint, C0412 # (ungrouped-imports) Imports from package X are not grouped
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
27 |
from util.TranslationCatalogs import NoTranslate |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
28 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
29 |
# ----------------------------------------------------------------------- |
2405
af050469fc5c
clean etherlab: pylint, W1618 # (no-absolute-import) import missing `from __future__ import absolute_import`
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2395
diff
changeset
|
30 |
from etherlab.EtherCATManagementEditor import EtherCATManagementTreebook, MasterStatePanelClass |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
31 |
# ----------------------------------------------------------------------- |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
32 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
33 |
[ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
34 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
35 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
36 |
def GetVariablesTableColnames(position=False): |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2371
diff
changeset
|
37 |
_ = NoTranslate |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
38 |
colname = ["#"] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
39 |
if position: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
40 |
colname.append(_("Position")) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
41 |
return colname + [_("Name"), _("Index"), _("SubIndex"), _("Type"), _("Access")] |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
42 |
|
2370
e40f3914e55f
cleanup etherlab: pep8, E305 expected 2 blank lines after class or function definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2367
diff
changeset
|
43 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
44 |
ACCESS_TYPES = { |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
45 |
'ro': 'R', |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
46 |
'wo': 'W', |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
47 |
'rw': 'R/W'} |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
48 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
49 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
50 |
def GetAccessValue(access, pdo_mapping): |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
51 |
value = "SDO: %s" % ACCESS_TYPES.get(access, "") |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
52 |
if pdo_mapping != "": |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
53 |
value += ", PDO: %s" % pdo_mapping |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
54 |
return value |
2034 | 55 |
|
2370
e40f3914e55f
cleanup etherlab: pep8, E305 expected 2 blank lines after class or function definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2367
diff
changeset
|
56 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
57 |
VARIABLES_FILTERS = [ |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
58 |
(_("All"), (0x0000, 0xffff)), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
59 |
(_("Communication Parameters"), (0x1000, 0x1fff)), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
60 |
(_("Manufacturer Specific"), (0x2000, 0x5fff)), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
61 |
(_("Standardized Device Profile"), (0x6000, 0x9fff))] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
62 |
|
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
63 |
VARIABLE_INDEX_FILTER_FORMAT = _("Variable Index: #x%4.4X") |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
64 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
65 |
ETHERCAT_INDEX_MODEL = re.compile("#x([0-9a-fA-F]{0,4})$") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
66 |
ETHERCAT_SUBINDEX_MODEL = re.compile("#x([0-9a-fA-F]{0,2})$") |
2439
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
67 |
LOCATION_MODEL = re.compile(r"(?:%[IQM](?:[XBWLD]?([0-9]+(?:\.[0-9]+)*)))$") |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
68 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
69 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
70 |
class NodeVariablesSizer(wx.FlexGridSizer): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
71 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
72 |
def __init__(self, parent, controler, position_column=False): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
73 |
wx.FlexGridSizer.__init__(self, cols=1, hgap=0, rows=2, vgap=5) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
74 |
self.AddGrowableCol(0) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
75 |
self.AddGrowableRow(1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
76 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
77 |
self.Controler = controler |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
78 |
self.PositionColumn = position_column |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
79 |
|
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
80 |
self.VariablesFilter = wx.ComboBox(parent, style=wx.TE_PROCESS_ENTER) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
81 |
self.VariablesFilter.Bind(wx.EVT_COMBOBOX, self.OnVariablesFilterChanged) |
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
82 |
self.VariablesFilter.Bind(wx.EVT_TEXT_ENTER, self.OnVariablesFilterChanged) |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
83 |
self.VariablesFilter.Bind(wx.EVT_CHAR, self.OnVariablesFilterKeyDown) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
84 |
self.Add(self.VariablesFilter, flag=wx.GROW) |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
85 |
|
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
86 |
self.VariablesGrid = wx.adv.TreeListCtrl(parent, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
87 |
style=wx.TR_DEFAULT_STYLE | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
88 |
wx.TR_ROW_LINES | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
89 |
wx.TR_COLUMN_LINES | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
90 |
wx.TR_HIDE_ROOT | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
91 |
wx.TR_FULL_ROW_HIGHLIGHT) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
92 |
self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
93 |
self.OnVariablesGridLeftClick) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
94 |
self.Add(self.VariablesGrid, flag=wx.GROW) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
95 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
96 |
self.Filters = [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
97 |
for desc, value in VARIABLES_FILTERS: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
98 |
self.VariablesFilter.Append(desc) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
99 |
self.Filters.append(value) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
100 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
101 |
self.VariablesFilter.SetSelection(0) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
102 |
self.CurrentFilter = self.Filters[0] |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
103 |
self.VariablesFilterFirstCharacter = True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
104 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
105 |
if position_column: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
106 |
for colname, colsize, colalign in zip(GetVariablesTableColnames(position_column), |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
107 |
[40, 80, 350, 80, 100, 80, 150], |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
108 |
[wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_LEFT, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
109 |
wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_LEFT, |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
110 |
wx.ALIGN_LEFT]): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
111 |
self.VariablesGrid.AddColumn(_(colname), colsize, colalign) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
112 |
self.VariablesGrid.SetMainColumn(2) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
113 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
114 |
for colname, colsize, colalign in zip(GetVariablesTableColnames(), |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
115 |
[40, 350, 80, 100, 80, 150], |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
116 |
[wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
117 |
wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
118 |
self.VariablesGrid.AddColumn(_(colname), colsize, colalign) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
119 |
self.VariablesGrid.SetMainColumn(1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
120 |
|
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 |
def RefreshView(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
122 |
entries = self.Controler.GetSlaveVariables(self.CurrentFilter) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
123 |
self.RefreshVariablesGrid(entries) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
124 |
|
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
125 |
def RefreshVariablesGrid(self, entries): |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
126 |
root = self.VariablesGrid.GetRootItem() |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
127 |
if not root.IsOk(): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
128 |
root = self.VariablesGrid.AddRoot(_("Slave entries")) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
129 |
self.GenerateVariablesGridBranch(root, entries, GetVariablesTableColnames(self.PositionColumn)) |
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
130 |
self.VariablesGrid.Expand(root) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
131 |
|
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
132 |
def GenerateVariablesGridBranch(self, root, entries, colnames, idx=0): |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
133 |
item, root_cookie = self.VariablesGrid.GetFirstChild(root) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
134 |
|
2056 | 135 |
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
|
136 |
for entry in entries: |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
137 |
idx += 1 |
2056 | 138 |
if no_more_items: |
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
139 |
item = self.VariablesGrid.AppendItem(root, "") |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
140 |
for col, colname in enumerate(colnames): |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
141 |
if col == 0: |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
142 |
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
|
143 |
else: |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
144 |
value = entry.get(colname, "") |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
145 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
146 |
if value is None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
147 |
value = "" |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
148 |
if colname == "Access": |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
149 |
value = GetAccessValue(value, entry.get("PDOMapping", "")) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
150 |
self.VariablesGrid.SetItemText(item, value, col) |
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
151 |
if entry["PDOMapping"] == "": |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
152 |
self.VariablesGrid.SetItemBackgroundColour(item, wx.LIGHT_GREY) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
153 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
154 |
self.VariablesGrid.SetItemBackgroundColour(item, wx.WHITE) |
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
155 |
self.VariablesGrid.SetItemPyData(item, entry) |
2056 | 156 |
idx = self.GenerateVariablesGridBranch(item, entry["children"], colnames, idx) |
157 |
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
|
158 |
item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie) |
2056 | 159 |
no_more_items = not item.IsOk() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
160 |
|
2056 | 161 |
if not no_more_items: |
162 |
to_delete = [] |
|
163 |
while item.IsOk(): |
|
164 |
to_delete.append(item) |
|
165 |
item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie) |
|
166 |
for item in to_delete: |
|
167 |
self.VariablesGrid.Delete(item) |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
168 |
|
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
169 |
return idx |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
170 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
171 |
def OnVariablesFilterChanged(self, event): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
172 |
filter = self.VariablesFilter.GetSelection() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
173 |
if filter != -1: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
174 |
self.CurrentFilter = self.Filters[filter] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
175 |
self.RefreshView() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
176 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
177 |
try: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
178 |
value = self.VariablesFilter.GetValue() |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
179 |
if value == "": |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
180 |
self.CurrentFilter = self.Filters[0] |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
181 |
self.VariablesFilter.SetSelection(0) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
182 |
else: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
183 |
result = ETHERCAT_INDEX_MODEL.match(value) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
184 |
if result is not None: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
185 |
value = result.group(1) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
186 |
index = int(value, 16) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
187 |
self.CurrentFilter = (index, index) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
188 |
self.VariablesFilter.SetValue(VARIABLE_INDEX_FILTER_FORMAT % index) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
189 |
self.RefreshView() |
2353
8f1a2846b2f5
cleanup etherlab: pep8, E722 do not use bare except
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
190 |
except Exception: |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
191 |
if self.CurrentFilter in self.Filters: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
192 |
self.VariablesFilter.SetSelection(self.Filters.index(self.CurrentFilter)) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
193 |
else: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
194 |
self.VariablesFilter.SetValue(VARIABLE_INDEX_FILTER_FORMAT % self.CurrentFilter[0]) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
195 |
self.VariablesFilterFirstCharacter = True |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
196 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
197 |
|
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
198 |
def OnVariablesFilterKeyDown(self, event): |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
199 |
if self.VariablesFilterFirstCharacter: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
200 |
keycode = event.GetKeyCode() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
201 |
if keycode not in [wx.WXK_RETURN, |
2130 | 202 |
wx.WXK_NUMPAD_ENTER]: |
203 |
self.VariablesFilterFirstCharacter = False |
|
204 |
if keycode not in NAVIGATION_KEYS: |
|
205 |
self.VariablesFilter.SetValue("") |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
206 |
if keycode not in [wx.WXK_DELETE, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
207 |
wx.WXK_NUMPAD_DELETE, |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
208 |
wx.WXK_BACK]: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
209 |
event.Skip() |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
210 |
else: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
211 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
212 |
|
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
213 |
def OnVariablesGridLeftClick(self, event): |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
214 |
item, _flags, col = self.VariablesGrid.HitTest(event.GetPosition()) |
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
215 |
if item.IsOk(): |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
216 |
entry = self.VariablesGrid.GetItemPyData(item) |
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
217 |
data_type = entry.get("Type", "") |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
218 |
data_size = self.Controler.GetSizeOfType(data_type) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
219 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
220 |
if col == -1 and data_size is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
221 |
pdo_mapping = entry.get("PDOMapping", "") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
222 |
access = entry.get("Access", "") |
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
223 |
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
|
224 |
entry_subindex = self.Controler.ExtractHexDecValue(entry.get("SubIndex", "0")) |
2124
1f2c3fdd70d0
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
Laurent Bessard
parents:
2110
diff
changeset
|
225 |
location = self.Controler.GetCurrentLocation() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
226 |
if self.PositionColumn: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
227 |
slave_pos = self.Controler.ExtractHexDecValue(entry.get("Position", "0")) |
2124
1f2c3fdd70d0
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
Laurent Bessard
parents:
2110
diff
changeset
|
228 |
location += (slave_pos,) |
1f2c3fdd70d0
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
Laurent Bessard
parents:
2110
diff
changeset
|
229 |
node_name = self.Controler.GetSlaveName(slave_pos) |
2038
6f78c4ac22f9
Replacing wx.Grid control by a wx.TreeListCtrl for displaying slaves entries
laurent
parents:
2037
diff
changeset
|
230 |
else: |
2124
1f2c3fdd70d0
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
Laurent Bessard
parents:
2110
diff
changeset
|
231 |
node_name = self.Controler.CTNName() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
232 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
233 |
if pdo_mapping != "": |
2124
1f2c3fdd70d0
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
Laurent Bessard
parents:
2110
diff
changeset
|
234 |
var_name = "%s_%4.4x_%2.2x" % (node_name, entry_index, entry_subindex) |
1f2c3fdd70d0
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
Laurent Bessard
parents:
2110
diff
changeset
|
235 |
if pdo_mapping == "T": |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
236 |
dir = "%I" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
237 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
238 |
dir = "%Q" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
239 |
location = "%s%s" % (dir, data_size) + \ |
2392
aad985da14f7
clean etherlab: pylint, C0412 # (ungrouped-imports) Imports from package X are not grouped
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
240 |
".".join(map(str, location + (entry_index, entry_subindex))) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
241 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
242 |
data = wx.TextDataObject(str((location, "location", data_type, var_name, "", access))) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
243 |
dragSource = wx.DropSource(self.VariablesGrid) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
244 |
dragSource.SetData(data) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
245 |
dragSource.DoDragDrop() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
246 |
return |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
247 |
|
2124
1f2c3fdd70d0
Fixed bugs in drag'n drop from variables panel in master and slaves editor panel
Laurent Bessard
parents:
2110
diff
changeset
|
248 |
elif self.PositionColumn: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
249 |
location = self.Controler.GetCurrentLocation() +\ |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
250 |
(slave_pos, entry_index, entry_subindex) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
251 |
data = wx.TextDataObject(str((location, "variable", access))) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
252 |
dragSource = wx.DropSource(self.VariablesGrid) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
253 |
dragSource.SetData(data) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
254 |
dragSource.DoDragDrop() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
255 |
return |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
256 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
257 |
event.Skip() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
258 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
259 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
260 |
class NodeEditor(ConfTreeNodeEditor): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
261 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
262 |
CONFNODEEDITOR_TABS = [ |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
263 |
(_("Ethercat node"), "_create_EthercatNodeEditor"), |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
264 |
# Add Notebook Tab for EtherCAT Management Treebook |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
265 |
(_("EtherCAT Management"), "_create_EtherCATManagementEditor") |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
266 |
] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
267 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
268 |
def _create_EthercatNodeEditor(self, prnt): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
269 |
self.EthercatNodeEditor = wx.Panel(prnt, style=wx.TAB_TRAVERSAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
270 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
271 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
272 |
main_sizer.AddGrowableCol(0) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
273 |
main_sizer.AddGrowableRow(1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
274 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
275 |
variables_label = wx.StaticText(self.EthercatNodeEditor, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
276 |
label=_('Variable entries:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
277 |
main_sizer.Add(variables_label, border=10, flag=wx.TOP | wx.LEFT | wx.RIGHT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
278 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
279 |
self.NodeVariables = NodeVariablesSizer(self.EthercatNodeEditor, self.Controler) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
280 |
main_sizer.Add(self.NodeVariables, border=10, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
281 |
flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
282 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
283 |
self.EthercatNodeEditor.SetSizer(main_sizer) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
284 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
285 |
return self.EthercatNodeEditor |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
286 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
287 |
def __init__(self, parent, controler, window): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
288 |
ConfTreeNodeEditor.__init__(self, parent, controler, window) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
289 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
290 |
# add Contoler for use EthercatSlave.py Method |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
291 |
self.Controler = controler |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
292 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
293 |
def GetBufferState(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
294 |
return False, False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
295 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
296 |
def RefreshView(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
297 |
ConfTreeNodeEditor.RefreshView(self) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
298 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
299 |
self.NodeVariables.RefreshView() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
300 |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
301 |
# -------------------For EtherCAT Management ---------------------------------------------- |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
302 |
def _create_EtherCATManagementEditor(self, prnt): |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
303 |
self.EtherCATManagementEditor = wx.ScrolledWindow(prnt, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
304 |
style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL) |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
305 |
self.EtherCATManagementEditor.Bind(wx.EVT_SIZE, self.OnResize) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
306 |
|
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
307 |
self.EtherCATManagermentEditor_Main_Sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
308 |
self.EtherCATManagermentEditor_Main_Sizer.AddGrowableCol(0) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
309 |
self.EtherCATManagermentEditor_Main_Sizer.AddGrowableRow(0) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
310 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
311 |
self.EtherCATManagementTreebook = EtherCATManagementTreebook(self.EtherCATManagementEditor, self.Controler, self) |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
312 |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
313 |
self.EtherCATManagermentEditor_Main_Sizer.Add(self.EtherCATManagementTreebook, border=10, flag=wx.GROW) |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
314 |
|
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
315 |
self.EtherCATManagementEditor.SetSizer(self.EtherCATManagermentEditor_Main_Sizer) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
316 |
return self.EtherCATManagementEditor |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
317 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
318 |
def OnResize(self, event): |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
319 |
self.EtherCATManagementEditor.GetBestSize() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
320 |
xstart, ystart = self.EtherCATManagementEditor.GetViewStart() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
321 |
window_size = self.EtherCATManagementEditor.GetClientSize() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
322 |
maxx, maxy = self.EtherCATManagementEditor.GetMinSize() |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
323 |
posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
324 |
posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
325 |
self.EtherCATManagementEditor.Scroll(posx, posy) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
326 |
self.EtherCATManagementEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
327 |
maxx // SCROLLBAR_UNIT, |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
328 |
maxy // SCROLLBAR_UNIT, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
329 |
posx, posy) |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
330 |
event.Skip() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
331 |
# ------------------------------------------------------------------------------------------------------- |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
332 |
|
2370
e40f3914e55f
cleanup etherlab: pep8, E305 expected 2 blank lines after class or function definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2367
diff
changeset
|
333 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
334 |
CIA402NodeEditor = NodeEditor |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
335 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
336 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
337 |
def GetProcessVariablesTableColnames(): |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2371
diff
changeset
|
338 |
_ = NoTranslate |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
339 |
return ["#", _("Name"), |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
340 |
_("Read from (nodeid, index, subindex)"), |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
341 |
_("Write to (nodeid, index, subindex)"), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
342 |
_("Description")] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
343 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
344 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
345 |
class ProcessVariablesTable(CustomTable): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
346 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
347 |
def GetValue(self, row, col): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
348 |
if row < self.GetNumberRows(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
349 |
if col == 0: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
350 |
return row + 1 |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
351 |
colname = self.GetColLabelValue(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
352 |
if colname.startswith("Read from"): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
353 |
value = self.data[row].get("ReadFrom", "") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
354 |
if value == "": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
355 |
return value |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
356 |
return "%d, #x%0.4X, #x%0.2X" % value |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
357 |
elif colname.startswith("Write to"): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
358 |
value = self.data[row].get("WriteTo", "") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
359 |
if value == "": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
360 |
return value |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
361 |
return "%d, #x%0.4X, #x%0.2X" % value |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
362 |
return self.data[row].get(colname, "") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
363 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
364 |
def SetValue(self, row, col, value): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
365 |
if col < len(self.colnames): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
366 |
colname = self.GetColLabelValue(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
367 |
if colname.startswith("Read from"): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
368 |
self.data[row]["ReadFrom"] = value |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
369 |
elif colname.startswith("Write to"): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
370 |
self.data[row]["WriteTo"] = value |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
371 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
372 |
self.data[row][colname] = value |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
373 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
374 |
def _updateColAttrs(self, grid): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
375 |
""" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
376 |
wx.grid.Grid -> update the column attributes to add the |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
377 |
appropriate renderer given the column name. |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
378 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
379 |
Otherwise default to the default renderer. |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
380 |
""" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
381 |
for row in range(self.GetNumberRows()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
382 |
for col in range(self.GetNumberCols()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
383 |
editor = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
384 |
renderer = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
385 |
colname = self.GetColLabelValue(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
386 |
if colname in ["Name", "Description"]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
387 |
editor = wx.grid.GridCellTextEditor() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
388 |
renderer = wx.grid.GridCellStringRenderer() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
389 |
grid.SetReadOnly(row, col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
390 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
391 |
grid.SetReadOnly(row, col, True) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
392 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
393 |
grid.SetCellEditor(row, col, editor) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
394 |
grid.SetCellRenderer(row, col, renderer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
395 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
396 |
self.ResizeRow(grid, row) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
397 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
398 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
399 |
class ProcessVariableDropTarget(wx.TextDropTarget): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
400 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
401 |
def __init__(self, parent): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
402 |
wx.TextDropTarget.__init__(self) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
403 |
self.ParentWindow = parent |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
404 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
405 |
def OnDropText(self, x, y, data): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
406 |
self.ParentWindow.Select() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
407 |
x, y = self.ParentWindow.ProcessVariablesGrid.CalcUnscrolledPosition(x, y) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
408 |
col = self.ParentWindow.ProcessVariablesGrid.XToCol(x) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
409 |
row = self.ParentWindow.ProcessVariablesGrid.YToRow(y - self.ParentWindow.ProcessVariablesGrid.GetColLabelSize()) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
410 |
message = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
411 |
try: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
412 |
values = eval(data) |
2353
8f1a2846b2f5
cleanup etherlab: pep8, E722 do not use bare except
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
413 |
except Exception: |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
414 |
message = _("Invalid value \"%s\" for process variable") % data |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
415 |
values = None |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
416 |
if not isinstance(values, tuple): |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
417 |
message = _("Invalid value \"%s\" for process variable") % data |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
418 |
values = None |
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
419 |
if values is not None and col != wx.NOT_FOUND and row != wx.NOT_FOUND and 2 <= col <= 3: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
420 |
location = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
421 |
if values[1] == "location": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
422 |
result = LOCATION_MODEL.match(values[0]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
423 |
if result is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
424 |
location = map(int, result.group(1).split('.')) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
425 |
master_location = self.ParentWindow.GetMasterLocation() |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
426 |
if master_location == tuple(location[:len(master_location)]) and \ |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
427 |
len(location) - len(master_location) == 3: |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
428 |
values = tuple(location[len(master_location):]) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
429 |
var_type = self.ParentWindow.Controler.GetSlaveVariableDataType(*values) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
430 |
if col == 2: |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
431 |
other_values = self.ParentWindow.ProcessVariablesTable.GetValueByName(row, "WriteTo") |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
432 |
else: |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
433 |
other_values = self.ParentWindow.ProcessVariablesTable.GetValueByName(row, "ReadFrom") |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
434 |
if other_values != "": |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
435 |
other_type = self.ParentWindow.Controler.GetSlaveVariableDataType(*other_values) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
436 |
else: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
437 |
other_type = None |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
438 |
if other_type is None or var_type == other_type: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
439 |
if col == 2: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
440 |
self.ParentWindow.ProcessVariablesTable.SetValueByName(row, "ReadFrom", values) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
441 |
else: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
442 |
self.ParentWindow.ProcessVariablesTable.SetValueByName(row, "WriteTo", values) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
443 |
self.ParentWindow.SaveProcessVariables() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
444 |
self.ParentWindow.RefreshProcessVariables() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
445 |
else: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
446 |
message = _("'Read from' and 'Write to' variables types are not compatible") |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
447 |
else: |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
448 |
message = _("Invalid value \"%s\" for process variable") % data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
449 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
450 |
if message is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
451 |
wx.CallAfter(self.ShowMessage, message) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
452 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
453 |
def ShowMessage(self, message): |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
454 |
message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
455 |
message.ShowModal() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
456 |
message.Destroy() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
457 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
458 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
459 |
def GetStartupCommandsTableColnames(): |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2371
diff
changeset
|
460 |
_ = NoTranslate |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
461 |
return [_("Position"), _("Index"), _("Subindex"), _("Value"), _("Description")] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
462 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
463 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
464 |
class StartupCommandDropTarget(wx.TextDropTarget): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
465 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
466 |
def __init__(self, parent): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
467 |
wx.TextDropTarget.__init__(self) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
468 |
self.ParentWindow = parent |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
469 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
470 |
def OnDropText(self, x, y, data): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
471 |
self.ParentWindow.Select() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
472 |
message = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
473 |
try: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
474 |
values = eval(data) |
2353
8f1a2846b2f5
cleanup etherlab: pep8, E722 do not use bare except
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
475 |
except Exception: |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
476 |
message = _("Invalid value \"%s\" for startup command") % data |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
477 |
values = None |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
478 |
if not isinstance(values, tuple): |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
479 |
message = _("Invalid value \"%s\" for startup command") % data |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
480 |
values = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
481 |
if values is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
482 |
location = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
483 |
if values[1] == "location": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
484 |
result = LOCATION_MODEL.match(values[0]) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
485 |
if result is not None and len(values) > 5: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
486 |
location = map(int, result.group(1).split('.')) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
487 |
access = values[5] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
488 |
elif values[1] == "variable": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
489 |
location = values[0] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
490 |
access = values[2] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
491 |
if location is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
492 |
master_location = self.ParentWindow.GetMasterLocation() |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
493 |
if master_location == tuple(location[:len(master_location)]) and \ |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
494 |
len(location) - len(master_location) == 3: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
495 |
if access in ["wo", "rw"]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
496 |
self.ParentWindow.AddStartupCommand(*location[len(master_location):]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
497 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
498 |
message = _("Entry can't be write through SDO") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
499 |
else: |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
500 |
message = _("Invalid value \"%s\" for startup command") % data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
501 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
502 |
if message is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
503 |
wx.CallAfter(self.ShowMessage, message) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
504 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
505 |
def ShowMessage(self, message): |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
506 |
message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
507 |
message.ShowModal() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
508 |
message.Destroy() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
509 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
510 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
511 |
class StartupCommandsTable(CustomTable): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
512 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
513 |
""" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
514 |
A custom wx.grid.Grid Table using user supplied data |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
515 |
""" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
516 |
def __init__(self, parent, data, colnames): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
517 |
# The base class must be initialized *first* |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
518 |
CustomTable.__init__(self, parent, data, colnames) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
519 |
self.old_value = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
520 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
521 |
def GetValue(self, row, col): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
522 |
if row < self.GetNumberRows(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
523 |
colname = self.GetColLabelValue(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
524 |
value = self.data[row].get(colname, "") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
525 |
if colname == "Index": |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
526 |
return "#x%0.4X" % value |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
527 |
elif colname == "Subindex": |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
528 |
return "#x%0.2X" % value |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
529 |
return value |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
530 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
531 |
def SetValue(self, row, col, value): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
532 |
if col < len(self.colnames): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
533 |
colname = self.GetColLabelValue(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
534 |
if colname in ["Index", "Subindex"]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
535 |
if colname == "Index": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
536 |
result = ETHERCAT_INDEX_MODEL.match(value) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
537 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
538 |
result = ETHERCAT_SUBINDEX_MODEL.match(value) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
539 |
if result is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
540 |
return |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
541 |
value = int(result.group(1), 16) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
542 |
elif colname == "Value": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
543 |
value = int(value) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
544 |
elif colname == "Position": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
545 |
self.old_value = self.data[row][colname] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
546 |
value = int(value) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
547 |
self.data[row][colname] = value |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
548 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
549 |
def GetOldValue(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
550 |
return self.old_value |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
551 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
552 |
def _updateColAttrs(self, grid): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
553 |
""" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
554 |
wx.grid.Grid -> update the column attributes to add the |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
555 |
appropriate renderer given the column name. |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
556 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
557 |
Otherwise default to the default renderer. |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
558 |
""" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
559 |
for row in range(self.GetNumberRows()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
560 |
for col in range(self.GetNumberCols()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
561 |
editor = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
562 |
renderer = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
563 |
colname = self.GetColLabelValue(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
564 |
if colname in ["Position", "Value"]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
565 |
editor = wx.grid.GridCellNumberEditor() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
566 |
renderer = wx.grid.GridCellNumberRenderer() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
567 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
568 |
editor = wx.grid.GridCellTextEditor() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
569 |
renderer = wx.grid.GridCellStringRenderer() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
570 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
571 |
grid.SetCellEditor(row, col, editor) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
572 |
grid.SetCellRenderer(row, col, renderer) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
573 |
grid.SetReadOnly(row, col, False) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
574 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
575 |
self.ResizeRow(grid, row) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
576 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
577 |
def GetCommandIndex(self, position, command_idx): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
578 |
for row, command in enumerate(self.data): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
579 |
if command["Position"] == position and command["command_idx"] == command_idx: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
580 |
return row |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
581 |
return None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
582 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
583 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
584 |
class MasterNodesVariablesSizer(NodeVariablesSizer): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
585 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
586 |
def __init__(self, parent, controler): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
587 |
NodeVariablesSizer.__init__(self, parent, controler, True) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
588 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
589 |
self.CurrentNodesFilter = {} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
590 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
591 |
def SetCurrentNodesFilter(self, nodes_filter): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
592 |
self.CurrentNodesFilter = nodes_filter |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
593 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
594 |
def RefreshView(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
595 |
if self.CurrentNodesFilter is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
596 |
args = self.CurrentNodesFilter.copy() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
597 |
args["limits"] = self.CurrentFilter |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
598 |
entries = self.Controler.GetNodesVariables(**args) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
599 |
self.RefreshVariablesGrid(entries) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
600 |
|
2370
e40f3914e55f
cleanup etherlab: pep8, E305 expected 2 blank lines after class or function definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2367
diff
changeset
|
601 |
|
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
602 |
NODE_POSITION_FILTER_FORMAT = _("Node Position: %d") |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
603 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
604 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
605 |
class MasterEditor(ConfTreeNodeEditor): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
606 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
607 |
CONFNODEEDITOR_TABS = [ |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
608 |
(_("Network"), "_create_EthercatMasterEditor"), |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
609 |
(_("Master State"), "_create_MasterStateEditor") |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
610 |
] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
611 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
612 |
def _create_MasterStateEditor(self, prnt): |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
613 |
self.MasterStateEditor = wx.ScrolledWindow(prnt, style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL) |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
614 |
self.MasterStateEditor.Bind(wx.EVT_SIZE, self.OnResize) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
615 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
616 |
self.MasterStateEditor_Panel_Main_Sizer = wx.BoxSizer(wx.VERTICAL) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
617 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
618 |
self.MasterStateEditor_Panel = MasterStatePanelClass(self.MasterStateEditor, self.Controler) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
619 |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
620 |
self.MasterStateEditor_Panel_Main_Sizer.Add(self.MasterStateEditor_Panel, border=10, flag=wx.GROW) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
621 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
622 |
self.MasterStateEditor.SetSizer(self.MasterStateEditor_Panel_Main_Sizer) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
623 |
return self.MasterStateEditor |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
624 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
625 |
def OnResize2(self, event): |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
626 |
self.MasterStateEditor.GetBestSize() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
627 |
xstart, ystart = self.MasterStateEditor.GetViewStart() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
628 |
window_size = self.MasterStateEditor.GetClientSize() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
629 |
maxx, maxy = self.MasterStateEditor.GetMinSize() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
630 |
posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
631 |
posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
632 |
self.MasterStateEditor.Scroll(posx, posy) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
633 |
self.MasterStateEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
634 |
maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
635 |
event.Skip() |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
636 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
637 |
def _create_EthercatMasterEditor(self, prnt): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
638 |
self.EthercatMasterEditor = wx.ScrolledWindow(prnt, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
639 |
style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
640 |
self.EthercatMasterEditor.Bind(wx.EVT_SIZE, self.OnResize) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
641 |
|
2134
6f4b08348a60
Fixed bug on Windows with sizers on Windows in Master Editor panel when its size changed
Laurent Bessard
parents:
2130
diff
changeset
|
642 |
self.EthercatMasterEditorSizer = wx.BoxSizer(wx.VERTICAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
643 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
644 |
self.NodesFilter = wx.ComboBox(self.EthercatMasterEditor, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
645 |
style=wx.TE_PROCESS_ENTER) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
646 |
self.Bind(wx.EVT_COMBOBOX, self.OnNodesFilterChanged, self.NodesFilter) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
647 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnNodesFilterChanged, self.NodesFilter) |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
648 |
self.NodesFilter.Bind(wx.EVT_CHAR, self.OnNodesFilterKeyDown) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
649 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
650 |
process_variables_header = wx.BoxSizer(wx.HORIZONTAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
651 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
652 |
process_variables_label = wx.StaticText(self.EthercatMasterEditor, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
653 |
label=_("Process variables mapped between nodes:")) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
654 |
process_variables_header.Add(process_variables_label, 1, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
655 |
flag=wx.ALIGN_CENTER_VERTICAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
656 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
657 |
for name, bitmap, help in [ |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
658 |
("AddVariableButton", "add_element", _("Add process variable")), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
659 |
("DeleteVariableButton", "remove_element", _("Remove process variable")), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
660 |
("UpVariableButton", "up", _("Move process variable up")), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
661 |
("DownVariableButton", "down", _("Move process variable down"))]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
662 |
button = wx.lib.buttons.GenBitmapButton(self.EthercatMasterEditor, bitmap=GetBitmap(bitmap), |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
663 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
664 |
button.SetToolTip(help) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
665 |
setattr(self, name, button) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
666 |
process_variables_header.Add(button, border=5, flag=wx.LEFT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
667 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
668 |
self.ProcessVariablesGrid = CustomGrid(self.EthercatMasterEditor, style=wx.VSCROLL) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
669 |
self.ProcessVariablesGrid.SetMinSize(wx.Size(0, 150)) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
670 |
self.ProcessVariablesGrid.SetDropTarget(ProcessVariableDropTarget(self)) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
671 |
self.ProcessVariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGING, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
672 |
self.OnProcessVariablesGridCellChange) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
673 |
self.ProcessVariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
674 |
self.OnProcessVariablesGridCellLeftClick) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
675 |
self.ProcessVariablesGrid.Bind(wx.EVT_KEY_DOWN, self.OnProcessVariablesGridKeyDown) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
676 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
677 |
startup_commands_header = wx.BoxSizer(wx.HORIZONTAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
678 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
679 |
startup_commands_label = wx.StaticText(self.EthercatMasterEditor, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
680 |
label=_("Startup service variables assignments:")) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
681 |
startup_commands_header.Add(startup_commands_label, 1, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
682 |
flag=wx.ALIGN_CENTER_VERTICAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
683 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
684 |
for name, bitmap, help in [ |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
685 |
("AddCommandButton", "add_element", _("Add startup service variable")), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
686 |
("DeleteCommandButton", "remove_element", _("Remove startup service variable"))]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
687 |
button = wx.lib.buttons.GenBitmapButton(self.EthercatMasterEditor, bitmap=GetBitmap(bitmap), |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
688 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
689 |
button.SetToolTip(help) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
690 |
setattr(self, name, button) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
691 |
startup_commands_header.Add(button, border=5, flag=wx.LEFT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
692 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
693 |
self.StartupCommandsGrid = CustomGrid(self.EthercatMasterEditor, style=wx.VSCROLL) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
694 |
self.StartupCommandsGrid.SetDropTarget(StartupCommandDropTarget(self)) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
695 |
self.StartupCommandsGrid.SetMinSize(wx.Size(0, 150)) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
696 |
self.StartupCommandsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGING, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
697 |
self.OnStartupCommandsGridCellChange) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
698 |
self.StartupCommandsGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
699 |
self.OnStartupCommandsGridEditorShow) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
700 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
701 |
self.NodesVariables = MasterNodesVariablesSizer(self.EthercatMasterEditor, self.Controler) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
702 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
703 |
main_staticbox = wx.StaticBox(self.EthercatMasterEditor, label=_("Node filter:")) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
704 |
staticbox_sizer = wx.StaticBoxSizer(main_staticbox, wx.VERTICAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
705 |
self.EthercatMasterEditorSizer.Add(staticbox_sizer, 0, border=10, flag=wx.GROW | wx.ALL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
706 |
|
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
707 |
main_staticbox_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=0) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
708 |
main_staticbox_sizer.AddGrowableCol(0) |
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
709 |
main_staticbox_sizer.AddGrowableRow(2) |
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
710 |
main_staticbox_sizer.AddGrowableRow(4) |
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
711 |
main_staticbox_sizer.AddGrowableRow(5) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
712 |
staticbox_sizer.Add(main_staticbox_sizer, 1, flag=wx.GROW) |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
713 |
main_staticbox_sizer.Add(self.NodesFilter, border=5, flag=wx.GROW | wx.ALL) |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
714 |
main_staticbox_sizer.Add(process_variables_header, border=5, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
715 |
flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
716 |
main_staticbox_sizer.Add(self.ProcessVariablesGrid, 1, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
717 |
border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
718 |
main_staticbox_sizer.Add(startup_commands_header, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
719 |
border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
720 |
main_staticbox_sizer.Add(self.StartupCommandsGrid, 1, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
721 |
border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
722 |
|
2134
6f4b08348a60
Fixed bug on Windows with sizers on Windows in Master Editor panel when its size changed
Laurent Bessard
parents:
2130
diff
changeset
|
723 |
second_staticbox = wx.StaticBox(self.EthercatMasterEditor, label=_("Nodes variables filter:")) |
6f4b08348a60
Fixed bug on Windows with sizers on Windows in Master Editor panel when its size changed
Laurent Bessard
parents:
2130
diff
changeset
|
724 |
second_staticbox_sizer = wx.StaticBoxSizer(second_staticbox, wx.VERTICAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
725 |
second_staticbox_sizer.Add(self.NodesVariables, 1, border=5, flag=wx.GROW | wx.ALL) |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
726 |
|
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
727 |
main_staticbox_sizer.Add(second_staticbox_sizer, 1, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
728 |
border=5, flag=wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
729 |
|
2134
6f4b08348a60
Fixed bug on Windows with sizers on Windows in Master Editor panel when its size changed
Laurent Bessard
parents:
2130
diff
changeset
|
730 |
self.EthercatMasterEditor.SetSizer(self.EthercatMasterEditorSizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
731 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
732 |
return self.EthercatMasterEditor |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
733 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
734 |
def __init__(self, parent, controler, window): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
735 |
ConfTreeNodeEditor.__init__(self, parent, controler, window) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
736 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
737 |
# ------------------------------------------------------------------ |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
738 |
self.Controler = controler |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
739 |
# ------------------------------------------------------------------ |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
740 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
741 |
self.ProcessVariables = [] |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
742 |
self.CellShown = None |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
743 |
self.NodesFilterFirstCharacter = True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
744 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
745 |
self.ProcessVariablesDefaultValue = {"Name": "", "ReadFrom": "", "WriteTo": "", "Description": ""} |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
746 |
self.ProcessVariablesTable = ProcessVariablesTable(self, [], GetProcessVariablesTableColnames()) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
747 |
self.ProcessVariablesColSizes = [40, 100, 150, 150, 200] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
748 |
self.ProcessVariablesColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
749 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
750 |
self.ProcessVariablesGrid.SetTable(self.ProcessVariablesTable) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
751 |
self.ProcessVariablesGrid.SetButtons({"Add": self.AddVariableButton, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
752 |
"Delete": self.DeleteVariableButton, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
753 |
"Up": self.UpVariableButton, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
754 |
"Down": self.DownVariableButton}) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
755 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
756 |
def _AddVariablesElement(new_row): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
757 |
self.ProcessVariablesTable.InsertRow(new_row, self.ProcessVariablesDefaultValue.copy()) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
758 |
self.SaveProcessVariables() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
759 |
self.ProcessVariablesTable.ResetView(self.ProcessVariablesGrid) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
760 |
return new_row |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
761 |
setattr(self.ProcessVariablesGrid, "_AddRow", _AddVariablesElement) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
762 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
763 |
def _DeleteVariablesElement(row): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
764 |
self.ProcessVariablesTable.RemoveRow(row) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
765 |
self.SaveProcessVariables() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
766 |
self.ProcessVariablesTable.ResetView(self.ProcessVariablesGrid) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
767 |
setattr(self.ProcessVariablesGrid, "_DeleteRow", _DeleteVariablesElement) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
768 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
769 |
def _MoveVariablesElement(row, move): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
770 |
new_row = self.ProcessVariablesTable.MoveRow(row, move) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
771 |
if new_row != row: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
772 |
self.SaveProcessVariables() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
773 |
self.ProcessVariablesTable.ResetView(self.ProcessVariablesGrid) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
774 |
return new_row |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
775 |
setattr(self.ProcessVariablesGrid, "_MoveRow", _MoveVariablesElement) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
776 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
777 |
_refresh_buttons = getattr(self.ProcessVariablesGrid, "RefreshButtons") |
2371
f1f10ceb9341
cleanup etherlab: pep8, E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2370
diff
changeset
|
778 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
779 |
def _RefreshButtons(): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
780 |
if self.NodesFilter.GetSelection() == 0: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
781 |
_refresh_buttons() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
782 |
else: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
783 |
self.AddVariableButton.Enable(False) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
784 |
self.DeleteVariableButton.Enable(False) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
785 |
self.UpVariableButton.Enable(False) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
786 |
self.DownVariableButton.Enable(False) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
787 |
setattr(self.ProcessVariablesGrid, "RefreshButtons", _RefreshButtons) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
788 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
789 |
self.ProcessVariablesGrid.SetRowLabelSize(0) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
790 |
for col in range(self.ProcessVariablesTable.GetNumberCols()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
791 |
attr = wx.grid.GridCellAttr() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
792 |
attr.SetAlignment(self.ProcessVariablesColAlignements[col], wx.ALIGN_CENTRE) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
793 |
self.ProcessVariablesGrid.SetColAttr(col, attr) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
794 |
self.ProcessVariablesGrid.SetColMinimalWidth(col, self.ProcessVariablesColSizes[col]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
795 |
self.ProcessVariablesGrid.AutoSizeColumn(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
796 |
self.ProcessVariablesGrid.RefreshButtons() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
797 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
798 |
self.StartupCommandsDefaultValue = {"Position": 0, "Index": 0, "Subindex": 0, "Value": 0, "Description": ""} |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
799 |
self.StartupCommandsTable = StartupCommandsTable(self, [], GetStartupCommandsTableColnames()) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
800 |
self.StartupCommandsColSizes = [100, 100, 50, 100, 200] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
801 |
self.StartupCommandsColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_LEFT] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
802 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
803 |
self.StartupCommandsGrid.SetTable(self.StartupCommandsTable) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
804 |
self.StartupCommandsGrid.SetButtons({"Add": self.AddCommandButton, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
805 |
"Delete": self.DeleteCommandButton}) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
806 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
807 |
def _AddCommandsElement(new_row): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
808 |
command = self.StartupCommandsDefaultValue.copy() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
809 |
command_idx = self.Controler.AppendStartupCommand(command) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
810 |
self.RefreshStartupCommands() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
811 |
self.RefreshBuffer() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
812 |
return self.StartupCommandsTable.GetCommandIndex(command["Position"], command_idx) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
813 |
setattr(self.StartupCommandsGrid, "_AddRow", _AddCommandsElement) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
814 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
815 |
def _DeleteCommandsElement(row): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
816 |
command = self.StartupCommandsTable.GetRow(row) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
817 |
self.Controler.RemoveStartupCommand(command["Position"], command["command_idx"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
818 |
self.RefreshStartupCommands() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
819 |
self.RefreshBuffer() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
820 |
setattr(self.StartupCommandsGrid, "_DeleteRow", _DeleteCommandsElement) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
821 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
822 |
self.StartupCommandsGrid.SetRowLabelSize(0) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
823 |
for col in range(self.StartupCommandsTable.GetNumberCols()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
824 |
attr = wx.grid.GridCellAttr() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
825 |
attr.SetAlignment(self.StartupCommandsColAlignements[col], wx.ALIGN_CENTRE) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
826 |
self.StartupCommandsGrid.SetColAttr(col, attr) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
827 |
self.StartupCommandsGrid.SetColMinimalWidth(col, self.StartupCommandsColSizes[col]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
828 |
self.StartupCommandsGrid.AutoSizeColumn(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
829 |
self.StartupCommandsGrid.RefreshButtons() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
830 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
831 |
def RefreshBuffer(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
832 |
self.ParentWindow.RefreshTitle() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
833 |
self.ParentWindow.RefreshFileMenu() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
834 |
self.ParentWindow.RefreshEditMenu() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
835 |
self.ParentWindow.RefreshPageTitles() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
836 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
837 |
def GetBufferState(self): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
838 |
return self.Controler.GetBufferState() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
839 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
840 |
def Undo(self): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
841 |
self.Controler.LoadPrevious() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
842 |
self.RefreshView() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
843 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
844 |
def Redo(self): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
845 |
self.Controler.LoadNext() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
846 |
self.RefreshView() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
847 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
848 |
def RefreshView(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
849 |
ConfTreeNodeEditor.RefreshView(self) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
850 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
851 |
self.RefreshNodesFilter() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
852 |
self.RefreshProcessVariables() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
853 |
self.RefreshStartupCommands() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
854 |
self.NodesVariables.RefreshView() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
855 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
856 |
def RefreshNodesFilter(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
857 |
value = self.NodesFilter.GetValue() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
858 |
self.NodesFilter.Clear() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
859 |
self.NodesFilter.Append(_("All")) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
860 |
self.NodesFilterValues = [{}] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
861 |
for vendor_id, vendor_name in self.Controler.GetLibraryVendors(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
862 |
self.NodesFilter.Append(_("%s's nodes") % vendor_name) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
863 |
self.NodesFilterValues.append({"vendor": vendor_id}) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
864 |
self.NodesFilter.Append(_("CIA402 nodes")) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
865 |
self.NodesFilterValues.append({"slave_profile": 402}) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
866 |
if value in self.NodesFilter.GetStrings(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
867 |
self.NodesFilter.SetStringSelection(value) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
868 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
869 |
try: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
870 |
int(value) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
871 |
self.NodesFilter.SetValue(value) |
2353
8f1a2846b2f5
cleanup etherlab: pep8, E722 do not use bare except
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
872 |
except Exception: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
873 |
self.NodesFilter.SetSelection(0) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
874 |
self.RefreshCurrentNodesFilter() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
875 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
876 |
def RefreshCurrentNodesFilter(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
877 |
filter = self.NodesFilter.GetSelection() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
878 |
if filter != -1: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
879 |
self.CurrentNodesFilter = self.NodesFilterValues[filter] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
880 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
881 |
try: |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
882 |
value = self.NodesFilter.GetValue() |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
883 |
if value == "": |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
884 |
self.CurrentNodesFilter = self.NodesFilterValues[0] |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
885 |
self.NodesFilter.SetSelection(0) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
886 |
else: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
887 |
position = int(self.NodesFilter.GetValue()) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
888 |
self.CurrentNodesFilter = {"slave_pos": position} |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
889 |
self.NodesFilter.SetValue(NODE_POSITION_FILTER_FORMAT % position) |
2353
8f1a2846b2f5
cleanup etherlab: pep8, E722 do not use bare except
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
890 |
except Exception: |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
891 |
if self.CurrentNodesFilter in self.NodesFilterValues: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
892 |
self.NodesFilter.SetSelection(self.NodesFilterValues.index(self.CurrentNodesFilter)) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
893 |
else: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
894 |
self.NodesFilter.SetValue(NODE_POSITION_FILTER_FORMAT % self.CurrentNodesFilter["slave_pos"]) |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
895 |
self.NodesFilterFirstCharacter = True |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
896 |
self.NodesVariables.SetCurrentNodesFilter(self.CurrentNodesFilter) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
897 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
898 |
def RefreshProcessVariables(self): |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
899 |
if self.CurrentNodesFilter is not None: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
900 |
self.ProcessVariables = self.Controler.GetProcessVariables() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
901 |
slaves = self.Controler.GetSlaves(**self.CurrentNodesFilter) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
902 |
data = [] |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
903 |
for variable in self.ProcessVariables: |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
904 |
if variable["ReadFrom"] == "" or variable["ReadFrom"][0] in slaves or \ |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
905 |
variable["WriteTo"] == "" or variable["WriteTo"][0] in slaves: |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
906 |
data.append(variable) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
907 |
self.ProcessVariablesTable.SetData(data) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
908 |
self.ProcessVariablesTable.ResetView(self.ProcessVariablesGrid) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
909 |
self.ProcessVariablesGrid.RefreshButtons() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
910 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
911 |
def SaveProcessVariables(self): |
2110 | 912 |
if self.CurrentNodesFilter is not None: |
913 |
if len(self.CurrentNodesFilter) > 0: |
|
914 |
self.Controler.SetProcessVariables(self.ProcessVariables) |
|
915 |
else: |
|
916 |
self.Controler.SetProcessVariables(self.ProcessVariablesTable.GetData()) |
|
917 |
self.RefreshBuffer() |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
918 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
919 |
def RefreshStartupCommands(self, position=None, command_idx=None): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
920 |
if self.CurrentNodesFilter is not None: |
2151
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
921 |
col = max(self.StartupCommandsGrid.GetGridCursorCol(), 0) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
922 |
self.StartupCommandsTable.SetData( |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
923 |
self.Controler.GetStartupCommands(**self.CurrentNodesFilter)) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
924 |
self.StartupCommandsTable.ResetView(self.StartupCommandsGrid) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
925 |
if position is not None and command_idx is not None: |
2151
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
926 |
self.SelectStartupCommand(position, command_idx, col) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
927 |
|
2151
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
928 |
def SelectStartupCommand(self, position, command_idx, col): |
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
929 |
self.StartupCommandsGrid.SetSelectedCell( |
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
930 |
self.StartupCommandsTable.GetCommandIndex(position, command_idx), |
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
931 |
col) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
932 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
933 |
def GetMasterLocation(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
934 |
return self.Controler.GetCurrentLocation() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
935 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
936 |
def AddStartupCommand(self, position, index, subindex): |
2151
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
937 |
col = max(self.StartupCommandsGrid.GetGridCursorCol(), 0) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
938 |
command = self.StartupCommandsDefaultValue.copy() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
939 |
command["Position"] = position |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
940 |
command["Index"] = index |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
941 |
command["Subindex"] = subindex |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
942 |
command_idx = self.Controler.AppendStartupCommand(command) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
943 |
self.RefreshStartupCommands() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
944 |
self.RefreshBuffer() |
2151
015dab6a915f
Fixed bug when drag'n dropping variable in master startup command grid
Laurent Bessard
parents:
2147
diff
changeset
|
945 |
self.SelectStartupCommand(position, command_idx, col) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
946 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
947 |
def OnNodesFilterChanged(self, event): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
948 |
self.RefreshCurrentNodesFilter() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
949 |
if self.CurrentNodesFilter is not None: |
2110 | 950 |
self.RefreshProcessVariables() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
951 |
self.RefreshStartupCommands() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
952 |
self.NodesVariables.RefreshView() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
953 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
954 |
|
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
955 |
def OnNodesFilterKeyDown(self, event): |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
956 |
if self.NodesFilterFirstCharacter: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
957 |
keycode = event.GetKeyCode() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
958 |
if keycode not in [wx.WXK_RETURN, |
2130 | 959 |
wx.WXK_NUMPAD_ENTER]: |
960 |
self.NodesFilterFirstCharacter = False |
|
961 |
if keycode not in NAVIGATION_KEYS: |
|
962 |
self.NodesFilter.SetValue("") |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
963 |
if keycode not in [wx.WXK_DELETE, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
964 |
wx.WXK_NUMPAD_DELETE, |
2129
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
965 |
wx.WXK_BACK]: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
966 |
event.Skip() |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
967 |
else: |
f1d93f44570f
Fixed filter behavior in MasterEditor and SlaveEditor
Laurent Bessard
parents:
2124
diff
changeset
|
968 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
969 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
970 |
def OnProcessVariablesGridCellChange(self, event): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
971 |
row, col = event.GetRow(), event.GetCol() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
972 |
colname = self.ProcessVariablesTable.GetColLabelValue(col, False) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
973 |
value = self.ProcessVariablesTable.GetValue(row, col) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
974 |
message = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
975 |
if colname == "Name": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
976 |
if not TestIdentifier(value): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
977 |
message = _("\"%s\" is not a valid identifier!") % value |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
978 |
elif value.upper() in IEC_KEYWORDS: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
979 |
message = _("\"%s\" is a keyword. It can't be used!") % value |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
980 |
elif value.upper() in [var["Name"].upper() for idx, var in enumerate(self.ProcessVariablesTable.GetData()) if idx != row]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
981 |
message = _("An variable named \"%s\" already exists!") % value |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
982 |
if message is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
983 |
self.SaveProcessVariables() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
984 |
wx.CallAfter(self.ProcessVariablesTable.ResetView, self.ProcessVariablesGrid) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
985 |
event.Skip() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
986 |
else: |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
987 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
988 |
dialog.ShowModal() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
989 |
dialog.Destroy() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
990 |
event.Veto() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
991 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
992 |
def OnProcessVariablesGridCellLeftClick(self, event): |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
993 |
row = event.GetRow() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
994 |
if event.GetCol() == 0: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
995 |
var_name = self.ProcessVariablesTable.GetValueByName(row, "Name") |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
996 |
var_type = self.Controler.GetSlaveVariableDataType( |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
997 |
*self.ProcessVariablesTable.GetValueByName(row, "ReadFrom")) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
998 |
data_size = self.Controler.GetSizeOfType(var_type) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
999 |
number = self.ProcessVariablesTable.GetValueByName(row, "Number") |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1000 |
location = "%%M%s" % data_size + \ |
2392
aad985da14f7
clean etherlab: pylint, C0412 # (ungrouped-imports) Imports from package X are not grouped
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
1001 |
".".join(map(str, self.Controler.GetCurrentLocation() + (number,))) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1002 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1003 |
data = wx.TextDataObject(str((location, "location", var_type, var_name, ""))) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1004 |
dragSource = wx.DropSource(self.ProcessVariablesGrid) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1005 |
dragSource.SetData(data) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1006 |
dragSource.DoDragDrop() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1007 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1008 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1009 |
def OnProcessVariablesGridKeyDown(self, event): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1010 |
keycode = event.GetKeyCode() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1011 |
col = self.ProcessVariablesGrid.GetGridCursorCol() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1012 |
row = self.ProcessVariablesGrid.GetGridCursorRow() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1013 |
colname = self.ProcessVariablesTable.GetColLabelValue(col, False) |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
1014 |
if keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE) and \ |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
1015 |
(colname.startswith("Read from") or colname.startswith("Write to")): |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1016 |
self.ProcessVariablesTable.SetValue(row, col, "") |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1017 |
self.SaveProcessVariables() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1018 |
wx.CallAfter(self.ProcessVariablesTable.ResetView, self.ProcessVariablesGrid) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1019 |
else: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1020 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1021 |
|
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1022 |
def OnStartupCommandsGridEditorShow(self, event): |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1023 |
self.CellShown = event.GetRow(), event.GetCol() |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1024 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1025 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1026 |
def OnStartupCommandsGridCellChange(self, event): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1027 |
row, col = event.GetRow(), event.GetCol() |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1028 |
if self.CellShown == (row, col): |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1029 |
self.CellShown = None |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1030 |
colname = self.StartupCommandsTable.GetColLabelValue(col, False) |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1031 |
value = self.StartupCommandsTable.GetValue(row, col) |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1032 |
message = None |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1033 |
if colname == "Position": |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1034 |
if value not in self.Controler.GetSlaves(): |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1035 |
message = _("No slave defined at position %d!") % value |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1036 |
old_value = self.StartupCommandsTable.GetOldValue() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1037 |
command = self.StartupCommandsTable.GetRow(row) |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1038 |
if message is None and old_value != command["Position"]: |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1039 |
self.Controler.RemoveStartupCommand( |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1040 |
self.StartupCommandsTable.GetOldValue(), |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1041 |
command["command_idx"], False) |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1042 |
command_idx = self.Controler.AppendStartupCommand(command) |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1043 |
wx.CallAfter(self.RefreshStartupCommands, command["Position"], command_idx) |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1044 |
else: |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1045 |
command = self.StartupCommandsTable.GetRow(row) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1046 |
self.Controler.SetStartupCommandInfos(command) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1047 |
if colname in ["Index", "SubIndex"]: |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1048 |
wx.CallAfter(self.RefreshStartupCommands, command["Position"], command["command_idx"]) |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1049 |
if message is None: |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1050 |
self.RefreshBuffer() |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1051 |
event.Skip() |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1052 |
else: |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
1053 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) |
2100
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1054 |
dialog.ShowModal() |
bb43a81356eb
Fixed modifications in Startup Commands grid
Laurent Bessard
parents:
2099
diff
changeset
|
1055 |
dialog.Destroy() |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1056 |
event.Veto() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1057 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1058 |
event.Veto() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1059 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1060 |
def OnResize(self, event): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1061 |
self.EthercatMasterEditor.GetBestSize() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1062 |
xstart, ystart = self.EthercatMasterEditor.GetViewStart() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1063 |
window_size = self.EthercatMasterEditor.GetClientSize() |
2134
6f4b08348a60
Fixed bug on Windows with sizers on Windows in Master Editor panel when its size changed
Laurent Bessard
parents:
2130
diff
changeset
|
1064 |
maxx, maxy = self.EthercatMasterEditorSizer.GetMinSize() |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1065 |
posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1066 |
posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1067 |
self.EthercatMasterEditor.Scroll(posx, posy) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1068 |
self.EthercatMasterEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1069 |
maxx // SCROLLBAR_UNIT, |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1070 |
maxy // SCROLLBAR_UNIT, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1071 |
posx, posy) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1072 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1073 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1074 |
# def OnButtonClick(self, event): |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1075 |
# self.MasterState = self.Controler.getMasterState() |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1076 |
# if self.MasterState: |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1077 |
# self.Phase.SetValue(self.MasterState["phase"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1078 |
# self.Active.SetValue(self.MasterState["active"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1079 |
# self.SlaveCount.SetValue(self.MasterState["slave"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1080 |
# self.MacAddress.SetValue(self.MasterState["MAC"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1081 |
# self.LinkState.SetValue(self.MasterState["link"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1082 |
# self.TxFrames.SetValue(self.MasterState["TXframe"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1083 |
# self.RxFrames.SetValue(self.MasterState["RXframe"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1084 |
# self.TxByte.SetValue(self.MasterState["TXbyte"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1085 |
# self.TxError.SetValue(self.MasterState["TXerror"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1086 |
# self.LostFrames.SetValue(self.MasterState["lost"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1087 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1088 |
# self.TxFrameRate1.SetValue(self.MasterState["TXframerate1"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1089 |
# self.TxFrameRate2.SetValue(self.MasterState["TXframerate2"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1090 |
# self.TxFrameRate3.SetValue(self.MasterState["TXframerate3"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1091 |
# self.TxRate1.SetValue(self.MasterState["TXrate1"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1092 |
# self.TxRate2.SetValue(self.MasterState["TXrate2"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1093 |
# self.TxRate3.SetValue(self.MasterState["TXrate3"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1094 |
# self.LossRate1.SetValue(self.MasterState["loss1"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1095 |
# self.LossRate2.SetValue(self.MasterState["loss2"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1096 |
# self.LossRate3.SetValue(self.MasterState["loss3"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1097 |
# self.FrameLoss1.SetValue(self.MasterState["frameloss1"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1098 |
# self.FrameLoss2.SetValue(self.MasterState["frameloss2"]) |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2151
diff
changeset
|
1099 |
# self.FrameLoss3.SetValue(self.MasterState["frameloss3"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1100 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
1101 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1102 |
class LibraryEditorSizer(wx.FlexGridSizer): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1103 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1104 |
def __init__(self, parent, module_library, buttons): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1105 |
wx.FlexGridSizer.__init__(self, cols=1, hgap=0, rows=4, vgap=5) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1106 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1107 |
self.ModuleLibrary = module_library |
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
1108 |
self.ParentWindow = parent |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1109 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1110 |
self.AddGrowableCol(0) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1111 |
self.AddGrowableRow(1) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1112 |
self.AddGrowableRow(3) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1113 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1114 |
ESI_files_label = wx.StaticText(parent, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1115 |
label=_("ESI Files:")) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1116 |
self.Add(ESI_files_label, border=10, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1117 |
flag=wx.TOP | wx.LEFT | wx.RIGHT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1118 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1119 |
folder_tree_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=0) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1120 |
folder_tree_sizer.AddGrowableCol(0) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1121 |
folder_tree_sizer.AddGrowableRow(0) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1122 |
self.Add(folder_tree_sizer, border=10, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1123 |
flag=wx.GROW | wx.LEFT | wx.RIGHT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1124 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1125 |
self.ESIFiles = FolderTree(parent, self.GetPath(), editable=False) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1126 |
self.ESIFiles.SetFilter(".xml") |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1127 |
folder_tree_sizer.Add(self.ESIFiles, flag=wx.GROW) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1128 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1129 |
buttons_sizer = wx.BoxSizer(wx.VERTICAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1130 |
folder_tree_sizer.Add(buttons_sizer, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1131 |
flag=wx.ALIGN_CENTER_VERTICAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1132 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1133 |
for idx, (name, bitmap, help, callback) in enumerate(buttons): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1134 |
button = wx.lib.buttons.GenBitmapButton(parent, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1135 |
bitmap=GetBitmap(bitmap), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1136 |
size=wx.Size(28, 28), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1137 |
style=wx.NO_BORDER) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1138 |
button.SetToolTip(help) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1139 |
setattr(self, name, button) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1140 |
if idx > 0: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1141 |
flag = wx.TOP |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1142 |
else: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1143 |
flag = 0 |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1144 |
if callback is None: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1145 |
callback = getattr(self, "On" + name, None) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1146 |
if callback is not None: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1147 |
parent.Bind(wx.EVT_BUTTON, callback, button) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1148 |
buttons_sizer.Add(button, border=10, flag=flag) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1149 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1150 |
modules_label = wx.StaticText(parent, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1151 |
label=_("Modules library:")) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1152 |
self.Add(modules_label, border=10, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1153 |
flag=wx.LEFT | wx.RIGHT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1154 |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1155 |
self.ModulesGrid = wx.adv.TreeListCtrl(parent, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1156 |
style=wx.TR_DEFAULT_STYLE | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1157 |
wx.TR_ROW_LINES | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1158 |
wx.TR_COLUMN_LINES | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1159 |
wx.TR_HIDE_ROOT | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1160 |
wx.TR_FULL_ROW_HIGHLIGHT) |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1161 |
self.ModulesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1162 |
self.OnModulesGridLeftDown) |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1163 |
self.ModulesGrid.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1164 |
self.OnModulesGridBeginLabelEdit) |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1165 |
self.ModulesGrid.Bind(wx.EVT_TREE_END_LABEL_EDIT, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1166 |
self.OnModulesGridEndLabelEdit) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1167 |
self.ModulesGrid.GetHeaderWindow().Bind(wx.EVT_MOTION, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1168 |
self.OnModulesGridHeaderMotion) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1169 |
self.Add(self.ModulesGrid, border=10, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1170 |
flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1171 |
|
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2134
diff
changeset
|
1172 |
for colname, colsize, colalign in zip( |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1173 |
[_("Name")] + [param_infos["column_label"] |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1174 |
for _param, param_infos in |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2134
diff
changeset
|
1175 |
self.ModuleLibrary.MODULES_EXTRA_PARAMS], |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1176 |
[400] + [param_infos["column_size"] |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1177 |
for _param, param_infos in |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1178 |
self.ModuleLibrary.MODULES_EXTRA_PARAMS], |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2134
diff
changeset
|
1179 |
[wx.ALIGN_LEFT] + [wx.ALIGN_RIGHT] * len(self.ModuleLibrary.MODULES_EXTRA_PARAMS)): |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1180 |
self.ModulesGrid.AddColumn(_(colname), colsize, colalign, edit=True) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1181 |
self.ModulesGrid.SetMainColumn(0) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1182 |
|
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1183 |
self.CurrentSelectedCol = None |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1184 |
self.LastToolTipCol = None |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1185 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1186 |
def GetPath(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1187 |
return self.ModuleLibrary.GetPath() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1188 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1189 |
def SetControlMinSize(self, size): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1190 |
self.ESIFiles.SetMinSize(size) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1191 |
self.ModulesGrid.SetMinSize(size) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1192 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1193 |
def GetSelectedFilePath(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1194 |
return self.ESIFiles.GetPath() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1195 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1196 |
def RefreshView(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1197 |
self.ESIFiles.RefreshTree() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1198 |
self.RefreshModulesGrid() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1199 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1200 |
def RefreshModulesGrid(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1201 |
root = self.ModulesGrid.GetRootItem() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1202 |
if not root.IsOk(): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1203 |
root = self.ModulesGrid.AddRoot("Modules") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1204 |
self.GenerateModulesGridBranch(root, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1205 |
self.ModuleLibrary.GetModulesLibrary(), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1206 |
GetVariablesTableColnames()) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1207 |
self.ModulesGrid.Expand(root) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1208 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1209 |
def GenerateModulesGridBranch(self, root, modules, colnames): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1210 |
item, root_cookie = self.ModulesGrid.GetFirstChild(root) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1211 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1212 |
no_more_items = not item.IsOk() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1213 |
for module in modules: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1214 |
if no_more_items: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1215 |
item = self.ModulesGrid.AppendItem(root, "") |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1216 |
self.ModulesGrid.SetItemText(item, module["name"], 0) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1217 |
if module["infos"] is not None: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1218 |
for param_idx, (param, _param_infos) in enumerate(self.ModuleLibrary.MODULES_EXTRA_PARAMS): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1219 |
self.ModulesGrid.SetItemText(item, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1220 |
str(module["infos"][param]), |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2134
diff
changeset
|
1221 |
param_idx + 1) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1222 |
else: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1223 |
self.ModulesGrid.SetItemBackgroundColour(item, wx.LIGHT_GREY) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1224 |
self.ModulesGrid.SetItemPyData(item, module["infos"]) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1225 |
self.GenerateModulesGridBranch(item, module["children"], colnames) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1226 |
if not no_more_items: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1227 |
item, root_cookie = self.ModulesGrid.GetNextChild(root, root_cookie) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1228 |
no_more_items = not item.IsOk() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1229 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1230 |
if not no_more_items: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1231 |
to_delete = [] |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1232 |
while item.IsOk(): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1233 |
to_delete.append(item) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1234 |
item, root_cookie = self.ModulesGrid.GetNextChild(root, root_cookie) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1235 |
for item in to_delete: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1236 |
self.ModulesGrid.Delete(item) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1237 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1238 |
def OnImportButton(self, event): |
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2100
diff
changeset
|
1239 |
dialog = wx.FileDialog(self.ParentWindow, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1240 |
_("Choose an XML file"), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1241 |
os.getcwd(), "", |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1242 |
_("XML files (*.xml)|*.xml|All files|*.*"), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1243 |
wx.OPEN) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1244 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1245 |
if dialog.ShowModal() == wx.ID_OK: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1246 |
filepath = dialog.GetPath() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1247 |
if self.ModuleLibrary.ImportModuleLibrary(filepath): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1248 |
wx.CallAfter(self.RefreshView) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1249 |
else: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1250 |
message = wx.MessageDialog(self, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1251 |
_("No such XML file: %s\n") % filepath, |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1252 |
_("Error"), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1253 |
wx.OK | wx.ICON_ERROR) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1254 |
message.ShowModal() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1255 |
message.Destroy() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1256 |
dialog.Destroy() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1257 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1258 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1259 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1260 |
def OnDeleteButton(self, event): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1261 |
filepath = self.GetSelectedFilePath() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1262 |
if os.path.isfile(filepath): |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1263 |
_folder, filename = os.path.split(filepath) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1264 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1265 |
dialog = wx.MessageDialog(self.ParentWindow, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1266 |
_("Do you really want to delete the file '%s'?") % filename, |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1267 |
_("Delete File"), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1268 |
wx.YES_NO | wx.ICON_QUESTION) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1269 |
remove = dialog.ShowModal() == wx.ID_YES |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1270 |
dialog.Destroy() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1271 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1272 |
if remove: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1273 |
os.remove(filepath) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1274 |
self.ModuleLibrary.LoadModules() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1275 |
wx.CallAfter(self.RefreshView) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1276 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1277 |
|
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1278 |
def OnModulesGridLeftDown(self, event): |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1279 |
item, _flags, col = self.ModulesGrid.HitTest(event.GetPosition()) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1280 |
if item.IsOk(): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1281 |
entry_infos = self.ModulesGrid.GetItemPyData(item) |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2134
diff
changeset
|
1282 |
if entry_infos is not None and col > 0: |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1283 |
self.CurrentSelectedCol = col |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1284 |
else: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1285 |
self.CurrentSelectedCol = None |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1286 |
else: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1287 |
self.CurrentSelectedCol = None |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1288 |
event.Skip() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1289 |
|
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1290 |
def OnModulesGridBeginLabelEdit(self, event): |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1291 |
item = event.GetItem() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1292 |
if item.IsOk(): |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1293 |
entry_infos = self.ModulesGrid.GetItemPyData(item) |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1294 |
if entry_infos is not None: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1295 |
event.Skip() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1296 |
else: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1297 |
event.Veto() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1298 |
else: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1299 |
event.Veto() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1300 |
|
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1301 |
def OnModulesGridEndLabelEdit(self, event): |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1302 |
item = event.GetItem() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1303 |
if item.IsOk() and self.CurrentSelectedCol is not None: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1304 |
entry_infos = self.ModulesGrid.GetItemPyData(item) |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1305 |
if entry_infos is not None and self.CurrentSelectedCol > 0: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1306 |
param, param_infos = self.ModuleLibrary.MODULES_EXTRA_PARAMS[self.CurrentSelectedCol - 1] |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1307 |
stripped_column_label = param_infos["column_label"].split('(')[0].strip() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1308 |
try: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1309 |
self.ModuleLibrary.SetModuleExtraParam( |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1310 |
entry_infos["vendor"], |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1311 |
entry_infos["product_code"], |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1312 |
entry_infos["revision_number"], |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1313 |
param, |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1314 |
int(event.GetLabel())) |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1315 |
wx.CallAfter(self.RefreshModulesGrid) |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1316 |
event.Skip() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1317 |
except ValueError: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1318 |
message = wx.MessageDialog(self, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1319 |
_("Module %s must be an integer!") % stripped_column_label, |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1320 |
_("Error"), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1321 |
wx.OK | wx.ICON_ERROR) |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1322 |
message.ShowModal() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1323 |
message.Destroy() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1324 |
event.Veto() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1325 |
else: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1326 |
event.Veto() |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1327 |
else: |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1328 |
event.Veto() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1329 |
|
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1330 |
def OnModulesGridHeaderMotion(self, event): |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1331 |
_item, _flags, col = self.ModulesGrid.HitTest(event.GetPosition()) |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1332 |
if col != self.LastToolTipCol and self.LastToolTipCol is not None: |
2143
83a2e3db4c8c
Fixed ToolTip on VariablesGrid columns on Windows
Laurent Bessard
parents:
2138
diff
changeset
|
1333 |
self.ModulesGrid.GetHeaderWindow().SetToolTip(None) |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1334 |
self.LastToolTipCol = None |
2143
83a2e3db4c8c
Fixed ToolTip on VariablesGrid columns on Windows
Laurent Bessard
parents:
2138
diff
changeset
|
1335 |
if col > 0 and self.LastToolTipCol != col: |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
1336 |
self.LastToolTipCol = col |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1337 |
_param, param_infos = self.ModuleLibrary.MODULES_EXTRA_PARAMS[col - 1] |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1338 |
wx.CallAfter(self.ModulesGrid.GetHeaderWindow().SetToolTip, |
2143
83a2e3db4c8c
Fixed ToolTip on VariablesGrid columns on Windows
Laurent Bessard
parents:
2138
diff
changeset
|
1339 |
param_infos["description"]) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1340 |
event.Skip() |
2058
b3bc00dae385
Replacing Panel by ScrolledWindow for displaying node information for more clarity when window is small
Laurent Bessard
parents:
2056
diff
changeset
|
1341 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
1342 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1343 |
class DatabaseManagementDialog(wx.Dialog): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1344 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1345 |
def __init__(self, parent, database): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1346 |
wx.Dialog.__init__(self, parent, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1347 |
size=wx.Size(700, 500), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1348 |
title=_('ESI Files Database management'), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1349 |
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1350 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1351 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1352 |
main_sizer.AddGrowableCol(0) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1353 |
main_sizer.AddGrowableRow(0) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1354 |
|
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1355 |
self.DatabaseSizer = LibraryEditorSizer( |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1356 |
self, database, |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1357 |
[ |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1358 |
("ImportButton", "ImportESI", _("Import file to ESI files database"), None), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1359 |
("DeleteButton", "remove_element", _("Remove file from database"), None) |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1360 |
]) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1361 |
self.DatabaseSizer.SetControlMinSize(wx.Size(0, 0)) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1362 |
main_sizer.Add(self.DatabaseSizer, border=10, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1363 |
flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT) |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
1364 |
|
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
1365 |
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1366 |
# FIXME: find a way to change buttons label compatible with wxPython 4.x |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1367 |
# button_sizer.GetAffirmativeButton().SetLabel(_("Add file to project")) |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1368 |
# button_sizer.GetCancelButton().SetLabel(_("Close")) |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
1369 |
main_sizer.Add(button_sizer, border=10, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1370 |
flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1371 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1372 |
self.SetSizer(main_sizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1373 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1374 |
self.DatabaseSizer.RefreshView() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1375 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1376 |
def GetValue(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1377 |
return self.DatabaseSizer.GetSelectedFilePath() |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1378 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
1379 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1380 |
class LibraryEditor(ConfTreeNodeEditor): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1381 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1382 |
CONFNODEEDITOR_TABS = [ |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1383 |
(_("Modules Library"), "_create_ModuleLibraryEditor")] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1384 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1385 |
def _create_ModuleLibraryEditor(self, prnt): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1386 |
self.ModuleLibraryEditor = wx.ScrolledWindow(prnt, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1387 |
style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1388 |
self.ModuleLibraryEditor.Bind(wx.EVT_SIZE, self.OnResize) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1389 |
|
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1390 |
self.ModuleLibrarySizer = LibraryEditorSizer( |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1391 |
self.ModuleLibraryEditor, |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1392 |
self.Controler.GetModulesLibraryInstance(), |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1393 |
[ |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1394 |
("ImportButton", "ImportESI", _("Import ESI file"), None), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1395 |
("AddButton", "ImportDatabase", _("Add file from ESI files database"), self.OnAddButton), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1396 |
("DeleteButton", "remove_element", _("Remove file from library"), None) |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1397 |
]) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1398 |
self.ModuleLibrarySizer.SetControlMinSize(wx.Size(0, 200)) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1399 |
self.ModuleLibraryEditor.SetSizer(self.ModuleLibrarySizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1400 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1401 |
return self.ModuleLibraryEditor |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1402 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1403 |
def __init__(self, parent, controler, window): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1404 |
ConfTreeNodeEditor.__init__(self, parent, controler, window) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1405 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1406 |
self.RefreshView() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1407 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1408 |
def RefreshView(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1409 |
ConfTreeNodeEditor.RefreshView(self) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1410 |
self.ModuleLibrarySizer.RefreshView() |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1411 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1412 |
def OnAddButton(self, event): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1413 |
dialog = DatabaseManagementDialog(self, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1414 |
self.Controler.GetModulesDatabaseInstance()) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1415 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1416 |
if dialog.ShowModal() == wx.ID_OK: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1417 |
module_library = self.Controler.GetModulesLibraryInstance() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1418 |
module_library.ImportModuleLibrary(dialog.GetValue()) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1419 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1420 |
dialog.Destroy() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1421 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1422 |
wx.CallAfter(self.ModuleLibrarySizer.RefreshView) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1423 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1424 |
event.Skip() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2095
diff
changeset
|
1425 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1426 |
def OnResize(self, event): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1427 |
self.ModuleLibraryEditor.GetBestSize() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1428 |
xstart, ystart = self.ModuleLibraryEditor.GetViewStart() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1429 |
window_size = self.ModuleLibraryEditor.GetClientSize() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1430 |
maxx, maxy = self.ModuleLibraryEditor.GetMinSize() |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1431 |
posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1432 |
posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1433 |
self.ModuleLibraryEditor.Scroll(posx, posy) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1434 |
self.ModuleLibraryEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1435 |
maxx // SCROLLBAR_UNIT, |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1436 |
maxy // SCROLLBAR_UNIT, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1437 |
posx, posy) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1438 |
event.Skip() |