author | Edouard Tisserant |
Thu, 28 May 2020 11:38:09 +0200 | |
branch | svghmi |
changeset 2972 | 1f043fdaa7fb |
parent 2413 | 803daf19a1b5 |
child 2643 | b98d9e08231f |
permissions | -rw-r--r-- |
2165
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
1 |
#!/usr/bin/env python |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
3 |
|
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
4 |
# This file is part of Beremiz |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
5 |
# |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
6 |
# Copyright (C) 2011-2014: Laurent BESSARD, Edouard TISSERANT |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
7 |
# RTES Lab : CRKim, JBLee, youcu |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
8 |
# Higen Motor : Donggu Kang |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
9 |
# |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2164
diff
changeset
|
11 |
|
2405
af050469fc5c
clean etherlab: pylint, W1618 # (no-absolute-import) import missing `from __future__ import absolute_import`
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2396
diff
changeset
|
12 |
from __future__ import absolute_import |
2111 | 13 |
import os |
14 |
||
15 |
import wx |
|
16 |
||
2396
41adf1dfc7a7
clean etherlab: pylint, W0611 # (unused-import) Unused import X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2393
diff
changeset
|
17 |
from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_INPUT |
2111 | 18 |
|
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
19 |
from MotionLibrary import AxisXSD |
2405
af050469fc5c
clean etherlab: pylint, W1618 # (no-absolute-import) import missing `from __future__ import absolute_import`
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2396
diff
changeset
|
20 |
from etherlab.EthercatSlave import _EthercatSlaveCTN, _CommonSlave |
af050469fc5c
clean etherlab: pylint, W1618 # (no-absolute-import) import missing `from __future__ import absolute_import`
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2396
diff
changeset
|
21 |
from etherlab.ConfigEditor import CIA402NodeEditor |
2111 | 22 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
23 |
# Definition of node variables that have to be mapped in PDO |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
24 |
# [(name, index, subindex, type, |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
25 |
# direction for master ('I': input, 'Q': output)),...] |
2111 | 26 |
NODE_VARIABLES = [ |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
27 |
("ControlWord", 0x6040, 0x00, "UINT", "Q"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
28 |
("TargetPosition", 0x607a, 0x00, "DINT", "Q"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
29 |
("TargetVelocity", 0x60ff, 0x00, "DINT", "Q"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
30 |
("TargetTorque", 0x6071, 0x00, "INT", "Q"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
31 |
("ModesOfOperation", 0x6060, 0x00, "SINT", "Q"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
32 |
("StatusWord", 0x6041, 0x00, "UINT", "I"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
33 |
("ModesOfOperationDisplay", 0x6061, 0x00, "SINT", "I"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
34 |
("ActualPosition", 0x6064, 0x00, "DINT", "I"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
35 |
("ActualVelocity", 0x606c, 0x00, "DINT", "I"), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
36 |
("ActualTorque", 0x6077, 0x00, "INT", "I"), |
2111 | 37 |
] |
38 |
||
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
39 |
# Definition of optional node variables that can be added to PDO mapping. |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
40 |
# A checkbox will be displayed for each section in node configuration panel to |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
41 |
# enable them |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
42 |
# [(section_name, |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
43 |
# [{'description', (name, index, subindex, type, |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
44 |
# direction for master ('I': input, 'Q': output)), |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
45 |
# 'retrieve', string_template_for_retrieve_variable (None: not retrieved, |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
46 |
# default string template if not defined), |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
47 |
# 'publish', string_template_for_publish_variable (None: not published, |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
48 |
# default string template if not defined), |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
49 |
# },...] |
2111 | 50 |
EXTRA_NODE_VARIABLES = [ |
51 |
("ErrorCode", [ |
|
52 |
{"description": ("ErrorCode", 0x603F, 0x00, "UINT", "I"), |
|
53 |
"publish": None} |
|
54 |
]), |
|
55 |
("DigitalInputs", [ |
|
56 |
{"description": ("DigitalInputs", 0x60FD, 0x00, "UDINT", "I"), |
|
57 |
"publish": None} |
|
58 |
]), |
|
59 |
("DigitalOutputs", [ |
|
60 |
{"description": ("DigitalOutputs", 0x60FE, 0x00, "UDINT", "Q"), |
|
61 |
"retrieve": None} |
|
2146
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
62 |
]), |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
63 |
("TouchProbe", [ |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
64 |
{"description": ("TouchProbeFunction", 0x60B8, 0x00, "UINT", "Q"), |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
65 |
"retrieve": None}, |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
66 |
{"description": ("TouchProbeStatus", 0x60B9, 0x00, "UINT", "I"), |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
67 |
"publish": None}, |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
68 |
{"description": ("TouchProbePos1PosValue", 0x60BA, 0x00, "DINT", "I"), |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
69 |
"publish": None}, |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
70 |
{"description": ("TouchProbePos1NegValue", 0x60BB, 0x00, "DINT", "I"), |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
71 |
"publish": None}, |
0c65c96a8379
Added mapping for TouchProbe function in CIA402 slave node
Laurent Bessard
parents:
2145
diff
changeset
|
72 |
]), |
2111 | 73 |
] |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
74 |
|
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
75 |
# List of parameters name in no configuration panel for optional variable |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
76 |
# sections |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
77 |
EXTRA_NODE_VARIABLES_DICT = { |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
78 |
"Enable" + name: params |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
79 |
for name, params in EXTRA_NODE_VARIABLES} |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
80 |
|
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
81 |
# List of block to define to interface MCL to fieldbus for specific functions |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
82 |
FIELDBUS_INTERFACE_GLOBAL_INSTANCES = [ |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
83 |
{"blocktype": "GetTorqueLimit", |
2111 | 84 |
"inputs": [], |
85 |
"outputs": [{"name": "TorqueLimitPos", "type": "UINT"}, |
|
86 |
{"name": "TorqueLimitNeg", "type": "UINT"}]}, |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
87 |
{"blocktype": "SetTorqueLimit", |
2111 | 88 |
"inputs": [{"name": "TorqueLimitPos", "type": "UINT"}, |
89 |
{"name": "TorqueLimitNeg", "type": "UINT"}], |
|
90 |
"outputs": []}, |
|
91 |
] |
|
92 |
||
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
93 |
# -------------------------------------------------- |
2111 | 94 |
# Ethercat CIA402 Node |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
95 |
# -------------------------------------------------- |
2111 | 96 |
|
2360
2a3d022a7dac
cleanup etherlab: pep8, E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2358
diff
changeset
|
97 |
|
2111 | 98 |
class _EthercatCIA402SlaveCTN(_EthercatSlaveCTN): |
99 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
100 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
101 |
<xsd:element name="CIA402SlaveParams"> |
|
102 |
<xsd:complexType> |
|
103 |
%s |
|
104 |
</xsd:complexType> |
|
105 |
</xsd:element> |
|
106 |
</xsd:schema> |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
107 |
""" % ("\n".join(["""\ |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
108 |
<xsd:attribute name="Enable%s" type="xsd:boolean" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
109 |
use="optional" default="false"/>""" % category |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
110 |
for category, variables in EXTRA_NODE_VARIABLES]) + AxisXSD) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
111 |
|
2111 | 112 |
NODE_PROFILE = 402 |
113 |
EditorType = CIA402NodeEditor |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
114 |
|
2111 | 115 |
ConfNodeMethods = [ |
2375
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
116 |
{ |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
117 |
"bitmap": "CIA402AxisRef", |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
118 |
"name": _("Axis Ref"), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
119 |
"tooltip": _("Initiate Drag'n drop of Axis ref located variable"), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
120 |
"method": "_getCIA402AxisRef", |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
121 |
"push": True, |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
122 |
}, |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
123 |
{ |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
124 |
"bitmap": "CIA402NetPos", |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
125 |
"name": _("Axis Pos"), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
126 |
"tooltip": _("Initiate Drag'n drop of Network position located variable"), |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
127 |
"method": "_getCIA402NetworkPosition", |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
128 |
"push": True, |
cfa68a06a24d
clean etherlab: pep8, E203 whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2364
diff
changeset
|
129 |
}, |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
130 |
] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
131 |
|
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
132 |
# -------------------------------------------------- |
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2148
diff
changeset
|
133 |
# class code |
2356
c26e0c66d8d5
cleanup etherlab: pep8, E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2355
diff
changeset
|
134 |
# -------------------------------------------------- |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
135 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2148
diff
changeset
|
136 |
def __init__(self): |
2393
fddc29dee614
clean etherlab: pylint,W0231 # (super-init-not-called) __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2391
diff
changeset
|
137 |
_EthercatSlaveCTN.__init__(self) |
fddc29dee614
clean etherlab: pylint,W0231 # (super-init-not-called) __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2391
diff
changeset
|
138 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2148
diff
changeset
|
139 |
# ----------- call ethercat mng. function -------------- |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2148
diff
changeset
|
140 |
self.CommonMethod = _CommonSlave(self) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
141 |
|
2111 | 142 |
def GetIconName(self): |
143 |
return "CIA402Slave" |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
144 |
|
2111 | 145 |
def SetParamsAttribute(self, path, value): |
146 |
if path == "CIA402SlaveParams.Type": |
|
147 |
path = "SlaveParams.Type" |
|
148 |
elif path == "CIA402SlaveParams.Alias": |
|
149 |
path = "SlaveParams.Alias" |
|
150 |
return _EthercatSlaveCTN.SetParamsAttribute(self, path, value) |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
151 |
|
2111 | 152 |
def GetVariableLocationTree(self): |
153 |
axis_name = self.CTNName() |
|
154 |
current_location = self.GetCurrentLocation() |
|
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
155 |
children = [ |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
156 |
{ |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
157 |
"name": name_frmt % (axis_name), |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
158 |
"type": LOCATION_VAR_INPUT, |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
159 |
"size": "W", |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
160 |
"IEC_type": iec_type, |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
161 |
"var_name": var_name_frmt % axis_name, |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
162 |
"location": location_frmt % (".".join(map(str, current_location))), |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
163 |
"description": "", |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
164 |
"children": [] |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
165 |
} |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
166 |
for name_frmt, iec_type, var_name_frmt, location_frmt in [ |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
167 |
("%s Network Position", "UINT", "%s_pos", "%%IW%s"), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
168 |
("%s Axis Ref", "AXIS_REF", "%s", "%%IW%s.402") |
2380
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
169 |
] |
b35bce45bc5a
clean etherlab: pep8, E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2375
diff
changeset
|
170 |
] |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
171 |
children.extend(self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(), |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
172 |
current_location, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
173 |
axis_name)) |
2362
6d31ef14f396
cleanup etherlab: pep8, E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
174 |
return { |
6d31ef14f396
cleanup etherlab: pep8, E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
175 |
"name": axis_name, |
6d31ef14f396
cleanup etherlab: pep8, E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
176 |
"type": LOCATION_CONFNODE, |
6d31ef14f396
cleanup etherlab: pep8, E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
177 |
"location": self.GetFullIEC_Channel(), |
6d31ef14f396
cleanup etherlab: pep8, E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2360
diff
changeset
|
178 |
"children": children, |
2111 | 179 |
} |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
180 |
|
2111 | 181 |
def CTNGlobalInstances(self): |
182 |
current_location = self.GetCurrentLocation() |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
183 |
return [("%s_%s" % (block_infos["blocktype"], |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
184 |
"_".join(map(str, current_location))), |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
185 |
"EtherLab%s" % block_infos["blocktype"], "") |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
186 |
for block_infos in FIELDBUS_INTERFACE_GLOBAL_INSTANCES] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
187 |
|
2154
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
188 |
def StartDragNDrop(self, data): |
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
189 |
data_obj = wx.TextDataObject(str(data)) |
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
190 |
dragSource = wx.DropSource(self.GetCTRoot().AppFrame) |
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
191 |
dragSource.SetData(data_obj) |
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
192 |
dragSource.DoDragDrop() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
193 |
|
2154
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
194 |
def _getCIA402NetworkPosition(self): |
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
195 |
self.StartDragNDrop( |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
196 |
("%%IW%s" % ".".join(map(str, self.GetCurrentLocation())), |
2154
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
197 |
"location", "UINT", self.CTNName() + "_Pos", "")) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
198 |
|
2111 | 199 |
def _getCIA402AxisRef(self): |
2154
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
200 |
self.StartDragNDrop( |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
201 |
("%%IW%s.402" % ".".join(map(str, self.GetCurrentLocation())), |
2154
6bbe93799956
Replaced location for axis ref from %IW(location).0 to %IW(location).402. Added location for network position at %IW(location).
Laurent Bessard
parents:
2153
diff
changeset
|
202 |
"location", "AXIS_REF", self.CTNName(), "")) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
203 |
|
2111 | 204 |
def CTNGenerate_C(self, buildpath, locations): |
205 |
current_location = self.GetCurrentLocation() |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
206 |
|
2391
3315e621d7fb
clean etherlab: pylint,W0108 # (unnecessary-lambda) Lambda may not be necessary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
207 |
location_str = "_".join(map(str, current_location)) |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
208 |
slave_pos = self.GetSlavePos() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
209 |
|
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
210 |
# Open CIA402 node code template file |
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
211 |
plc_cia402node_filepath = os.path.join(os.path.split(__file__)[0], |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
212 |
"plc_cia402node.c") |
2111 | 213 |
plc_cia402node_file = open(plc_cia402node_filepath, 'r') |
214 |
plc_cia402node_code = plc_cia402node_file.read() |
|
215 |
plc_cia402node_file.close() |
|
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
216 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
217 |
# Init list of generated strings for each code template file section |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
218 |
fieldbus_interface_declaration = [] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
219 |
fieldbus_interface_definition = [] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
220 |
init_axis_params = [] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
221 |
extra_variables_retrieve = [] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
222 |
extra_variables_publish = [] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
223 |
extern_located_variables_declaration = [] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
224 |
entry_variables = [] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
225 |
init_entry_variables = [] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
226 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
227 |
# Fieldbus interface code sections |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
228 |
for blocktype_infos in FIELDBUS_INTERFACE_GLOBAL_INSTANCES: |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
229 |
blocktype = blocktype_infos["blocktype"] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
230 |
ucase_blocktype = blocktype.upper() |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
231 |
blockname = "_".join([ucase_blocktype, location_str]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
232 |
|
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
233 |
extract_inputs = "\n".join([ |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
234 |
"""\ |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
235 |
__SET_VAR(%s->, %s,, %s);""" % (blockname, input_name, input_value) |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
236 |
for (input_name, input_value) in |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
237 |
[("EXECUTE", "__GET_VAR(data__->EXECUTE)")] + [ |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
238 |
(input["name"].upper(), |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
239 |
"__GET_VAR(data__->%s)" % input["name"].upper()) |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
240 |
for input in blocktype_infos["inputs"] |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
241 |
]]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
242 |
|
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
243 |
return_outputs = "\n".join([ |
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
244 |
"""\ |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
245 |
__SET_VAR(data__->,%(output_name)s,, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
246 |
__GET_VAR(%(blockname)s->%(output_name)s));""" % { |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
247 |
"output_name": output_name, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
248 |
"blockname": blockname |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
249 |
} |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
250 |
for output_name in ["DONE", "BUSY", "ERROR"] + [ |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
251 |
output["name"].upper() |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
252 |
for output in blocktype_infos["outputs"]] |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
253 |
]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
254 |
|
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
255 |
loc_dict = { |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
256 |
"ucase_blocktype": ucase_blocktype, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
257 |
"blocktype": blocktype, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
258 |
"blockname": blockname, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
259 |
"location_str": location_str, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
260 |
"extract_inputs": extract_inputs, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
261 |
"return_outputs": return_outputs, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
262 |
} |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
263 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
264 |
fieldbus_interface_declaration.append(""" |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
265 |
extern void ETHERLAB%(ucase_blocktype)s_body__(ETHERLAB%(ucase_blocktype)s* data__); |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
266 |
void __%(blocktype)s_%(location_str)s(MC_%(ucase_blocktype)s *data__) { |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
267 |
__DECLARE_GLOBAL_PROTOTYPE(ETHERLAB%(ucase_blocktype)s, %(blockname)s); |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
268 |
ETHERLAB%(ucase_blocktype)s* %(blockname)s = __GET_GLOBAL_%(blockname)s(); |
2164
7a959b19d5a4
Propagated matiec changes in FB var accessors
Edouard Tisserant
parents:
2156
diff
changeset
|
269 |
__SET_VAR(%(blockname)s->, POS,, AxsPub.axis->NetworkPosition); |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
270 |
%(extract_inputs)s |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
271 |
ETHERLAB%(ucase_blocktype)s_body__(%(blockname)s); |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
272 |
%(return_outputs)s |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
273 |
}""" % loc_dict) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
274 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
275 |
fieldbus_interface_definition.append("""\ |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
276 |
AxsPub.axis->__mcl_func_MC_%(blocktype)s = __%(blocktype)s_%(location_str)s;\ |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
277 |
""" % loc_dict) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
278 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
279 |
# Get a copy list of default variables to map |
2111 | 280 |
variables = NODE_VARIABLES[:] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
281 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
282 |
# Set AxisRef public struct members value |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
283 |
node_params = self.CTNParams[1].getElementInfos(self.CTNParams[0]) |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
284 |
for param in node_params["children"]: |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
285 |
param_name = param["name"] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
286 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
287 |
# Param is optional variables section enable flag |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
288 |
extra_node_variable_infos = EXTRA_NODE_VARIABLES_DICT.get(param_name) |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
289 |
if extra_node_variable_infos is not None: |
2156
c8eee6be2da8
Added bug in support for set flag for optional variables activation in axis public struct
Laurent Bessard
parents:
2155
diff
changeset
|
290 |
param_name = param_name.replace("Enable", "") + "Enabled" |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
291 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
292 |
if not param["value"]: |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
293 |
continue |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
294 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
295 |
# Optional variables section is enabled |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
296 |
for variable_infos in extra_node_variable_infos: |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
297 |
var_name = variable_infos["description"][0] |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
298 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
299 |
# Add each variables defined in section description to the |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
300 |
# list of variables to map |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
301 |
variables.append(variable_infos["description"]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
302 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
303 |
# Add code to publish or retrive variable |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
304 |
coded = [ |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
305 |
("retrieve", |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
306 |
extra_variables_retrieve, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
307 |
" AxsPub.axis->%(var_name)s = *(AxsPub.%(var_name)s);"), |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
308 |
("publish", |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
309 |
extra_variables_publish, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
310 |
" *(AxsPub.%(var_name)s) = AxsPub.axis->%(var_name)s;") |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
311 |
] |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
312 |
for var_exchange_dir, _str_list, default_template in coded: |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
313 |
template = variable_infos.get(var_exchange_dir, default_template) |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
314 |
if template is not None: |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
315 |
extra_variables_publish.append(template % locals()) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
316 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
317 |
# Set AxisRef public struct member value if defined |
2155
d63541200d8e
Added support for set flag for optional variables activation in axis public struct
Laurent Bessard
parents:
2154
diff
changeset
|
318 |
if param["value"] is not None: |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
319 |
param_value = ({True: "1", False: "0"}[param["value"]] |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
320 |
if param["type"] == "boolean" |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
321 |
else str(param["value"])) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
322 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
323 |
init_axis_params.append("""\ |
2413
803daf19a1b5
cleanup: pylint, E1304 # (missing-format-string-key) Missing key 'X_name' in format string dictionary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
324 |
AxsPub.axis->%(param_name)s = %(param_value)s;""" % { |
803daf19a1b5
cleanup: pylint, E1304 # (missing-format-string-key) Missing key 'X_name' in format string dictionary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
325 |
"param_value": param_value, |
803daf19a1b5
cleanup: pylint, E1304 # (missing-format-string-key) Missing key 'X_name' in format string dictionary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
326 |
"param_name": param_name, |
803daf19a1b5
cleanup: pylint, E1304 # (missing-format-string-key) Missing key 'X_name' in format string dictionary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2407
diff
changeset
|
327 |
}) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
328 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
329 |
# Add each variable in list of variables to map to master list of |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
330 |
# variables to add to network configuration |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
331 |
for name, index, subindex, var_type, dir in variables: |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
332 |
var_size = self.GetSizeOfType(var_type) |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
333 |
loc_dict = { |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
334 |
"var_size": var_size, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
335 |
"var_type": var_type, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
336 |
"name:": name, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
337 |
"location_str": location_str, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
338 |
"index": index, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
339 |
"subindex": subindex, |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
340 |
} |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
341 |
var_name = """\ |
2406
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
342 |
__%(dir)s%(var_size)s%(location_str)s_%(index)d_%(subindex)d""" % loc_dict |
ffd091b51cd0
clean etherlab: pylint, W0612 # (unused-variable) Unused variable 'X'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2405
diff
changeset
|
343 |
loc_dict["var_name"] = var_name |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
344 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
345 |
extern_located_variables_declaration.append( |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
346 |
"IEC_%(var_type)s *%(var_name)s;" % loc_dict) |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
347 |
entry_variables.append( |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
348 |
" IEC_%(var_type)s *%(name)s;" % loc_dict) |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
349 |
init_entry_variables.append( |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
350 |
" AxsPub.%(name)s = %(var_name)s;" % loc_dict) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
351 |
|
2111 | 352 |
self.CTNParent.FileGenerator.DeclareVariable( |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
353 |
slave_pos, index, subindex, var_type, dir, var_name) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
354 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
355 |
# Add newline between string in list of generated strings for sections |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
356 |
[fieldbus_interface_declaration, fieldbus_interface_definition, |
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
357 |
init_axis_params, extra_variables_retrieve, extra_variables_publish, |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
358 |
extern_located_variables_declaration, entry_variables, |
2391
3315e621d7fb
clean etherlab: pylint,W0108 # (unnecessary-lambda) Lambda may not be necessary
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2381
diff
changeset
|
359 |
init_entry_variables] = map("\n".join, [ |
2407
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
360 |
fieldbus_interface_declaration, fieldbus_interface_definition, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
361 |
init_axis_params, extra_variables_retrieve, extra_variables_publish, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
362 |
extern_located_variables_declaration, entry_variables, |
5f2b1bb464a0
clean etherlab: pylint, C0330 # (bad-continuation) Wrong hanging indentation before block
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2406
diff
changeset
|
363 |
init_entry_variables]) |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
364 |
|
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
365 |
# Write generated content to CIA402 node file |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
366 |
Gen_CIA402Nodefile_path = os.path.join(buildpath, |
2381
1c40e3976cc2
clean etherlab: pep8, E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2380
diff
changeset
|
367 |
"cia402node_%s.c" % location_str) |
2111 | 368 |
cia402nodefile = open(Gen_CIA402Nodefile_path, 'w') |
2153
91c10856adaa
Rewrite CIA402 node specific code generating part
Laurent Bessard
parents:
2152
diff
changeset
|
369 |
cia402nodefile.write(plc_cia402node_code % locals()) |
2111 | 370 |
cia402nodefile.close() |
2355
fec77f2b9e07
cleanup etherlab: pep8, W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2165
diff
changeset
|
371 |
|
2363
9c7da6ff6a34
cleanup etherlab: pep8, E231 missing whitespace after ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2362
diff
changeset
|
372 |
return [(Gen_CIA402Nodefile_path, '"-I%s"' % os.path.abspath(self.GetCTRoot().GetIECLibPath()))], "", True |