author | Edouard Tisserant |
Fri, 11 Oct 2019 12:03:14 +0200 | |
branch | svghmi |
changeset 2797 | c5ba1e77f054 |
parent 2446 | 922f0d84f869 |
child 2643 | b98d9e08231f |
permissions | -rw-r--r-- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1 |
#!/usr/bin/env python |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
3 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
4 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
5 |
# 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
|
6 |
# |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
7 |
# Copyright (C) 2013: Real-Time & Embedded Systems (RTES) Lab. University of Seoul, Korea |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
8 |
# |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
9 |
# 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
|
10 |
|
2405
af050469fc5c
clean etherlab: pylint, W1618 # (no-absolute-import) import missing `from __future__ import absolute_import`
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2400
diff
changeset
|
11 |
from __future__ import absolute_import |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
12 |
from __future__ import division |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
13 |
from builtins import str as text |
2446
922f0d84f869
python3 support: pylint, W1646 # (invalid-str-codec) non-text encoding used in str.decode
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
14 |
import codecs |
2354
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 |
|
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
17 |
|
2373
73d35ba8f982
clean etherlab: pep8, E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2370
diff
changeset
|
18 |
mailbox_protocols = ["AoE", "EoE", "CoE", "FoE", "SoE", "VoE"] |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
19 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
20 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
21 |
def ExtractHexDecValue(value): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
22 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
23 |
convert numerical value in string format into decimal or hex format. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
24 |
@param value : hex or decimal data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
25 |
@return integer data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
26 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
27 |
try: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
28 |
return int(value) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
29 |
except Exception: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
30 |
pass |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
31 |
try: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
32 |
return int(value.replace("#", "0"), 16) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
33 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
34 |
except Exception: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2421
diff
changeset
|
35 |
raise ValueError(_("Invalid value for HexDecValue \"%s\"") % value) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
36 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
37 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
38 |
def ExtractName(names, default=None): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
39 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
40 |
Extract "name" field from XML entries. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
41 |
@param names : XML entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
42 |
@default : if it fails to extract from the designated XML entry, return the default value ("None"). |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
43 |
@return default or the name extracted |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
44 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
45 |
if len(names) == 1: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
46 |
return names[0].getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
47 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
48 |
for name in names: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
49 |
if name.getLcId() == 1033: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
50 |
return name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
51 |
return default |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
52 |
|
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 |
# Remote Exec Etherlab Commands |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
55 |
# -------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
56 |
|
2370
e40f3914e55f
cleanup etherlab: pep8, E305 expected 2 blank lines after class or function definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2367
diff
changeset
|
57 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
58 |
# --------------------- for master --------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
59 |
MASTER_STATE = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
60 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
61 |
result = commands.getoutput("ethercat master") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
62 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
63 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
64 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
65 |
# --------------------- for slave ---------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
66 |
# ethercat state -p (slave position) (state (INIT, PREOP, SAFEOP, OP)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
67 |
SLAVE_STATE = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
68 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
69 |
result = commands.getoutput("ethercat state -p %d %s") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
70 |
returnVal = result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
71 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
72 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
73 |
# ethercat slave |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
74 |
GET_SLAVE = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
75 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
76 |
result = commands.getoutput("ethercat slaves") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
77 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
78 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
79 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
80 |
# ethercat xml -p (slave position) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
81 |
SLAVE_XML = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
82 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
83 |
result = commands.getoutput("ethercat xml -p %d") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
84 |
returnVal = result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
85 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
86 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
87 |
# ethercat sdos -p (slave position) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
88 |
SLAVE_SDO = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
89 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
90 |
result = commands.getoutput("ethercat sdos -p %d") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
91 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
92 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
93 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
94 |
# ethercat upload -p (slave position) (main index) (sub index) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
95 |
GET_SLOW_SDO = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
96 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
97 |
result = commands.getoutput("ethercat upload -p %d %s %s") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
98 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
99 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
100 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
101 |
# ethercat download -p (slave position) (main index) (sub index) (value) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
102 |
SDO_DOWNLOAD = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
103 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
104 |
result = commands.getoutput("ethercat download --type %s -p %d %s %s %s") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
105 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
106 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
107 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
108 |
# ethercat sii_read -p (slave position) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
109 |
SII_READ = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
110 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
111 |
result = commands.getoutput("ethercat sii_read -p %d") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
112 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
113 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
114 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
115 |
# ethercat reg_read -p (slave position) (address) (size) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
116 |
REG_READ = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
117 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
118 |
result = commands.getoutput("ethercat reg_read -p %d %s %s") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
119 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
120 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
121 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
122 |
# ethercat sii_write -p (slave position) - (contents) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
123 |
SII_WRITE = """ |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
124 |
import subprocess |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
125 |
process = subprocess.Popen( |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
126 |
["ethercat", "-f", "sii_write", "-p", "%d", "-"], |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
127 |
stdin=subprocess.PIPE) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
128 |
process.communicate(sii_data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
129 |
returnVal = process.returncode |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
130 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
131 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
132 |
# ethercat reg_write -p (slave position) -t (uinit16) (address) (data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
133 |
REG_WRITE = """ |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
134 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
135 |
result = commands.getoutput("ethercat reg_write -p %d -t uint16 %s %s") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
136 |
returnVal =result |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
137 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
138 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
139 |
# ethercat rescan -p (slave position) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
140 |
RESCAN = """ |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
141 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
142 |
result = commands.getoutput("ethercat rescan -p %d") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
143 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
144 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
145 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
146 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
147 |
# -------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
148 |
# Common Method For EtherCAT Management |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
149 |
# -------------------------------------------------- |
2397
25f16349644b
clean etherlab: pylint, C1001 # (old-style-class) Old-style class defined.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2396
diff
changeset
|
150 |
class _CommonSlave(object): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
151 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
152 |
# ----- Data Structure for ethercat management ---- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
153 |
SlaveState = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
154 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
155 |
# category of SDO data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
156 |
DatatypeDescription, CommunicationObject, ManufacturerSpecific, \ |
2384
d7d9f0e60bc9
clean etherlab: pep8, E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2383
diff
changeset
|
157 |
ProfileSpecific, Reserved, AllSDOData = range(6) |
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 |
# store the execution result of "ethercat sdos" command into SaveSDOData. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
160 |
SaveSDOData = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
161 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
162 |
# Flags for checking "write" permission of OD entries |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
163 |
CheckPREOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
164 |
CheckSAFEOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
165 |
CheckOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
166 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
167 |
# Save PDO Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
168 |
TxPDOInfo = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
169 |
TxPDOCategory = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
170 |
RxPDOInfo = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
171 |
RxPDOCategory = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
172 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
173 |
# Save EEPROM Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
174 |
SiiData = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
175 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
176 |
# Save Register Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
177 |
RegData = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
178 |
CrtRegSpec = {"ESCType": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
179 |
"FMMUNumber": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
180 |
"SMNumber": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
181 |
"PDIType": ""} |
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 |
def __init__(self, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
184 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
185 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
186 |
@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
|
187 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
188 |
self.Controler = controler |
2446
922f0d84f869
python3 support: pylint, W1646 # (invalid-str-codec) non-text encoding used in str.decode
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
189 |
self.HexDecode = codecs.getdecoder("hex_codec") |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
190 |
self.ClearSDODataSet() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
191 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
192 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
193 |
# Used Master State |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
194 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
195 |
def GetMasterState(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
196 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
197 |
Execute "ethercat master" command and parse the execution result |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
198 |
@return MasterState |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
199 |
""" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
200 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
201 |
# exectute "ethercat master" command |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
202 |
_error, return_val = self.Controler.RemoteExec(MASTER_STATE, return_val=None) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
203 |
master_state = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
204 |
# parse the reslut |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
205 |
for each_line in return_val.splitlines(): |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
206 |
if len(each_line) > 0: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
207 |
chunks = each_line.strip().split(':', 1) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
208 |
key = chunks[0] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
209 |
value = [] |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
210 |
if len(chunks) > 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
211 |
value = chunks[1].split() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
212 |
if '(attached)' in value: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
213 |
value.remove('(attached)') |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
214 |
master_state[key] = value |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
215 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
216 |
return master_state |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
217 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
218 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
219 |
# Used Slave State |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
220 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
221 |
def RequestSlaveState(self, command): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
222 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
223 |
Set slave state to the specified one using "ethercat states -p %d %s" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
224 |
Command example : "ethercat states -p 0 PREOP" (target slave position and target state are given.) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
225 |
@param command : target slave state |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
226 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
227 |
_error, _return_val = self.Controler.RemoteExec( |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
228 |
SLAVE_STATE % (self.Controler.GetSlavePos(), command), |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
229 |
return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
230 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
231 |
def GetSlaveStateFromSlave(self): |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
232 |
""" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
233 |
Get slave information using "ethercat slaves" command and store the information into internal data structure |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
234 |
(self.SlaveState) for "Slave State" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
235 |
return_val example : 0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
236 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
237 |
_error, return_val = self.Controler.RemoteExec(GET_SLAVE, return_val=None) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
238 |
self.SlaveState = return_val |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
239 |
return return_val |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
240 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
241 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
242 |
# Used SDO Management |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
243 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
244 |
def GetSlaveSDOFromSlave(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
245 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
246 |
Get SDO objects information of current slave using "ethercat sdos -p %d" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
247 |
Command example : "ethercat sdos -p 0" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
248 |
@return return_val : execution results of "ethercat sdos" command (need to be parsed later) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
249 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
250 |
_error, return_val = self.Controler.RemoteExec(SLAVE_SDO % (self.Controler.GetSlavePos()), return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
251 |
return return_val |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
252 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
253 |
def SDODownload(self, data_type, idx, sub_idx, value): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
254 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
255 |
Set an SDO object value to user-specified value using "ethercat download" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
256 |
Command example : "ethercat download --type int32 -p 0 0x8020 0x12 0x00000000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
257 |
@param data_type : data type of SDO entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
258 |
@param idx : index of the SDO entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
259 |
@param sub_idx : subindex of the SDO entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
260 |
@param value : value of SDO entry |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
261 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
262 |
_error, _return_val = self.Controler.RemoteExec( |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
263 |
SDO_DOWNLOAD % (data_type, self.Controler.GetSlavePos(), idx, sub_idx, value), |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
264 |
return_val=None) |
2355
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 BackupSDODataSet(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
267 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
268 |
Back-up current SDO entry information to restore the SDO data |
2383
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
269 |
in case that the user cancels SDO update operation. |
6cc3460be285
clean etherlab: pep8, W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2382
diff
changeset
|
270 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
271 |
self.BackupDatatypeDescription = self.SaveDatatypeDescription |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
272 |
self.BackupCommunicationObject = self.SaveCommunicationObject |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
273 |
self.BackupManufacturerSpecific = self.SaveManufacturerSpecific |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
274 |
self.BackupProfileSpecific = self.SaveProfileSpecific |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
275 |
self.BackupReserved = self.SaveReserved |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
276 |
self.BackupAllSDOData = self.SaveAllSDOData |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
277 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
278 |
def ClearSDODataSet(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
279 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
280 |
Clear the specified SDO entry information. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
281 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
282 |
for dummy in range(6): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
283 |
self.SaveSDOData.append([]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
284 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
285 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
286 |
# Used PDO Monitoring |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
287 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
288 |
def RequestPDOInfo(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
289 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
290 |
Load slave information from RootClass (XML data) and parse the information (calling SlavePDOData() method). |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
291 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
292 |
# Load slave information from ESI XML file (def EthercatMaster.py) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
293 |
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
294 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
295 |
type_infos = slave.getType() |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
296 |
device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
297 |
# Initialize PDO data set |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
298 |
self.ClearDataSet() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
299 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
300 |
# if 'device' object is valid, call SavePDOData() to parse PDO data |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
301 |
if device is not None: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
302 |
self.SavePDOData(device) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
303 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
304 |
def SavePDOData(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
305 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
306 |
Parse PDO data and store the results in TXPDOCategory and RXPDOCategory |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
307 |
Tx(Rx)PDOCategory : index, name, entry number |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
308 |
Tx(Rx)Info : 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
|
309 |
@param device : Slave information extracted from ESI XML file |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
310 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
311 |
# Parsing TXPDO entries |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
312 |
for pdo, _pdo_info in ([(pdo, "Inputs") for pdo in device.getTxPdo()]): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
313 |
# Save pdo_index, entry, and name of each entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
314 |
pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
315 |
entries = pdo.getEntry() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
316 |
pdo_name = ExtractName(pdo.getName()) |
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 |
# Initialize entry number count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
319 |
count = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
320 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
321 |
# Parse entries |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
322 |
for entry in entries: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
323 |
# Save index and subindex |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
324 |
index = ExtractHexDecValue(entry.getIndex().getcontent()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
325 |
subindex = ExtractHexDecValue(entry.getSubIndex()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
326 |
# if entry name exists, save entry data |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
327 |
if ExtractName(entry.getName()) is not None: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
328 |
entry_infos = { |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
329 |
"entry_index": index, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
330 |
"subindex": subindex, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
331 |
"name": ExtractName(entry.getName()), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
332 |
"bitlen": entry.getBitLen(), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
333 |
"type": entry.getDataType().getcontent() |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
334 |
} |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
335 |
self.TxPDOInfo.append(entry_infos) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
336 |
count += 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
337 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
338 |
categorys = {"pdo_index": pdo_index, "name": pdo_name, "number_of_entry": count} |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
339 |
self.TxPDOCategory.append(categorys) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
340 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
341 |
# Parsing RxPDO entries |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
342 |
for pdo, _pdo_info in ([(rxpdo, "Outputs") for rxpdo in device.getRxPdo()]): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
343 |
# Save pdo_index, entry, and name of each entry |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
344 |
pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
345 |
entries = pdo.getEntry() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
346 |
pdo_name = ExtractName(pdo.getName()) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
347 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
348 |
# Initialize entry number count |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
349 |
count = 0 |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
350 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
351 |
# Parse entries |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
352 |
for entry in entries: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
353 |
# Save index and subindex |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
354 |
index = ExtractHexDecValue(entry.getIndex().getcontent()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
355 |
subindex = ExtractHexDecValue(entry.getSubIndex()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
356 |
# if entry name exists, save entry data |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
357 |
if ExtractName(entry.getName()) is not None: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
358 |
entry_infos = { |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
359 |
"entry_index": index, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
360 |
"subindex": subindex, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
361 |
"name": ExtractName(entry.getName()), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
362 |
"bitlen": str(entry.getBitLen()), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
363 |
"type": entry.getDataType().getcontent() |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
364 |
} |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
365 |
self.RxPDOInfo.append(entry_infos) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
366 |
count += 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
367 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
368 |
categorys = {"pdo_index": pdo_index, "name": pdo_name, "number_of_entry": count} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
369 |
self.RxPDOCategory.append(categorys) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
370 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
371 |
def GetTxPDOCategory(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
372 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
373 |
Get TxPDOCategory data structure (Meta informaton of TxPDO). |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
374 |
TxPDOCategorys : index, name, number of entries |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
375 |
@return TxPDOCategorys |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
376 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
377 |
return self.TxPDOCategory |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
378 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
379 |
def GetRxPDOCategory(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
380 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
381 |
Get RxPDOCategory data structure (Meta information of RxPDO). |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
382 |
RxPDOCategorys : index, name, number of entries |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
383 |
@return RxPDOCategorys |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
384 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
385 |
return self.RxPDOCategory |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
386 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
387 |
def GetTxPDOInfo(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
388 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
389 |
Get TxPDOInfo data structure (Detailed information on TxPDO entries). |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
390 |
TxPDOInfos : 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
|
391 |
@return TxPDOInfos |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
392 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
393 |
return self.TxPDOInfo |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
394 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
395 |
def GetRxPDOInfo(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
396 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
397 |
Get RxPDOInfo data structure (Detailed information on RxPDO entries). |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
398 |
RxPDOInfos : 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
|
399 |
@return RxPDOInfos |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
400 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
401 |
return self.RxPDOInfo |
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 |
def ClearDataSet(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
404 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
405 |
Initialize PDO management data structure. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
406 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
407 |
self.TxPDOInfos = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
408 |
self.TxPDOCategorys = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
409 |
self.RxPDOInfos = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
410 |
self.RxPDOCategorys = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
411 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
412 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
413 |
# Used EEPROM Management |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
414 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
415 |
# Base data types in ETG2000; format = {"Name": "BitSize"} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
416 |
BaseDataTypeDict = {"BOOL": "01", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
417 |
"SINT": "02", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
418 |
"INT": "03", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
419 |
"DINT": "04", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
420 |
"USINT": "05", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
421 |
"UINT": "06", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
422 |
"UDINT": "07", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
423 |
"REAL": "08", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
424 |
"INT24": "10", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
425 |
"LREAL": "11", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
426 |
"INT40": "12", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
427 |
"INT48": "13", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
428 |
"INT56": "14", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
429 |
"LINT": "15", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
430 |
"UINT24": "16", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
431 |
"UINT40": "18", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
432 |
"UINT48": "19", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
433 |
"UINT56": "1a", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
434 |
"ULINT": "1b", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
435 |
"BITARR8": "2d", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
436 |
"BITARR16": "2e", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
437 |
"BITARR32": "2f", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
438 |
"BIT1": "30", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
439 |
"BIT2": "31", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
440 |
"BIT3": "32", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
441 |
"BIT4": "33", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
442 |
"BIT5": "34", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
443 |
"BIT6": "35", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
444 |
"BIT7": "36", |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
445 |
"BIT8": "37"} |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
446 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
447 |
def GetSmartViewInfos(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
448 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
449 |
Parse XML data for "Smart View" of EEPROM contents. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
450 |
@return smartview_infos : EEPROM contents dictionary |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
451 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
452 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
453 |
smartview_infos = {"eeprom_size": 128, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
454 |
"pdi_type": 0, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
455 |
"device_emulation": "False", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
456 |
"vendor_id": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
457 |
"product_code": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
458 |
"revision_no": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
459 |
"serial_no": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
460 |
"supported_mailbox": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
461 |
"mailbox_bootstrapconf_outstart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
462 |
"mailbox_bootstrapconf_outlength": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
463 |
"mailbox_bootstrapconf_instart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
464 |
"mailbox_bootstrapconf_inlength": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
465 |
"mailbox_standardconf_outstart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
466 |
"mailbox_standardconf_outlength": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
467 |
"mailbox_standardconf_instart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
468 |
"mailbox_standardconf_inlength": '0'} |
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 |
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
471 |
type_infos = slave.getType() |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
472 |
device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
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 |
# 'device' represents current slave device selected by user |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
475 |
if device is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
476 |
for eeprom_element in device.getEeprom().getcontent(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
477 |
# get EEPROM size; <Device>-<Eeprom>-<ByteSize> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
478 |
if eeprom_element["name"] == "ByteSize": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
479 |
smartview_infos["eeprom_size"] = eeprom_element |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
480 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
481 |
elif eeprom_element["name"] == "ConfigData": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
482 |
configData_data = self.DecimalToHex(eeprom_element) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
483 |
# get PDI type; <Device>-<Eeprom>-<ConfigData> address 0x00 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
484 |
smartview_infos["pdi_type"] = int(configData_data[0:2], 16) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
485 |
# get state of device emulation; <Device>-<Eeprom>-<ConfigData> address 0x01 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
486 |
if "{:0>8b}".format(int(configData_data[2:4], 16))[7] == '1': |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
487 |
smartview_infos["device_emulation"] = "True" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
488 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
489 |
elif eeprom_element["name"] == "BootStrap": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
490 |
bootstrap_data = "{:0>16x}".format(eeprom_element) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
491 |
# get bootstrap configuration; <Device>-<Eeprom>-<BootStrap> |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
492 |
for cfg, iter in [("mailbox_bootstrapconf_outstart", 0), |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
493 |
("mailbox_bootstrapconf_outlength", 1), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
494 |
("mailbox_bootstrapconf_instart", 2), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
495 |
("mailbox_bootstrapconf_inlength", 3)]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
496 |
smartview_infos[cfg] = str(int(bootstrap_data[4*iter+2:4*(iter+1)]+bootstrap_data[4*iter:4*iter+2], 16)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
497 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
498 |
# get protocol (profile) types supported by mailbox; <Device>-<Mailbox> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
499 |
mb = device.getMailbox() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
500 |
if mb is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
501 |
for mailbox_protocol in mailbox_protocols: |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
502 |
if getattr(mb, "get%s" % mailbox_protocol)() is not None: |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
503 |
smartview_infos["supported_mailbox"] += "%s, " % mailbox_protocol |
2410
4e7ebd6ec248
cleanup: pylint, E1310 (bad-str-strip-call) Suspicious argument in str.strip call
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
504 |
smartview_infos["supported_mailbox"] = smartview_infos["supported_mailbox"].strip(", ") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
505 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
506 |
# get standard configuration of mailbox; <Device>-<Sm> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
507 |
for sm_element in device.getSm(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
508 |
if sm_element.getcontent() == "MBoxOut": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
509 |
smartview_infos["mailbox_standardconf_outstart"] = str(ExtractHexDecValue(sm_element.getStartAddress())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
510 |
smartview_infos["mailbox_standardconf_outlength"] = str(ExtractHexDecValue(sm_element.getDefaultSize())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
511 |
elif sm_element.getcontent() == "MBoxIn": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
512 |
smartview_infos["mailbox_standardconf_instart"] = str(ExtractHexDecValue(sm_element.getStartAddress())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
513 |
smartview_infos["mailbox_standardconf_inlength"] = str(ExtractHexDecValue(sm_element.getDefaultSize())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
514 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
515 |
pass |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
516 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
517 |
# get device identity from <Device>-<Type> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
518 |
# vendor ID; by default, pre-defined value in self.ModulesLibrary |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
519 |
# if device type in 'vendor' item equals to actual slave device type, set 'vendor_id' to vendor ID. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
520 |
for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
521 |
for available_device in vendor["groups"][vendor["groups"].keys()[0]]["devices"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
522 |
if available_device[0] == type_infos["device_type"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
523 |
smartview_infos["vendor_id"] = "0x" + "{:0>8x}".format(vendor_id) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
524 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
525 |
# product code; |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
526 |
if device.getType().getProductCode() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
527 |
product_code = device.getType().getProductCode() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
528 |
smartview_infos["product_code"] = "0x"+"{:0>8x}".format(ExtractHexDecValue(product_code)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
529 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
530 |
# revision number; |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
531 |
if device.getType().getRevisionNo() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
532 |
revision_no = device.getType().getRevisionNo() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
533 |
smartview_infos["revision_no"] = "0x"+"{:0>8x}".format(ExtractHexDecValue(revision_no)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
534 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
535 |
# serial number; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
536 |
if device.getType().getSerialNo() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
537 |
serial_no = device.getType().getSerialNo() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
538 |
smartview_infos["serial_no"] = "0x"+"{:0>8x}".format(ExtractHexDecValue(serial_no)) |
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 |
return smartview_infos |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
541 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
542 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
543 |
return None |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
544 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
545 |
def DecimalToHex(self, decnum): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
546 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
547 |
Convert decimal value into hexadecimal representation. |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
548 |
@param decnum : decimal value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
549 |
@return hex_data : hexadecimal representation of input value in decimal |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
550 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
551 |
value = "%x" % decnum |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
552 |
value_len = len(value) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
553 |
if (value_len % 2) == 0: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
554 |
hex_len = value_len |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
555 |
else: |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
556 |
hex_len = (value_len // 2) * 2 + 2 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
557 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
558 |
hex_data = ("{:0>"+str(hex_len)+"x}").format(decnum) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
559 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
560 |
return hex_data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
561 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
562 |
def SiiRead(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
563 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
564 |
Get slave EEPROM contents maintained by master device using "ethercat sii_read -p %d" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
565 |
Command example : "ethercat sii_read -p 0" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
566 |
@return return_val : result of "ethercat sii_read" (binary data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
567 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
568 |
_error, return_val = self.Controler.RemoteExec(SII_READ % (self.Controler.GetSlavePos()), return_val=None) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
569 |
self.SiiData = return_val |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
570 |
return return_val |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
571 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
572 |
def SiiWrite(self, binary): |
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 |
Overwrite slave EEPROM contents using "ethercat sii_write -p %d" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
575 |
Command example : "ethercat sii_write -p 0 - (binary contents)" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
576 |
@param binary : EEPROM contents in binary data format |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
577 |
@return return_val : result of "ethercat sii_write" (If it succeeds, the return value is NULL.) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
578 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
579 |
_error, return_val = self.Controler.RemoteExec( |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
580 |
SII_WRITE % (self.Controler.GetSlavePos()), |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
581 |
return_val=None, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
582 |
sii_data=binary) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
583 |
return return_val |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
584 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
585 |
def LoadData(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
586 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
587 |
Loading data from EEPROM use Sii_Read Method |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
588 |
@return self.BinaryCode : slave EEPROM data in binary format (zero-padded) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
589 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
590 |
return_val = self.Controler.CommonMethod.SiiRead() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
591 |
self.BinaryCode = return_val |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
592 |
self.Controler.SiiData = self.BinaryCode |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
593 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
594 |
# append zero-filled padding data up to EEPROM size |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
595 |
for dummy in range(self.SmartViewInfosFromXML["eeprom_size"] - len(self.BinaryCode)): |
2446
922f0d84f869
python3 support: pylint, W1646 # (invalid-str-codec) non-text encoding used in str.decode
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
596 |
self.BinaryCode = self.BinaryCode + self.HexDecode('ff')[0] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
597 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
598 |
return self.BinaryCode |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
599 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
600 |
def HexRead(self, binary): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
601 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
602 |
Convert binary digit representation into hexadecimal representation for "Hex View" menu. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
603 |
@param binary : binary digits |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
604 |
@return hexCode : hexadecimal digits |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
605 |
@return hexview_table_row, hexview_table_col : Grid size for "Hex View" UI |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
606 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
607 |
row_code = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
608 |
row_text = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
609 |
row = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
610 |
hex_code = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
611 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
612 |
hexview_table_col = 17 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
613 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
614 |
for index in range(0, len(binary)): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
615 |
if len(binary[index]) != 1: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
616 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
617 |
else: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
618 |
digithexstr = hex(ord(binary[index])) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
619 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
620 |
tempvar2 = digithexstr[2:4] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
621 |
if len(tempvar2) == 1: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
622 |
tempvar2 = "0" + tempvar2 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
623 |
row_code.append(tempvar2) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
624 |
|
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
625 |
if int(digithexstr, 16) >= 32 and int(digithexstr, 16) <= 126: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
626 |
row_text = row_text + chr(int(digithexstr, 16)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
627 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
628 |
row_text = row_text + "." |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
629 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
630 |
if index != 0: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
631 |
if len(row_code) == (hexview_table_col - 1): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
632 |
row_code.append(row_text) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
633 |
hex_code.append(row_code) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
634 |
row_text = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
635 |
row_code = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
636 |
row = row + 1 |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
637 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
638 |
hexview_table_row = row |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
639 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
640 |
return hex_code, hexview_table_row, hexview_table_col |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
641 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
642 |
def GenerateEEPROMList(self, data, direction, length): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
643 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
644 |
Generate EEPROM data list by reconstructing 'data' string. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
645 |
example : data="12345678", direction=0, length=8 -> eeprom_list=['12', '34', '56', '78'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
646 |
data="12345678", direction=1, length=8 -> eeprom_list=['78', '56', '34', '12'] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
647 |
@param data : string to be reconstructed |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
648 |
@param direction : endianness |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
649 |
@param length : data length |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
650 |
@return eeprom_list : reconstructed list data structure |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
651 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
652 |
eeprom_list = [] |
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 |
if direction is 0 or 1: |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
655 |
for dummy in range(length//2): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
656 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
657 |
eeprom_list.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
658 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
659 |
eeprom_list.append(data[direction*(length-2):direction*(length-2)+2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
660 |
data = data[(1-direction)*2:length-direction*2] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
661 |
length -= 2 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
662 |
return eeprom_list |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
663 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
664 |
def XmlToEeprom(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
665 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
666 |
Extract slave EEPROM contents using slave ESI XML file. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
667 |
- Mandatory parts |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
668 |
- String category : ExtractEEPROMStringCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
669 |
- General category : ExtractEEPROMGeneralCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
670 |
- FMMU category : ExtractEEPROMFMMUCategory |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
671 |
- SyncM category : ExtractEEPROMSyncMCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
672 |
- Tx/RxPDO category : ExtractEEPROMPDOCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
673 |
- DC category : ExtractEEPROMDCCategory() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
674 |
@return eeprom_binary |
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 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
677 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
678 |
eeprom_size = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
679 |
eeprom_binary = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
680 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
681 |
# 'device' is the slave device of the current EtherCAT slave plugin |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
682 |
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
683 |
type_infos = slave.getType() |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
684 |
device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
685 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
686 |
if device is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
687 |
# get ConfigData for EEPROM offset 0x0000-0x000d; <Device>-<Eeprom>-<ConfigData> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
688 |
for eeprom_element in device.getEeprom().getcontent(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
689 |
if eeprom_element["name"] == "ConfigData": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
690 |
data = self.DecimalToHex(eeprom_element) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
691 |
eeprom += self.GenerateEEPROMList(data, 0, 28) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
692 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
693 |
# calculate CRC for EEPROM offset 0x000e-0x000f |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
694 |
crc = 0x48 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
695 |
for segment in eeprom: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
696 |
for i in range(8): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
697 |
bit = crc & 0x80 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
698 |
crc = (crc << 1) | ((int(segment, 16) >> (7 - i)) & 0x01) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
699 |
if bit: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
700 |
crc ^= 0x07 |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
701 |
for dummy in range(8): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
702 |
bit = crc & 0x80 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
703 |
crc <<= 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
704 |
if bit: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
705 |
crc ^= 0x07 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
706 |
eeprom.append(hex(crc)[len(hex(crc))-3:len(hex(crc))-1]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
707 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
708 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
709 |
# get VendorID for EEPROM offset 0x0010-0x0013; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
710 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
711 |
for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
712 |
for available_device in vendor["groups"][vendor["groups"].keys()[0]]["devices"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
713 |
if available_device[0] == type_infos["device_type"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
714 |
data = "{:0>8x}".format(vendor_id) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
715 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
716 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
717 |
# get Product Code for EEPROM offset 0x0014-0x0017; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
718 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
719 |
if device.getType().getProductCode() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
720 |
data = "{:0>8x}".format(ExtractHexDecValue(device.getType().getProductCode())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
721 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
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 |
# get Revision Number for EEPROM offset 0x0018-0x001b; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
724 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
725 |
if device.getType().getRevisionNo() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
726 |
data = "{:0>8x}".format(ExtractHexDecValue(device.getType().getRevisionNo())) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
727 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
728 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
729 |
# get Serial Number for EEPROM 0x001c-0x001f; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
730 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
731 |
if device.getType().getSerialNo() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
732 |
data = "{:0>8x}".format(ExtractHexDecValue(device.getType().getSerialNo())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
733 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
734 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
735 |
# get Execution Delay for EEPROM 0x0020-0x0021; not analyzed yet |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
736 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
737 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
738 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
739 |
# get Port0/1 Delay for EEPROM offset 0x0022-0x0025; not analyzed yet |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
740 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
741 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
742 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
743 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
744 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
745 |
# reserved for EEPROM offset 0x0026-0x0027; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
746 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
747 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
748 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
749 |
# get BootStrap for EEPROM offset 0x0028-0x002e; <Device>-<Eeprom>-<BootStrap> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
750 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
751 |
for eeprom_element in device.getEeprom().getcontent(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
752 |
if eeprom_element["name"] == "BootStrap": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
753 |
data = "{:0>16x}".format(eeprom_element) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
754 |
eeprom += self.GenerateEEPROMList(data, 0, 16) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
755 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
756 |
# get Standard Mailbox for EEPROM offset 0x0030-0x0037; <Device>-<sm> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
757 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
758 |
standard_send_mailbox_offset = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
759 |
standard_send_mailbox_size = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
760 |
standard_receive_mailbox_offset = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
761 |
standard_receive_mailbox_size = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
762 |
for sm_element in device.getSm(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
763 |
if sm_element.getcontent() == "MBoxOut": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
764 |
standard_receive_mailbox_offset = "{:0>4x}".format(ExtractHexDecValue(sm_element.getStartAddress())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
765 |
standard_receive_mailbox_size = "{:0>4x}".format(ExtractHexDecValue(sm_element.getDefaultSize())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
766 |
elif sm_element.getcontent() == "MBoxIn": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
767 |
standard_send_mailbox_offset = "{:0>4x}".format(ExtractHexDecValue(sm_element.getStartAddress())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
768 |
standard_send_mailbox_size = "{:0>4x}".format(ExtractHexDecValue(sm_element.getDefaultSize())) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
769 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
770 |
if standard_receive_mailbox_offset is None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
771 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
772 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
773 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
774 |
eeprom.append(standard_receive_mailbox_offset[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
775 |
eeprom.append(standard_receive_mailbox_offset[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
776 |
if standard_receive_mailbox_size is None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
777 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
778 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
779 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
780 |
eeprom.append(standard_receive_mailbox_size[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
781 |
eeprom.append(standard_receive_mailbox_size[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
782 |
if standard_send_mailbox_offset is None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
783 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
784 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
785 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
786 |
eeprom.append(standard_send_mailbox_offset[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
787 |
eeprom.append(standard_send_mailbox_offset[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
788 |
if standard_send_mailbox_size is None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
789 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
790 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
791 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
792 |
eeprom.append(standard_send_mailbox_size[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
793 |
eeprom.append(standard_send_mailbox_size[0:2]) |
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 |
# get supported mailbox protocols for EEPROM offset 0x0038-0x0039; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
796 |
data = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
797 |
mb = device.getMailbox() |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
798 |
if mb is not None: |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
799 |
for bit, mbprot in enumerate(mailbox_protocols): |
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
800 |
if getattr(mb, "get%s" % mbprot)() is not None: |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
801 |
data += 1 << bit |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
802 |
data = "{:0>4x}".format(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
803 |
eeprom.append(data[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
804 |
eeprom.append(data[0:2]) |
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 |
# resereved for EEPROM offset 0x003a-0x007b; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
807 |
for i in range(0x007b-0x003a+0x0001): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
808 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
809 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
810 |
# get EEPROM size for EEPROM offset 0x007c-0x007d; |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
811 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
812 |
for eeprom_element in device.getEeprom().getcontent(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
813 |
if eeprom_element["name"] == "ByteSize": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
814 |
eeprom_size = int(str(eeprom_element)) |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
815 |
data = "{:0>4x}".format(int(eeprom_element)//1024*8-1) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
816 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
817 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
818 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
819 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
820 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
821 |
eeprom.append(data[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
822 |
eeprom.append(data[0:2]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
823 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
824 |
# Version for EEPROM 0x007e-0x007f; |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
825 |
# According to "EtherCAT Slave Device Description(V0.3.0)" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
826 |
eeprom.append("01") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
827 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
828 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
829 |
# append String Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
830 |
for data in self.ExtractEEPROMStringCategory(device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
831 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
832 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
833 |
# append General Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
834 |
for data in self.ExtractEEPROMGeneralCategory(device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
835 |
eeprom.append(data) |
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 |
# append FMMU Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
838 |
for data in self.ExtractEEPROMFMMUCategory(device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
839 |
eeprom.append(data) |
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 |
# append SyncM Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
842 |
for data in self.ExtractEEPROMSyncMCategory(device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
843 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
844 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
845 |
# append TxPDO Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
846 |
for data in self.ExtractEEPROMPDOCategory(device, "TxPdo"): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
847 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
848 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
849 |
# append RxPDO Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
850 |
for data in self.ExtractEEPROMPDOCategory(device, "RxPdo"): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
851 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
852 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
853 |
# append DC Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
854 |
for data in self.ExtractEEPROMDCCategory(device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
855 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
856 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
857 |
# append padding |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
858 |
padding = eeprom_size-len(eeprom) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
859 |
for i in range(padding): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
860 |
eeprom.append("ff") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
861 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
862 |
# convert binary code |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
863 |
for index in range(eeprom_size): |
2446
922f0d84f869
python3 support: pylint, W1646 # (invalid-str-codec) non-text encoding used in str.decode
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
864 |
eeprom_binary = eeprom_binary + self.HexDecode(eeprom[index])[0] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
865 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
866 |
return eeprom_binary |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
867 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
868 |
def ExtractEEPROMStringCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
869 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
870 |
Extract "Strings" category data from slave ESI XML and generate EEPROM image data. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
871 |
@param device : 'device' object in the slave ESI XML |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
872 |
@return eeprom : "Strings" category EEPROM image data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
873 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
874 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
875 |
self.Strings = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
876 |
data = "" |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
877 |
count = 0 # string counter |
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
878 |
padflag = False # padding flag if category length is odd |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
879 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
880 |
# index information for General Category in EEPROM |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
881 |
self.GroupIdx = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
882 |
self.ImgIdx = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
883 |
self.OrderIdx = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
884 |
self.NameIdx = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
885 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
886 |
# flag for preventing duplicated vendor specific data |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
887 |
typeflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
888 |
grouptypeflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
889 |
groupnameflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
890 |
devnameflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
891 |
imageflag = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
892 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
893 |
# vendor specific data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
894 |
# element1; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Type> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
895 |
# vendor_specific_data : vendor specific data (binary type) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
896 |
vendor_specific_data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
897 |
# vendor_spec_strings : list of vendor specific "strings" for preventing duplicated strings |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
898 |
vendor_spec_strings = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
899 |
for element in device.getType().getcontent(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
900 |
data += element |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
901 |
if data != "" and isinstance(data, text): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
902 |
for vendor_spec_string in vendor_spec_strings: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
903 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
904 |
self.OrderIdx = vendor_spec_strings.index(data)+1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
905 |
typeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
906 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
907 |
if typeflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
908 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
909 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
910 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
911 |
typeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
912 |
self.OrderIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
913 |
vendor_specific_data += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
914 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
915 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
916 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
917 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
918 |
# element2-1; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<GroupType> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
919 |
data = device.getGroupType() |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
920 |
if data is not None and isinstance(data, text): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
921 |
for vendor_spec_string in vendor_spec_strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
922 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
923 |
self.GroupIdx = vendor_spec_strings.index(data)+1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
924 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
925 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
926 |
if grouptypeflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
927 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
928 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
929 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
930 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
931 |
self.GroupIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
932 |
vendor_specific_data += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
933 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
934 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
935 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
936 |
# element2-2; <EtherCATInfo>-<Groups>-<Group>-<Type> |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
937 |
if grouptypeflag is False: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
938 |
if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
939 |
for _vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
940 |
for group_type, group_etc in vendor["groups"].iteritems(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
941 |
for device_item in group_etc["devices"]: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
942 |
if device == device_item[1]: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
943 |
data = group_type |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
944 |
if data is not None and isinstance(data, text): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
945 |
for vendor_spec_string in vendor_spec_strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
946 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
947 |
self.GroupIdx = vendor_spec_strings.index(data)+1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
948 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
949 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
950 |
if grouptypeflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
951 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
952 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
953 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
954 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
955 |
self.GroupIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
956 |
vendor_specific_data += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
957 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
958 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
959 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
960 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
961 |
# element3; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Name(LcId is "1033")> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
962 |
if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
963 |
for _vendorId, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
964 |
for group_type, group_etc in vendor["groups"].iteritems(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
965 |
for device_item in group_etc["devices"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
966 |
if device == device_item[1]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
967 |
data = group_etc["name"] |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
968 |
if data != "" and isinstance(data, text): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
969 |
for vendor_spec_string in vendor_spec_strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
970 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
971 |
groupnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
972 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
973 |
if groupnameflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
974 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
975 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
976 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
977 |
groupnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
978 |
vendor_specific_data += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
979 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
980 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
981 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
982 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
983 |
# element4; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Name(LcId is "1033" or "1"?)> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
984 |
for element in device.getName(): |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
985 |
if element.getLcId() == 1 or element.getLcId() == 1033: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
986 |
data = element.getcontent() |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
987 |
if data != "" and isinstance(data, text): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
988 |
for vendor_spec_string in vendor_spec_strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
989 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
990 |
self.NameIdx = vendor_spec_strings.index(data)+1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
991 |
devnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
992 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
993 |
if devnameflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
994 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
995 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
996 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
997 |
devnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
998 |
self.NameIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
999 |
vendor_specific_data += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1000 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1001 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1002 |
data = "" |
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 |
# element5-1; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Image16x14> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1005 |
if device.getcontent() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1006 |
data = device.getcontent() |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
1007 |
if data is not None and isinstance(data, text): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1008 |
for vendor_spec_string in vendor_spec_strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1009 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1010 |
self.ImgIdx = vendor_spec_strings.index(data)+1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1011 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1012 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1013 |
if imageflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1014 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1015 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1016 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1017 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1018 |
self.ImgIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1019 |
vendor_specific_data += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1020 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1021 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1022 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1023 |
# element5-2; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Image16x14> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1024 |
if imageflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1025 |
if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1026 |
for _vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1027 |
for group_type, group_etc in vendor["groups"].iteritems(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1028 |
for device_item in group_etc["devices"]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1029 |
if device == device_item[1]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1030 |
data = group_etc |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
1031 |
if data is not None and isinstance(data, text): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1032 |
for vendor_spec_string in vendor_spec_strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1033 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1034 |
self.ImgIdx = vendor_spec_strings.index(data)+1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1035 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1036 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1037 |
if imageflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1038 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1039 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1040 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1041 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1042 |
self.ImgIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1043 |
vendor_specific_data += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1044 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1045 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1046 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1047 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1048 |
# DC related elements |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1049 |
# <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Dc>-<OpMode>-<Name> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1050 |
dc_related_elements = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1051 |
if device.getDc() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1052 |
for element in device.getDc().getOpMode(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1053 |
data = element.getName() |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1054 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1055 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1056 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1057 |
dc_related_elements += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1058 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1059 |
dc_related_elements += "{:0>2x}".format(ord(data[character])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1060 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1061 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1062 |
# Input elements(TxPDO) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1063 |
# <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<TxPdo>; Name |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1064 |
input_elements = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1065 |
inputs = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1066 |
for element in device.getTxPdo(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1067 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1068 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1069 |
for input in inputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1070 |
if data == input: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1071 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1072 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1073 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1074 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1075 |
inputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1076 |
input_elements += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1077 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1078 |
input_elements += "{:0>2x}".format(ord(data[character])) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1079 |
data = "" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1080 |
for entry in element.getEntry(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1081 |
for name in entry.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1082 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1083 |
for input in inputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1084 |
if data == input: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1085 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1086 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1087 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1088 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1089 |
inputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1090 |
input_elements += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1091 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1092 |
input_elements += "{:0>2x}".format(ord(data[character])) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1093 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1094 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1095 |
# Output elements(RxPDO) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1096 |
# <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<RxPdo>; Name |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1097 |
output_elements = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1098 |
outputs = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1099 |
for element in device.getRxPdo(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1100 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1101 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1102 |
for output in outputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1103 |
if data == output: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1104 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1105 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1106 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1107 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1108 |
outputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1109 |
output_elements += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1110 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1111 |
output_elements += "{:0>2x}".format(ord(data[character])) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1112 |
data = "" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1113 |
for entry in element.getEntry(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1114 |
for name in entry.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1115 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1116 |
for output in outputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1117 |
if data == output: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1118 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1119 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1120 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1121 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1122 |
outputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1123 |
output_elements += "{:0>2x}".format(len(data)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1124 |
for character in range(len(data)): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1125 |
output_elements += "{:0>2x}".format(ord(data[character])) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1126 |
data = "" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1127 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1128 |
# form eeprom data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1129 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1130 |
eeprom.append("0a") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1131 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1132 |
# category length (word); 1 word is 4 bytes. "+2" is the length of string's total number |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1133 |
length = len(vendor_specific_data + dc_related_elements + input_elements + output_elements) + 2 |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
1134 |
if length % 4 == 0: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1135 |
pass |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1136 |
else: |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
1137 |
length += length % 4 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1138 |
padflag = True |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1139 |
eeprom.append("{:0>4x}".format(length//4)[2:4]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1140 |
eeprom.append("{:0>4x}".format(length//4)[0:2]) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1141 |
# total numbers of strings |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1142 |
eeprom.append("{:0>2x}".format(count)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1143 |
for element in [vendor_specific_data, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1144 |
dc_related_elements, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1145 |
input_elements, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1146 |
output_elements]: |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1147 |
for dummy in range(len(element)//2): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1148 |
if element == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1149 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1150 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1151 |
eeprom.append(element[0:2]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1152 |
element = element[2:len(element)] |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1153 |
# padding if length is odd bytes |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1154 |
if padflag is True: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1155 |
eeprom.append("ff") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1156 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1157 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1158 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1159 |
def ExtractEEPROMGeneralCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1160 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1161 |
Extract "General" category data from slave ESI XML and generate EEPROM image data. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1162 |
@param device : 'device' object in the slave ESI XML |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1163 |
@return eeprom : "Strings" category EEPROM image data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1164 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1165 |
eeprom = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1166 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1167 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1168 |
eeprom.append("1e") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1169 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1170 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1171 |
# category length |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1172 |
eeprom.append("10") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1173 |
eeprom.append("00") |
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 |
# word 1 : Group Type index and Image index in STRINGS Category |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1176 |
eeprom.append("{:0>2x}".format(self.GroupIdx)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1177 |
eeprom.append("{:0>2x}".format(self.ImgIdx)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1178 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1179 |
# word 2 : Device Type index and Device Name index in STRINGS Category |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1180 |
eeprom.append("{:0>2x}".format(self.OrderIdx)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1181 |
eeprom.append("{:0>2x}".format(self.NameIdx)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1182 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1183 |
# word 3 : Physical Layer Port info. and CoE Details |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1184 |
eeprom.append("01") # Physical Layer Port info - assume 01 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1185 |
# CoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1186 |
coe_details = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1187 |
mb = device.getMailbox() |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1188 |
coe_details = 1 # sdo enabled |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1189 |
if mb is not None: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1190 |
coe = mb.getCoE() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1191 |
if coe is not None: |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1192 |
for bit, flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig", |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
1193 |
"PdoUpload", "CompleteAccess"]): |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1194 |
if getattr(coe, "get%s" % flag)() is not None: |
2367
0fb54172a18b
cleanup etherlab: pep8, E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2366
diff
changeset
|
1195 |
coe_details += 1 << bit |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1196 |
eeprom.append("{:0>2x}".format(coe_details)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1197 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1198 |
# word 4 : FoE Details and EoE Details |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1199 |
# FoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<FoE> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1200 |
if mb is not None and mb.getFoE() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1201 |
eeprom.append("01") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1202 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1203 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1204 |
# EoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<EoE> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1205 |
if mb is not None and mb.getEoE() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1206 |
eeprom.append("01") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1207 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1208 |
eeprom.append("00") |
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 |
# word 5 : SoE Channels(reserved) and DS402 Channels |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1211 |
# SoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<SoE> |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1212 |
if mb is not None and mb.getSoE() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1213 |
eeprom.append("01") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1214 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1215 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1216 |
# DS402Channels; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE>: DS402Channels |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1217 |
ds402ch = False |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1218 |
if mb is not None: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1219 |
coe = mb.getCoE() |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1220 |
if coe is not None: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1221 |
ds402ch = coe.getDS402Channels() |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1222 |
eeprom.append("01" if ds402ch in [True, 1] else "00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1223 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1224 |
# word 6 : SysmanClass(reserved) and Flags |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1225 |
eeprom.append("00") # reserved |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1226 |
# Flags |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1227 |
en_safeop = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1228 |
en_lrw = False |
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
|
1229 |
if device.getType().getTcCfgModeSafeOp() is True \ |
2384
d7d9f0e60bc9
clean etherlab: pep8, E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2383
diff
changeset
|
1230 |
or device.getType().getTcCfgModeSafeOp() == 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1231 |
en_safeop = True |
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
|
1232 |
if device.getType().getUseLrdLwr() is True \ |
2384
d7d9f0e60bc9
clean etherlab: pep8, E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2383
diff
changeset
|
1233 |
or device.getType().getUseLrdLwr() == 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1234 |
en_lrw = True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1235 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1236 |
flags = "0b"+"000000"+str(int(en_lrw))+str(int(en_safeop)) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1237 |
eeprom.append("{:0>2x}".format(int(flags, 2))) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1238 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1239 |
# word 7 : Current On EBus (assume 0x0000) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1240 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1241 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1242 |
# after word 7; couldn't analyze yet |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1243 |
eeprom.append("03") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1244 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1245 |
eeprom.append("11") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1246 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1247 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1248 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1249 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1250 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1251 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1252 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1253 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1254 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1255 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1256 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1257 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1258 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1259 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1260 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1261 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1262 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1263 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1264 |
def ExtractEEPROMFMMUCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1265 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1266 |
Extract "FMMU" category data from slave ESI XML and generate EEPROM image data. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1267 |
@param device : 'device' object in the slave ESI XML |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1268 |
@return eeprom : "Strings" category EEPROM image data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1269 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1270 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1271 |
data = "" |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1272 |
count = 0 # number of FMMU |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1273 |
padflag = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1274 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1275 |
for fmmu in device.getFmmu(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1276 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1277 |
if fmmu.getcontent() == "Outputs": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1278 |
data += "01" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1279 |
if fmmu.getcontent() == "Inputs": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1280 |
data += "02" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1281 |
if fmmu.getcontent() == "MBoxState": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1282 |
data += "03" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1283 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1284 |
# construct of EEPROM data |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1285 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1286 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1287 |
eeprom.append("28") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1288 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1289 |
# category length |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
1290 |
if count % 2 == 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1291 |
padflag = True |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1292 |
eeprom.append("{:0>4x}".format((count+1)//2)[2:4]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1293 |
eeprom.append("{:0>4x}".format((count+1)//2)[0:2]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1294 |
else: |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1295 |
eeprom.append("{:0>4x}".format((count)//2)[2:4]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1296 |
eeprom.append("{:0>4x}".format((count)//2)[0:2]) |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1297 |
for dummy in range(count): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1298 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1299 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1300 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1301 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1302 |
data = data[2:len(data)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1303 |
# padding if length is odd bytes |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1304 |
if padflag is True: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1305 |
eeprom.append("ff") |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1306 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1307 |
return eeprom |
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 |
def ExtractEEPROMSyncMCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1310 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1311 |
Extract "SyncM" category data from slave ESI XML and generate EEPROM image data. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1312 |
@param device : 'device' object in the slave ESI XML |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1313 |
@return eeprom : "Strings" category EEPROM image data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1314 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1315 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1316 |
data = "" |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1317 |
number = {"MBoxOut": "01", "MBoxIn": "02", "Outputs": "03", "Inputs": "04"} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1318 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1319 |
for sm in device.getSm(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1320 |
for attr in [sm.getStartAddress(), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1321 |
sm.getDefaultSize(), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1322 |
sm.getControlByte()]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1323 |
if attr is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1324 |
data += "{:0>4x}".format(ExtractHexDecValue(attr))[2:4] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1325 |
data += "{:0>4x}".format(ExtractHexDecValue(attr))[0:2] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1326 |
else: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1327 |
data += "0000" |
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
|
1328 |
if sm.getEnable() == "1" or sm.getEnable() is True: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1329 |
data += "01" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1330 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1331 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1332 |
data += number[sm.getcontent()] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1333 |
|
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1334 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1335 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1336 |
eeprom.append("29") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1337 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1338 |
# category length |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1339 |
eeprom.append("{:0>4x}".format(len(data)//4)[2:4]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1340 |
eeprom.append("{:0>4x}".format(len(data)//4)[0:2]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1341 |
for dummy in range(len(data)//2): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1342 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1343 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1344 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1345 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1346 |
data = data[2:len(data)] |
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 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1349 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1350 |
def ExtractEEPROMPDOCategory(self, device, pdotype): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1351 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1352 |
Extract ""PDO (Tx, Rx)"" category data from slave ESI XML and generate EEPROM image data. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1353 |
@param device : 'device' object in the slave ESI XML |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1354 |
@param pdotype : identifier whether "TxPDO" or "RxPDO". |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1355 |
@return eeprom : "Strings" category EEPROM image data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1356 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1357 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1358 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1359 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1360 |
en_fixed = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1361 |
en_mandatory = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1362 |
en_virtual = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1363 |
|
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
1364 |
for element in eval("device.get%s()" % pdotype): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1365 |
# PDO Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1366 |
data += "{:0>4x}".format(ExtractHexDecValue(element.getIndex().getcontent()))[2:4] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1367 |
data += "{:0>4x}".format(ExtractHexDecValue(element.getIndex().getcontent()))[0:2] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1368 |
# Number of Entries |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1369 |
data += "{:0>2x}".format(len(element.getEntry())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1370 |
# About Sync Manager |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1371 |
if element.getSm() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1372 |
data += "{:0>2x}".format(element.getSm()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1373 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1374 |
data += "ff" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1375 |
# Reference to DC Synch (according to ET1100 documentation) - assume 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1376 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1377 |
# Name Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1378 |
objname = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1379 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1380 |
objname = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1381 |
for name in self.Strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1382 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1383 |
if objname == name: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1384 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1385 |
if len(self.Strings)+1 == count: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1386 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1387 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1388 |
data += "{:0>2x}".format(count) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1389 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1390 |
# Flags; by Fixed, Mandatory, Virtual attributes ? |
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
|
1391 |
if element.getFixed() is True or 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1392 |
en_fixed = True |
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
|
1393 |
if element.getMandatory() is True or 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1394 |
en_mandatory = True |
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
|
1395 |
if element.getVirtual() is True or element.getVirtual(): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1396 |
en_virtual = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1397 |
data += str(int(en_fixed)) + str(int(en_mandatory)) + str(int(en_virtual)) + "0" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1398 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1399 |
for entry in element.getEntry(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1400 |
# Entry Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1401 |
data += "{:0>4x}".format(ExtractHexDecValue(entry.getIndex().getcontent()))[2:4] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1402 |
data += "{:0>4x}".format(ExtractHexDecValue(entry.getIndex().getcontent()))[0:2] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1403 |
# Subindex |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1404 |
data += "{:0>2x}".format(int(entry.getSubIndex())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1405 |
# Entry Name Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1406 |
objname = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1407 |
for name in entry.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1408 |
objname = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1409 |
for name in self.Strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1410 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1411 |
if objname == name: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1412 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1413 |
if len(self.Strings)+1 == count: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1414 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1415 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1416 |
data += "{:0>2x}".format(count) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1417 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1418 |
# DataType |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1419 |
if entry.getDataType() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1420 |
if entry.getDataType().getcontent() in self.BaseDataTypeDict: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1421 |
data += self.BaseDataTypeDict[entry.getDataType().getcontent()] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1422 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1423 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1424 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1425 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1426 |
# BitLen |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1427 |
if entry.getBitLen() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1428 |
data += "{:0>2x}".format(int(entry.getBitLen())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1429 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1430 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1431 |
# Flags; by Fixed attributes ? |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1432 |
en_fixed = False |
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
|
1433 |
if entry.getFixed() is True or entry.getFixed() == 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1434 |
en_fixed = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1435 |
data += str(int(en_fixed)) + "000" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1436 |
|
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1437 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1438 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1439 |
if pdotype == "TxPdo": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1440 |
eeprom.append("32") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1441 |
elif pdotype == "RxPdo": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1442 |
eeprom.append("33") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1443 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1444 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1445 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1446 |
# category length |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1447 |
eeprom.append("{:0>4x}".format(len(data)//4)[2:4]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1448 |
eeprom.append("{:0>4x}".format(len(data)//4)[0:2]) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1449 |
data = str(data.lower()) |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1450 |
for dummy in range(len(data)//2): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1451 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1452 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1453 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1454 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1455 |
data = data[2:len(data)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1456 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1457 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1458 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1459 |
def ExtractEEPROMDCCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1460 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1461 |
Extract "DC(Distributed Clock)" category data from slave ESI XML and generate EEPROM image data. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1462 |
@param device : 'device' object in the slave ESI XML |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1463 |
@return eeprom : "Strings" category EEPROM image data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1464 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1465 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1466 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1467 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1468 |
namecount = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1469 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1470 |
if device.getDc() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1471 |
for element in device.getDc().getOpMode(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1472 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1473 |
# assume that word 1-7 are 0x0000 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1474 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1475 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1476 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1477 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1478 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1479 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1480 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1481 |
# word 8-10 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1482 |
# AssignActivate |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1483 |
if element.getAssignActivate() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1484 |
data += "{:0>4x}".format(ExtractHexDecValue(element.getAssignActivate()))[2:4] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1485 |
data += "{:0>4x}".format(ExtractHexDecValue(element.getAssignActivate()))[0:2] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1486 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1487 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1488 |
# Factor of CycleTimeSync0 ? and default is 1? |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1489 |
if element.getCycleTimeSync0() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1490 |
if element.getCycleTimeSync0().getFactor() is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1491 |
data += "{:0>2x}".format(int(element.getCycleTimeSync0().getFactor())) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1492 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1493 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1494 |
data += "0100" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1495 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1496 |
data += "0100" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1497 |
# Index of Name in STRINGS Category |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1498 |
# Name Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1499 |
objname = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1500 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1501 |
objname += name |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1502 |
for name in self.Strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1503 |
namecount += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1504 |
if objname == name: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1505 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1506 |
if len(self.Strings)+1 == namecount: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1507 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1508 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1509 |
data += "{:0>2x}".format(namecount) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1510 |
namecount = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1511 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1512 |
# assume that word 11-12 are 0x0000 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1513 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1514 |
data += "0000" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1515 |
|
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1516 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1517 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1518 |
eeprom.append("3c") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1519 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1520 |
# category length |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1521 |
eeprom.append("{:0>4x}".format(len(data)//4)[2:4]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1522 |
eeprom.append("{:0>4x}".format(len(data)//4)[0:2]) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1523 |
data = str(data.lower()) |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1524 |
for dummy in range(len(data)//2): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1525 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1526 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1527 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1528 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1529 |
data = data[2:len(data)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1530 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1531 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1532 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1533 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1534 |
# Used Register Access |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1535 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1536 |
def RegRead(self, offset, length): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1537 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1538 |
Read slave ESC register content using "ethercat reg_read -p %d %s %s" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1539 |
Command example : "ethercat reg_read -p 0 0x0c00 0x0400" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1540 |
@param offset : register address |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1541 |
@param length : register length |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1542 |
@return return_val : register data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1543 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1544 |
_error, return_val = self.Controler.RemoteExec( |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1545 |
REG_READ % (self.Controler.GetSlavePos(), offset, length), |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1546 |
return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1547 |
return return_val |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1548 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1549 |
def RegWrite(self, address, data): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1550 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1551 |
Write data to slave ESC register using "ethercat reg_write -p %d %s %s" command. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1552 |
Command example : "ethercat reg_write -p 0 0x0c04 0x0001" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1553 |
@param address : register address |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1554 |
@param data : data to write |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1555 |
@return return_val : the execution result of "ethercat reg_write" (for error check) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1556 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1557 |
_error, return_val = self.Controler.RemoteExec( |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1558 |
REG_WRITE % (self.Controler.GetSlavePos(), address, data), |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1559 |
return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1560 |
return return_val |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1561 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1562 |
def Rescan(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1563 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1564 |
Synchronize EEPROM data in master controller with the data in slave device after EEPROM write. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1565 |
Command example : "ethercat rescan -p 0" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1566 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1567 |
_error, _return_val = self.Controler.RemoteExec(RESCAN % (self.Controler.GetSlavePos()), return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1568 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1569 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1570 |
# Common Use Methods |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1571 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1572 |
def CheckConnect(self, cyclic_flag): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1573 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1574 |
Check connection status (1) between Beremiz and the master (2) between the master and the slave. |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1575 |
@param cyclic_flag: 0 - one shot, 1 - periodic |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1576 |
@return True or False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1577 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1578 |
if self.Controler.GetCTRoot()._connector is not None: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1579 |
# Check connection between the master and the slave. |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1580 |
# Command example : "ethercat xml -p 0" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1581 |
_error, return_val = self.Controler.RemoteExec(SLAVE_XML % (self.Controler.GetSlavePos()), return_val=None) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1582 |
number_of_lines = return_val.split("\n") |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1583 |
if len(number_of_lines) <= 2: # No slave connected to the master controller |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1584 |
if not cyclic_flag: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2421
diff
changeset
|
1585 |
self.CreateErrorDialog(_('No connected slaves')) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1586 |
return False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1587 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1588 |
elif len(number_of_lines) > 2: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1589 |
return True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1590 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1591 |
# The master controller is not connected to Beremiz host |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
1592 |
if not cyclic_flag: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2421
diff
changeset
|
1593 |
self.CreateErrorDialog(_('PLC not connected!')) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1594 |
return False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1595 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1596 |
def CreateErrorDialog(self, mention): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1597 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1598 |
Create a dialog to indicate error or warning. |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1599 |
@param mention : Error String |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1600 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1601 |
app_frame = self.Controler.GetCTRoot().AppFrame |
2382
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2378
diff
changeset
|
1602 |
dlg = wx.MessageDialog(app_frame, mention, |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2421
diff
changeset
|
1603 |
_(' Warning...'), |
2382
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2378
diff
changeset
|
1604 |
wx.OK | wx.ICON_INFORMATION) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1605 |
dlg.ShowModal() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1606 |
dlg.Destroy() |