author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 01 Oct 2021 15:32:38 +0200 | |
branch | wxPython4 |
changeset 3324 | 13779d34293b |
parent 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 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
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 |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
55 |
#-------------------------------------------------- |
2370
e40f3914e55f
cleanup etherlab: pep8, E305 expected 2 blank lines after class or function definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2367
diff
changeset
|
56 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
57 |
# --------------------- for master --------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
58 |
MASTER_STATE = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
59 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
60 |
result = commands.getoutput("ethercat master") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
61 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
62 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
63 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
64 |
# --------------------- for slave ---------------------------- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
65 |
# 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
|
66 |
SLAVE_STATE = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
67 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
68 |
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
|
69 |
returnVal = result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
70 |
""" |
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 |
# ethercat slave |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
73 |
GET_SLAVE = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
74 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
75 |
result = commands.getoutput("ethercat slaves") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
76 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
77 |
""" |
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 |
# ethercat xml -p (slave position) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
80 |
SLAVE_XML = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
81 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
82 |
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
|
83 |
returnVal = result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
84 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
85 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
86 |
# ethercat upload -p (slave position) -t (type) (index) (sub index) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
87 |
SDO_UPLOAD = """ |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
88 |
import commands |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
89 |
sdo_data = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
90 |
input_data = "%s" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
91 |
slave_pos = %d |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
92 |
command_string = "" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
93 |
for sdo_token in input_data.split(","): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
94 |
if len(sdo_token) > 1: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
95 |
sdo_token = sdo_token.strip() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
96 |
type, idx, subidx = sdo_token.split(" ") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
97 |
command_string = "ethercat upload -p " + str(slave_pos) + " -t " + type + " " + idx + " " + subidx |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
98 |
result = commands.getoutput(command_string) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
99 |
sdo_data.append(result) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
100 |
returnVal =sdo_data |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
101 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
102 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
103 |
# 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
|
104 |
SDO_DOWNLOAD = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
105 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
106 |
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
|
107 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
108 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
109 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
110 |
# 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
|
111 |
SII_READ = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
112 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
113 |
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
|
114 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
115 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
116 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
117 |
# 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
|
118 |
REG_READ = """ |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
119 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
120 |
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
|
121 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
122 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
123 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
124 |
# ethercat reg_read -p (slave position) (address) (size) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
125 |
MULTI_REG_READ = """ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
126 |
import commands |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
127 |
output = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
128 |
addr, size = range(2) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
129 |
slave_num = %d |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
130 |
reg_info_str = "%s" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
131 |
reg_info_list = reg_info_str.split("|") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
132 |
for slave_idx in range(slave_num): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
133 |
for reg_info in reg_info_list: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
134 |
param = reg_info.split(",") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
135 |
result = commands.getoutput("ethercat reg_read -p " |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
136 |
+ str(slave_idx) + " " |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
137 |
+ param[addr] + " " |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
138 |
+ param[size]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
139 |
output.append(str(slave_idx) + "," + param[addr] + "," + result) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
140 |
returnVal = output |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
141 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
142 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
143 |
# 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
|
144 |
SII_WRITE = """ |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
145 |
import subprocess |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
146 |
process = subprocess.Popen( |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
147 |
["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
|
148 |
stdin=subprocess.PIPE) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
149 |
process.communicate(sii_data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
150 |
returnVal = process.returncode |
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 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
153 |
# 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
|
154 |
REG_WRITE = """ |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
155 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
156 |
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
|
157 |
returnVal =result |
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 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
160 |
# ethercat rescan -p (slave position) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
161 |
RESCAN = """ |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
162 |
import commands |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
163 |
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
|
164 |
returnVal =result |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
165 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
166 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
167 |
# ethercat pdos |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
168 |
PDOS = """ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
169 |
import commands |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
170 |
result = commands.getoutput("ethercat pdos -p 0") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
171 |
returnVal =result |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
172 |
""" |
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
173 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
174 |
# -------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
175 |
# 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
|
176 |
# -------------------------------------------------- |
2397
25f16349644b
clean etherlab: pylint, C1001 # (old-style-class) Old-style class defined.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2396
diff
changeset
|
177 |
class _CommonSlave(object): |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
178 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
179 |
# ----- Data Structure for ethercat management ---- |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
180 |
SlaveState = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
181 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
182 |
# SDO base data type for Ethercatmaster |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
183 |
BaseDataTypes = { |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
184 |
"bool": ["BOOLEAN", "BOOL", "BIT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
185 |
"uint8": ["BYTE", "USINT", "BIT1", "BIT2", "BIT3", "BIT4", "BIT5", "BIT6", |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
186 |
"BIT7", "BIT8", "BITARR8", "UNSIGNED8"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
187 |
"uint16": ["BITARR16", "UNSIGNED16", "UINT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
188 |
"uint32": ["BITARR32", "UNSIGNED24", "UINT24", "UNSIGNED32", "UDINT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
189 |
"uint64": ["UNSINED40", "UINT40", "UNSIGNED48", "UINT48", "UNSIGNED56", |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
190 |
"UINT56", "UNSIGNED64", "ULINT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
191 |
"int8": ["INTEGER8", "SINT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
192 |
"int16": ["INTEGER16", "INT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
193 |
"int32": ["INTEGER24", "INT24", "INTEGER32", "DINT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
194 |
"int64": ["INTEGER40", "INT40", "INTEGER48", "INT48", "INTEGER56", "INT56", |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
195 |
"INTEGER64", "LINT"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
196 |
"float": ["REAL", "REAL32"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
197 |
"double": ["LREAL", "REAL64"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
198 |
"string": ["VISUBLE_STRING", "STRING(n)"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
199 |
"octet_string": ["OCTET_STRING"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
200 |
"unicode_string": ["UNICODE_STRING"] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
201 |
} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
202 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
203 |
# category of SDO data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
204 |
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
|
205 |
ProfileSpecific, Reserved, AllSDOData = range(6) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
206 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
207 |
# SDO data informations: index, sub-index, type, bit size, category-name |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
208 |
SDOVariables = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
209 |
SDOSubEntryData = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
210 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
211 |
# defalut value of SDO data in XML |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
212 |
# Not Used |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
213 |
DefaultValueDic = {} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
214 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
215 |
# 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
|
216 |
CheckPREOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
217 |
CheckSAFEOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
218 |
CheckOP = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
219 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
220 |
# Save PDO Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
221 |
TxPDOInfo = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
222 |
TxPDOCategory = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
223 |
RxPDOInfo = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
224 |
RxPDOCategory = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
225 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
226 |
# Save EEPROM Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
227 |
SiiData = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
228 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
229 |
# Save Register Data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
230 |
RegData = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
231 |
CrtRegSpec = {"ESCType": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
232 |
"FMMUNumber": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
233 |
"SMNumber": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
234 |
"PDIType": ""} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
235 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
236 |
def __init__(self, controler): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
237 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
238 |
Constructor |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
239 |
@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
|
240 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
241 |
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
|
242 |
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
|
243 |
self.ClearSDODataSet() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
244 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
245 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
246 |
# Used Master State |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
247 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
248 |
def GetMasterState(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
249 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
250 |
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
|
251 |
@return MasterState |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
252 |
""" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
253 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
254 |
# 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
|
255 |
_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
|
256 |
master_state = {} |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
257 |
# parse the reslut |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
258 |
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
|
259 |
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
|
260 |
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
|
261 |
key = chunks[0] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
262 |
value = [] |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
263 |
if len(chunks) > 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
264 |
value = chunks[1].split() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
265 |
if '(attached)' in value: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
266 |
value.remove('(attached)') |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
267 |
master_state[key] = value |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
268 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
269 |
return master_state |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
270 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
271 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
272 |
# Used Slave State |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
273 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
274 |
def RequestSlaveState(self, command): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
275 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
@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
|
279 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
280 |
_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
|
281 |
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
|
282 |
return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
283 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
284 |
def GetSlaveStateFromSlave(self): |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
285 |
""" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
286 |
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
|
287 |
(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
|
288 |
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
|
289 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
290 |
_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
|
291 |
self.SlaveState = return_val |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
292 |
return return_val |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
293 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
294 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
295 |
# Used SDO Management |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
296 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
297 |
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
|
298 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
299 |
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
|
300 |
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
|
301 |
@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
|
302 |
@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
|
303 |
@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
|
304 |
@param value : value of SDO entry |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
305 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
306 |
valid_type = self.GetValidDataType(data_type) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
307 |
_error, return_val = self.Controler.RemoteExec( |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
308 |
SDO_DOWNLOAD%(valid_type, self.Controler.GetSlavePos(), |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
309 |
idx, sub_idx, value), return_val = None) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
310 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
311 |
return return_val |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
312 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
313 |
def BackupSDODataSet(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
314 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
315 |
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
|
316 |
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
|
317 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
318 |
self.BackupDatatypeDescription = self.SaveDatatypeDescription |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
319 |
self.BackupCommunicationObject = self.SaveCommunicationObject |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
320 |
self.BackupManufacturerSpecific = self.SaveManufacturerSpecific |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
321 |
self.BackupProfileSpecific = self.SaveProfileSpecific |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
322 |
self.BackupReserved = self.SaveReserved |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
323 |
self.BackupAllSDOData = self.SaveAllSDOData |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
324 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
325 |
def ClearSDODataSet(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
326 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
327 |
Clear the specified SDO entry information. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
328 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
329 |
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
|
330 |
self.SaveSDOData.append([]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
331 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
332 |
def GetAllSDOValuesFromSlave(self): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
333 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
334 |
Get SDO values of All SDO entries. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
335 |
@return return_val: list of result of "SDO_UPLOAD" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
336 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
337 |
entry_infos = "" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
338 |
alldata_idx = len(self.SDOVariables) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
339 |
counter = 0 |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
340 |
for category in self.SDOVariables: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
341 |
counter +=1 |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
342 |
# for avoid redundant repetition |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
343 |
if counter == alldata_idx: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
344 |
continue |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
345 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
346 |
for entry in category: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
347 |
valid_type = self.GetValidDataType(entry["type"]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
348 |
for_command_string = "%s %s %s ," % \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
349 |
(valid_type, entry["idx"], entry["subIdx"]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
350 |
entry_infos += for_command_string |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
351 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
352 |
error, return_val = self.Controler.RemoteExec(SDO_UPLOAD%(entry_infos, self.Controler.GetSlavePos()), return_val = None) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
353 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
354 |
return return_val |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
355 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
356 |
def GetSDOValuesFromSlave(self, entries_info): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
357 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
358 |
Get SDO values of some SDO entries. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
359 |
@param entries_info: dictionary of SDO entries that is wanted to know the value. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
360 |
@return return_val: list of result of "SDO_UPLOAD" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
361 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
362 |
entry_infos = "" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
363 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
364 |
entries_info_list = entries_info.items() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
365 |
entries_info_list.sort() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
366 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
367 |
for (idx, subIdx), entry in entries_info_list: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
368 |
valid_type = self.GetValidDataType(entry["type"]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
369 |
for_command_string = "%s %s %s ," % \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
370 |
(valid_type, str(idx), str(subIdx)) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
371 |
entry_infos += for_command_string |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
372 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
373 |
error, return_val = self.Controler.RemoteExec(SDO_UPLOAD%(entry_infos, self.Controler.GetSlavePos()), return_val = None) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
374 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
375 |
return return_val |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
376 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
377 |
def ExtractObjects(self): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
378 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
379 |
Extract object type items from imported ESI xml. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
380 |
And they are stuctured as dictionary. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
381 |
@return objects: dictionary of objects |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
382 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
383 |
objects = {} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
384 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
385 |
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
386 |
type_infos = slave.getType() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
387 |
device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
388 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
389 |
if device is not None : |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
390 |
for dictionary in device.GetProfileDictionaries(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
391 |
dictionary.load() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
392 |
for object in dictionary.getObjects().getObject(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
393 |
object_index = ExtractHexDecValue(object.getIndex().getcontent()) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
394 |
objects[(object_index)] = object |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
395 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
396 |
return objects |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
397 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
398 |
def ExtractAllDataTypes(self): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
399 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
400 |
Extract all data types from imported ESI xml. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
401 |
@return dataTypes: dictionary of datatypes |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
402 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
403 |
dataTypes = {} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
404 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
405 |
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
406 |
type_infos = slave.getType() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
407 |
device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
408 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
409 |
for dictionary in device.GetProfileDictionaries(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
410 |
dictionary.load() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
411 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
412 |
datatypes = dictionary.getDataTypes() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
413 |
if datatypes is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
414 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
415 |
for datatype in datatypes.getDataType(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
416 |
dataTypes[datatype.getName()] = datatype |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
417 |
return dataTypes |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
418 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
419 |
def IsBaseDataType(self, datatype): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
420 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
421 |
Check if the datatype is a base data type. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
422 |
@return baseTypeFlag: true if datatype is a base data type, unless false |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
423 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
424 |
baseTypeFlag = False |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
425 |
for baseDataTypeList in self.BaseDataTypes.values(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
426 |
if datatype in baseDataTypeList: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
427 |
baseTypeFlag = True |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
428 |
break |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
429 |
return baseTypeFlag |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
430 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
431 |
def GetBaseDataType(self, datatype): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
432 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
433 |
Get a base data type corresponding the datatype. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
434 |
@param datatype: Some data type (string format) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
435 |
@return base data type |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
436 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
437 |
if self.IsBaseDataType(datatype): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
438 |
return datatype |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
439 |
elif not datatype.find("STRING") == -1: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
440 |
return datatype |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
441 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
442 |
datatypes = self.ExtractAllDataTypes() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
443 |
base_datatype = datatypes[datatype].getBaseType() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
444 |
return self.GetBaseDataType(base_datatype) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
445 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
446 |
def GetValidDataType(self, datatype): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
447 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
448 |
Convert the datatype into a data type that is possible to download/upload |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
449 |
in etherlab master stack. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
450 |
@param datatype: Some data type (string format) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
451 |
@return base_type: vaild data type |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
452 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
453 |
base_type = self.GetBaseDataType(datatype) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
454 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
455 |
if re.match("STRING\([0-9]*\)", datatype) is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
456 |
return "string" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
457 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
458 |
for key, value in self.BaseDataTypes.items(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
459 |
if base_type in value: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
460 |
return key |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
461 |
return base_type |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
462 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
463 |
# Not Used |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
464 |
def GetAllEntriesList(self): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
465 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
466 |
Get All entries information that includes index, sub-index, name, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
467 |
type, bit size, PDO mapping, and default value. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
468 |
@return self.entries: dictionary of entry |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
469 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
470 |
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
471 |
type_infos = slave.getType() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
472 |
device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
473 |
self.entries = device.GetEntriesList() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
474 |
datatypes = self.ExtractAllDataTypes() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
475 |
objects = self.ExtractObjects() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
476 |
entries_list = self.entries.items() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
477 |
entries_list.sort() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
478 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
479 |
# append sub entries |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
480 |
for (index, subidx), entry in entries_list: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
481 |
# entry_* is string type |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
482 |
entry_type = entry["Type"] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
483 |
entry_index = entry["Index"] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
484 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
485 |
try: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
486 |
object_info = objects[index].getInfo() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
487 |
except: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
488 |
continue |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
489 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
490 |
if object_info is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
491 |
obj_content = object_info.getcontent() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
492 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
493 |
typeinfo = datatypes.get(entry_type, None) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
494 |
bitsize = typeinfo.getBitSize() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
495 |
type_content = typeinfo.getcontent() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
496 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
497 |
# ArrayInfo type |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
498 |
if type_content is not None and type_content["name"] == "ArrayInfo": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
499 |
for arrayinfo in type_content["value"]: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
500 |
element_num = arrayinfo.getElements() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
501 |
first_subidx = arrayinfo.getLBound() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
502 |
for offset in range(element_num): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
503 |
new_subidx = int(first_subidx) + offset |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
504 |
entry_subidx = hex(new_subidx) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
505 |
if obj_content["value"][new_subidx]["name"] == "SubItem": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
506 |
subitem = obj_content["value"][new_subidx]["value"] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
507 |
subname = subitem[new_subidx].getName() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
508 |
if subname is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
509 |
entry_name = "%s - %s" % \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
510 |
(ExtractName(objects[index].getName()), subname) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
511 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
512 |
entry_name = ExtractName(objects[index].getName()) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
513 |
self.entries[(index, new_subidx)] = { |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
514 |
"Index": entry_index, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
515 |
"SubIndex": entry_subidx, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
516 |
"Name": entry_name, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
517 |
"Type": typeinfo.getBaseType(), |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
518 |
"BitSize": str(bitsize/element_num), |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
519 |
"Access": entry["Access"], |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
520 |
"PDOMapping": entry["PDOMapping"]} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
521 |
try: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
522 |
value_info = subitem[new_subidx].getInfo().getcontent()\ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
523 |
["value"][0]["value"][0] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
524 |
self.AppendDefaultValue(index, new_subidx, value_info) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
525 |
except: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
526 |
pass |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
527 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
528 |
try: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
529 |
value_info = subitem[subidx].getInfo().getcontent()\ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
530 |
["value"][0]["value"][0] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
531 |
self.AppendDefaultValue(index, subidx, value_info) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
532 |
except: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
533 |
pass |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
534 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
535 |
# EnumInfo type |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
536 |
elif type_content is not None and type_content["name"] == "EnumInfo": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
537 |
self.entries[(index, subidx)]["EnumInfo"] = {} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
538 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
539 |
for enuminfo in type_content["value"]: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
540 |
text = enuminfo.getText() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
541 |
enum = enuminfo.getEnum() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
542 |
self.entries[(index, subidx)]["EnumInfo"][str(enum)] = text |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
543 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
544 |
self.entries[(index, subidx)]["DefaultValue"] = "0x00" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
545 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
546 |
# another types |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
547 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
548 |
if subidx == 0x00: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
549 |
tmp_subidx = 0x00 |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
550 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
551 |
try: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
552 |
if obj_content["value"][tmp_subidx]["name"] == "SubItem": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
553 |
sub_name = entry["Name"].split(" - ")[1] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
554 |
for num in range(len(obj_content["value"])): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
555 |
if sub_name == \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
556 |
obj_content["value"][num]["value"][num].getName(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
557 |
subitem_content = obj_content["value"][tmp_subidx]\ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
558 |
["value"][tmp_subidx] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
559 |
value_info = subitem_content.getInfo().getcontent()\ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
560 |
["value"][0]["value"][0] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
561 |
tmp_subidx += 1 |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
562 |
break |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
563 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
564 |
value_info = None |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
565 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
566 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
567 |
value_info = \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
568 |
obj_content["value"][tmp_subidx]["value"][tmp_subidx] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
569 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
570 |
self.AppendDefaultValue(index, subidx, value_info) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
571 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
572 |
except: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
573 |
pass |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
574 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
575 |
return self.entries |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
576 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
577 |
# Not Used |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
578 |
def AppendDefaultValue(self, index, subidx, value_info=None): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
579 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
580 |
Get the default value from the ESI xml |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
581 |
@param index: entry index |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
582 |
@param subidx: entry sub index |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
583 |
@param value_info: dictionary of infomation about default value |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
584 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
585 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
586 |
# there is not default value. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
587 |
if value_info == None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
588 |
return |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
589 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
590 |
raw_value = value_info["value"] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
591 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
592 |
# default value is hex binary type. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
593 |
if value_info["name"] == "DefaultData": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
594 |
raw_value_bit = list(hex(raw_value).split("0x")[1]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
595 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
596 |
datatype = self.GetValidDataType(self.entries[(index, subidx)]["Type"]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
597 |
if datatype is "string" or datatype is "octet_string": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
598 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
599 |
if "L" in raw_value_bit: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
600 |
raw_value_bit.remove("L") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
601 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
602 |
default_value = "".join(raw_value_bit).decode("hex") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
603 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
604 |
elif datatype is "unicode_string": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
605 |
default_value = "".join(raw_value_bit).decode("hex").\ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
606 |
decode("utf-8") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
607 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
608 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
609 |
bit_num = len(raw_value_bit) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
610 |
# padding |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
611 |
if not bit_num%2 == 0: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
612 |
raw_value_bit.insert(0, "0") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
613 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
614 |
default_value_bit = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
615 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
616 |
# little endian -> big endian |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
617 |
for num in range(bit_num): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
618 |
if num%2 == 0: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
619 |
default_value_bit.insert(0, raw_value_bit[num]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
620 |
default_value_bit.insert(1, raw_value_bit[num+1]) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
621 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
622 |
default_value = "0x%s" % "".join(default_value_bit) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
623 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
624 |
# default value is string type. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
625 |
# this case is not tested yet. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
626 |
elif value_info["name"] == "DefaultString": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
627 |
default_value = raw_value |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
628 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
629 |
# default value is Hex or Dec type. |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
630 |
elif value_info["name"] == "DefaultValue": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
631 |
default_value = "0x" + hex(ExtractHexDecValue(raw_value)) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
632 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
633 |
self.entries[(index, subidx)]["DefaultValue"] = default_value |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
634 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
635 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
636 |
# Used PDO Monitoring |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
637 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
638 |
def RequestPDOInfo(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
639 |
""" |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
640 |
Load slave information from RootClass (XML data) and parse the information |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
641 |
(calling SlavePDOData() method). |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
642 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
643 |
# 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
|
644 |
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
|
645 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
646 |
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
|
647 |
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
|
648 |
# Initialize PDO data set |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
649 |
self.ClearDataSet() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
650 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
651 |
# 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
|
652 |
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
|
653 |
self.SavePDOData(device) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
654 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
655 |
def SavePDOData(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
656 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
657 |
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
|
658 |
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
|
659 |
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
|
660 |
@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
|
661 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
662 |
# Parsing TXPDO entries |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
663 |
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
|
664 |
# 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
|
665 |
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
|
666 |
entries = pdo.getEntry() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
667 |
pdo_name = ExtractName(pdo.getName()) |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
668 |
excludes = pdo.getExclude() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
669 |
exclude_list = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
670 |
Sm = pdo.getSm() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
671 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
672 |
if excludes : |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
673 |
for exclude in excludes: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
674 |
exclude_list.append(ExtractHexDecValue(exclude.getcontent())) |
2355
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 |
# Initialize entry number count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
677 |
count = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
678 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
679 |
# Parse entries |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
680 |
for entry in entries: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
681 |
# Save index and subindex |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
682 |
index = ExtractHexDecValue(entry.getIndex().getcontent()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
683 |
subindex = ExtractHexDecValue(entry.getSubIndex()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
684 |
# 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
|
685 |
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
|
686 |
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
|
687 |
"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
|
688 |
"subindex": subindex, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
689 |
"name": ExtractName(entry.getName()), |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
690 |
"bitlen": entry.getBitLen() |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
691 |
} |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
692 |
if entry.getDataType() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
693 |
entry_infos["type"] = entry.getDataType().getcontent() |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
694 |
self.TxPDOInfo.append(entry_infos) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
695 |
count += 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
696 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
697 |
categorys = {"pdo_index" : pdo_index, "name" : pdo_name, "sm" : Sm, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
698 |
"number_of_entry" : count, "exclude_list" : exclude_list} |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
699 |
self.TxPDOCategory.append(categorys) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
700 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
701 |
# Parsing RxPDO entries |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
702 |
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
|
703 |
# 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
|
704 |
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
|
705 |
entries = pdo.getEntry() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
706 |
pdo_name = ExtractName(pdo.getName()) |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
707 |
excludes = pdo.getExclude() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
708 |
exclude_list = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
709 |
Sm = pdo.getSm() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
710 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
711 |
if excludes : |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
712 |
for exclude in excludes: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
713 |
exclude_list.append(ExtractHexDecValue(exclude.getcontent())) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
714 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
715 |
# Initialize entry number count |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
716 |
count = 0 |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
717 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
718 |
# Parse entries |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
719 |
for entry in entries: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
720 |
# Save index and subindex |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
721 |
index = ExtractHexDecValue(entry.getIndex().getcontent()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
722 |
subindex = ExtractHexDecValue(entry.getSubIndex()) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
723 |
# 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
|
724 |
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
|
725 |
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
|
726 |
"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
|
727 |
"subindex": subindex, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
728 |
"name": ExtractName(entry.getName()), |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
729 |
"bitlen": str(entry.getBitLen()) |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
730 |
} |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
731 |
if entry.getDataType() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
732 |
entry_infos["type"] = entry.getDataType().getcontent() |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
733 |
self.RxPDOInfo.append(entry_infos) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
734 |
count += 1 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
735 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
736 |
categorys = {"pdo_index" : pdo_index, "name" : pdo_name, "sm" : Sm, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
737 |
"number_of_entry" : count, "exclude_list" : exclude_list} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
738 |
self.RxPDOCategory.append(categorys) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
739 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
740 |
def GetTxPDOCategory(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
741 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
742 |
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
|
743 |
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
|
744 |
@return TxPDOCategorys |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
745 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
746 |
return self.TxPDOCategory |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
747 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
748 |
def GetRxPDOCategory(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
749 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
750 |
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
|
751 |
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
|
752 |
@return RxPDOCategorys |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
753 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
754 |
return self.RxPDOCategory |
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 |
def GetTxPDOInfo(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
757 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
758 |
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
|
759 |
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
|
760 |
@return TxPDOInfos |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
761 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
762 |
return self.TxPDOInfo |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
763 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
764 |
def GetRxPDOInfo(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
765 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
766 |
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
|
767 |
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
|
768 |
@return RxPDOInfos |
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 |
return self.RxPDOInfo |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
771 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
772 |
def ClearDataSet(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
773 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
774 |
Initialize PDO management data structure. |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
775 |
""" |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
776 |
self.TxPDOInfo = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
777 |
self.TxPDOCategory = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
778 |
self.RxPDOInfo = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
779 |
self.RxPDOCategory = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
780 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
781 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
782 |
# Used EEPROM Management |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
783 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
784 |
# 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
|
785 |
BaseDataTypeDict = {"BOOL": "01", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
786 |
"SINT": "02", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
787 |
"INT": "03", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
788 |
"DINT": "04", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
789 |
"USINT": "05", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
790 |
"UINT": "06", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
791 |
"UDINT": "07", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
792 |
"REAL": "08", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
793 |
"INT24": "10", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
794 |
"LREAL": "11", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
795 |
"INT40": "12", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
796 |
"INT48": "13", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
797 |
"INT56": "14", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
798 |
"LINT": "15", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
799 |
"UINT24": "16", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
800 |
"UINT40": "18", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
801 |
"UINT48": "19", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
802 |
"UINT56": "1a", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
803 |
"ULINT": "1b", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
804 |
"BITARR8": "2d", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
805 |
"BITARR16": "2e", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
806 |
"BITARR32": "2f", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
807 |
"BIT1": "30", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
808 |
"BIT2": "31", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
809 |
"BIT3": "32", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
810 |
"BIT4": "33", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
811 |
"BIT5": "34", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
812 |
"BIT6": "35", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
813 |
"BIT7": "36", |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
814 |
"BIT8": "37"} |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
815 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
816 |
def GetSmartViewInfos(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
817 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
818 |
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
|
819 |
@return smartview_infos : EEPROM contents dictionary |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
820 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
821 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
822 |
smartview_infos = {"eeprom_size": 128, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
823 |
"pdi_type": 0, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
824 |
"device_emulation": "False", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
825 |
"vendor_id": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
826 |
"product_code": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
827 |
"revision_no": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
828 |
"serial_no": '0x00000000', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
829 |
"supported_mailbox": "", |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
830 |
"mailbox_bootstrapconf_outstart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
831 |
"mailbox_bootstrapconf_outlength": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
832 |
"mailbox_bootstrapconf_instart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
833 |
"mailbox_bootstrapconf_inlength": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
834 |
"mailbox_standardconf_outstart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
835 |
"mailbox_standardconf_outlength": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
836 |
"mailbox_standardconf_instart": '0', |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
837 |
"mailbox_standardconf_inlength": '0'} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
838 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
839 |
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
|
840 |
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
|
841 |
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
|
842 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
843 |
# '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
|
844 |
if device is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
845 |
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
|
846 |
# 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
|
847 |
if eeprom_element["name"] == "ByteSize": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
848 |
smartview_infos["eeprom_size"] = eeprom_element |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
849 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
850 |
elif eeprom_element["name"] == "ConfigData": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
851 |
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
|
852 |
# 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
|
853 |
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
|
854 |
# 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
|
855 |
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
|
856 |
smartview_infos["device_emulation"] = "True" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
857 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
858 |
elif eeprom_element["name"] == "BootStrap": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
859 |
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
|
860 |
# get bootstrap configuration; <Device>-<Eeprom>-<BootStrap> |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
861 |
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
|
862 |
("mailbox_bootstrapconf_outlength", 1), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
863 |
("mailbox_bootstrapconf_instart", 2), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
864 |
("mailbox_bootstrapconf_inlength", 3)]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
865 |
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
|
866 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
867 |
# get protocol (profile) types supported by mailbox; <Device>-<Mailbox> |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
868 |
with device.getMailbox() as mb: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
869 |
if mb is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
870 |
for mailbox_protocol in mailbox_protocols: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
871 |
if getattr(mb, "get%s" % mailbox_protocol)() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
872 |
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
|
873 |
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
|
874 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
875 |
# 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
|
876 |
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
|
877 |
if sm_element.getcontent() == "MBoxOut": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
878 |
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
|
879 |
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
|
880 |
elif sm_element.getcontent() == "MBoxIn": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
881 |
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
|
882 |
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
|
883 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
884 |
pass |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
885 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
886 |
# get device identity from <Device>-<Type> |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
887 |
# vendor ID; by default, pre-defined value in self.ModulesLibrary |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
888 |
# if device type in 'vendor' item equals to actual slave device type, set 'vendor_id' to vendor ID. |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
889 |
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
|
890 |
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
|
891 |
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
|
892 |
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
|
893 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
894 |
# product code; |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
895 |
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
|
896 |
product_code = device.getType().getProductCode() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
897 |
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
|
898 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
899 |
# revision number; |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
900 |
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
|
901 |
revision_no = device.getType().getRevisionNo() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
902 |
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
|
903 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
904 |
# serial number; |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
905 |
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
|
906 |
serial_no = device.getType().getSerialNo() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
907 |
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
|
908 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
909 |
return smartview_infos |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
910 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
911 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
912 |
return None |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
913 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
914 |
def DecimalToHex(self, decnum): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
915 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
916 |
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
|
917 |
@param decnum : decimal value |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
918 |
@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
|
919 |
""" |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
920 |
value = "%x" % int(decnum, 16) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
921 |
value_len = len(value) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
922 |
if (value_len % 2) == 0: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
923 |
hex_len = value_len |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
924 |
else: |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
925 |
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
|
926 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
927 |
hex_data = ("{:0>"+str(hex_len)+"x}").format(int(decnum, 16)) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
928 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
929 |
return hex_data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
930 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
931 |
def SiiRead(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
932 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
933 |
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
|
934 |
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
|
935 |
@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
|
936 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
937 |
_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
|
938 |
self.SiiData = return_val |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
939 |
return return_val |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
940 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
941 |
def SiiWrite(self, binary): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
942 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
943 |
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
|
944 |
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
|
945 |
@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
|
946 |
@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
|
947 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
948 |
_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
|
949 |
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
|
950 |
return_val=None, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
951 |
sii_data=binary) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
952 |
return return_val |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
953 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
954 |
def LoadData(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
955 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
956 |
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
|
957 |
@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
|
958 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
959 |
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
|
960 |
self.BinaryCode = return_val |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
961 |
self.Controler.SiiData = self.BinaryCode |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
962 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
963 |
# 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
|
964 |
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
|
965 |
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
|
966 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
967 |
return self.BinaryCode |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
968 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
969 |
def HexRead(self, binary): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
970 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
971 |
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
|
972 |
@param binary : binary digits |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
973 |
@return hexCode : hexadecimal digits |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
974 |
@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
|
975 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
976 |
row_code = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
977 |
row_text = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
978 |
row = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
979 |
hex_code = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
980 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
981 |
hexview_table_col = 17 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
982 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
983 |
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
|
984 |
if len(binary[index]) != 1: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
985 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
986 |
else: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
987 |
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
|
988 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
989 |
tempvar2 = digithexstr[2:4] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
990 |
if len(tempvar2) == 1: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
991 |
tempvar2 = "0" + tempvar2 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
992 |
row_code.append(tempvar2) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
993 |
|
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
994 |
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
|
995 |
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
|
996 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
997 |
row_text = row_text + "." |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
998 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
999 |
if index != 0: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1000 |
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
|
1001 |
row_code.append(row_text) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1002 |
hex_code.append(row_code) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1003 |
row_text = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1004 |
row_code = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1005 |
row = row + 1 |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1006 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1007 |
hexview_table_row = row |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1008 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1009 |
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
|
1010 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1011 |
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
|
1012 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1013 |
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
|
1014 |
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
|
1015 |
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
|
1016 |
@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
|
1017 |
@param direction : endianness |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1018 |
@param length : data length |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1019 |
@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
|
1020 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1021 |
eeprom_list = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1022 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1023 |
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
|
1024 |
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
|
1025 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1026 |
eeprom_list.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1027 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1028 |
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
|
1029 |
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
|
1030 |
length -= 2 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1031 |
return eeprom_list |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1032 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1033 |
def XmlToEeprom(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1034 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1035 |
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
|
1036 |
- Mandatory parts |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1037 |
- String category : ExtractEEPROMStringCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1038 |
- General category : ExtractEEPROMGeneralCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1039 |
- FMMU category : ExtractEEPROMFMMUCategory |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1040 |
- SyncM category : ExtractEEPROMSyncMCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1041 |
- Tx/RxPDO category : ExtractEEPROMPDOCategory() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1042 |
- DC category : ExtractEEPROMDCCategory() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1043 |
@return eeprom_binary |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1044 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1045 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1046 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1047 |
eeprom_size = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1048 |
eeprom_binary = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1049 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1050 |
# '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
|
1051 |
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
|
1052 |
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
|
1053 |
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
|
1054 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1055 |
if device is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1056 |
# 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
|
1057 |
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
|
1058 |
if eeprom_element["name"] == "ConfigData": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1059 |
data = self.DecimalToHex(eeprom_element) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1060 |
eeprom += self.GenerateEEPROMList(data, 0, 28) |
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 |
# 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
|
1063 |
crc = 0x48 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1064 |
for segment in eeprom: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1065 |
for i in range(8): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1066 |
bit = crc & 0x80 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1067 |
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
|
1068 |
if bit: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1069 |
crc ^= 0x07 |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1070 |
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
|
1071 |
bit = crc & 0x80 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1072 |
crc <<= 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1073 |
if bit: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1074 |
crc ^= 0x07 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1075 |
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
|
1076 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1077 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1078 |
# 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
|
1079 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1080 |
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
|
1081 |
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
|
1082 |
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
|
1083 |
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
|
1084 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1085 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1086 |
# 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
|
1087 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1088 |
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
|
1089 |
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
|
1090 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1091 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1092 |
# 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
|
1093 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1094 |
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
|
1095 |
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
|
1096 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1097 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1098 |
# 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
|
1099 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1100 |
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
|
1101 |
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
|
1102 |
eeprom += self.GenerateEEPROMList(data, 1, 8) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1103 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1104 |
# 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
|
1105 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1106 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1107 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1108 |
# 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
|
1109 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1110 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1111 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1112 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1113 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1114 |
# 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
|
1115 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1116 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1117 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1118 |
# 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
|
1119 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1120 |
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
|
1121 |
if eeprom_element["name"] == "BootStrap": |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1122 |
data = "{:0>16x}".format(int(eeprom_element,16)) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1123 |
eeprom += self.GenerateEEPROMList(data, 0, 16) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1124 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1125 |
# 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
|
1126 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1127 |
standard_send_mailbox_offset = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1128 |
standard_send_mailbox_size = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1129 |
standard_receive_mailbox_offset = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1130 |
standard_receive_mailbox_size = None |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1131 |
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
|
1132 |
if sm_element.getcontent() == "MBoxOut": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1133 |
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
|
1134 |
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
|
1135 |
elif sm_element.getcontent() == "MBoxIn": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1136 |
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
|
1137 |
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
|
1138 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1139 |
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
|
1140 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1141 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1142 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1143 |
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
|
1144 |
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
|
1145 |
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
|
1146 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1147 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1148 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1149 |
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
|
1150 |
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
|
1151 |
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
|
1152 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1153 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1154 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1155 |
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
|
1156 |
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
|
1157 |
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
|
1158 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1159 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1160 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1161 |
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
|
1162 |
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
|
1163 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1164 |
# 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
|
1165 |
data = 0 |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1166 |
with device.getMailbox() as mb: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1167 |
if mb is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1168 |
for bit, mbprot in enumerate(mailbox_protocols): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1169 |
if getattr(mb, "get%s" % mbprot)() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1170 |
data += 1 << bit |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1171 |
data = "{:0>4x}".format(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1172 |
eeprom.append(data[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1173 |
eeprom.append(data[0:2]) |
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 |
# 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
|
1176 |
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
|
1177 |
eeprom.append("00") |
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 |
# get EEPROM size for EEPROM offset 0x007c-0x007d; |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1180 |
# Modify by jblee because of update IDE module (minidom -> lxml) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1181 |
data = "" |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1182 |
for eeprom_element in device.getEeprom().getchildren(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1183 |
if eeprom_element.tag == "ByteSize": |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1184 |
eeprom_size = int(objectify.fromstring(eeprom_element.tostring()).text) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1185 |
data = "{:0>4x}".format(eeprom_size/1024*8-1) |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1186 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1187 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1188 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1189 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1190 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1191 |
eeprom.append(data[2:4]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1192 |
eeprom.append(data[0:2]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1193 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1194 |
# Version for EEPROM 0x007e-0x007f; |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1195 |
# According to "EtherCAT Slave Device Description(V0.3.0)" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1196 |
eeprom.append("01") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1197 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1198 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1199 |
# append String Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1200 |
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
|
1201 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1202 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1203 |
# append General Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1204 |
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
|
1205 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1206 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1207 |
# append FMMU Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1208 |
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
|
1209 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1210 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1211 |
# append SyncM Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1212 |
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
|
1213 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1214 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1215 |
# append TxPDO Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1216 |
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
|
1217 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1218 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1219 |
# append RxPDO Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1220 |
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
|
1221 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1222 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1223 |
# append DC Category data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1224 |
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
|
1225 |
eeprom.append(data) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1226 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1227 |
# append padding |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1228 |
padding = eeprom_size-len(eeprom) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1229 |
for i in range(padding): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1230 |
eeprom.append("ff") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1231 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1232 |
# convert binary code |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1233 |
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
|
1234 |
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
|
1235 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1236 |
return eeprom_binary |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1237 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1238 |
def ExtractEEPROMStringCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1239 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1240 |
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
|
1241 |
@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
|
1242 |
@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
|
1243 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1244 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1245 |
self.Strings = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1246 |
data = "" |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1247 |
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
|
1248 |
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
|
1249 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1250 |
# 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
|
1251 |
self.GroupIdx = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1252 |
self.ImgIdx = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1253 |
self.OrderIdx = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1254 |
self.NameIdx = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1255 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1256 |
# 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
|
1257 |
typeflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1258 |
grouptypeflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1259 |
groupnameflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1260 |
devnameflag = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1261 |
imageflag = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1262 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1263 |
# vendor specific data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1264 |
# 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
|
1265 |
# 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
|
1266 |
vendor_specific_data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1267 |
# 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
|
1268 |
vendor_spec_strings = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1269 |
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
|
1270 |
data += element |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2423
diff
changeset
|
1271 |
if data != "" and isinstance(data, text): |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1272 |
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
|
1273 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1274 |
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
|
1275 |
typeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1276 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1277 |
if typeflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1278 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1279 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1280 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1281 |
typeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1282 |
self.OrderIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1283 |
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
|
1284 |
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
|
1285 |
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
|
1286 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1287 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1288 |
# element2-1; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<GroupType> |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1289 |
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
|
1290 |
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
|
1291 |
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
|
1292 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1293 |
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
|
1294 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1295 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1296 |
if grouptypeflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1297 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1298 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1299 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1300 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1301 |
self.GroupIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1302 |
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
|
1303 |
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
|
1304 |
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
|
1305 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1306 |
# element2-2; <EtherCATInfo>-<Groups>-<Group>-<Type> |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1307 |
if grouptypeflag is False: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1308 |
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
|
1309 |
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
|
1310 |
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
|
1311 |
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
|
1312 |
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
|
1313 |
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
|
1314 |
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
|
1315 |
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
|
1316 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1317 |
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
|
1318 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1319 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1320 |
if grouptypeflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1321 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1322 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1323 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1324 |
grouptypeflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1325 |
self.GroupIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1326 |
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
|
1327 |
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
|
1328 |
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
|
1329 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1330 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1331 |
# 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
|
1332 |
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
|
1333 |
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
|
1334 |
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
|
1335 |
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
|
1336 |
if device == device_item[1]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1337 |
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
|
1338 |
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
|
1339 |
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
|
1340 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1341 |
groupnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1342 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1343 |
if groupnameflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1344 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1345 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1346 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1347 |
groupnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1348 |
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
|
1349 |
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
|
1350 |
vendor_specific_data += "{:0>2x}".format(ord(data[character])) |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1351 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1352 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1353 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1354 |
# 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
|
1355 |
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
|
1356 |
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
|
1357 |
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
|
1358 |
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
|
1359 |
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
|
1360 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1361 |
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
|
1362 |
devnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1363 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1364 |
if devnameflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1365 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1366 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1367 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1368 |
devnameflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1369 |
self.NameIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1370 |
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
|
1371 |
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
|
1372 |
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
|
1373 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1374 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1375 |
# 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
|
1376 |
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
|
1377 |
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
|
1378 |
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
|
1379 |
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
|
1380 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1381 |
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
|
1382 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1383 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1384 |
if imageflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1385 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1386 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1387 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1388 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1389 |
self.ImgIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1390 |
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
|
1391 |
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
|
1392 |
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
|
1393 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1394 |
# 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
|
1395 |
if imageflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1396 |
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
|
1397 |
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
|
1398 |
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
|
1399 |
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
|
1400 |
if device == device_item[1]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1401 |
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
|
1402 |
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
|
1403 |
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
|
1404 |
if data == vendor_spec_string: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1405 |
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
|
1406 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1407 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1408 |
if imageflag is False: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1409 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1410 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1411 |
vendor_spec_strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1412 |
imageflag = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1413 |
self.ImgIdx = count |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1414 |
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
|
1415 |
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
|
1416 |
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
|
1417 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1418 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1419 |
# DC related elements |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1420 |
# <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
|
1421 |
dc_related_elements = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1422 |
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
|
1423 |
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
|
1424 |
data = element.getName() |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1425 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1426 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1427 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1428 |
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
|
1429 |
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
|
1430 |
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
|
1431 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1432 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1433 |
# Input elements(TxPDO) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1434 |
# <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
|
1435 |
input_elements = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1436 |
inputs = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1437 |
for element in device.getTxPdo(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1438 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1439 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1440 |
for input in inputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1441 |
if data == input: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1442 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1443 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1444 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1445 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1446 |
inputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1447 |
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
|
1448 |
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
|
1449 |
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
|
1450 |
data = "" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1451 |
for entry in element.getEntry(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1452 |
for name in entry.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1453 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1454 |
for input in inputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1455 |
if data == input: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1456 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1457 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1458 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1459 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1460 |
inputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1461 |
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
|
1462 |
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
|
1463 |
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
|
1464 |
data = "" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1465 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1466 |
# Output elements(RxPDO) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1467 |
# <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
|
1468 |
output_elements = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1469 |
outputs = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1470 |
for element in device.getRxPdo(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1471 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1472 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1473 |
for output in outputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1474 |
if data == output: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1475 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1476 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1477 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1478 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1479 |
outputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1480 |
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
|
1481 |
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
|
1482 |
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
|
1483 |
data = "" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1484 |
for entry in element.getEntry(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1485 |
for name in entry.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1486 |
data = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1487 |
for output in outputs: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1488 |
if data == output: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1489 |
data = "" |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1490 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1491 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1492 |
self.Strings.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1493 |
outputs.append(data) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1494 |
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
|
1495 |
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
|
1496 |
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
|
1497 |
data = "" |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1498 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1499 |
# form eeprom data |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1500 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1501 |
eeprom.append("0a") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1502 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1503 |
# 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
|
1504 |
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
|
1505 |
if length % 4 == 0: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1506 |
pass |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1507 |
else: |
2365
bc07b9910cdb
cleanup etherlab: pep8, E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2363
diff
changeset
|
1508 |
length += length % 4 |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1509 |
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
|
1510 |
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
|
1511 |
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
|
1512 |
# total numbers of strings |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1513 |
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
|
1514 |
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
|
1515 |
dc_related_elements, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1516 |
input_elements, |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1517 |
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
|
1518 |
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
|
1519 |
if element == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1520 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1521 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1522 |
eeprom.append(element[0:2]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1523 |
element = element[2:len(element)] |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1524 |
# 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
|
1525 |
if padflag is True: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1526 |
eeprom.append("ff") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1527 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1528 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1529 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1530 |
def ExtractEEPROMGeneralCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1531 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1532 |
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
|
1533 |
@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
|
1534 |
@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
|
1535 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1536 |
eeprom = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1537 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1538 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1539 |
eeprom.append("1e") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1540 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1541 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1542 |
# category length |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1543 |
eeprom.append("10") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1544 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1545 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1546 |
# 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
|
1547 |
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
|
1548 |
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
|
1549 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1550 |
# 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
|
1551 |
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
|
1552 |
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
|
1553 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1554 |
# 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
|
1555 |
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
|
1556 |
# CoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE> |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1557 |
coe_details = 1 # sdo enabled |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1558 |
with device.getMailbox() as mb |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1559 |
if mb is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1560 |
coe = mb.getCoE() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1561 |
if coe is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1562 |
for bit, flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig", |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1563 |
"PdoUpload", "CompleteAccess"]): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1564 |
if getattr(coe, "get%s" % flag)() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1565 |
coe_details += 1 << bit |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1566 |
eeprom.append("{:0>2x}".format(coe_details)) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1567 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1568 |
# word 4 : FoE Details and EoE Details |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1569 |
# FoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<FoE> |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1570 |
if mb is not None and mb.getFoE() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1571 |
eeprom.append("01") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1572 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1573 |
eeprom.append("00") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1574 |
# EoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<EoE> |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1575 |
if mb is not None and mb.getEoE() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1576 |
eeprom.append("01") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1577 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1578 |
eeprom.append("00") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1579 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1580 |
# word 5 : SoE Channels(reserved) and DS402 Channels |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1581 |
# SoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<SoE> |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1582 |
if mb is not None and mb.getSoE() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1583 |
eeprom.append("01") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1584 |
else: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1585 |
eeprom.append("00") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1586 |
# DS402Channels; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE>: DS402Channels |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1587 |
ds402ch = False |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1588 |
if mb is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1589 |
coe = mb.getCoE() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1590 |
if coe is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1591 |
ds402ch = coe.getDS402Channels() |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1592 |
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
|
1593 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1594 |
# 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
|
1595 |
eeprom.append("00") # reserved |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1596 |
# Flags |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1597 |
en_safeop = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1598 |
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
|
1599 |
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
|
1600 |
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
|
1601 |
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
|
1602 |
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
|
1603 |
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
|
1604 |
en_lrw = True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1605 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1606 |
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
|
1607 |
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
|
1608 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1609 |
# 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
|
1610 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1611 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1612 |
# 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
|
1613 |
eeprom.append("03") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1614 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1615 |
eeprom.append("11") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1616 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1617 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1618 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1619 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1620 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1621 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1622 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1623 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1624 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1625 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1626 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1627 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1628 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1629 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1630 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1631 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1632 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1633 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1634 |
def ExtractEEPROMFMMUCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1635 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1636 |
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
|
1637 |
@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
|
1638 |
@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
|
1639 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1640 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1641 |
data = "" |
2361
5d6ce74f7835
cleanup etherlab: pep8, E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
1642 |
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
|
1643 |
padflag = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1644 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1645 |
for fmmu in device.getFmmu(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1646 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1647 |
if fmmu.getcontent() == "Outputs": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1648 |
data += "01" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1649 |
if fmmu.getcontent() == "Inputs": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1650 |
data += "02" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1651 |
if fmmu.getcontent() == "MBoxState": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1652 |
data += "03" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1653 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1654 |
# construct of EEPROM data |
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1655 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1656 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1657 |
eeprom.append("28") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1658 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1659 |
# category length |
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
1660 |
if count % 2 == 1: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1661 |
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
|
1662 |
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
|
1663 |
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
|
1664 |
else: |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
1665 |
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
|
1666 |
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
|
1667 |
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
|
1668 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1669 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1670 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1671 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1672 |
data = data[2:len(data)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1673 |
# 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
|
1674 |
if padflag is True: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1675 |
eeprom.append("ff") |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1676 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1677 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1678 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1679 |
def ExtractEEPROMSyncMCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1680 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1681 |
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
|
1682 |
@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
|
1683 |
@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
|
1684 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1685 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1686 |
data = "" |
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2361
diff
changeset
|
1687 |
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
|
1688 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1689 |
for sm in device.getSm(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1690 |
for attr in [sm.getStartAddress(), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1691 |
sm.getDefaultSize(), |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1692 |
sm.getControlByte()]: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1693 |
if attr is not None: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1694 |
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
|
1695 |
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
|
1696 |
else: |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1697 |
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
|
1698 |
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
|
1699 |
data += "01" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1700 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1701 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1702 |
data += number[sm.getcontent()] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1703 |
|
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1704 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1705 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1706 |
eeprom.append("29") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1707 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1708 |
# 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
|
1709 |
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
|
1710 |
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
|
1711 |
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
|
1712 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1713 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1714 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1715 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1716 |
data = data[2:len(data)] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1717 |
|
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1718 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1719 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1720 |
def ExtractEEPROMPDOCategory(self, device, pdotype): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1721 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1722 |
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
|
1723 |
@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
|
1724 |
@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
|
1725 |
@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
|
1726 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1727 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1728 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1729 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1730 |
en_fixed = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1731 |
en_mandatory = False |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1732 |
en_virtual = False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1733 |
|
2358
8e5a9830867e
cleanup etherlab: pep8, E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2356
diff
changeset
|
1734 |
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
|
1735 |
# PDO Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1736 |
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
|
1737 |
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
|
1738 |
# Number of Entries |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1739 |
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
|
1740 |
# About Sync Manager |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1741 |
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
|
1742 |
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
|
1743 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1744 |
data += "ff" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1745 |
# 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
|
1746 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1747 |
# Name Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1748 |
objname = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1749 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1750 |
objname = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1751 |
for name in self.Strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1752 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1753 |
if objname == name: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1754 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1755 |
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
|
1756 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1757 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1758 |
data += "{:0>2x}".format(count) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1759 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1760 |
# 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
|
1761 |
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
|
1762 |
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
|
1763 |
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
|
1764 |
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
|
1765 |
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
|
1766 |
en_virtual = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1767 |
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
|
1768 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1769 |
for entry in element.getEntry(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1770 |
# Entry Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1771 |
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
|
1772 |
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
|
1773 |
# Subindex |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1774 |
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
|
1775 |
# Entry Name Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1776 |
objname = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1777 |
for name in entry.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1778 |
objname = name.getcontent() |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1779 |
for name in self.Strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1780 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1781 |
if objname == name: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1782 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1783 |
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
|
1784 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1785 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1786 |
data += "{:0>2x}".format(count) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1787 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1788 |
# DataType |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1789 |
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
|
1790 |
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
|
1791 |
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
|
1792 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1793 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1794 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1795 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1796 |
# BitLen |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1797 |
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
|
1798 |
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
|
1799 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1800 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1801 |
# Flags; by Fixed attributes ? |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1802 |
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
|
1803 |
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
|
1804 |
en_fixed = True |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1805 |
data += str(int(en_fixed)) + "000" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1806 |
|
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1807 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1808 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1809 |
if pdotype == "TxPdo": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1810 |
eeprom.append("32") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1811 |
elif pdotype == "RxPdo": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1812 |
eeprom.append("33") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1813 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1814 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1815 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1816 |
# 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
|
1817 |
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
|
1818 |
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
|
1819 |
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
|
1820 |
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
|
1821 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1822 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1823 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1824 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1825 |
data = data[2:len(data)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1826 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1827 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1828 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1829 |
def ExtractEEPROMDCCategory(self, device): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1830 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1831 |
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
|
1832 |
@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
|
1833 |
@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
|
1834 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1835 |
eeprom = [] |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1836 |
data = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1837 |
count = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1838 |
namecount = 0 |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1839 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1840 |
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
|
1841 |
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
|
1842 |
count += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1843 |
# 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
|
1844 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1845 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1846 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1847 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1848 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1849 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1850 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1851 |
# word 8-10 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1852 |
# AssignActivate |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1853 |
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
|
1854 |
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
|
1855 |
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
|
1856 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1857 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1858 |
# 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
|
1859 |
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
|
1860 |
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
|
1861 |
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
|
1862 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1863 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1864 |
data += "0100" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1865 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1866 |
data += "0100" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1867 |
# 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
|
1868 |
# Name Index |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1869 |
objname = "" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1870 |
for name in element.getName(): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1871 |
objname += name |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1872 |
for name in self.Strings: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1873 |
namecount += 1 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1874 |
if objname == name: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1875 |
break |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1876 |
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
|
1877 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1878 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1879 |
data += "{:0>2x}".format(namecount) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1880 |
namecount = 0 |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1881 |
data += "00" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1882 |
# 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
|
1883 |
data += "0000" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1884 |
data += "0000" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1885 |
|
2417
316ee9fff395
cleanup: pylint, R0123 # (literal-comparison) Comparison to literal
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2410
diff
changeset
|
1886 |
if data != "": |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1887 |
# category header |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1888 |
eeprom.append("3c") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1889 |
eeprom.append("00") |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1890 |
# 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
|
1891 |
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
|
1892 |
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
|
1893 |
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
|
1894 |
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
|
1895 |
if data == "": |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1896 |
eeprom.append("00") |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1897 |
else: |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1898 |
eeprom.append(data[0:2]) |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1899 |
data = data[2:len(data)] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1900 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1901 |
return eeprom |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1902 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1903 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1904 |
# Used Register Access |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1905 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1906 |
def RegRead(self, offset, length): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1907 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1908 |
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
|
1909 |
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
|
1910 |
@param offset : register address |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1911 |
@param length : register length |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1912 |
@return return_val : register data |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1913 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1914 |
_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
|
1915 |
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
|
1916 |
return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1917 |
return return_val |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1918 |
|
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1919 |
def MultiRegRead(self, slave_num, reg_infos): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1920 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1921 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1922 |
@slave_num: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1923 |
@param addr_info: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1924 |
@return return_val: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1925 |
""" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1926 |
reg_info_str = "" |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1927 |
for reg_info in reg_infos: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1928 |
reg_info_str = reg_info_str + "%s|" % reg_info |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1929 |
reg_info_str = reg_info_str.strip("|") |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1930 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1931 |
_error, return_val = self.Controler.RemoteExec(\ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1932 |
MULTI_REG_READ%(slave_num, reg_info_str), |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1933 |
return_val = None) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1934 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1935 |
return return_val |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1936 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1937 |
def RegWrite(self, address, data): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1938 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1939 |
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
|
1940 |
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
|
1941 |
@param address : register address |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1942 |
@param data : data to write |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1943 |
@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
|
1944 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1945 |
_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
|
1946 |
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
|
1947 |
return_val=None) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1948 |
return return_val |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1949 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1950 |
def Rescan(self): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1951 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1952 |
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
|
1953 |
Command example : "ethercat rescan -p 0" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1954 |
""" |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
1955 |
_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
|
1956 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1957 |
# ------------------------------------------------------------------------------- |
2643
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1958 |
# Used DC Configuration |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1959 |
#------------------------------------------------------------------------------- |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1960 |
def LoadESIData(self): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1961 |
return_data = [] |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1962 |
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos()) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1963 |
type_infos = slave.getType() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1964 |
device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1965 |
if device.getDc() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1966 |
for OpMode in device.getDc().getOpMode(): |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1967 |
temp_data = { |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1968 |
"desc" : OpMode.getDesc() if OpMode.getDesc() is not None else "Unused", |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1969 |
"assign_activate" : OpMode.getAssignActivate() \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1970 |
if OpMode.getAssignActivate() is not None else "#x0000", |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1971 |
"cycletime_sync0" : OpMode.getCycleTimeSync0().getcontent() \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1972 |
if OpMode.getCycleTimeSync0() is not None else None, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1973 |
"shifttime_sync0" : OpMode.getShiftTimeSync0().getcontent() \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1974 |
if OpMode.getShiftTimeSync0() is not None else None, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1975 |
"cycletime_sync1" : OpMode.getShiftTimeSync1().getcontent() \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1976 |
if OpMode.getShiftTimeSync1() is not None else None, |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1977 |
"shifttime_sync1" : OpMode.getShiftTimeSync1().getcontent() \ |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1978 |
if OpMode.getShiftTimeSync1() is not None else None |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1979 |
} |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1980 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1981 |
if OpMode.getCycleTimeSync0() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1982 |
temp_data["cycletime_sync0_factor"] = OpMode.getCycleTimeSync0().getFactor() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1983 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1984 |
if OpMode.getCycleTimeSync1() is not None: |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1985 |
temp_data["cycletime_sync1_factor"] = OpMode.getCycleTimeSync1().getFactor() |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1986 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1987 |
return_data.append(temp_data) |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1988 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1989 |
return return_data |
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1990 |
|
b98d9e08231f
Etherlab : Merged 2014-2018 changes from jblee and others
Edouard Tisserant <edouard.tisserant@gmail.com>
diff
changeset
|
1991 |
#------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1992 |
# Common Use Methods |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
1993 |
# ------------------------------------------------------------------------------- |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1994 |
def CheckConnect(self, cyclic_flag): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
1995 |
""" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1996 |
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
|
1997 |
@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
|
1998 |
@return True or False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
1999 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2000 |
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
|
2001 |
# 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
|
2002 |
# 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
|
2003 |
_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
|
2004 |
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
|
2005 |
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
|
2006 |
if not cyclic_flag: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2421
diff
changeset
|
2007 |
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
|
2008 |
return False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2009 |
|
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2374
diff
changeset
|
2010 |
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
|
2011 |
return True |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2012 |
else: |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2013 |
# 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
|
2014 |
if not cyclic_flag: |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2421
diff
changeset
|
2015 |
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
|
2016 |
return False |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2017 |
|
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2018 |
def CreateErrorDialog(self, mention): |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2019 |
""" |
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2020 |
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
|
2021 |
@param mention : Error String |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2022 |
""" |
2354
9460872f1440
convert some etherlab source files to unix format
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2353
diff
changeset
|
2023 |
app_frame = self.Controler.GetCTRoot().AppFrame |
2382
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2378
diff
changeset
|
2024 |
dlg = wx.MessageDialog(app_frame, mention, |
2423
2c7b7ae24d57
Improve localization support in etherlab (mostly)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2421
diff
changeset
|
2025 |
_(' Warning...'), |
2382
e783c6beacf1
clean etherlab: pep8, E211 whitespace before '['
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2378
diff
changeset
|
2026 |
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
|
2027 |
dlg.ShowModal() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2354
diff
changeset
|
2028 |
dlg.Destroy() |