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