author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Tue, 19 Oct 2021 12:58:22 +0200 | |
changeset 3366 | 1ca385429bba |
parent 2736 | a81b72ef156c |
child 3750 | f62625418bff |
permissions | -rw-r--r-- |
1511
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
1 |
#!/usr/bin/env python |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
3 |
|
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
6 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
1680
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1511
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov |
1511
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
9 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
11 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
12 |
# This program is free software; you can redistribute it and/or |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
13 |
# modify it under the terms of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
14 |
# as published by the Free Software Foundation; either version 2 |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
15 |
# of the License, or (at your option) any later version. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
16 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
17 |
# This program is distributed in the hope that it will be useful, |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
20 |
# GNU General Public License for more details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
21 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
22 |
# You should have received a copy of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
23 |
# along with this program; if not, write to the Free Software |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1464
diff
changeset
|
25 |
|
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
26 |
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:
2418
diff
changeset
|
27 |
from __future__ import division |
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
28 |
import os |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
29 |
import sys |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
30 |
import shutil |
1783
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
31 |
import wx |
1919
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
32 |
from gnosis.xml.pickle import * # pylint: disable=import-error |
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
33 |
from gnosis.xml.pickle.util import setParanoia # pylint: disable=import-error |
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
34 |
|
1680
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1511
diff
changeset
|
35 |
import util.paths as paths |
2736
a81b72ef156c
Add ThirPartyPath call in util.path module, so that individual extensions don't have to each implement same logic to find dependencies
Edouard Tisserant
parents:
2442
diff
changeset
|
36 |
|
1783
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
37 |
from util.TranslationCatalogs import AddCatalog |
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
38 |
from ConfigTreeNode import ConfigTreeNode |
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
39 |
from PLCControler import \ |
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
40 |
LOCATION_CONFNODE, \ |
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
41 |
LOCATION_VAR_MEMORY |
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
42 |
|
2736
a81b72ef156c
Add ThirPartyPath call in util.path module, so that individual extensions don't have to each implement same logic to find dependencies
Edouard Tisserant
parents:
2442
diff
changeset
|
43 |
CanFestivalPath = paths.ThirdPartyPath("CanFestival-3") # noqa |
1997 | 44 |
sys.path.append(os.path.join(CanFestivalPath, "objdictgen")) # noqa |
45 |
||
46 |
# pylint: disable=wrong-import-position |
|
1979
dc9e6f97cd8c
Removed useless try/except in Canfestival.py
Edouard Tisserant
parents:
1919
diff
changeset
|
47 |
from nodelist import NodeList |
11 | 48 |
from nodemanager import NodeManager |
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
49 |
import gen_cfile |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
50 |
import eds_utils |
1919
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
51 |
import canfestival_config as local_canfestival_config # pylint: disable=import-error |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
52 |
from commondialogs import CreateNodeDialog |
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
53 |
from subindextable import IECTypeConversion, SizeConversion |
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
54 |
from canfestival import config_utils |
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
55 |
from canfestival.SlaveEditor import SlaveEditor, MasterViewer |
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
56 |
from canfestival.NetworkEditor import NetworkEditor |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
57 |
|
1783
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
58 |
|
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
59 |
AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale")) |
77
7de69369373e
Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents:
65
diff
changeset
|
60 |
setParanoia(0) |
7de69369373e
Adding file with generated master in build folder and a button for editing it with objdictedit
lbessard
parents:
65
diff
changeset
|
61 |
|
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
802
diff
changeset
|
62 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
63 |
# -------------------------------------------------- |
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
64 |
# Location Tree Helper |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
65 |
# -------------------------------------------------- |
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
66 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
67 |
|
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
68 |
def GetSlaveLocationTree(slave_node, current_location, name): |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
69 |
entries = [] |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
70 |
for index, subindex, size, entry_name in slave_node.GetMapVariableList(): |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
71 |
subentry_infos = slave_node.GetSubentryInfos(index, subindex) |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
72 |
typeinfos = slave_node.GetEntryInfos(subentry_infos["type"]) |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
73 |
if typeinfos: |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
74 |
entries.append({ |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
75 |
"name": "0x%4.4x-0x%2.2x: %s" % (index, subindex, entry_name), |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
76 |
"type": LOCATION_VAR_MEMORY, |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
77 |
"size": size, |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
78 |
"IEC_type": IECTypeConversion.get(typeinfos["name"]), |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
79 |
"var_name": "%s_%4.4x_%2.2x" % ("_".join(name.split()), index, subindex), |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
80 |
"location": "%s%s" % (SizeConversion[size], ".".join(map(str, current_location + |
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
81 |
(index, subindex)))), |
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
82 |
"description": "", |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
83 |
"children": []}) |
1738
d2e979738700
clean-up: fix PEP8 E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
84 |
return {"name": name, |
d2e979738700
clean-up: fix PEP8 E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
85 |
"type": LOCATION_CONFNODE, |
d2e979738700
clean-up: fix PEP8 E271 multiple spaces after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
86 |
"location": ".".join([str(i) for i in current_location]) + ".x", |
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
87 |
"children": entries} |
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
88 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
89 |
# -------------------------------------------------- |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
90 |
# SLAVE |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
91 |
# -------------------------------------------------- |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
92 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
93 |
|
718 | 94 |
class _SlaveCTN(NodeManager): |
12 | 95 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
96 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
166 | 97 |
<xsd:element name="CanFestivalSlaveNode"> |
12 | 98 |
<xsd:complexType> |
960
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
99 |
<xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/> |
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
100 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/> |
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
101 |
<xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="2"/> |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
102 |
<xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/> |
203 | 103 |
<xsd:attribute name="Sync_Align_Ratio" use="optional" default="50"> |
104 |
<xsd:simpleType> |
|
105 |
<xsd:restriction base="xsd:integer"> |
|
106 |
<xsd:minInclusive value="1"/> |
|
107 |
<xsd:maxInclusive value="99"/> |
|
108 |
</xsd:restriction> |
|
109 |
</xsd:simpleType> |
|
110 |
</xsd:attribute> |
|
12 | 111 |
</xsd:complexType> |
112 |
</xsd:element> |
|
113 |
</xsd:schema> |
|
960
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
114 |
""" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
115 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
116 |
EditorType = SlaveEditor |
738 | 117 |
IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png") |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
118 |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
15
diff
changeset
|
119 |
def __init__(self): |
23 | 120 |
# TODO change netname when name change |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
121 |
NodeManager.__init__(self) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
122 |
odfilepath = self.GetSlaveODPath() |
1828
396da88d7b5c
fix unnecessary parens after keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
123 |
if os.path.isfile(odfilepath): |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
124 |
self.OpenFileInCurrent(odfilepath) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
125 |
else: |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
126 |
self.FilePath = "" |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
127 |
dialog = CreateNodeDialog(None, wx.OK) |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
128 |
dialog.Type.Enable(False) |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
129 |
dialog.GenSYNC.Enable(False) |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
130 |
if dialog.ShowModal() == wx.ID_OK: |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
131 |
name, id, _nodetype, description = dialog.GetValues() |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
132 |
profile, filepath = dialog.GetProfile() |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
133 |
NMT = dialog.GetNMTManagement() |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
134 |
options = dialog.GetOptions() |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
135 |
self.CreateNewNode(name, # Name - will be changed at build time |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
136 |
id, # NodeID - will be changed at build time |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
137 |
"slave", # Type |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
138 |
description, # description |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
139 |
profile, # profile |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
140 |
filepath, # prfile filepath |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
141 |
NMT, # NMT |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
142 |
options) # options |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
143 |
else: |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
144 |
self.CreateNewNode("SlaveNode", # Name - will be changed at build time |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
145 |
0x00, # NodeID - will be changed at build time |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
146 |
"slave", # Type |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
147 |
"", # description |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
148 |
"None", # profile |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
149 |
"", # prfile filepath |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
150 |
"heartbeat", # NMT |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
151 |
[]) # options |
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
152 |
dialog.Destroy() |
718 | 153 |
self.OnCTNSave() |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
154 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
155 |
def GetCurrentNodeName(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
156 |
return self.CTNName() |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
157 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
158 |
def GetSlaveODPath(self): |
718 | 159 |
return os.path.join(self.CTNPath(), 'slave.od') |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
160 |
|
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
161 |
def GetCanDevice(self): |
948
89fead207c35
Fix semantic error while compiling project including canfestival extension instances
Laurent Bessard
parents:
847
diff
changeset
|
162 |
return self.CanFestivalSlaveNode.getCAN_Device() |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
163 |
|
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
164 |
def _OpenView(self, name=None, onlyopened=False): |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
165 |
ConfigTreeNode._OpenView(self, name, onlyopened) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
166 |
if self._View is not None: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
167 |
self._View.SetBusId(self.GetCurrentLocation()) |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
168 |
return self._View |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
169 |
|
777 | 170 |
def _ExportSlave(self): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
171 |
dialog = wx.FileDialog(self.GetCTRoot().AppFrame, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
172 |
_("Choose a file"), |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
173 |
os.path.expanduser("~"), |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
174 |
"%s.eds" % self.CTNName(), |
847
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
175 |
_("EDS files (*.eds)|*.eds|All files|*.*"), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
176 |
wx.SAVE | wx.OVERWRITE_PROMPT) |
777 | 177 |
if dialog.ShowModal() == wx.ID_OK: |
178 |
result = eds_utils.GenerateEDSFile(dialog.GetPath(), self.GetCurrentNodeCopy()) |
|
179 |
if result: |
|
180 |
self.GetCTRoot().logger.write_error(_("Error: Export slave failed\n")) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
181 |
dialog.Destroy() |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
182 |
|
717 | 183 |
ConfNodeMethods = [ |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
184 |
{ |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
185 |
"bitmap": "ExportSlave", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
186 |
"name": _("Export slave"), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
187 |
"tooltip": _("Export CanOpen slave to EDS file"), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
188 |
"method": "_ExportSlave" |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
189 |
}, |
65 | 190 |
] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
191 |
|
718 | 192 |
def CTNTestModified(self): |
166 | 193 |
return self.ChangesToSave or self.OneFileHasChanged() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
194 |
|
1061 | 195 |
def OnCTNSave(self, from_project_path=None): |
166 | 196 |
return self.SaveCurrentInFile(self.GetSlaveODPath()) |
12 | 197 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
198 |
def SetParamsAttribute(self, path, value): |
717 | 199 |
result = ConfigTreeNode.SetParamsAttribute(self, path, value) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
200 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
201 |
# Filter IEC_Channel and Name, that have specific behavior |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
202 |
if path == "BaseParams.IEC_Channel" and self._View is not None: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
203 |
self._View.SetBusId(self.GetCurrentLocation()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
204 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
205 |
return result |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
206 |
|
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
207 |
def GetVariableLocationTree(self): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
208 |
return GetSlaveLocationTree(self.CurrentNode, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
209 |
self.GetCurrentLocation(), |
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
210 |
self.BaseParams.getName()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
211 |
|
718 | 212 |
def CTNGenerate_C(self, buildpath, locations): |
12 | 213 |
""" |
15
7a473efc4530
More precise design for plugins.... to be continued...
etisserant
parents:
13
diff
changeset
|
214 |
Generate C code |
717 | 215 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
15
7a473efc4530
More precise design for plugins.... to be continued...
etisserant
parents:
13
diff
changeset
|
216 |
@param locations: List of complete variables locations \ |
22 | 217 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
218 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
|
219 |
"DIR" : direction "Q","I" or "M" |
|
220 |
"SIZE" : size "X", "B", "W", "D", "L" |
|
221 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
|
222 |
}, ...] |
|
223 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
|
12 | 224 |
""" |
24 | 225 |
current_location = self.GetCurrentLocation() |
22 | 226 |
# define a unique name for the generated C file |
166 | 227 |
prefix = "_".join(map(str, current_location)) |
1746
45d6f5fba016
clean-up: fix PEP8 E202 whitespace before ')'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
228 |
Gen_OD_path = os.path.join(buildpath, "OD_%s.c" % prefix) |
166 | 229 |
# Create a new copy of the model |
230 |
slave = self.GetCurrentNodeCopy() |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
231 |
slave.SetNodeName("OD_%s" % prefix) |
166 | 232 |
# allow access to local OD from Slave PLC |
233 |
pointers = config_utils.LocalODPointers(locations, current_location, slave) |
|
234 |
res = gen_cfile.GenerateFile(Gen_OD_path, slave, pointers) |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
235 |
if res: |
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1751
diff
changeset
|
236 |
raise Exception(res) |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
237 |
res = eds_utils.GenerateEDSFile(os.path.join(buildpath, "Slave_%s.eds" % prefix), slave) |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
238 |
if res: |
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1751
diff
changeset
|
239 |
raise Exception(res) |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
240 |
return [(Gen_OD_path, local_canfestival_config.getCFLAGS(CanFestivalPath))], "", False |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
241 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
242 |
def LoadPrevious(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
243 |
self.LoadCurrentPrevious() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
244 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
245 |
def LoadNext(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
246 |
self.LoadCurrentNext() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
247 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
248 |
def GetBufferState(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
249 |
return self.GetCurrentBufferState() |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
250 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
251 |
# -------------------------------------------------- |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
252 |
# MASTER |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
253 |
# -------------------------------------------------- |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
254 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
255 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
256 |
class MiniNodeManager(NodeManager): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
257 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
258 |
def __init__(self, parent, filepath, fullname): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
259 |
NodeManager.__init__(self) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
260 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
261 |
self.OpenFileInCurrent(filepath) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
262 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
263 |
self.Parent = parent |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
264 |
self.Fullname = fullname |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
265 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
777
diff
changeset
|
266 |
def GetIconName(self): |
777 | 267 |
return None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
268 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
269 |
def OnCloseEditor(self, view): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
270 |
self.Parent.OnCloseEditor(view) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
271 |
|
718 | 272 |
def CTNFullName(self): |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
273 |
return self.Fullname |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
274 |
|
777 | 275 |
def CTNTestModified(self): |
276 |
return False |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
277 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
278 |
def GetBufferState(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
279 |
return self.GetCurrentBufferState() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
280 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
281 |
ConfNodeMethods = [] |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
282 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
283 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
284 |
class _NodeManager(NodeManager): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
285 |
|
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
286 |
def __init__(self, parent, *args, **kwargs): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
287 |
NodeManager.__init__(self, *args, **kwargs) |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
288 |
self.Parent = parent |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
289 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
290 |
def __del__(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
291 |
self.Parent = None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
292 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
293 |
def GetCurrentNodeName(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
294 |
return self.Parent.CTNName() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
295 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
296 |
def GetCurrentNodeID(self): |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
297 |
return self.Parent.CanFestivalNode.getNodeId() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
298 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
299 |
|
718 | 300 |
class _NodeListCTN(NodeList): |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
301 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
302 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
303 |
<xsd:element name="CanFestivalNode"> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
304 |
<xsd:complexType> |
960
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
305 |
<xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/> |
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
306 |
<xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/> |
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
307 |
<xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="1"/> |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
308 |
<xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
309 |
</xsd:complexType> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
310 |
</xsd:element> |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
311 |
</xsd:schema> |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
312 |
""" |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
313 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
314 |
EditorType = NetworkEditor |
738 | 315 |
IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
316 |
|
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
317 |
def __init__(self): |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
318 |
manager = _NodeManager(self) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
319 |
NodeList.__init__(self, manager) |
718 | 320 |
self.LoadProject(self.CTNPath()) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
321 |
self.SetNetworkName(self.BaseParams.getName()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
322 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
323 |
def GetCanDevice(self): |
948
89fead207c35
Fix semantic error while compiling project including canfestival extension instances
Laurent Bessard
parents:
847
diff
changeset
|
324 |
return self.CanFestivalNode.getCAN_Device() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
325 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
326 |
def SetParamsAttribute(self, path, value): |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
327 |
if path == "CanFestivalNode.NodeId": |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
328 |
nodeid = self.CanFestivalNode.getNodeId() |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
329 |
if value != nodeid: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
330 |
slaves = self.GetSlaveIDs() |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2418
diff
changeset
|
331 |
dir = (value - nodeid) // abs(value - nodeid) |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
332 |
while value in slaves and value >= 0: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
333 |
value += dir |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
334 |
if value < 0: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
335 |
value = nodeid |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
336 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
337 |
value, refresh = ConfigTreeNode.SetParamsAttribute(self, path, value) |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
338 |
refresh_network = False |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
339 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
340 |
# Filter IEC_Channel and Name, that have specific behavior |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
341 |
if path == "BaseParams.IEC_Channel" and self._View is not None: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
342 |
self._View.SetBusId(self.GetCurrentLocation()) |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
343 |
elif path == "BaseParams.Name": |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
344 |
self.SetNetworkName(value) |
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
345 |
refresh_network = True |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
346 |
elif path == "CanFestivalNode.NodeId": |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
347 |
refresh_network = True |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
348 |
|
845
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
349 |
if refresh_network and self._View is not None: |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
350 |
wx.CallAfter(self._View.RefreshBufferState) |
412a9f05070f
Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents:
815
diff
changeset
|
351 |
return value, refresh |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
352 |
|
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
353 |
def GetVariableLocationTree(self): |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
354 |
current_location = self.GetCurrentLocation() |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
355 |
nodeindexes = self.SlaveNodes.keys() |
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
356 |
nodeindexes.sort() |
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
357 |
children = [] |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
358 |
children += [GetSlaveLocationTree(self.Manager.GetCurrentNodeCopy(), |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
359 |
current_location, |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
360 |
_("Local entries"))] |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
361 |
children += [GetSlaveLocationTree(self.SlaveNodes[nodeid]["Node"], |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
362 |
current_location + (nodeid,), |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
363 |
self.SlaveNodes[nodeid]["Name"]) for nodeid in nodeindexes] |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
364 |
|
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
365 |
return { |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
366 |
"name": self.BaseParams.getName(), |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
367 |
"type": LOCATION_CONFNODE, |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
368 |
"location": self.GetFullIEC_Channel(), |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
369 |
"children": children |
1003
de812e258213
Fixed CanFestival extension, adding CANOpen entries in BrowseLocationsDialog
Laurent Bessard
parents:
976
diff
changeset
|
370 |
} |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
371 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
372 |
_GeneratedMasterView = None |
1751
c28db6f7616b
clean-up: fix PEP8 E301 expected 1 blank line, found 0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1746
diff
changeset
|
373 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
374 |
def _ShowGeneratedMaster(self): |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
375 |
self._OpenView("Generated master") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
376 |
|
782 | 377 |
def _OpenView(self, name=None, onlyopened=False): |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
378 |
if name == "Generated master": |
782 | 379 |
app_frame = self.GetCTRoot().AppFrame |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
380 |
if self._GeneratedMasterView is None: |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
381 |
buildpath = self._getBuildPath() |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
382 |
# Eventually create build dir |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
383 |
if not os.path.exists(buildpath): |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
384 |
self.GetCTRoot().logger.write_error(_("Error: No PLC built\n")) |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
385 |
return |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
386 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
387 |
masterpath = os.path.join(buildpath, "MasterGenerated.od") |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
388 |
if not os.path.exists(masterpath): |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
389 |
self.GetCTRoot().logger.write_error(_("Error: No Master generated\n")) |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
390 |
return |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
391 |
|
847
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
392 |
manager = MiniNodeManager(self, masterpath, self.CTNFullName()) |
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
393 |
self._GeneratedMasterView = MasterViewer(app_frame.TabsOpened, manager, app_frame, name) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
394 |
|
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
395 |
if self._GeneratedMasterView is not None: |
847
b157705a9024
Fix bug in generated master panel in CanFestival extension
laurent
parents:
845
diff
changeset
|
396 |
app_frame.EditProjectElement(self._GeneratedMasterView, self._GeneratedMasterView.GetInstancePath()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
397 |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
398 |
return self._GeneratedMasterView |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
399 |
else: |
782 | 400 |
ConfigTreeNode._OpenView(self, name, onlyopened) |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
401 |
if self._View is not None: |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
402 |
self._View.SetBusId(self.GetCurrentLocation()) |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
403 |
return self._View |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
404 |
|
717 | 405 |
ConfNodeMethods = [ |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
406 |
{ |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
407 |
"bitmap": "ShowMaster", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
408 |
"name": _("Show Master"), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
409 |
"tooltip": _("Show Master generated by config_utils"), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
410 |
"method": "_ShowGeneratedMaster" |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
411 |
} |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
412 |
] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
413 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
414 |
def OnCloseEditor(self, view): |
717 | 415 |
ConfigTreeNode.OnCloseEditor(self, view) |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
416 |
if self._GeneratedMasterView == view: |
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
417 |
self._GeneratedMasterView = None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
418 |
|
718 | 419 |
def OnCTNClose(self): |
420 |
ConfigTreeNode.OnCTNClose(self) |
|
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
421 |
self._CloseView(self._GeneratedMasterView) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
422 |
return True |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
423 |
|
718 | 424 |
def CTNTestModified(self): |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
425 |
return self.ChangesToSave or self.HasChanged() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
426 |
|
1061 | 427 |
def OnCTNSave(self, from_project_path=None): |
718 | 428 |
self.SetRoot(self.CTNPath()) |
1063 | 429 |
if from_project_path is not None: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
430 |
shutil.copytree(self.GetEDSFolder(from_project_path), |
1063 | 431 |
self.GetEDSFolder()) |
250 | 432 |
return self.SaveProject() is None |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
433 |
|
718 | 434 |
def CTNGenerate_C(self, buildpath, locations): |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
435 |
""" |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
436 |
Generate C code |
717 | 437 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
438 |
@param locations: List of complete variables locations \ |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
439 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
440 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
441 |
"DIR" : direction "Q","I" or "M" |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
442 |
"SIZE" : size "X", "B", "W", "D", "L" |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
443 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
444 |
}, ...] |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
445 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
446 |
""" |
774
78b5fa92dd1c
Fix bug when opening and closing confnode extra viewers
laurent
parents:
762
diff
changeset
|
447 |
self._CloseView(self._GeneratedMasterView) |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
448 |
current_location = self.GetCurrentLocation() |
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
449 |
# define a unique name for the generated C file |
166 | 450 |
prefix = "_".join(map(str, current_location)) |
1746
45d6f5fba016
clean-up: fix PEP8 E202 whitespace before ')'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
451 |
Gen_OD_path = os.path.join(buildpath, "OD_%s.c" % prefix) |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
452 |
# Create a new copy of the model with DCF loaded with PDO mappings for desired location |
341 | 453 |
try: |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
454 |
master, pointers = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(), "OD_%s" % prefix) |
2418
5587c490a070
Use python 3 compatible exception syntax everywhere
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1997
diff
changeset
|
455 |
except config_utils.PDOmappingException as e: |
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1751
diff
changeset
|
456 |
raise Exception(e.message) |
166 | 457 |
# Do generate C file. |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
458 |
res = gen_cfile.GenerateFile(Gen_OD_path, master, pointers) |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
459 |
if res: |
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1751
diff
changeset
|
460 |
raise Exception(res) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
461 |
|
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
462 |
file = open(os.path.join(buildpath, "MasterGenerated.od"), "w") |
1919
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
463 |
# linter disabled here, undefined variable happens |
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
464 |
# here because gnosis isn't impored while linting |
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
465 |
dump(master, file) # pylint: disable=undefined-variable |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
466 |
file.close() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
467 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
468 |
return [(Gen_OD_path, local_canfestival_config.getCFLAGS(CanFestivalPath))], "", False |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
469 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
470 |
def LoadPrevious(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
471 |
self.Manager.LoadCurrentPrevious() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
472 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
473 |
def LoadNext(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
474 |
self.Manager.LoadCurrentNext() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
475 |
|
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
476 |
def GetBufferState(self): |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
477 |
return self.Manager.GetCurrentBufferState() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
478 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
479 |
|
1831
56b48961cc68
fix (old-style-class) Old-style class defined error for most parts of
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1828
diff
changeset
|
480 |
class RootClass(object): |
12 | 481 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
482 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
483 |
<xsd:element name="CanFestivalInstance"> |
|
484 |
<xsd:complexType> |
|
960
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
485 |
<xsd:attribute name="CAN_Driver" type="xsd:string" use="optional"/> |
12 | 486 |
</xsd:complexType> |
487 |
</xsd:element> |
|
488 |
</xsd:schema> |
|
960
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
489 |
""" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
490 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
491 |
CTNChildrenTypes = [("CanOpenNode", _NodeListCTN, "CanOpen Master"), |
1746
45d6f5fba016
clean-up: fix PEP8 E202 whitespace before ')'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
492 |
("CanOpenSlave", _SlaveCTN, "CanOpen Slave")] |
1751
c28db6f7616b
clean-up: fix PEP8 E301 expected 1 blank line, found 0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1746
diff
changeset
|
493 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
494 |
def GetParamsAttributes(self, path=None): |
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
495 |
infos = ConfigTreeNode.GetParamsAttributes(self, path=path) |
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
496 |
for element in infos: |
163
482ca562d414
Support for extern pointer for located variables + Preliminary slave code (broken)
etisserant
parents:
159
diff
changeset
|
497 |
if element["name"] == "CanFestivalInstance": |
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
498 |
for child in element["children"]: |
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
499 |
if child["name"] == "CAN_Driver": |
960
d72a866cf9b0
Cleanup in canfestival plugin. No more meaningless default values.
Edouard Tisserant
parents:
957
diff
changeset
|
500 |
child["type"] = local_canfestival_config.DLL_LIST |
95
646a44a12e2a
add GetParamsAttributes to canfestival.py to allow dll list in beremiz
greg
parents:
86
diff
changeset
|
501 |
return infos |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
502 |
|
974 | 503 |
def GetCanDriver(self): |
976 | 504 |
res = self.CanFestivalInstance.getCAN_Driver() |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
505 |
if not res: |
976 | 506 |
return "" |
507 |
return res |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
508 |
|
974 | 509 |
def CTNGenerate_C(self, buildpath, locations): |
976 | 510 |
can_driver = self.GetCanDriver() |
511 |
if can_driver is not None: |
|
512 |
can_drivers = local_canfestival_config.DLL_LIST |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
513 |
if can_driver not in can_drivers: |
976 | 514 |
can_driver = can_drivers[0] |
515 |
can_drv_ext = self.GetCTRoot().GetBuilder().extension |
|
1279
0eb9f8af479f
Added 'dlopen_prefix' class attributes to targets, in order to handle dlopen of shared object passed to runtime as extra file, and then in PWD (was working with windows only)
Edouard Tisserant
parents:
1063
diff
changeset
|
516 |
can_drv_prefix = self.GetCTRoot().GetBuilder().dlopen_prefix |
0eb9f8af479f
Added 'dlopen_prefix' class attributes to targets, in order to handle dlopen of shared object passed to runtime as extra file, and then in PWD (was working with windows only)
Edouard Tisserant
parents:
1063
diff
changeset
|
517 |
can_driver_name = can_drv_prefix + "libcanfestival_" + can_driver + can_drv_ext |
976 | 518 |
else: |
519 |
can_driver_name = "" |
|
520 |
||
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
521 |
format_dict = { |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
522 |
"locstr": "_".join(map(str, self.GetCurrentLocation())), |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
523 |
"candriver": can_driver_name, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
524 |
"nodes_includes": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
525 |
"board_decls": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
526 |
"nodes_init": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
527 |
"nodes_open": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
528 |
"nodes_stop": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
529 |
"nodes_close": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
530 |
"nodes_send_sync": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
531 |
"nodes_proceed_sync": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
532 |
"slavebootups": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
533 |
"slavebootup_register": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
534 |
"post_sync": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
535 |
"post_sync_register": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
536 |
"pre_op": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
537 |
"pre_op_register": "", |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
538 |
} |
718 | 539 |
for child in self.IECSortedChildren(): |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
540 |
childlocstr = "_".join(map(str, child.GetCurrentLocation())) |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
541 |
nodename = "OD_%s" % childlocstr |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
542 |
|
166 | 543 |
# Try to get Slave Node |
544 |
child_data = getattr(child, "CanFestivalSlaveNode", None) |
|
545 |
if child_data is None: |
|
546 |
# Not a slave -> master |
|
547 |
child_data = getattr(child, "CanFestivalNode") |
|
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
548 |
# Apply sync setting |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
549 |
format_dict["nodes_init"] += 'NODE_MASTER_INIT(%s, %s)\n ' % ( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
550 |
nodename, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
551 |
child_data.getNodeId()) |
166 | 552 |
if child_data.getSync_TPDOs(): |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
553 |
format_dict["nodes_send_sync"] += 'NODE_SEND_SYNC(%s)\n ' % (nodename) |
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
554 |
format_dict["nodes_proceed_sync"] += 'NODE_PROCEED_SYNC(%s)\n ' % (nodename) |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
555 |
|
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
556 |
# initialize and declare node boot status variables for post_SlaveBootup lookup |
169
8e87b69286c0
SlaveBootup now set operational state for both local node and network nodes only when all nodes declared in network edit have been initialized.
etisserant
parents:
166
diff
changeset
|
557 |
SlaveIDs = child.GetSlaveIDs() |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
558 |
if len(SlaveIDs) == 0: |
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
559 |
# define post_SlaveBootup lookup functions |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
560 |
format_dict["slavebootups"] += ( |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
561 |
"static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){}\n" % (nodename)) |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
562 |
else: |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
563 |
format_dict["slavebootups"] += ( |
1742
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
564 |
"static void %s_post_SlaveBootup(CO_Data* d, UNS8 nodeId){\n" % (nodename) + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
565 |
" check_and_start_node(d, nodeId);\n" + |
682
9d20df7c144a
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
512
diff
changeset
|
566 |
"}\n") |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
567 |
# register previously declared func as post_SlaveBootup callback for that node |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
568 |
format_dict["slavebootup_register"] += ( |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
569 |
"%s_Data.post_SlaveBootup = %s_post_SlaveBootup;\n" % (nodename, nodename)) |
779 | 570 |
format_dict["pre_op"] += ( |
1742
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
571 |
"static void %s_preOperational(CO_Data* d){\n " % (nodename) + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
572 |
"".join([" masterSendNMTstateChange(d, %d, NMT_Reset_Comunication);\n" % NdId for NdId in SlaveIDs]) + |
779 | 573 |
"}\n") |
574 |
format_dict["pre_op_register"] += ( |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
575 |
"%s_Data.preOperational = %s_preOperational;\n" % (nodename, nodename)) |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
576 |
else: |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
577 |
# Slave node |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
578 |
align = child_data.getSync_Align() |
1742
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
579 |
align_ratio = child_data.getSync_Align_Ratio() |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
580 |
if align > 0: |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
581 |
format_dict["post_sync"] += ( |
1742
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
582 |
"static int %s_CalCount = 0;\n" % (nodename) + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
583 |
"static void %s_post_sync(CO_Data* d){\n" % (nodename) + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
584 |
" if(%s_CalCount < %d){\n" % (nodename, align) + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
585 |
" %s_CalCount++;\n" % (nodename) + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
586 |
" align_tick(-1);\n" + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
587 |
" }else{\n" + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
588 |
" align_tick(%d);\n" % (align_ratio) + |
92932cd370a4
clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
589 |
" }\n" + |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
590 |
"}\n") |
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
591 |
format_dict["post_sync_register"] += ( |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
592 |
"%s_Data.post_sync = %s_post_sync;\n" % (nodename, nodename)) |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
593 |
format_dict["nodes_init"] += 'NODE_SLAVE_INIT(%s, %s)\n ' % ( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
594 |
nodename, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
595 |
child_data.getNodeId()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
596 |
|
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
597 |
# Include generated OD headers |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
598 |
format_dict["nodes_includes"] += '#include "%s.h"\n' % (nodename) |
178
2390b409eb93
Added PLC tick alignement on external synchronization source feature.
etisserant
parents:
174
diff
changeset
|
599 |
# Declare CAN channels according user filled config |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
600 |
format_dict["board_decls"] += 'BOARD_DECL(%s, "%s", "%s")\n' % ( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
601 |
nodename, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
602 |
child.GetCanDevice(), |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
603 |
child_data.getCAN_Baudrate()) |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
604 |
format_dict["nodes_open"] += 'NODE_OPEN(%s)\n ' % (nodename) |
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
605 |
format_dict["nodes_close"] += 'NODE_CLOSE(%s)\n ' % (nodename) |
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
606 |
format_dict["nodes_stop"] += 'NODE_STOP(%s)\n ' % (nodename) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
607 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
608 |
filename = paths.AbsNeighbourFile(__file__, "cf_runtime.c") |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
609 |
cf_main = open(filename).read() % format_dict |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
610 |
cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c" % format_dict) |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
611 |
f = open(cf_main_path, 'w') |
52
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
612 |
f.write(cf_main) |
eaffcd0a2f03
Added CanFestival "main" runtime part, initialize, all nodes, and start CF timer loop
etisserant
parents:
49
diff
changeset
|
613 |
f.close() |
957
463d4b2b058d
CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents:
948
diff
changeset
|
614 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
615 |
res = [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))], local_canfestival_config.getLDFLAGS(CanFestivalPath), True |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
616 |
|
976 | 617 |
if can_driver is not None: |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
618 |
can_driver_path = os.path.join(CanFestivalPath, "drivers", can_driver, can_driver_name) |
974 | 619 |
if os.path.exists(can_driver_path): |
2442
b13f021c68a5
python3 support: pylint, W1607 # (file-builtin) file built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
620 |
res += ((can_driver_name, open(can_driver_path, "rb")),) |
957
463d4b2b058d
CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents:
948
diff
changeset
|
621 |
|
463d4b2b058d
CanFestival plugin now sends driver as extra file to runtime if matching target. Helps on windows to resolve DLL
Edouard Tisserant
parents:
948
diff
changeset
|
622 |
return res |