author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Sun, 10 May 2020 17:01:09 +0200 | |
branch | svghmi |
changeset 2954 | b5dccd0d99ac |
parent 2437 | 105c20fdeb19 |
child 2643 | b98d9e08231f |
permissions | -rw-r--r-- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1 |
#!/usr/bin/env python |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
3 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
4 |
# This file is part of Beremiz |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
5 |
# |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
6 |
# Copyright (C) 2013: Real-Time & Embedded Systems (RTES) Lab., University of Seoul |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
7 |
# |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
8 |
# See COPYING file for copyrights details. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
9 |
|
2405
af050469fc5c
clean etherlab: pylint, W1618 # (no-absolute-import) import missing `from __future__ import absolute_import`
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2390
diff
changeset
|
10 |
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:
2423
diff
changeset
|
11 |
from __future__ import division |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
12 |
import os |
2390
81116c5db60f
clean etherlab: pylint, C0411 # (wrong-import-order) standard import "import x" comes before "import y"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2389
diff
changeset
|
13 |
import string |
81116c5db60f
clean etherlab: pylint, C0411 # (wrong-import-order) standard import "import x" comes before "import y"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2389
diff
changeset
|
14 |
from xml.dom import minidom |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
15 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
16 |
import wx |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
17 |
import wx.grid |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
18 |
import wx.gizmos |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
19 |
import wx.lib.buttons |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
20 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
21 |
# -------------------------------------------------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
22 |
from controls import CustomGrid, CustomTable |
2416
1ca207782dde
Use predefined constants for PlcStatus instead of string literals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
23 |
from runtime import PlcStatus |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
24 |
# -------------------------------------------------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
25 |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
26 |
# ------------ for register management --------------- |
2390
81116c5db60f
clean etherlab: pylint, C0411 # (wrong-import-order) standard import "import x" comes before "import y"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2389
diff
changeset
|
27 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
28 |
from util.TranslationCatalogs import NoTranslate |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
29 |
# ------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
30 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
31 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
32 |
# ----------------------------- For Sync Manager Table ----------------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
33 |
def GetSyncManagersTableColnames(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
34 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
35 |
Returns column names of SyncManager Table in Slave state panel. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
36 |
""" |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
37 |
_ = NoTranslate |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
38 |
return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
39 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
40 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
41 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
42 |
# Sync Managers Table |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
43 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
44 |
class SyncManagersTable(CustomTable): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
45 |
def GetValue(self, row, col): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
46 |
if row < self.GetNumberRows(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
47 |
if col == 0: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
48 |
return row |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
49 |
return self.data[row].get(self.GetColLabelValue(col, False), "") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
50 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
51 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
52 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
53 |
# EtherCAT Management Treebook |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
54 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
55 |
class EtherCATManagementTreebook(wx.Treebook): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
56 |
def __init__(self, parent, controler, node_editor): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
57 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
58 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
59 |
@param parent: Reference to the parent wx.ScrolledWindow object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
60 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
61 |
@param node_editor: Reference to Beremiz frame |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
62 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
63 |
wx.Treebook.__init__(self, parent, -1, size=wx.DefaultSize, style=wx.BK_DEFAULT) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
64 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
65 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
66 |
self.NodeEditor = node_editor |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
67 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
68 |
self.EtherCATManagementClassObject = {} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
69 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
70 |
# fill EtherCAT Management Treebook |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
71 |
panels = [ |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
72 |
("Slave State", SlaveStatePanelClass, []), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
73 |
("SDO Management", SDOPanelClass, []), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
74 |
("PDO Monitoring", PDOPanelClass, []), |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
75 |
("ESC Management", EEPROMAccessPanel, [ |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
76 |
("Smart View", SlaveSiiSmartView), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
77 |
("Hex View", HexView)]), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
78 |
("Register Access", RegisterAccessPanel, []) |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
79 |
] |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
80 |
for pname, pclass, subs in panels: |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
81 |
self.AddPage(pclass(self, self.Controler), pname) |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
82 |
for spname, spclass in subs: |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
83 |
self.AddSubPage(spclass(self, self.Controler), spname) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
84 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
85 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
86 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
87 |
# For SlaveState Panel |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
88 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
89 |
class SlaveStatePanelClass(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
90 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
91 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
92 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
93 |
@param parent: Reference to the parent EtherCATManagementTreebook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
94 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
95 |
""" |
2366
d635680e4c2c
cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2365
diff
changeset
|
96 |
wx.Panel.__init__(self, parent, -1, (0, 0), size=wx.DefaultSize, style=wx.SUNKEN_BORDER) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
97 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
98 |
self.parent = parent |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
99 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
100 |
# initialize SlaveStatePanel UI dictionaries |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
101 |
self.StaticBoxDic = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
102 |
self.StaticTextDic = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
103 |
self.TextCtrlDic = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
104 |
self.ButtonDic = {} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
105 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
106 |
# iniitalize BoxSizer and FlexGridSizer |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
107 |
self.SizerDic = { |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
108 |
"SlaveState_main_sizer": wx.BoxSizer(wx.VERTICAL), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
109 |
"SlaveState_inner_main_sizer": wx.FlexGridSizer(cols=1, hgap=50, rows=3, vgap=10), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
110 |
"SlaveInfosDetailsInnerSizer": wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
111 |
"SyncManagerInnerSizer": wx.FlexGridSizer(cols=1, hgap=5, rows=1, vgap=5), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
112 |
"SlaveState_sizer": wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
113 |
"SlaveState_up_sizer": wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
114 |
"SlaveState_down_sizer": wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10)} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
115 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
116 |
# initialize StaticBox and StaticBoxSizer |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
117 |
for box_name, box_label in [ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
118 |
("SlaveInfosDetailsBox", "Slave Informations"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
119 |
("SyncManagerBox", "Sync Manager"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
120 |
("SlaveStateBox", "Slave State Transition && Monitoring")]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
121 |
self.StaticBoxDic[box_name] = wx.StaticBox(self, label=_(box_label)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
122 |
self.SizerDic[box_name] = wx.StaticBoxSizer(self.StaticBoxDic[box_name]) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
123 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
124 |
for statictext_name, statictext_label, textctrl_name in [ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
125 |
("VendorLabel", "Vendor:", "vendor"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
126 |
("ProductcodeLabel", "Product code:", "product_code"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
127 |
("RevisionnumberLabel", "Slave Count:", "revision_number"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
128 |
("PhysicsLabel", "Physics:", "physics")]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
129 |
self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
130 |
self.TextCtrlDic[textctrl_name] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
131 |
self.SizerDic["SlaveInfosDetailsInnerSizer"].AddMany([self.StaticTextDic[statictext_name], |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
132 |
self.TextCtrlDic[textctrl_name]]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
133 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
134 |
self.SizerDic["SlaveInfosDetailsBox"].AddSizer(self.SizerDic["SlaveInfosDetailsInnerSizer"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
135 |
|
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
136 |
self.SyncManagersGrid = CustomGrid(self, size=wx.Size(605, 155), style=wx.VSCROLL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
137 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
138 |
self.SizerDic["SyncManagerInnerSizer"].Add(self.SyncManagersGrid) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
139 |
self.SizerDic["SyncManagerBox"].Add(self.SizerDic["SyncManagerInnerSizer"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
140 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
141 |
buttons = [ |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
142 |
("InitButton", 0, "INIT", "State Transition to \"Init\" State", self.OnButtonClick, []), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
143 |
("PreOPButton", 1, "PREOP", "State Transition to \"PreOP\" State", self.OnButtonClick, [ |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
144 |
("TargetStateLabel", "Target State:", "TargetState")]), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
145 |
("SafeOPButton", 2, "SAFEOP", "State Transition to \"SafeOP\" State", self.OnButtonClick, []), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
146 |
("OPButton", 3, "OP", "State Transition to \"OP\" State", self.OnButtonClick, [ |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
147 |
("CurrentStateLabel", "Current State:", "CurrentState")]) |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
148 |
] |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
149 |
for button_name, button_id, button_label, button_tooltipstring, event_method, sub_item in buttons: |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
150 |
self.ButtonDic[button_name] = wx.Button(self, id=button_id, label=_(button_label)) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
151 |
self.ButtonDic[button_name].Bind(wx.EVT_BUTTON, event_method) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
152 |
self.ButtonDic[button_name].SetToolTipString(button_tooltipstring) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
153 |
self.SizerDic["SlaveState_up_sizer"].Add(self.ButtonDic[button_name]) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
154 |
for statictext_name, statictext_label, textctrl_name in sub_item: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
155 |
self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
156 |
self.TextCtrlDic[textctrl_name] = wx.TextCtrl(self, size=wx.DefaultSize, style=wx.TE_READONLY) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
157 |
self.SizerDic["SlaveState_up_sizer"].AddMany([self.StaticTextDic[statictext_name], |
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
158 |
self.TextCtrlDic[textctrl_name]]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
159 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
160 |
for button_name, button_label, button_tooltipstring, event_method in [ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
161 |
("StartTimerButton", "Start State Monitoring", "Slave State Update Restart", self.StartTimer), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
162 |
("StopTimerButton", "Stop State Monitoring", "Slave State Update Stop", self.CurrentStateThreadStop)]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
163 |
self.ButtonDic[button_name] = wx.Button(self, label=_(button_label)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
164 |
self.ButtonDic[button_name].Bind(wx.EVT_BUTTON, event_method) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
165 |
self.ButtonDic[button_name].SetToolTipString(button_tooltipstring) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
166 |
self.SizerDic["SlaveState_down_sizer"].Add(self.ButtonDic[button_name]) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
167 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
168 |
self.SizerDic["SlaveState_sizer"].AddMany([self.SizerDic["SlaveState_up_sizer"], |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
169 |
self.SizerDic["SlaveState_down_sizer"]]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
170 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
171 |
self.SizerDic["SlaveStateBox"].Add(self.SizerDic["SlaveState_sizer"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
172 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
173 |
self.SizerDic["SlaveState_inner_main_sizer"].AddMany([ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
174 |
self.SizerDic["SlaveInfosDetailsBox"], self.SizerDic["SyncManagerBox"], |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
175 |
self.SizerDic["SlaveStateBox"]]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
176 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
177 |
self.SizerDic["SlaveState_main_sizer"].Add(self.SizerDic["SlaveState_inner_main_sizer"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
178 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
179 |
self.SetSizer(self.SizerDic["SlaveState_main_sizer"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
180 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
181 |
# register a timer for periodic exectuion of slave state update (period: 1000 ms) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
182 |
self.Bind(wx.EVT_TIMER, self.GetCurrentState) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
183 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
184 |
self.CreateSyncManagerTable() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
185 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
186 |
self.Centre() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
187 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
188 |
def CreateSyncManagerTable(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
189 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
190 |
Create grid for "SyncManager" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
191 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
192 |
# declare Table object |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
193 |
self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
194 |
self.SyncManagersGrid.SetTable(self.SyncManagersTable) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
195 |
# set grid alignment attr. (CENTER) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
196 |
self.SyncManagersGridColAlignements = [wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
197 |
wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
198 |
# set grid size |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
199 |
self.SyncManagersGridColSizes = [40, 150, 100, 100, 100, 100] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
200 |
self.SyncManagersGrid.SetRowLabelSize(0) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
201 |
for col in range(self.SyncManagersTable.GetNumberCols()): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
202 |
attr = wx.grid.GridCellAttr() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
203 |
attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTRE) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
204 |
self.SyncManagersGrid.SetColAttr(col, attr) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
205 |
self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
206 |
self.SyncManagersGrid.AutoSizeColumn(col, False) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
207 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
208 |
self.RefreshSlaveInfos() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
209 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
210 |
def RefreshSlaveInfos(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
211 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
212 |
Fill data in "Slave Information" and "SyncManager" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
213 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
214 |
slave_infos = self.Controler.GetSlaveInfos() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
215 |
sync_manager_section = ["vendor", "product_code", "revision_number", "physics"] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
216 |
if slave_infos is not None: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
217 |
# this method is same as "TextCtrl.SetValue" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
218 |
for textctrl_name in sync_manager_section: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
219 |
self.TextCtrlDic[textctrl_name].SetValue(slave_infos[textctrl_name]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
220 |
self.SyncManagersTable.SetData(slave_infos["sync_managers"]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
221 |
self.SyncManagersTable.ResetView(self.SyncManagersGrid) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
222 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
223 |
for textctrl_name in sync_manager_section: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
224 |
self.TextCtrlDic[textctrl_name].SetValue("") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
225 |
self.SyncManagersTable.SetData([]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
226 |
self.SyncManagersTable.ResetView(self.SyncManagersGrid) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
227 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
228 |
def OnButtonClick(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
229 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
230 |
Event handler for slave state transition button click (Init, PreOP, SafeOP, OP button) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
231 |
@param event : wx.EVT_BUTTON object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
232 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
233 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
234 |
if check_connect_flag: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
235 |
state_dic = ["INIT", "PREOP", "SAFEOP", "OP"] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
236 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
237 |
# If target state is one of {INIT, PREOP, SAFEOP}, request slave state transition immediately. |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
238 |
if event.GetId() < 3: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
239 |
self.Controler.CommonMethod.RequestSlaveState(state_dic[event.GetId()]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
240 |
self.TextCtrlDic["TargetState"].SetValue(state_dic[event.GetId()]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
241 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
242 |
# If target state is OP, first check "PLC status". |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
243 |
# (1) If current PLC status is "Started", then request slave state transition |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
244 |
# (2) Otherwise, show error message and return |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
245 |
else: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
246 |
status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
2416
1ca207782dde
Use predefined constants for PlcStatus instead of string literals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
247 |
if status == PlcStatus.Started: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
248 |
self.Controler.CommonMethod.RequestSlaveState("OP") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
249 |
self.TextCtrlDic["TargetState"].SetValue("OP") |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
250 |
else: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
251 |
self.Controler.CommonMethod.CreateErrorDialog(_("PLC is Not Started")) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
252 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
253 |
def GetCurrentState(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
254 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
255 |
Timer event handler for periodic slave state monitoring (Default period: 1 sec = 1000 msec). |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
256 |
@param event : wx.TIMER object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
257 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
258 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(True) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
259 |
if check_connect_flag: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
260 |
returnVal = self.Controler.CommonMethod.GetSlaveStateFromSlave() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
261 |
line = returnVal.split("\n") |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
262 |
try: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
263 |
self.SetCurrentState(line[self.Controler.GetSlavePos()]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
264 |
except Exception: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
265 |
pass |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
266 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
267 |
def SetCurrentState(self, line): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
268 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
269 |
Show current slave state using the executiob result of "ethercat slaves" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
270 |
@param line : result of "ethercat slaves" command |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
271 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
272 |
state_array = ["INIT", "PREOP", "SAFEOP", "OP"] |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
273 |
try: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
274 |
# parse the execution result of "ethercat slaves" command |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
275 |
# Result example : 0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
276 |
token = line.split(" ") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
277 |
if token[2] in state_array: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
278 |
self.TextCtrlDic["CurrentState"].SetValue(token[2]) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
279 |
except Exception: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
280 |
pass |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
281 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
282 |
def StartTimer(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
283 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
284 |
Event handler for "Start State Monitoring" button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
285 |
- start slave state monitoring thread |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
286 |
@param event : wx.EVT_BUTTON object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
287 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
288 |
self.SlaveStateThread = wx.Timer(self) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
289 |
# set timer period (1000 ms) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
290 |
self.SlaveStateThread.Start(1000) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
291 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
292 |
def CurrentStateThreadStop(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
293 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
294 |
Event handler for "Stop State Monitoring" button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
295 |
- stop slave state monitoring thread |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
296 |
@param event : wx.EVT_BUTTON object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
297 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
298 |
try: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
299 |
self.SlaveStateThread.Stop() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
300 |
except Exception: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
301 |
pass |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
302 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
303 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
304 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
305 |
# For SDO Management Panel |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
306 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
307 |
class SDOPanelClass(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
308 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
309 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
310 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
311 |
@param parent: Reference to the parent EtherCATManagementTreebook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
312 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
313 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
314 |
wx.Panel.__init__(self, parent, -1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
315 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
316 |
self.DatatypeDescription, self.CommunicationObject, self.ManufacturerSpecific, \ |
2384
d7d9f0e60bc9
clean etherlab: pep8, E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2383
diff
changeset
|
317 |
self.ProfileSpecific, self.Reserved, self.AllSDOData = range(6) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
318 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
319 |
self.Controler = controler |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
320 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
321 |
self.SDOManagementMainSizer = wx.BoxSizer(wx.VERTICAL) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
322 |
self.SDOManagementInnerMainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
323 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
324 |
self.SDOUpdate = wx.Button(self, label=_('update')) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
325 |
self.SDOUpdate.Bind(wx.EVT_BUTTON, self.SDOInfoUpdate) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
326 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
327 |
self.CallSDONoteBook = SDONoteBook(self, controler=self.Controler) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
328 |
self.SDOManagementInnerMainSizer.Add(self.SDOUpdate) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
329 |
self.SDOManagementInnerMainSizer.Add(self.CallSDONoteBook, wx.ALL | wx.EXPAND) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
330 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
331 |
self.SDOManagementMainSizer.Add(self.SDOManagementInnerMainSizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
332 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
333 |
self.SetSizer(self.SDOManagementMainSizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
334 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
335 |
def SDOInfoUpdate(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
336 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
337 |
Evenet handler for SDO "update" button. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
338 |
- Load SDO data from current slave |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
339 |
@param event : wx.EVT_BUTTON object |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
340 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
341 |
self.Controler.CommonMethod.SaveSDOData = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
342 |
self.Controler.CommonMethod.ClearSDODataSet() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
343 |
self.SDOFlag = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
344 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
345 |
# Check whether beremiz connected or not. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
346 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
347 |
if check_connect_flag: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
348 |
self.SDOs = self.Controler.CommonMethod.GetSlaveSDOFromSlave() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
349 |
# SDOFlag is "False", user click "Cancel" button |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
350 |
self.SDOFlag = self.SDOParser() |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
351 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
352 |
if self.SDOFlag: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
353 |
self.CallSDONoteBook.CreateNoteBook() |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
354 |
self.Refresh() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
355 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
356 |
def SDOParser(self): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
357 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
358 |
Parse SDO data set that obtain "SDOInfoUpdate" Method |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
359 |
@return True or False |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
360 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
361 |
|
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
362 |
slaveSDO_progress = wx.ProgressDialog(_("Slave SDO Monitoring"), _("Now Uploading..."), |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
363 |
maximum=len(self.SDOs.splitlines()), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
364 |
parent=self, |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
365 |
style=wx.PD_CAN_ABORT | wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
366 |
wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME | |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
367 |
wx.PD_AUTO_HIDE | wx.PD_SMOOTH) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
368 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
369 |
# If keep_going flag is False, SDOParser method is stop and return "False". |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
370 |
keep_going = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
371 |
count = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
372 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
373 |
# SDO data example |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
374 |
# SDO 0x1000, "Device type" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
375 |
# 0x1000:00,r-r-r-,uint32,32 bit,"Device type",0x00020192, 131474 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
376 |
for details_line in self.SDOs.splitlines(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
377 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
378 |
line_token = details_line.split("\"") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
379 |
# len(line_token[2]) case : SDO 0x1000, "Device type" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
380 |
if len(line_token[2]) == 0: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
381 |
title_name = line_token[1] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
382 |
# else case : 0x1000:00,r-r-r-,uint32,32 bit,"Device type",0x00020192, 131474 |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
383 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
384 |
# line_token = ['0x1000:00,r-r-r-,uint32,32 bit,', 'Device type', ',0x00020192, 131474'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
385 |
token_head, name, token_tail = line_token |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
386 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
387 |
# token_head = ['0x1000:00', 'r-r-r-', 'uint32', '32 bit', ''] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
388 |
token_head = token_head.split(",") |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
389 |
ful_idx, access, type, size, _empty = token_head |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
390 |
# ful_idx.split(":") = ['0x1000', '00'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
391 |
idx, sub_idx = ful_idx.split(":") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
392 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
393 |
# token_tail = ['', '0x00020192', '131474'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
394 |
token_tail = token_tail.split(",") |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
395 |
try: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
396 |
_empty, hex_val, _dec_val = token_tail |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
397 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
398 |
# SDO data is not return "dec value" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
399 |
# line example : |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
400 |
# 0x1702:01,rwr-r-,uint32,32 bit," 1st mapping", ---- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
401 |
except Exception: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
402 |
_empty, hex_val = token_tail |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
403 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
404 |
name_after_check = self.StringTest(name) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
405 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
406 |
# convert hex type |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
407 |
sub_idx = "0x" + sub_idx |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
408 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
409 |
if type == "octet_string": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
410 |
hex_val = ' ---- ' |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
411 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
412 |
# SResult of SlaveSDO data parsing. (data type : dictionary) |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
413 |
self.Data = {'idx': idx.strip(), 'subIdx': sub_idx.strip(), 'access': access.strip(), |
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
414 |
'type': type.strip(), 'size': size.strip(), 'name': name_after_check.strip("\""), |
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
415 |
'value': hex_val.strip(), "category": title_name.strip("\"")} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
416 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
417 |
category_divide_value = [0x1000, 0x2000, 0x6000, 0xa000, 0xffff] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
418 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
419 |
for count in range(len(category_divide_value)): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
420 |
if int(idx, 0) < category_divide_value[count]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
421 |
self.Controler.CommonMethod.SaveSDOData[count].append(self.Data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
422 |
break |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
423 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
424 |
self.Controler.CommonMethod.SaveSDOData[self.AllSDOData].append(self.Data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
425 |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
426 |
if count >= len(self.SDOs.splitlines()) // 2: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
427 |
(keep_going, _skip) = slaveSDO_progress.Update(count, "Please waiting a moment!!") |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
428 |
else: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
429 |
(keep_going, _skip) = slaveSDO_progress.Update(count) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
430 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
431 |
# If user click "Cancel" loop suspend immediately |
2374
aed3ca79a10a
clean etherlab: pep8, E712 comparison to True should be 'if cond is True:' or 'if cond:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2373
diff
changeset
|
432 |
if not keep_going: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
433 |
break |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
434 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
435 |
slaveSDO_progress.Destroy() |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
436 |
return keep_going |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
437 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
438 |
def StringTest(self, check_string): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
439 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
440 |
Test value 'name' is alphanumeric |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
441 |
@param check_string : input data for check |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
442 |
@return result : output data after check |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
443 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
444 |
# string.printable is print this result |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
445 |
# '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
446 |
# !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
447 |
allow_range = string.printable |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
448 |
result = check_string |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
449 |
for i in range(0, len(check_string)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
450 |
# string.isalnum() is check whether string is alphanumeric or not |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
451 |
if check_string[len(check_string)-1-i:len(check_string)-i] in allow_range: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
452 |
result = check_string[:len(check_string) - i] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
453 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
454 |
return result |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
455 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
456 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
457 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
458 |
# For SDO Notebook (divide category) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
459 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
460 |
class SDONoteBook(wx.Notebook): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
461 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
462 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
463 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
464 |
@param parent: Reference to the parent SDOPanelClass class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
465 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
466 |
""" |
2366
d635680e4c2c
cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2365
diff
changeset
|
467 |
wx.Notebook.__init__(self, parent, id=-1, size=(850, 500)) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
468 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
469 |
self.parent = parent |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
470 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
471 |
self.CreateNoteBook() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
472 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
473 |
def CreateNoteBook(self): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
474 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
475 |
Create each NoteBook page, divided SDO index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
476 |
According to EtherCAT Communication(03/2011), 158p |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
477 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
478 |
self.Data = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
479 |
count = 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
480 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
481 |
page_texts = [("all", self.parent.AllSDOData), |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
482 |
("0x0000 - 0x0ff", self.parent.DatatypeDescription), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
483 |
("0x1000 - 0x1fff", self.parent.CommunicationObject), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
484 |
("0x2000 - 0x5fff", self.parent.ManufacturerSpecific), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
485 |
("0x6000 - 0x9fff", self.parent.ProfileSpecific), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
486 |
("0xa000 - 0xffff", self.parent.Reserved)] |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
487 |
|
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
488 |
# page_tooltip_string = ["SDO Index 0x0000 - 0x0fff : Data Type Description", |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
489 |
# "SDO Index 0x1000 - 0x1fff : Communication object", |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
490 |
# "SDO Index 0x2000 - 0x5fff : Manufacturer specific", |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
491 |
# "SDO Index 0x6000 - 0x9fff : Profile specific", |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
492 |
# "SDO Index 0xa000 - 0xffff : Reserved", |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
493 |
# "All SDO Object"] |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
494 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
495 |
self.DeleteAllPages() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
496 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
497 |
for txt, count in page_texts: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
498 |
self.Data = self.Controler.CommonMethod.SaveSDOData[count] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
499 |
self.Win = SlaveSDOTable(self, self.Data) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
500 |
self.AddPage(self.Win, txt) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
501 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
502 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
503 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
504 |
# For SDO Grid (fill index, subindex, etc...) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
505 |
# ------------------------------------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
506 |
class SlaveSDOTable(wx.grid.Grid): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
507 |
def __init__(self, parent, data): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
508 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
509 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
510 |
@param parent: Reference to the parent SDOPanelClass class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
511 |
@param data: SDO data after parsing "SDOParser" method |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
512 |
""" |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
513 |
wx.grid.Grid.__init__(self, parent, -1, size=(830, 490), |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
514 |
style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
515 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
516 |
self.Controler = parent.Controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
517 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
518 |
self.SDOFlag = True |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
519 |
if data is None: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
520 |
self.SDOs = [] |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
521 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
522 |
self.SDOs = data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
523 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
524 |
self.CreateGrid(len(self.SDOs), 8) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
525 |
SDOCellSize = [(0, 65), (1, 65), (2, 50), (3, 55), |
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
526 |
(4, 40), (5, 200), (6, 250), (7, 85)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
527 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
528 |
for (index, size) in SDOCellSize: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
529 |
self.SetColSize(index, size) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
530 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
531 |
self.SetRowLabelSize(0) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
532 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
533 |
SDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Access"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
534 |
(3, "Type"), (4, "Size"), (5, "Category"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
535 |
(6, "Name"), (7, "Value")] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
536 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
537 |
for (index, label) in SDOTableLabel: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
538 |
self.SetColLabelValue(index, label) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
539 |
self.SetColLabelAlignment(index, wx.ALIGN_CENTRE) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
540 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
541 |
attr = wx.grid.GridCellAttr() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
542 |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
543 |
# for SDO download |
2389
f86eefc8d378
clean etherlab: pylint, W0404 # reimported module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2386
diff
changeset
|
544 |
self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.SDOModifyDialog) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
545 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
546 |
for i in range(7): |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
547 |
self.SetColAttr(i, attr) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
548 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
549 |
self.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
550 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
551 |
self.SetTableValue() |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
552 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
553 |
def SetTableValue(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
554 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
555 |
Cell is filled by new parsing data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
556 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
557 |
sdo_list = ['idx', 'subIdx', 'access', 'type', 'size', 'category', 'name', 'value'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
558 |
for row_idx in range(len(self.SDOs)): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
559 |
for col_idx in range(len(self.SDOs[row_idx])): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
560 |
self.SetCellValue(row_idx, col_idx, self.SDOs[row_idx][sdo_list[col_idx]]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
561 |
self.SetReadOnly(row_idx, col_idx, True) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
562 |
if col_idx < 5: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
563 |
self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
564 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
565 |
def CheckSDODataAccess(self, row): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
566 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
567 |
CheckSDODataAccess method is checking that access data has "w" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
568 |
Access field consist 6 char, if mean |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
569 |
rw rw rw |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
570 |
(preop) (safeop) (op) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
571 |
Example Access field : rwrwrw, rwrw-- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
572 |
@param row : Selected cell by user |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
573 |
@return Write_flag : If data has "w", flag is true |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
574 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
575 |
write_flag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
576 |
check = self.SDOs[row]['access'] |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
577 |
if check[1:2] == 'w': |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
578 |
self.Controler.CommonMethod.Check_PREOP = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
579 |
write_flag = True |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
580 |
if check[3:4] == 'w': |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
581 |
self.Controler.CommonMethod.Check_SAFEOP = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
582 |
write_flag = True |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
583 |
if check[5:] == 'w': |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
584 |
self.Controler.CommonMethod.Check_OP = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
585 |
write_flag = True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
586 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
587 |
return write_flag |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
588 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
589 |
def DecideSDODownload(self, state): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
590 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
591 |
compare current state and "access" field, |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
592 |
result notify SDOModifyDialog method |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
593 |
@param state : current slave state |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
594 |
@return True or False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
595 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
596 |
# Example of 'state' parameter : "0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100)" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
597 |
state = state[self.Controler.GetSlavePos()].split(" ")[2] |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
598 |
if state == "PREOP" and self.Controler.CommonMethod.Check_PREOP: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
599 |
return True |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
600 |
elif state == "SAFEOP" and self.Controler.CommonMethod.Check_SAFEOP: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
601 |
return True |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
602 |
elif state == "OP" and self.Controler.CommonMethod.Check_OP: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
603 |
return True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
604 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
605 |
return False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
606 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
607 |
def ClearStateFlag(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
608 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
609 |
Initialize StateFlag |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
610 |
StateFlag is notice SDOData access each slave state |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
611 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
612 |
self.Controler.CommonMethod.Check_PREOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
613 |
self.Controler.CommonMethod.Check_SAFEOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
614 |
self.Controler.CommonMethod.Check_OP = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
615 |
|
2382
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
616 |
def SDOModifyDialog(self, event): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
617 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
618 |
Create dialog for SDO value modify |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
619 |
if user enter data, perform command "ethercat download" |
2389
f86eefc8d378
clean etherlab: pylint, W0404 # reimported module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2386
diff
changeset
|
620 |
@param event : wx.grid.EVT_GRID_CELL_LEFT_DCLICK object |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
621 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
622 |
self.ClearStateFlag() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
623 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
624 |
# CheckSDODataAccess is checking that OD(Object Dictionary) has "w" |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
625 |
if event.GetCol() == 7 and self.CheckSDODataAccess(event.GetRow()): |
2382
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
626 |
dlg = wx.TextEntryDialog( |
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
627 |
self, |
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
628 |
_("Enter hex or dec value (if enter dec value, it automatically conversed hex value)"), |
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
629 |
"SDOModifyDialog", |
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
630 |
style=wx.OK | wx.CANCEL) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
631 |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
632 |
start_value = self.GetCellValue(event.GetRow(), event.GetCol()) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
633 |
dlg.SetValue(start_value) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
634 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
635 |
if dlg.ShowModal() == wx.ID_OK: |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
636 |
try: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
637 |
int(dlg.GetValue(), 0) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
638 |
# check "Access" field |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
639 |
if self.DecideSDODownload(self.Controler.CommonMethod.SlaveState[self.Controler.GetSlavePos()]): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
640 |
# Request "SDODownload" |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
641 |
self.Controler.CommonMethod.SDODownload( |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
642 |
self.SDOs[event.GetRow()]['type'], |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
643 |
self.SDOs[event.GetRow()]['idx'], |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
644 |
self.SDOs[event.GetRow()]['subIdx'], |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
645 |
dlg.GetValue()) |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
646 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
647 |
self.SetCellValue(event.GetRow(), event.GetCol(), hex(int(dlg.GetValue(), 0))) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
648 |
else: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
649 |
self.Controler.CommonMethod.CreateErrorDialog(_('You cannot SDO download this state')) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
650 |
# Error occured process of "int(variable)" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
651 |
# User input is not hex, dec value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
652 |
except ValueError: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
653 |
self.Controler.CommonMethod.CreateErrorDialog(_('You can input only hex, dec value')) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
654 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
655 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
656 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
657 |
# For PDO Monitoring Panel |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
658 |
# PDO Class UI : Panel -> Choicebook (RxPDO, TxPDO) -> |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
659 |
# Notebook (PDO Index) -> Grid (PDO entry) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
660 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
661 |
class PDOPanelClass(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
662 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
663 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
664 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
665 |
@param parent: Reference to the parent EtherCATManagementTreebook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
666 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
667 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
668 |
wx.Panel.__init__(self, parent, -1) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
669 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
670 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
671 |
self.PDOMonitoringEditorMainSizer = wx.BoxSizer(wx.VERTICAL) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
672 |
self.PDOMonitoringEditorInnerMainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
673 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
674 |
self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
675 |
self.PDOMonitoringEditorInnerMainSizer.Add(self.CallPDOChoicebook, wx.ALL) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
676 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
677 |
self.PDOMonitoringEditorMainSizer.Add(self.PDOMonitoringEditorInnerMainSizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
678 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
679 |
self.SetSizer(self.PDOMonitoringEditorMainSizer) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
680 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
681 |
def PDOInfoUpdate(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
682 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
683 |
Call RequestPDOInfo method and create Choicebook |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
684 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
685 |
self.Controler.CommonMethod.RequestPDOInfo() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
686 |
self.CallPDOChoicebook.Destroy() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
687 |
self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
688 |
self.Refresh() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
689 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
690 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
691 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
692 |
# For PDO Choicebook (divide Tx, Rx PDO) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
693 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
694 |
class PDOChoicebook(wx.Choicebook): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
695 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
696 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
697 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
698 |
@param parent: Reference to the parent PDOPanelClass class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
699 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
700 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
701 |
wx.Choicebook.__init__(self, parent, id=-1, size=(500, 500), style=wx.CHB_DEFAULT) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
702 |
self.Controler = controler |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
703 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
704 |
RxWin = PDONoteBook(self, controler=self.Controler, name="Rx") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
705 |
TxWin = PDONoteBook(self, controler=self.Controler, name="Tx") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
706 |
self.AddPage(RxWin, "RxPDO") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
707 |
self.AddPage(TxWin, "TxPDO") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
708 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
709 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
710 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
711 |
# For PDO Notebook (divide PDO index) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
712 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
713 |
class PDONoteBook(wx.Notebook): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
714 |
def __init__(self, parent, name, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
715 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
716 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
717 |
@param parent: Reference to the parent PDOChoicebook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
718 |
@param name: identifier whether RxPDO or TxPDO |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
719 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
720 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
721 |
wx.Notebook.__init__(self, parent, id=-1, size=(640, 400)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
722 |
self.Controler = controler |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
723 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
724 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
725 |
page_texts = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
726 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
727 |
self.Controler.CommonMethod.RequestPDOInfo() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
728 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
729 |
if name == "Tx": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
730 |
# obtain pdo_info and pdo_entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
731 |
# pdo_info include (PDO index, name, number of entry) |
2373
73d35ba8f982
clean etherlab: pep8, E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2369
diff
changeset
|
732 |
pdo_info = self.Controler.CommonMethod.GetTxPDOCategory() |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
733 |
pdo_entry = self.Controler.CommonMethod.GetTxPDOInfo() |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
734 |
for tmp in pdo_info: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
735 |
title = str(hex(tmp['pdo_index'])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
736 |
page_texts.append(title) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
737 |
# RX PDO case |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
738 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
739 |
pdo_info = self.Controler.CommonMethod.GetRxPDOCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
740 |
pdo_entry = self.Controler.CommonMethod.GetRxPDOInfo() |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
741 |
for tmp in pdo_info: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
742 |
title = str(hex(tmp['pdo_index'])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
743 |
page_texts.append(title) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
744 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
745 |
# Add page depending on the number of pdo_info |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
746 |
for txt in page_texts: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
747 |
win = PDOEntryTable(self, pdo_info, pdo_entry, count) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
748 |
self.AddPage(win, txt) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
749 |
count += 1 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
750 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
751 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
752 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
753 |
# For PDO Grid (fill entry index, subindex etc...) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
754 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
755 |
class PDOEntryTable(wx.grid.Grid): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
756 |
def __init__(self, parent, info, entry, count): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
757 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
758 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
759 |
@param parent: Reference to the parent PDONoteBook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
760 |
@param info : data structure including entry index, sub index, name, length, type |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
761 |
@param entry : data structure including index, name, entry number |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
762 |
@param count : page number |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
763 |
""" |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
764 |
wx.grid.Grid.__init__(self, parent, -1, size=(500, 400), pos=wx.Point(0, 0), |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
765 |
style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
766 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
767 |
self.Controler = parent.Controler |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
768 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
769 |
self.PDOInfo = info |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
770 |
self.PDOEntry = entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
771 |
self.Count = count |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
772 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
773 |
self.CreateGrid(self.PDOInfo[self.Count]['number_of_entry'], 5) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
774 |
self.SetColLabelSize(25) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
775 |
self.SetRowLabelSize(0) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
776 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
777 |
PDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Length"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
778 |
(3, "Type"), (4, "Name")] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
779 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
780 |
for (index, label) in PDOTableLabel: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
781 |
self.SetColLabelValue(index, label) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
782 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
783 |
PDOCellSize = [(0, 45), (1, 65), (2, 55), (3, 40), (4, 300)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
784 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
785 |
for (index, size) in PDOCellSize: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
786 |
self.SetColSize(index, size) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
787 |
self.SetColLabelAlignment(index, wx.ALIGN_LEFT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
788 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
789 |
attr = wx.grid.GridCellAttr() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
790 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
791 |
for i in range(5): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
792 |
self.SetColAttr(i, attr) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
793 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
794 |
self.SetTableValue() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
795 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
796 |
def SetTableValue(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
797 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
798 |
Cell is filled by new parsing data in XML |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
799 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
800 |
list_index = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
801 |
# number of entry |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
802 |
for i in range(self.Count + 1): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
803 |
list_index += self.PDOInfo[i]['number_of_entry'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
804 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
805 |
start_value = list_index - self.PDOInfo[self.Count]['number_of_entry'] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
806 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
807 |
pdo_list = ['entry_index', 'subindex', 'bitlen', 'type', 'name'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
808 |
for row_idx in range(self.PDOInfo[self.Count]['number_of_entry']): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
809 |
for col_idx in range(len(self.PDOEntry[row_idx])): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
810 |
# entry index is converted hex value. |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
811 |
if col_idx == 0: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
812 |
self.SetCellValue(row_idx, col_idx, hex(self.PDOEntry[start_value][pdo_list[col_idx]])) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
813 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
814 |
self.SetCellValue(row_idx, col_idx, str(self.PDOEntry[start_value][pdo_list[col_idx]])) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
815 |
if col_idx != 4: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
816 |
self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
817 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
818 |
self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_LEFT, wx.ALIGN_CENTRE) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
819 |
self.SetReadOnly(row_idx, col_idx, True) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
820 |
self.SetRowSize(row_idx, 25) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
821 |
start_value += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
822 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
823 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
824 |
# ------------------------------------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
825 |
# For EEPROM Access Main Panel |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
826 |
# (This class explain EEPROM Access) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
827 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
828 |
class EEPROMAccessPanel(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
829 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
830 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
831 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
832 |
@param parent: Reference to the parent EtherCATManagementTreebook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
833 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
834 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
835 |
wx.Panel.__init__(self, parent, -1) |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
836 |
sizer = wx.FlexGridSizer(cols=1, hgap=20, rows=3, vgap=20) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
837 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
838 |
line = wx.StaticText(self, -1, "\n EEPROM Access is composed to SmartView and HexView. \ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
839 |
\n\n - SmartView shows Config Data, Device Identity, Mailbox settings, etc. \ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
840 |
\n\n - HexView shows EEPROM's contents.") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
841 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
842 |
sizer.Add(line) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
843 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
844 |
self.SetSizer(sizer) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
845 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
846 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
847 |
# ------------------------------------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
848 |
# For Smart View Panel |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
849 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
850 |
class SlaveSiiSmartView(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
851 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
852 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
853 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
854 |
@param parent: Reference to the parent EtherCATManagementTreebook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
855 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
856 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
857 |
wx.Panel.__init__(self, parent, -1) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
858 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
859 |
self.Controler = controler |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
860 |
|
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
861 |
self.PDIType = { |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
862 |
0: ['none', '00000000'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
863 |
4: ['Digital I/O', '00000100'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
864 |
5: ['SPI Slave', '00000101'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
865 |
7: ['EtherCAT Bridge (port3)', '00000111'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
866 |
8: ['uC async. 16bit', '00001000'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
867 |
9: ['uC async. 8bit', '00001001'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
868 |
10: ['uC sync. 16bit', '00001010'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
869 |
11: ['uC sync. 8bit', '00001011'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
870 |
16: ['32 Digtal Input and 0 Digital Output', '00010000'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
871 |
17: ['24 Digtal Input and 8 Digital Output', '00010001'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
872 |
18: ['16 Digtal Input and 16 Digital Output', '00010010'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
873 |
19: ['8 Digtal Input and 24 Digital Output', '00010011'], |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
874 |
20: ['0 Digtal Input and 32 Digital Output', '00010100'], |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
875 |
128: ['On-chip bus', '11111111'] |
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
876 |
} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
877 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
878 |
sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
879 |
button_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=5) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
880 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
881 |
for button, mapping_method in [("Write EEPROM", self.WriteToEEPROM), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
882 |
("Read EEPROM", self.ReadFromEEPROM)]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
883 |
btn = wx.Button(self, -1, button, size=(150, 40)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
884 |
button_sizer.Add(btn, border=10, flag=wx.ALL) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
885 |
btn.Bind(wx.EVT_BUTTON, mapping_method) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
886 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
887 |
self.TreeListCtrl = SmartViewTreeListCtrl(self, self.Controler) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
888 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
889 |
sizer.Add(button_sizer, border=10, flag=wx.ALL) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
890 |
sizer.Add(self.TreeListCtrl, border=10, flag=wx.ALL) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
891 |
self.SetSizer(sizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
892 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
893 |
self.Create_SmartView() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
894 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
895 |
def Create_SmartView(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
896 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
897 |
SmartView shows information based on XML as initial value. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
898 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
899 |
self.Controler.CommonMethod.SmartViewInfosFromXML = self.Controler.CommonMethod.GetSmartViewInfos() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
900 |
self.SetXMLData() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
901 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
902 |
def WriteToEEPROM(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
903 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
904 |
Open binary file (user select) and write the selected binary data to EEPROM |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
905 |
@param event : wx.EVT_BUTTON object |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
906 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
907 |
# Check whether beremiz connected or not, and whether status is "Started" or not. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
908 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
909 |
if check_connect_flag: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
910 |
status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
2416
1ca207782dde
Use predefined constants for PlcStatus instead of string literals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
911 |
if status is not PlcStatus.Started: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
912 |
dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "", _("bin files (*.bin)|*.bin"), wx.OPEN) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
913 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
914 |
if dialog.ShowModal() == wx.ID_OK: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
915 |
filepath = dialog.GetPath() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
916 |
try: |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
917 |
binfile = open(filepath, "rb") |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
918 |
self.SiiBinary = binfile.read() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
919 |
dialog.Destroy() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
920 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
921 |
self.Controler.CommonMethod.SiiWrite(self.SiiBinary) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
922 |
# refresh data structure kept by master |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
923 |
self.Controler.CommonMethod.Rescan() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
924 |
# save binary data as inner global data of beremiz |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
925 |
# for fast loading when slave plugin node is reopened. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
926 |
self.Controler.CommonMethod.SiiData = self.SiiBinary |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
927 |
self.SetEEPROMData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
928 |
except Exception: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
929 |
self.Controler.CommonMethod.CreateErrorDialog(_('The file does not exist!')) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
930 |
dialog.Destroy() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
931 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
932 |
def ReadFromEEPROM(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
933 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
934 |
Refresh displayed data based on slave EEPROM and save binary file through dialog |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
935 |
@param event : wx.EVT_BUTTON object |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
936 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
937 |
# Check whether beremiz connected or not. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
938 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
939 |
if check_connect_flag: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
940 |
self.SiiBinary = self.Controler.CommonMethod.LoadData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
941 |
self.SetEEPROMData() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
942 |
dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(), |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
943 |
"slave0.bin", _("bin files (*.bin)|*.bin|All files|*.*"), |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
944 |
wx.SAVE | wx.OVERWRITE_PROMPT) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
945 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
946 |
if dialog.ShowModal() == wx.ID_OK: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
947 |
filepath = dialog.GetPath() |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
948 |
binfile = open(filepath, "wb") |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
949 |
binfile.write(self.SiiBinary) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
950 |
binfile.close() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
951 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
952 |
dialog.Destroy() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
953 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
954 |
def SetXMLData(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
955 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
956 |
Set data based on XML initially |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
957 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
958 |
# Config Data: EEPROM Size, PDI Type, Device Emulation |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
959 |
# Find PDI Type in pdiType dictionary |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
960 |
cnt_pdi_type = self.Controler.CommonMethod.SmartViewInfosFromXML["pdi_type"] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
961 |
for i in self.PDIType.keys(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
962 |
if cnt_pdi_type == i: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
963 |
cnt_pdi_type = self.PDIType[i][0] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
964 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
965 |
# Set Config Data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
966 |
for treelist, data in [("EEPROM Size (Bytes)", |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
967 |
str(self.Controler.CommonMethod.SmartViewInfosFromXML["eeprom_size"])), |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
968 |
("PDI Type", |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
969 |
cnt_pdi_type), |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
970 |
("Device Emulation", |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
971 |
self.Controler.CommonMethod.SmartViewInfosFromXML["device_emulation"])]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
972 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.ConfigData[treelist], data, 1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
973 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
974 |
# Device Identity: Vendor ID, Product Code, Revision No., Serial No. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
975 |
# Set Device Identity |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
976 |
for treelist, data in [("Vendor ID", self.Controler.CommonMethod.SmartViewInfosFromXML["vendor_id"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
977 |
("Product Code", self.Controler.CommonMethod.SmartViewInfosFromXML["product_code"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
978 |
("Revision No.", self.Controler.CommonMethod.SmartViewInfosFromXML["revision_no"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
979 |
("Serial No.", self.Controler.CommonMethod.SmartViewInfosFromXML["serial_no"])]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
980 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.DeviceIdentity[treelist], data, 1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
981 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
982 |
# Mailbox: Supported Mailbox, Bootstrap Configuration, Standard Configuration |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
983 |
# Set Mailbox |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
984 |
for treelist, data in [("Supported Mailbox", self.Controler.CommonMethod.SmartViewInfosFromXML["supported_mailbox"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
985 |
("Bootstrap Configuration", ""), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
986 |
("Standard Configuration", "")]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
987 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.Mailbox[treelist], data, 1) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
988 |
# Set Bootstrap Configuration: Receive Offset, Receive Size, Send Offset, Send Size |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
989 |
for treelist, data in [("Receive Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_outstart"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
990 |
("Receive Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_outlength"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
991 |
("Send Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_instart"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
992 |
("Send Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_inlength"])]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
993 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.BootstrapConfig[treelist], data, 1) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
994 |
# Set Standard Configuration: Receive Offset, Receive Size, Send Offset, Send Size |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
995 |
for treelist, data in [("Receive Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_outstart"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
996 |
("Receive Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_outlength"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
997 |
("Send Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_instart"]), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
998 |
("Send Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_inlength"])]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
999 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.StandardConfig[treelist], data, 1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1000 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1001 |
def SetEEPROMData(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1002 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1003 |
Set data based on slave EEPROM. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1004 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1005 |
# sii_dict = { Parameter : (WordAddress, WordSize) } |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
1006 |
sii_dict = { |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1007 |
'PDIControl': ('0', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1008 |
'PDIConfiguration': ('1', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1009 |
'PulseLengthOfSYNCSignals': ('2', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1010 |
'ExtendedPDIConfiguration': ('3', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1011 |
'ConfiguredStationAlias': ('4', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1012 |
'Checksum': ('7', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1013 |
'VendorID': ('8', 2), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1014 |
'ProductCode': ('a', 2), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1015 |
'RevisionNumber': ('c', 2), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1016 |
'SerialNumber': ('e', 2), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1017 |
'Execution Delay': ('10', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1018 |
'Port0Delay': ('11', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1019 |
'Port1Delay': ('12', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1020 |
'BootstrapReceiveMailboxOffset': ('14', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1021 |
'BootstrapReceiveMailboxSize': ('15', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1022 |
'BootstrapSendMailboxOffset': ('16', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1023 |
'BootstrapSendMailboxSize': ('17', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1024 |
'StandardReceiveMailboxOffset': ('18', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1025 |
'StandardReceiveMailboxSize': ('19', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1026 |
'StandardSendMailboxOffset': ('1a', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1027 |
'StandardSendMailboxSize': ('1b', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1028 |
'MailboxProtocol': ('1c', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1029 |
'Size': ('3e', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1030 |
'Version': ('3f', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1031 |
'First Category Type/Vendor Specific': ('40', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1032 |
'Following Category Word Size': ('41', 1), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1033 |
'Category Data': ('42', 1), |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
1034 |
} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1035 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1036 |
# Config Data: EEPROM Size, PDI Type, Device Emulation |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1037 |
# EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1 |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
1038 |
eeprom_size = str((int(self.GetWordAddressData(sii_dict.get('Size'), 10))+1)//8*1024) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1039 |
# Find PDI Type in pdiType dictionary |
2369
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1040 |
cnt_pdi_type = int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16).split('x')[1][2:4], 16) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1041 |
for i in self.PDIType.keys(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1042 |
if cnt_pdi_type == i: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1043 |
cnt_pdi_type = self.PDIType[i][0] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1044 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1045 |
# Get Device Emulation |
2369
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1046 |
device_emulation = str(bool(int("{:0>16b}".format(int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16), 16))[7]))) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1047 |
# Set Config Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1048 |
for treelist, data in [("EEPROM Size (Bytes)", eeprom_size), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1049 |
("PDI Type", cnt_pdi_type), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1050 |
("Device Emulation", device_emulation)]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1051 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.ConfigData[treelist], data, 1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1052 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1053 |
# Device Identity: Vendor ID, Product Code, Revision No., Serial No. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1054 |
# Set Device Identity |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1055 |
for treelist, data in [ |
2369
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1056 |
("Vendor ID", self.GetWordAddressData(sii_dict.get('VendorID'), 16)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1057 |
("Product Code", self.GetWordAddressData(sii_dict.get('ProductCode'), 16)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1058 |
("Revision No.", self.GetWordAddressData(sii_dict.get('RevisionNumber'), 16)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1059 |
("Serial No.", self.GetWordAddressData(sii_dict.get('SerialNumber'), 16))]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1060 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.DeviceIdentity[treelist], data, 1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1061 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1062 |
# Mailbox |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1063 |
# EEORPOM's word address '1c' indicates supported mailbox protocol. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1064 |
# each value of mailbox protocol : |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1065 |
# VoE(0x0020), SoE(0x0010), FoE(0x0008), CoE(0x0004), EoE(0x0002), AoE(0x0001) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1066 |
supported_mailbox = "" |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
1067 |
mailbox_protocol = ["VoE, ", "SoE, ", "FoE, ", "CoE, ", "EoE, ", "AoE, "] |
2369
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1068 |
mailbox_data = "{:0>8b}".format(int(self.GetWordAddressData(sii_dict.get('MailboxProtocol'), 16), 16)) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1069 |
for protocol in range(6): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1070 |
if mailbox_data[protocol+2] == '1': |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1071 |
supported_mailbox += mailbox_protocol[protocol] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1072 |
supported_mailbox = supported_mailbox.strip(", ") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1073 |
# Set Mailbox |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1074 |
for treelist, data in [("Supported Mailbox", supported_mailbox), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1075 |
("Bootstrap Configuration", ""), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1076 |
("Standard Configuration", "")]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1077 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.Mailbox[treelist], data, 1) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1078 |
# Set Bootstrap Configuration: Receive Offset, Receive Size, Send Offset, Send Size |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1079 |
for treelist, data in [ |
2369
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1080 |
("Receive Offset", self.GetWordAddressData(sii_dict.get('BootstrapReceiveMailboxOffset'), 10)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1081 |
("Receive Size", self.GetWordAddressData(sii_dict.get('BootstrapReceiveMailboxSize'), 10)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1082 |
("Send Offset", self.GetWordAddressData(sii_dict.get('BootstrapSendMailboxOffset'), 10)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1083 |
("Send Size", self.GetWordAddressData(sii_dict.get('BootstrapSendMailboxSize'), 10))]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1084 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.BootstrapConfig[treelist], data, 1) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1085 |
# Set Standard Configuration: Receive Offset, Receive Size, Send Offset, Send Size |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1086 |
for treelist, data in [ |
2369
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1087 |
("Receive Offset", self.GetWordAddressData(sii_dict.get('StandardReceiveMailboxOffset'), 10)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1088 |
("Receive Size", self.GetWordAddressData(sii_dict.get('StandardReceiveMailboxSize'), 10)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1089 |
("Send Offset", self.GetWordAddressData(sii_dict.get('StandardSendMailboxOffset'), 10)), |
24db1e592e20
cleanup etherlab: pep8, E201 whitespace after '('
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2368
diff
changeset
|
1090 |
("Send Size", self.GetWordAddressData(sii_dict.get('StandardSendMailboxSize'), 10))]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1091 |
self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.StandardConfig[treelist], data, 1) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1092 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1093 |
def MakeStaticBoxSizer(self, boxlabel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1094 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1095 |
Make StaticBoxSizer |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1096 |
@param boxlabel : label of box sizer |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1097 |
@return sizer : the StaticBoxSizer labeled 'boxlabel' |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1098 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1099 |
box = wx.StaticBox(self, -1, boxlabel) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1100 |
sizer = wx.StaticBoxSizer(box, wx.VERTICAL) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1101 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1102 |
return sizer |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1103 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1104 |
def GetWordAddressData(self, dict_tuple, format): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1105 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1106 |
This method converts word address data from EEPROM binary. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1107 |
@param dict_tuple : element of 'sii_dict' dictionary in SetEEPROMData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1108 |
@param format : format of data. It can be 16(hex), 10(decimal) and 2(binary). |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1109 |
@return formatted value |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1110 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1111 |
offset = int(str(dict_tuple[0]), 16) * 2 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1112 |
length = int(str(dict_tuple[1]), 16) * 2 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1113 |
list = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1114 |
data = '' |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1115 |
for index in range(length): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1116 |
hexdata = hex(ord(self.SiiBinary[offset + index]))[2:] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1117 |
list.append(hexdata.zfill(2)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1118 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1119 |
list.reverse() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1120 |
data = list[0:length] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1121 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1122 |
if format == 16: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1123 |
return '0x' + ''.join(data) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1124 |
elif format == 10: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1125 |
return str(int(str(''.join(data)), 16)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1126 |
elif format == 2: |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1127 |
''.join(data) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1128 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1129 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1130 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1131 |
# For Smart View TreeListCtrl |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1132 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1133 |
class SmartViewTreeListCtrl(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1134 |
def __init__(self, parent, Controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1135 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1136 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1137 |
@param parent: Reference to the parent SlaveSiiSmartView class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1138 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1139 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1140 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1141 |
wx.Panel.__init__(self, parent, -1, size=(350, 500)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1142 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1143 |
self.Tree = wx.gizmos.TreeListCtrl(self, -1, size=(350, 500), |
2386
d00f1430d57a
clean etherlab: pep8, W503 line break before binary operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2385
diff
changeset
|
1144 |
style=(wx.TR_DEFAULT_STYLE | |
d00f1430d57a
clean etherlab: pep8, W503 line break before binary operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2385
diff
changeset
|
1145 |
wx.TR_FULL_ROW_HIGHLIGHT | |
d00f1430d57a
clean etherlab: pep8, W503 line break before binary operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2385
diff
changeset
|
1146 |
wx.TR_HIDE_ROOT | |
d00f1430d57a
clean etherlab: pep8, W503 line break before binary operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2385
diff
changeset
|
1147 |
wx.TR_COLUMN_LINES | |
d00f1430d57a
clean etherlab: pep8, W503 line break before binary operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2385
diff
changeset
|
1148 |
wx.TR_ROW_LINES)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1149 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1150 |
self.Tree.AddColumn("Description", width=200) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1151 |
self.Tree.AddColumn("Value", width=140) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1152 |
self.Tree.SetMainColumn(0) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1153 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1154 |
self.Root = self.Tree.AddRoot("") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1155 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1156 |
# Add item |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1157 |
# Level 1 nodes |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1158 |
self.Level1Nodes = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1159 |
for lv1 in ["Config Data", "Device Identity", "Mailbox"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1160 |
self.Level1Nodes[lv1] = self.Tree.AppendItem(self.Root, lv1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1161 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1162 |
# Level 2 nodes |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1163 |
# Config Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1164 |
self.ConfigData = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1165 |
for lv2 in ["EEPROM Size (Bytes)", "PDI Type", "Device Emulation"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1166 |
self.ConfigData[lv2] = self.Tree.AppendItem(self.Level1Nodes["Config Data"], lv2) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1167 |
# Device Identity |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1168 |
self.DeviceIdentity = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1169 |
for lv2 in ["Vendor ID", "Product Code", "Revision No.", "Serial No."]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1170 |
self.DeviceIdentity[lv2] = self.Tree.AppendItem(self.Level1Nodes["Device Identity"], lv2) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1171 |
# Mailbox |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1172 |
self.Mailbox = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1173 |
for lv2 in ["Supported Mailbox", "Bootstrap Configuration", "Standard Configuration"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1174 |
self.Mailbox[lv2] = self.Tree.AppendItem(self.Level1Nodes["Mailbox"], lv2) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1175 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1176 |
# Level 3 nodes |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1177 |
# Children of Bootstrap Configuration |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1178 |
self.BootstrapConfig = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1179 |
for lv3 in ["Receive Offset", "Receive Size", "Send Offset", "Send Size"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1180 |
self.BootstrapConfig[lv3] = self.Tree.AppendItem(self.Mailbox["Bootstrap Configuration"], lv3) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1181 |
# Children of Standard Configuration |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1182 |
self.StandardConfig = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1183 |
for lv3 in ["Receive Offset", "Receive Size", "Send Offset", "Send Size"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1184 |
self.StandardConfig[lv3] = self.Tree.AppendItem(self.Mailbox["Standard Configuration"], lv3) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1185 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1186 |
# Expand Tree |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1187 |
for tree in [self.Root, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1188 |
self.Level1Nodes["Config Data"], |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1189 |
self.Level1Nodes["Device Identity"], |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1190 |
self.Level1Nodes["Mailbox"], |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1191 |
self.Mailbox["Bootstrap Configuration"], |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1192 |
self.Mailbox["Standard Configuration"]]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1193 |
self.Tree.Expand(tree) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1194 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1195 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1196 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1197 |
# For Hex View Panel |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1198 |
# shows EEPROM binary as hex data and characters. |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1199 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1200 |
class HexView(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1201 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1202 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1203 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1204 |
@param parent: Reference to the parent EtherCATManagementTreebook class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1205 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1206 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1207 |
wx.Panel.__init__(self, parent, -1) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1208 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1209 |
self.Controler = controler |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1210 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1211 |
self.HexRow = 8 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1212 |
self.HexCol = 17 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1213 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1214 |
self.HexViewSizer = {"view": wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1215 |
"siiButton": wx.BoxSizer()} |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1216 |
self.HexViewButton = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1217 |
|
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
1218 |
for key, evt_handler in [ |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
1219 |
("Sii Upload", self.OnButtonSiiUpload), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
1220 |
("Sii Download", self.OnButtonSiiDownload), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
1221 |
("Write to File", self.OnButtonWriteToBinFile), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
1222 |
("Read from File", self.OnButtonReadFromBinFile), |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
1223 |
("XML to EEPROM Image", self.OnButtonXmlToEEPROMImg)]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1224 |
self.HexViewButton[key] = wx.Button(self, -1, key) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1225 |
self.HexViewButton[key].Bind(wx.EVT_BUTTON, evt_handler) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1226 |
self.HexViewSizer["siiButton"].Add(self.HexViewButton[key]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1227 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1228 |
self.SiiBinary = self.Controler.CommonMethod.XmlToEeprom() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1229 |
self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1230 |
self.SiiGrid = SiiGridTable(self, self.Controler, self.HexRow, self.HexCol) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1231 |
self.HexViewSizer["view"].AddMany([self.HexViewSizer["siiButton"], self.SiiGrid]) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1232 |
self.SiiGrid.CreateGrid(self.HexRow, self.HexCol) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1233 |
self.SetSizer(self.HexViewSizer["view"]) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1234 |
self.HexViewSizer["view"].FitInside(self.parent.parent) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1235 |
self.parent.parent.FitInside() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1236 |
self.SiiGrid.SetValue(self.HexCode) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1237 |
self.SiiGrid.Update() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1238 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1239 |
def UpdateSiiGridTable(self, row, col): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1240 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1241 |
Destroy existing grid and recreate |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1242 |
@param row, col : Hex View grid size |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1243 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1244 |
self.HexViewSizer["view"].Detach(self.SiiGrid) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1245 |
self.SiiGrid.Destroy() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1246 |
self.SiiGrid = SiiGridTable(self, self.Controler, row, col) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1247 |
self.HexViewSizer["view"].Add(self.SiiGrid) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1248 |
self.SiiGrid.CreateGrid(row, col) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1249 |
self.SetSizer(self.HexViewSizer["view"]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1250 |
self.HexViewSizer["view"].FitInside(self.parent.parent) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1251 |
self.parent.parent.FitInside() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1252 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1253 |
def OnButtonSiiUpload(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1254 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1255 |
Load EEPROM data from slave and refresh Hex View grid |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1256 |
Binded to 'Sii Upload' button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1257 |
@param event : wx.EVT_BUTTON object |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1258 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1259 |
# Check whether beremiz connected or not. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1260 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1261 |
if check_connect_flag: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1262 |
# load from EEPROM data and parsing |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1263 |
self.SiiBinary = self.Controler.CommonMethod.LoadData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1264 |
self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1265 |
self.UpdateSiiGridTable(self.HexRow, self.HexCol) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1266 |
self.SiiGrid.SetValue(self.HexCode) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1267 |
self.SiiGrid.Update() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1268 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1269 |
def OnButtonSiiDownload(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1270 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1271 |
Write current EEPROM data to slave and refresh data structure kept by master |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1272 |
Binded to 'Sii Download' button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1273 |
@param event : wx.EVT_BUTTON object |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1274 |
""" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1275 |
# Check whether beremiz connected or not, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1276 |
# and whether status is "Started" or not. |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1277 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1278 |
if check_connect_flag: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1279 |
status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
2416
1ca207782dde
Use predefined constants for PlcStatus instead of string literals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
1280 |
if status is not PlcStatus.Started: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1281 |
self.Controler.CommonMethod.SiiWrite(self.SiiBinary) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1282 |
self.Controler.CommonMethod.Rescan() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1283 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1284 |
def OnButtonWriteToBinFile(self, event): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1285 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1286 |
Save current EEPROM data to binary file through FileDialog |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1287 |
Binded to 'Write to File' button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1288 |
@param event : wx.EVT_BUTTON object |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1289 |
""" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1290 |
dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(), "slave0.bin", |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
1291 |
_("bin files (*.bin)|*.bin|All files|*.*"), wx.SAVE | wx.OVERWRITE_PROMPT) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1292 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1293 |
if dialog.ShowModal() == wx.ID_OK: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1294 |
filepath = dialog.GetPath() |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1295 |
binfile = open(filepath, "wb") |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1296 |
binfile.write(self.SiiBinary) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1297 |
binfile.close() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1298 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1299 |
dialog.Destroy() |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1300 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1301 |
def OnButtonReadFromBinFile(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1302 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1303 |
Load binary file through FileDialog |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1304 |
Binded to 'Read from File' button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1305 |
@param event : wx.EVT_BUTTON object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1306 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1307 |
dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "", |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1308 |
_("bin files (*.bin)|*.bin"), wx.OPEN) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1309 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1310 |
if dialog.ShowModal() == wx.ID_OK: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1311 |
filepath = dialog.GetPath() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1312 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1313 |
try: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1314 |
binfile = open(filepath, "rb") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1315 |
self.SiiBinary = binfile.read() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1316 |
self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1317 |
self.UpdateSiiGridTable(self.HexRow, self.HexCol) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1318 |
self.SiiGrid.SetValue(self.HexCode) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1319 |
self.SiiGrid.Update() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1320 |
except Exception: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
1321 |
self.Controler.CommonMethod.CreateErrorDialog(_('The file does not exist!')) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1322 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1323 |
dialog.Destroy() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1324 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1325 |
def OnButtonXmlToEEPROMImg(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1326 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1327 |
Create EEPROM data based XML data that current imported |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1328 |
Binded to 'XML to EEPROM' button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1329 |
@param event : wx.EVT_BUTTON object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1330 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1331 |
self.SiiBinary = self.Controler.CommonMethod.XmlToEeprom() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1332 |
self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1333 |
self.UpdateSiiGridTable(self.HexRow, self.HexCol) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1334 |
self.SiiGrid.SetValue(self.HexCode) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1335 |
self.SiiGrid.Update() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1336 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1337 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1338 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1339 |
# For Hex View grid (fill hex data) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1340 |
# ------------------------------------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1341 |
class SiiGridTable(wx.grid.Grid): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1342 |
def __init__(self, parent, controler, row, col): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1343 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1344 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1345 |
@param parent: Reference to the parent HexView class |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1346 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1347 |
@param row, col: Hex View grid size |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1348 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1349 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1350 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1351 |
self.Row = row |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1352 |
self.Col = col |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1353 |
|
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1354 |
wx.grid.Grid.__init__(self, parent, -1, size=(830, 450), |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
1355 |
style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1356 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1357 |
def SetValue(self, value): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1358 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1359 |
Set data in the table |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1360 |
@param value: EEPROM data list of which element is 1 Byte hex data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1361 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1362 |
# set label name and size |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1363 |
self.SetRowLabelSize(100) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1364 |
for col in range(self.Col): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1365 |
if col == 16: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1366 |
self.SetColLabelValue(16, "Text View") |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
1367 |
self.SetColSize(16, (self.GetSize().x-120)*4//20) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1368 |
else: |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
1369 |
self.SetColLabelValue(col, '%s' % col) |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
1370 |
self.SetColSize(col, (self.GetSize().x-120)//20) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1371 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1372 |
# set data into table |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1373 |
row = col = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1374 |
for row_idx in value: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1375 |
col = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1376 |
self.SetRowLabelValue(row, "0x"+"{:0>4x}".format(row*(self.Col-1))) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1377 |
for hex in row_idx: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1378 |
self.SetCellValue(row, col, hex) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1379 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1380 |
if col == 16: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1381 |
self.SetCellAlignment(row, col, wx.ALIGN_LEFT, wx.ALIGN_CENTER) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1382 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1383 |
self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1384 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1385 |
self.SetReadOnly(row, col, True) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1386 |
col = col + 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1387 |
row = row + 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1388 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1389 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1390 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1391 |
# For Register Access Panel |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1392 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1393 |
class RegisterAccessPanel(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1394 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1395 |
""" |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1396 |
Constructor |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1397 |
@param parent: EEPROMAccessPanel object |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1398 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1399 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1400 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1401 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1402 |
self.__init_data() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1403 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1404 |
wx.Panel.__init__(self, parent, -1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1405 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1406 |
sizer = wx.FlexGridSizer(cols=1, hgap=20, rows=2, vgap=5) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1407 |
button_sizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1408 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1409 |
self.ReloadButton = wx.Button(self, -1, "Reload") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1410 |
self.CompactViewCheckbox = wx.CheckBox(self, -1, "Compact View") |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1411 |
self.RegisterNotebook = RegisterNotebook(self, self.Controler) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1412 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1413 |
button_sizer.AddMany([self.ReloadButton, self.CompactViewCheckbox]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1414 |
sizer.AddMany([button_sizer, self.RegisterNotebook]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1415 |
self.SetSizer(sizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1416 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1417 |
self.ReloadButton.Bind(wx.EVT_BUTTON, self.OnReloadButton) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1418 |
self.CompactViewCheckbox.Bind(wx.EVT_CHECKBOX, self.ToggleCompactViewCheckbox) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1419 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1420 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1421 |
self.RegisterNotebook.RegPage[index].MainTable.CreateGrid(self.MainRow[index], self.MainCol) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1422 |
self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, 0, index*512, (index+1)*512) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1423 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1424 |
# data default setting |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1425 |
if self.Controler.CommonMethod.RegData == "": |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1426 |
self.CompactViewCheckbox.Disable() |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1427 |
for index in range(4): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1428 |
self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, 0, index*512, (index+1)*512) |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1429 |
else: # If data was saved, |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1430 |
self.BasicSetData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1431 |
self.ParseData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1432 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1433 |
self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, self.RegMonitorData, index*512, (index+1)*512) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1434 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1435 |
def __init_data(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1436 |
""" |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1437 |
Declare initial data. |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1438 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1439 |
# flag for compact view |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1440 |
self.CompactFlag = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1441 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1442 |
# main grid의 rows and cols |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1443 |
self.MainRow = [512, 512, 512, 512] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1444 |
self.MainCol = 4 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1445 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1446 |
# main grids' data range |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1447 |
self.PageRange = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1448 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1449 |
self.PageRange.append([512*index, 512*(index+1)]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1450 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1451 |
# Previous value of register data for register description configuration |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1452 |
self.PreRegSpec = {"ESCType": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1453 |
"FMMUNumber": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1454 |
"SMNumber": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1455 |
"PDIType": ""} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1456 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1457 |
def LoadData(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1458 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1459 |
Get data from the register. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1460 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1461 |
self.Controler.CommonMethod.RegData = "" |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1462 |
# ethercat reg_read |
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1463 |
# ex : ethercat reg_read -p 0 0x0000 0x0001 |
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1464 |
# return value : 0x11 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1465 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1466 |
self.Controler.CommonMethod.RegData = self.Controler.CommonMethod.RegData + " " + self.Controler.CommonMethod.RegRead("0x"+"{:0>4x}".format(index*1024), "0x0400") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1467 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1468 |
# store previous value |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1469 |
# (ESC type, port number of FMMU, port number of SM, and PDI type)) |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1470 |
for reg_spec in ["ESCType", "FMMUNumber", "SMNumber", "PDIType"]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1471 |
self.PreRegSpec[reg_spec] = self.Controler.CommonMethod.CrtRegSpec[reg_spec] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1472 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1473 |
# update registers' description |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1474 |
# (ESC type, port number of FMMU, port number of SM, and PDI type) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1475 |
for reg_spec, address in [("ESCType", "0x0000"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1476 |
("FMMUNumber", "0x0004"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1477 |
("SMNumber", "0x0005"), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1478 |
("PDIType", "0x0140")]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1479 |
self.Controler.CommonMethod.CrtRegSpec[reg_spec] = self.Controler.CommonMethod.RegRead(address, "0x0001") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1480 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1481 |
# Enable compactView checkbox |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1482 |
self.CompactViewCheckbox.Enable() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1483 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1484 |
def BasicSetData(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1485 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1486 |
Get and save the description of registers. |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1487 |
It's done by parsing register_information.xml. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1488 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1489 |
# parse the above register's value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1490 |
# If the value is 0x12, the result is 12 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1491 |
self.ESCType = self.Controler.CommonMethod.CrtRegSpec["ESCType"].split('x')[1] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1492 |
self.PDIType = self.Controler.CommonMethod.CrtRegSpec["PDIType"].split('x')[1] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1493 |
# If the value is 0x12, the result is 18 (It's converted to decimal value) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1494 |
self.FMMUNumber = int(self.Controler.CommonMethod.CrtRegSpec["FMMUNumber"], 16) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1495 |
self.SMNumber = int(self.Controler.CommonMethod.CrtRegSpec["SMNumber"], 16) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1496 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1497 |
# initialize description dictionary of register main table and register sub table. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1498 |
self.RegisterDescriptionDict = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1499 |
self.RegisterSubGridDict = {} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1500 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1501 |
# ./EthercatMaster/register_information.xml contains register description. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1502 |
if wx.Platform == '__WXMSW__': |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1503 |
reg_info_file = open("../../EthercatMaster/register_information.xml", 'r') |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1504 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1505 |
reg_info_file = open("./EthercatMaster/register_information.xml", 'r') |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1506 |
reg_info_tree = minidom.parse(reg_info_file) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1507 |
reg_info_file.close() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1508 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1509 |
# parse register description |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1510 |
for register_info in reg_info_tree.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1511 |
for register in register_info.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1512 |
if register.nodeType == reg_info_tree.ELEMENT_NODE and register.nodeName == "Register": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1513 |
# If it depends on the property(ESC type, PDI type, FMMU number, SM number) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1514 |
for property, type, value in [("esc", "type", self.ESCType), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1515 |
("pdi", "type", self.PDIType), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1516 |
("fmmu", "number", self.FMMUNumber), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1517 |
("sm", "number", self.SMNumber)]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1518 |
if property in register.attributes.keys(): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1519 |
if type == "type": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1520 |
if register.attributes[property].value == value: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1521 |
self.GetRegisterInfo(reg_info_tree, register) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1522 |
break |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1523 |
else: # type == "number" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1524 |
if register.attributes[property].value < value: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1525 |
self.GetRegisterInfo(reg_info_tree, register) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1526 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1527 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1528 |
self.GetRegisterInfo(reg_info_tree, register) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1529 |
break |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1530 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1531 |
def GetRegisterInfo(self, reg_info_tree, register): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1532 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1533 |
Save the register's description into the dictionary. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1534 |
reg_info_tree is based on the register_information.xml. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1535 |
@param reg_info_tree: XML tree |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1536 |
@param register: register which you want to get the description |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1537 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1538 |
# temporary variables for register main table idescription dictionary |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1539 |
reg_index = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1540 |
reg_main_description = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1541 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1542 |
for data in register.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1543 |
if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Index": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1544 |
for index in data.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1545 |
reg_index = index.nodeValue |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1546 |
if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Description": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1547 |
for description in data.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1548 |
reg_main_description = description.nodeValue |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1549 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1550 |
# Add description for register main table |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2416
diff
changeset
|
1551 |
if reg_index != "" and reg_main_description != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1552 |
self.RegisterDescriptionDict[reg_index] = reg_main_description |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1553 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1554 |
if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Details": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1555 |
# declare register sub table description dictionary about this index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1556 |
self.RegisterSubGridDict[reg_index] = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1557 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1558 |
for detail in data.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1559 |
if detail.nodeType == reg_info_tree.ELEMENT_NODE and detail.nodeName == "Detail": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1560 |
# If it depends on the property(ESC type, PDI type, FMMU number, SM number) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1561 |
for property, type, value in [("esc", "type", self.ESCType), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1562 |
("pdi", "type", self.PDIType), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1563 |
("fmmu", "number", self.FMMUNumber), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1564 |
("sm", "number", self.SMNumber)]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1565 |
if property in detail.attributes.keys(): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1566 |
if type == "type": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1567 |
if detail.attributes[property].value == value: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1568 |
self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1569 |
break |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1570 |
else: # type == "number" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1571 |
if detail.attributes[property].value < value: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1572 |
self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1573 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1574 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1575 |
self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1576 |
break |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1577 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1578 |
def GetRegisterDetailInfo(self, reg_info_tree, reg_index, detail): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1579 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1580 |
Get the resgister's detailed description(for sub table) from the reg_info_tree. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1581 |
@param reg_info_tree: XML tree (register_information.xml) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1582 |
@param reg_index: index of the register |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1583 |
@param detail: description of the register |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1584 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1585 |
# temporary variables for register sub table description dictionary |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1586 |
# - It is initialized in every sub description |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1587 |
reg_bit_range = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1588 |
reg_sub_description = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1589 |
reg_enum_dictionary = {} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1590 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1591 |
for detail_data in detail.childNodes: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1592 |
if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Range": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1593 |
for range in detail_data.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1594 |
reg_bit_range = range.nodeValue |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1595 |
if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Description": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1596 |
for description in detail_data.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1597 |
reg_sub_description = description.nodeValue |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1598 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1599 |
if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Enum": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1600 |
for enum in detail_data.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1601 |
if enum.nodeType == reg_info_tree.ELEMENT_NODE and enum.nodeName == "item": |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1602 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1603 |
# temporary variables for a description of each value |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1604 |
# For example, if the bit is 1, it is 'enabled'('On', 'True', etc.), |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1605 |
# otherwise 'disabled'('Off', 'False', etc.). |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1606 |
reg_sub_value = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1607 |
reg_sub_value_description = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1608 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1609 |
for item in enum.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1610 |
if item.nodeType == reg_info_tree.ELEMENT_NODE and item.nodeName == "value": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1611 |
for value in item.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1612 |
reg_sub_value = value.nodeValue |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1613 |
if item.nodeType == reg_info_tree.ELEMENT_NODE and item.nodeName == "Description": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1614 |
for description in item.childNodes: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1615 |
reg_sub_value_description = description.nodeValue |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1616 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1617 |
# Add a description of each value to register enum dictionary |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2416
diff
changeset
|
1618 |
if reg_sub_value != "" and reg_sub_value_description != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1619 |
reg_enum_dictionary[reg_sub_value] = reg_sub_value_description |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1620 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1621 |
# add a description to register sub table description dictionary |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2416
diff
changeset
|
1622 |
if reg_bit_range != "" and reg_sub_description != "": |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1623 |
self.RegisterSubGridDict[reg_index].append([reg_bit_range, |
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1624 |
reg_sub_description, |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1625 |
reg_enum_dictionary]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1626 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1627 |
def ParseData(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1628 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1629 |
Transform the data into dec, hex, string, and description |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1630 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1631 |
row_data = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1632 |
self.RegMonitorData = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1633 |
reg_word = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1634 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1635 |
reg_data = self.Controler.CommonMethod.RegData.split() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1636 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1637 |
# loop for register(0x0000:0x0fff) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1638 |
for address in range(0x1000): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1639 |
# arrange 2 Bytes of register data |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1640 |
reg_word = reg_data[address].split('x')[1] + reg_word |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
1641 |
if (address % 2) == 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1642 |
# append address |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1643 |
hex_address = "{:0>4x}".format(address-1) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1644 |
row_data.append(hex_address) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1645 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1646 |
# append description |
2377
88a9d64560d3
clean etherlab: pep8, W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
1647 |
if hex_address in self.RegisterDescriptionDict: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1648 |
row_data.append(self.RegisterDescriptionDict[hex_address]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1649 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1650 |
row_data.append("") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1651 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1652 |
# append Decimal value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1653 |
row_data.append(str(int(reg_word, 16))) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1654 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1655 |
# append Hex value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1656 |
row_data.append('0x'+reg_word) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1657 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1658 |
# append ASCII value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1659 |
char_data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1660 |
for iter in range(2): |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
1661 |
if int(reg_word[iter*2:iter*2+2], 16) >= 32 and int(reg_word[iter*2:iter*2+2], 16) <= 126: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1662 |
char_data = char_data + chr(int(reg_word[iter*2:iter*2+2], 16)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1663 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1664 |
char_data = char_data + "." |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1665 |
row_data.append(char_data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1666 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1667 |
self.RegMonitorData.append(row_data) |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1668 |
reg_word = "" # initialize regWord |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1669 |
row_data = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1670 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1671 |
def OnReloadButton(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1672 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1673 |
Handle the click event of the 'Reload' button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1674 |
Get the data from registers again, and update the table. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1675 |
@param event: wx.EVT_BUTTON object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1676 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1677 |
# Check whether beremiz connected or not. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1678 |
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1679 |
if check_connect_flag: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1680 |
self.LoadData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1681 |
self.BasicSetData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1682 |
self.ParseData() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1683 |
# set data into UI |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1684 |
if self.CompactFlag: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1685 |
self.ToggleCompactViewCheckbox(True) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1686 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1687 |
for index in range(4): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1688 |
self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1689 |
self.PageRange[index][0], self.PageRange[index][1], |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1690 |
self.RegMonitorData) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1691 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1692 |
def ToggleCompactViewCheckbox(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1693 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1694 |
Handles the event of the 'Compact view' check box. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1695 |
If it's checked, show only the registers that have a description. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1696 |
If not, show all the registers. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1697 |
@param event: wx.EVT_CHECKBOX object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1698 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1699 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1700 |
# If "Compact View" Checkbox is True |
2385
f2a53fa6e5d7
clean etherlab: pep8, E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2384
diff
changeset
|
1701 |
# 'event' is argument of this method or event of checkbox. |
2374
aed3ca79a10a
clean etherlab: pep8, E712 comparison to True should be 'if cond is True:' or 'if cond:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2373
diff
changeset
|
1702 |
if event is True or event.GetEventObject().GetValue(): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1703 |
self.CompactFlag = True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1704 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1705 |
reg_compact_data = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1706 |
page_row = [0, 0, 0, 0] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1707 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1708 |
self.PageRange[index] = [0, 0] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1709 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1710 |
for reg_row_data in self.RegMonitorData: |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2416
diff
changeset
|
1711 |
if reg_row_data[1] != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1712 |
# data structure for "compact view" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1713 |
reg_compact_data.append(reg_row_data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1714 |
# count for each register notebooks' row |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1715 |
# It compare with register's address. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1716 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1717 |
if int('0x'+reg_row_data[0], 16) < (index+1)*1024: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1718 |
page_row[index] += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1719 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1720 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1721 |
# Setting tables' rows and cols, range for compact view |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1722 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1723 |
self.MainRow[index] = page_row[index] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1724 |
self.PageRange[index][1] = page_row[index] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1725 |
for iter in range(index): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1726 |
self.PageRange[index][0] += page_row[iter] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1727 |
self.PageRange[index][1] += page_row[iter] |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1728 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1729 |
# Update table |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1730 |
for index in range(4): |
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1731 |
self.RegisterNotebook.RegPage[index].UpdateMainTable( |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1732 |
self.MainRow[index], |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1733 |
self.MainCol, |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1734 |
self.PageRange[index][0], |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1735 |
self.PageRange[index][1], |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1736 |
reg_compact_data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1737 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1738 |
# Compact View Checkbox is False |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1739 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1740 |
self.CompactFlag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1741 |
# Setting original rows, cols and range |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1742 |
self.MainRow = [512, 512, 512, 512] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1743 |
self.PageRange = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1744 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1745 |
for index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1746 |
self.PageRange.append([512*index, 512*(index+1)]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1747 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1748 |
# Update table |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1749 |
for index in range(4): |
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1750 |
self.RegisterNotebook.RegPage[index].UpdateMainTable( |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1751 |
self.MainRow[index], |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1752 |
self.MainCol, |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1753 |
self.PageRange[index][0], |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1754 |
self.PageRange[index][1], |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
1755 |
self.RegMonitorData) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1756 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1757 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1758 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1759 |
# For Register Access Notebook (divide index range) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1760 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1761 |
class RegisterNotebook(wx.Notebook): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1762 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1763 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1764 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1765 |
@param parent: RegisterAccessPanel object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1766 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1767 |
""" |
2366
d635680e4c2c
cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2365
diff
changeset
|
1768 |
wx.Notebook.__init__(self, parent, id=-1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1769 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1770 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1771 |
self.Controler = controler |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1772 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1773 |
# Initialize pages |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1774 |
self.RegPage = [] |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1775 |
pages = 4 |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1776 |
for dummy in range(pages): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1777 |
self.RegPage.append(None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1778 |
|
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1779 |
for index in range(pages): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1780 |
self.RegPage[index] = RegisterNotebookPanel(self, self.Controler, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
1781 |
parent.MainRow[index], parent.MainCol) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1782 |
self.AddPage(self.RegPage[index], |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1783 |
"0x"+"{:0>4x}".format(index*1024)+" - 0x"+"{:0>4x}".format((index+1)*1024-1)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1784 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1785 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1786 |
# ------------------------------------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1787 |
# For Register Access Notebook Panel |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1788 |
# (Main UI : including main, sub table) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1789 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1790 |
class RegisterNotebookPanel(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1791 |
def __init__(self, parent, controler, row, col): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1792 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1793 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1794 |
@param parent: RegisterAccessPanel object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1795 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1796 |
@param row, col: size of the table |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1797 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1798 |
wx.Panel.__init__(self, parent, -1) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1799 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1800 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1801 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1802 |
self.Row = row |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1803 |
self.Col = col |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1804 |
sub_row = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1805 |
sub_col = 4 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1806 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1807 |
self.Sizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=30) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1808 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1809 |
self.MainTable = RegisterMainTable(self, self.Row, self.Col, self.Controler) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1810 |
self.SubTable = RegisterSubTable(self, sub_row, sub_col) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1811 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1812 |
self.SubTable.CreateGrid(sub_row, sub_col) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1813 |
self.SubTable.SetValue(self, []) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1814 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1815 |
self.Sizer.AddMany([self.MainTable, self.SubTable]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1816 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1817 |
self.SetSizer(self.Sizer) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1818 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1819 |
def UpdateMainTable(self, row, col, low_index, high_index, data): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1820 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1821 |
Updates main table. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1822 |
It's done by deleting the main table and creating it again. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1823 |
@param row, col: size of the table |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1824 |
@param low_index: the lowest index of the page |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1825 |
@param high_index: the highest index of the page |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1826 |
@param data: data |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1827 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1828 |
self.MainTable.Destroy() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1829 |
self.MainTable = RegisterMainTable(self, row, col, self.Controler) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1830 |
self.Sizer.Detach(self.SubTable) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1831 |
self.Sizer.AddMany([self.MainTable, self.SubTable]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1832 |
self.SetSizer(self.Sizer) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1833 |
self.MainTable.CreateGrid(row, col) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1834 |
self.MainTable.SetValue(self, data, low_index, high_index) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1835 |
self.MainTable.Update() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1836 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1837 |
def UpdateSubTable(self, row, col, data): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1838 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1839 |
Updates sub table. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1840 |
It's done by deleting the sub table and creating it again. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1841 |
@param row, col: size of the table |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1842 |
@param data: data |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1843 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1844 |
self.SubTable.Destroy() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1845 |
self.SubTable = RegisterSubTable(self, row, col) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1846 |
self.Sizer.Detach(self.MainTable) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1847 |
self.Sizer.AddMany([self.MainTable, self.SubTable]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1848 |
self.Sizer.Layout() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1849 |
self.SetSizer(self.Sizer) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1850 |
self.SubTable.CreateGrid(row, col) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1851 |
self.SubTable.SetValue(self, data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1852 |
self.SubTable.Update() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1853 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1854 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1855 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1856 |
# For Register Access Notebook Panel (Main Table) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1857 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1858 |
class RegisterMainTable(wx.grid.Grid): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1859 |
def __init__(self, parent, row, col, controler): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1860 |
""" |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1861 |
Constructor |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1862 |
@param parent: RegisterNotebook object |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1863 |
@param row, col: size of the table |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1864 |
@param controler: _EthercatSlaveCTN class in EthercatSlave.py |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1865 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1866 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1867 |
self.Data = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1868 |
self.Row = row |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1869 |
self.Col = col |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1870 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1871 |
self.RegisterAccessPanel = self.parent.parent.parent |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1872 |
|
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1873 |
wx.grid.Grid.__init__(self, parent, -1, size=(820, 300), |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
1874 |
style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1875 |
|
2389
f86eefc8d378
clean etherlab: pylint, W0404 # reimported module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2386
diff
changeset
|
1876 |
for evt, mapping_method in [(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell), |
f86eefc8d378
clean etherlab: pylint, W0404 # reimported module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2386
diff
changeset
|
1877 |
(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell), |
f86eefc8d378
clean etherlab: pylint, W0404 # reimported module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2386
diff
changeset
|
1878 |
(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1879 |
self.Bind(evt, mapping_method) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1880 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1881 |
def SetValue(self, parent, reg_monitor_data, low_index, high_index): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1882 |
""" |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1883 |
Set the RegMonitorData into the main table. |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1884 |
@param parent: RegisterNotebook object |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1885 |
@param reg_monitor_data: data |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1886 |
@param low_index: the lowest index of the page |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1887 |
@param high_index: the highest index of the page |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1888 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1889 |
self.RegMonitorData = reg_monitor_data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1890 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1891 |
# set label name and size |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1892 |
register_maintable_label = [(0, "Description"), (1, "Dec"), |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1893 |
(2, "Hex"), (3, "Char")] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1894 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1895 |
for (index, label) in register_maintable_label: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1896 |
self.SetColLabelValue(index, label) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1897 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1898 |
self.SetColSize(0, 200) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1899 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1900 |
# if reg_monitor_data is 0, it is initialization of register access. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1901 |
if reg_monitor_data == 0: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1902 |
return 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1903 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1904 |
# set data into UI |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1905 |
row = col = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1906 |
for row_index in reg_monitor_data[low_index:high_index]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1907 |
col = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1908 |
self.SetRowLabelValue(row, row_index[0]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1909 |
for data_index in range(4): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1910 |
self.SetCellValue(row, col, row_index[data_index+1]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1911 |
self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1912 |
self.SetReadOnly(row, col, True) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1913 |
col = col + 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1914 |
row = row + 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1915 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1916 |
def OnSelectCell(self, event): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1917 |
""" |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1918 |
Handles the event of the cell of the main table. |
2389
f86eefc8d378
clean etherlab: pylint, W0404 # reimported module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2386
diff
changeset
|
1919 |
@param event: wx.grid object (left click) |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1920 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1921 |
# if reg_monitor_data is 0, it is initialization of register access. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1922 |
if self.RegMonitorData == 0: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1923 |
event.Skip() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1924 |
return 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1925 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1926 |
sub_row = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1927 |
sub_col = 4 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1928 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1929 |
address = self.GetRowLabelValue(event.GetRow()) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1930 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1931 |
reg_sub_grid_data = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1932 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1933 |
BIT_RANGE, NAME, DESCRIPTIONS = range(3) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1934 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1935 |
# Check if this register's detail description is exist or not, |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1936 |
# and create data structure for the detail description table ; sub grid |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1937 |
if address in self.RegisterAccessPanel.RegisterSubGridDict: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1938 |
for element in self.RegisterAccessPanel.RegisterSubGridDict[address]: |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
1939 |
row_data = [] |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1940 |
row_data.append(element[BIT_RANGE]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1941 |
row_data.append(element[NAME]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1942 |
bin_data = "{:0>16b}".format(int(self.GetCellValue(event.GetRow(), 1))) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1943 |
value_range = element[BIT_RANGE].split('-') |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1944 |
value = (bin_data[8:16][::-1]+bin_data[0:8][::-1])[int(value_range[0]):(int(value_range[-1])+1)][::-1] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1945 |
row_data.append(str(int(('0b'+str(value)), 2))) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1946 |
if value in element[DESCRIPTIONS]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1947 |
row_data.append(element[DESCRIPTIONS][value]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1948 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1949 |
row_data.append('') |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1950 |
reg_sub_grid_data.append(row_data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1951 |
sub_row = sub_row + 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1952 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1953 |
self.parent.UpdateSubTable(sub_row, sub_col, reg_sub_grid_data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1954 |
# event.Skip() updates UI of selecting cell |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1955 |
event.Skip() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1956 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1957 |
def OnRegModifyDialog(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1958 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1959 |
Handle the event of the cell of the main table. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1960 |
Display the window where the user modifies the value of the cell. |
2389
f86eefc8d378
clean etherlab: pylint, W0404 # reimported module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2386
diff
changeset
|
1961 |
@param event: wx.grid object (double click) |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
1962 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1963 |
# user can enter a value in case that user double-clicked 'Dec' or 'Hex' value. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1964 |
if event.GetCol() == 1 or event.GetCol() == 2: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
1965 |
dlg = wx.TextEntryDialog(self, _("Enter hex(0xnnnn) or dec(n) value"), |
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
1966 |
_("Register Modify Dialog"), style=wx.OK | wx.CANCEL) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1967 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1968 |
# Setting value in initial dialog value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1969 |
start_value = self.GetCellValue(event.GetRow(), event.GetCol()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1970 |
dlg.SetValue(start_value) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1971 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1972 |
if dlg.ShowModal() == wx.ID_OK: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1973 |
try: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1974 |
# It int(input) success, this input is dev or hex value. |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1975 |
# Otherwise, it's error, so it goes except. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1976 |
int(dlg.GetValue(), 0) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1977 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1978 |
# reg_write |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1979 |
# ex) ethercat reg_write -p 0 -t uint16 0x0000 0x0000 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1980 |
return_val = self.Controler.CommonMethod.RegWrite('0x'+self.GetRowLabelValue(event.GetRow()), dlg.GetValue()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1981 |
|
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
1982 |
if len(return_val) == 0: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1983 |
# set dec |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1984 |
self.SetCellValue(event.GetRow(), 1, str(int(dlg.GetValue(), 0))) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1985 |
# set hex |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1986 |
hex_data = '0x'+"{:0>4x}".format(int(dlg.GetValue(), 0)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1987 |
self.SetCellValue(event.GetRow(), 2, hex_data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1988 |
# set char |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1989 |
char_data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1990 |
# If hex_data is been able to convert to ascii code, append ascii code. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1991 |
for iter in range(2): |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
1992 |
if int(hex_data[(iter+1)*2:(iter+2)*2], 16) >= 32 and int(hex_data[(iter+1)*2:(iter+2)*2], 16) <= 126: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1993 |
char_data = char_data + chr(int(hex_data[(iter+1)*2:(iter+2)*2], 16)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1994 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1995 |
char_data = char_data + "." |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1996 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1997 |
self.SetCellValue(event.GetRow(), 3, char_data) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1998 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1999 |
else: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
2000 |
self.Controler.CommonMethod.CreateErrorDialog(_('You can\'t modify it. This register is read-only or it\'s not connected.')) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2001 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2002 |
except ValueError: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
2003 |
self.Controler.CommonMethod.CreateErrorDialog(_('You entered wrong value. You can enter dec or hex value only.')) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2004 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2005 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
2006 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2007 |
# For Register Access Notebook Panel (Sub Table) |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
2008 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2009 |
class RegisterSubTable(wx.grid.Grid): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2010 |
def __init__(self, parent, row, col): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2011 |
""" |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2012 |
Constructor |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2013 |
@param parent: RegisterNotebook object |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2014 |
@param row, col: size of the table |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2015 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2016 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2017 |
self.Data = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2018 |
self.Row = row |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2019 |
self.Col = col |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2020 |
|
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
2021 |
wx.grid.Grid.__init__(self, parent, -1, size=(820, 150), |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
2022 |
style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2023 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2024 |
def SetValue(self, parent, data): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2025 |
""" |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2026 |
Set the data into the subtable. |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2027 |
@param parent: RegisterNotebook object |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2028 |
@param data: data |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
2029 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2030 |
# lset label name and size |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2031 |
Register_SubTable_Label = [(0, "Bits"), (1, "Name"), |
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2379
diff
changeset
|
2032 |
(2, "Value"), (3, "Enum")] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2033 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2034 |
for (index, label) in Register_SubTable_Label: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2035 |
self.SetColLabelValue(index, label) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2036 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2037 |
self.SetColSize(1, 200) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2038 |
self.SetColSize(3, 200) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2039 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2040 |
# set data into table |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2041 |
row = col = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2042 |
for rowData in data: |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2043 |
col = 0 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2044 |
for element in rowData: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2045 |
self.SetCellValue(row, col, element) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2046 |
self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2047 |
self.SetReadOnly(row, col, True) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2048 |
col = col + 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2049 |
row = row + 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2050 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2051 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
2052 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2053 |
# For Master State Panel |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
2054 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2055 |
class MasterStatePanelClass(wx.Panel): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2056 |
def __init__(self, parent, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2057 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2058 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2059 |
@param parent: wx.ScrollWindow object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2060 |
@Param controler: _EthercatSlaveCTN class in EthercatSlave.py |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2061 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2062 |
wx.Panel.__init__(self, parent, -1, (0, 0), |
2366
d635680e4c2c
cleanup etherlab: pep8, E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2365
diff
changeset
|
2063 |
size=wx.DefaultSize, style=wx.SUNKEN_BORDER) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2064 |
self.Controler = controler |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2065 |
self.parent = parent |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2066 |
self.StaticBox = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2067 |
self.StaticText = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2068 |
self.TextCtrl = {} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2069 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2070 |
# ----------------------- Main Sizer and Update Button -------------------------------------------- |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
2071 |
self.MasterStateSizer = {"main": wx.BoxSizer(wx.VERTICAL)} |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2072 |
for key, attr in [ |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2073 |
("innerMain", [1, 10, 2, 10]), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2074 |
("innerTopHalf", [2, 10, 1, 10]), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2075 |
("innerBottomHalf", [2, 10, 1, 10]), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2076 |
("innerMasterState", [2, 10, 3, 10]), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2077 |
("innerDeviceInfo", [4, 10, 3, 10]), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2078 |
("innerFrameInfo", [4, 10, 5, 10])]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2079 |
self.MasterStateSizer[key] = wx.FlexGridSizer(cols=attr[0], hgap=attr[1], rows=attr[2], vgap=attr[3]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2080 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2081 |
self.UpdateButton = wx.Button(self, label=_('Update')) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2082 |
self.UpdateButton.Bind(wx.EVT_BUTTON, self.OnButtonClick) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2083 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2084 |
for key, label in [ |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2085 |
('masterState', 'EtherCAT Master State'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2086 |
('deviceInfo', 'Ethernet Network Card Information'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2087 |
('frameInfo', 'Network Frame Information')]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2088 |
self.StaticBox[key] = wx.StaticBox(self, label=_(label)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2089 |
self.MasterStateSizer[key] = wx.StaticBoxSizer(self.StaticBox[key]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2090 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2091 |
# ----------------------- Master State ----------------------------------------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2092 |
for key, label in [ |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2093 |
('Phase', 'Phase:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2094 |
('Active', 'Active:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2095 |
('Slaves', 'Slave Count:')]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2096 |
self.StaticText[key] = wx.StaticText(self, label=_(label)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2097 |
self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2098 |
self.MasterStateSizer['innerMasterState'].AddMany([self.StaticText[key], self.TextCtrl[key]]) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2099 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2100 |
self.MasterStateSizer['masterState'].AddSizer(self.MasterStateSizer['innerMasterState']) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2101 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2102 |
# ----------------------- Ethernet Network Card Information --------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2103 |
for key, label in [ |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2104 |
('Main', 'MAC Address:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2105 |
('Link', 'Link State:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2106 |
('Tx frames', 'Tx Frames:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2107 |
('Rx frames', 'Rx Frames:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2108 |
('Lost frames', 'Lost Frames:')]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2109 |
self.StaticText[key] = wx.StaticText(self, label=_(label)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2110 |
self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2111 |
self.MasterStateSizer['innerDeviceInfo'].AddMany([self.StaticText[key], self.TextCtrl[key]]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2112 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2113 |
self.MasterStateSizer['deviceInfo'].AddSizer(self.MasterStateSizer['innerDeviceInfo']) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2114 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2115 |
# ----------------------- Network Frame Information ----------------------------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2116 |
for key, label in [ |
2379
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2117 |
('Tx frame rate [1/s]', 'Tx Frame Rate [1/s]:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2118 |
('Rx frame rate [1/s]', 'Tx Rate [kByte/s]:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2119 |
('Loss rate [1/s]', 'Loss Rate [1/s]:'), |
015b724c30a5
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2377
diff
changeset
|
2120 |
('Frame loss [%]', 'Frame Loss [%]:')]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2121 |
self.StaticText[key] = wx.StaticText(self, label=_(label)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2122 |
self.MasterStateSizer['innerFrameInfo'].Add(self.StaticText[key]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2123 |
self.TextCtrl[key] = {} |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2124 |
for index in ['0', '1', '2']: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2125 |
self.TextCtrl[key][index] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2126 |
self.MasterStateSizer['innerFrameInfo'].Add(self.TextCtrl[key][index]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2127 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2128 |
self.MasterStateSizer['frameInfo'].AddSizer(self.MasterStateSizer['innerFrameInfo']) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2129 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2130 |
# --------------------------------- Main Sizer ---------------------------------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2131 |
for key, sub, in [ |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
2132 |
('innerTopHalf', ['masterState', 'deviceInfo']), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
2133 |
('innerBottomHalf', ['frameInfo']), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
2134 |
('innerMain', ['innerTopHalf', 'innerBottomHalf']) |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
2135 |
]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2136 |
for key2 in sub: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2137 |
self.MasterStateSizer[key].AddSizer(self.MasterStateSizer[key2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2138 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2139 |
self.MasterStateSizer['main'].AddSizer(self.UpdateButton) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2140 |
self.MasterStateSizer['main'].AddSizer(self.MasterStateSizer['innerMain']) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2141 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2142 |
self.SetSizer(self.MasterStateSizer['main']) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2143 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2144 |
def OnButtonClick(self, event): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2145 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2146 |
Handle the event of the 'Update' button. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2147 |
Update the data of the master state. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2148 |
@param event: wx.EVT_BUTTON object |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2149 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2150 |
if self.Controler.GetCTRoot()._connector is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2151 |
self.MasterState = self.Controler.CommonMethod.GetMasterState() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2152 |
# Update each TextCtrl |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2153 |
if self.MasterState: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2154 |
for key in self.TextCtrl: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2155 |
if isinstance(self.TextCtrl[key], dict): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2156 |
for index in self.TextCtrl[key]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2157 |
self.TextCtrl[key][index].SetValue(self.MasterState[key][int(index)]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2158 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2159 |
self.TextCtrl[key].SetValue(self.MasterState[key][0]) |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
2160 |
else: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2417
diff
changeset
|
2161 |
self.Controler.CommonMethod.CreateErrorDialog(_('PLC not connected!')) |