author | Edouard Tisserant |
Tue, 26 Mar 2013 09:34:30 +0900 | |
changeset 2106 | 4ec3b833f2d5 |
parent 2105 | a62c0de6986f |
child 2107 | 6f9aa410a997 |
permissions | -rw-r--r-- |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1 |
import os, shutil |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2 |
import cPickle |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
3 |
from xml.dom import minidom |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
4 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
5 |
import wx |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
6 |
import csv |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
7 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
8 |
from xmlclass import * |
2086
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
9 |
from POULibrary import POULibrary |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
10 |
from ConfigTreeNode import ConfigTreeNode |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
11 |
from PLCControler import UndoBuffer, LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
12 |
from ConfigEditor import NodeEditor, CIA402NodeEditor, MasterEditor, LibraryEditor, ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE |
2102
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
13 |
from dialogs import BrowseValuesLibraryDialog |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
14 |
from IDEFrame import TITLE, FILEMENU, PROJECTTREE |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
15 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
16 |
try: |
2049 | 17 |
from MotionLibrary import Headers, AxisXSD |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
18 |
HAS_MCL = True |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
19 |
except: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
20 |
HAS_MCL = False |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
21 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
22 |
TYPECONVERSION = {"BOOL" : "X", "SINT" : "B", "INT" : "W", "DINT" : "D", "LINT" : "L", |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
23 |
"USINT" : "B", "UINT" : "W", "UDINT" : "D", "ULINT" : "L", |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
24 |
"BYTE" : "B", "WORD" : "W", "DWORD" : "D", "LWORD" : "L"} |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
25 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
26 |
DATATYPECONVERSION = {"BOOL" : "BIT", "SINT" : "S8", "INT" : "S16", "DINT" : "S32", "LINT" : "S64", |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
27 |
"USINT" : "U8", "UINT" : "U16", "UDINT" : "U32", "ULINT" : "U64", |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
28 |
"BYTE" : "U8", "WORD" : "U16", "DWORD" : "U32", "LWORD" : "U64"} |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
29 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
30 |
VARCLASSCONVERSION = {"T": LOCATION_VAR_INPUT, "R": LOCATION_VAR_OUTPUT, "RT": LOCATION_VAR_MEMORY} |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
31 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
32 |
#-------------------------------------------------- |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
33 |
# Remote Exec Etherlab Commands |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
34 |
#-------------------------------------------------- |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
35 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
36 |
SCAN_COMMAND = """ |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
37 |
import commands |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
38 |
result = commands.getoutput("ethercat slaves") |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
39 |
slaves = [] |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
40 |
for slave_line in result.splitlines(): |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
41 |
chunks = slave_line.split() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
42 |
idx, pos, state, flag = chunks[:4] |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
43 |
name = " ".join(chunks[4:]) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
44 |
alias, position = pos.split(":") |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
45 |
slave = {"idx": int(idx), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
46 |
"alias": int(alias), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
47 |
"position": int(position), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
48 |
"name": name} |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
49 |
details = commands.getoutput("ethercat slaves -p %d -v" % slave["idx"]) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
50 |
for details_line in details.splitlines(): |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
51 |
details_line = details_line.strip() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
52 |
for header, param in [("Vendor Id:", "vendor_id"), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
53 |
("Product code:", "product_code"), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
54 |
("Revision number:", "revision_number")]: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
55 |
if details_line.startswith(header): |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
56 |
slave[param] = details_line.split()[-1] |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
57 |
break |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
58 |
slaves.append(slave) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
59 |
returnVal = slaves |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
60 |
""" |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
61 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
62 |
#-------------------------------------------------- |
2086
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
63 |
# Etherlab Specific Blocks Library |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
64 |
#-------------------------------------------------- |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
65 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
66 |
def GetLocalPath(filename): |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
67 |
return os.path.join(os.path.split(__file__)[0], filename) |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
68 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
69 |
class EtherlabLibrary(POULibrary): |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
70 |
def GetLibraryPath(self): |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
71 |
return GetLocalPath("pous.xml") |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
72 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
73 |
def Generate_C(self, buildpath, varlist, IECCFLAGS): |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
74 |
etherlab_ext_file = open(GetLocalPath("etherlab_ext.c"), 'r') |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
75 |
etherlab_ext_code = etherlab_ext_file.read() |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
76 |
etherlab_ext_file.close() |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
77 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
78 |
Gen_etherlabfile_path = os.path.join(buildpath, "etherlab_ext.c") |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
79 |
ethelabfile = open(Gen_etherlabfile_path,'w') |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
80 |
ethelabfile.write(etherlab_ext_code) |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
81 |
ethelabfile.close() |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
82 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
83 |
runtimefile_path = os.path.join(os.path.split(__file__)[0], "runtime_etherlab.py") |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
84 |
return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
85 |
("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py")))) |
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
86 |
|
8e4992e0f147
Adding block library for SDO download and SDO upload
Laurent Bessard
parents:
2085
diff
changeset
|
87 |
#-------------------------------------------------- |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
88 |
# Ethercat Node |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
89 |
#-------------------------------------------------- |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
90 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
91 |
class _EthercatSlaveCTN: |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
92 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
93 |
NODE_PROFILE = None |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
94 |
EditorType = NodeEditor |
2034 | 95 |
|
2068
05a267b1a362
Adding support using plcopeneditor bitmap library for icon request
Laurent Bessard
parents:
2067
diff
changeset
|
96 |
def GetIconName(self): |
05a267b1a362
Adding support using plcopeneditor bitmap library for icon request
Laurent Bessard
parents:
2067
diff
changeset
|
97 |
return "Slave" |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2042
diff
changeset
|
98 |
|
2034 | 99 |
def ExtractHexDecValue(self, value): |
100 |
return ExtractHexDecValue(value) |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
101 |
|
2034 | 102 |
def GetSizeOfType(self, type): |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
103 |
return TYPECONVERSION.get(self.GetCTRoot().GetBaseType(type), None) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
104 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
105 |
def GetSlavePos(self): |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
106 |
return self.BaseParams.getIEC_Channel() |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
107 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
108 |
def GetParamsAttributes(self, path = None): |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
109 |
if path: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
110 |
parts = path.split(".", 1) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
111 |
if self.MandatoryParams and parts[0] == self.MandatoryParams[0]: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
112 |
return self.MandatoryParams[1].getElementInfos(parts[0], parts[1]) |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
113 |
elif self.CTNParams and parts[0] == self.CTNParams[0]: |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
114 |
return self.CTNParams[1].getElementInfos(parts[0], parts[1]) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
115 |
else: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
116 |
params = [] |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
117 |
if self.CTNParams: |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
118 |
params.append(self.CTNParams[1].getElementInfos(self.CTNParams[0])) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
119 |
else: |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
120 |
params.append({ |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
121 |
'use': 'required', |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
122 |
'type': 'element', |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
123 |
'name': 'SlaveParams', |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
124 |
'value': None, |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
125 |
'children': [] |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
126 |
}) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
127 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
128 |
slave_type = self.CTNParent.GetSlaveType(self.GetSlavePos()) |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
129 |
params[0]['children'].insert(0, |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
130 |
{'use': 'optional', |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
131 |
'type': self.CTNParent.GetSlaveTypesLibrary(self.NODE_PROFILE), |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
132 |
'name': 'Type', |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
133 |
'value': (slave_type["device_type"], slave_type)}) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
134 |
params[0]['children'].insert(1, |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
135 |
{'use': 'optional', |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
136 |
'type': 'unsignedLong', |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
137 |
'name': 'Alias', |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
138 |
'value': self.CTNParent.GetSlaveAlias(self.GetSlavePos())}) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
139 |
return params |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
140 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
141 |
def SetParamsAttribute(self, path, value): |
2066 | 142 |
position = self.BaseParams.getIEC_Channel() |
143 |
||
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
144 |
if path == "SlaveParams.Type": |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
145 |
self.CTNParent.SetSlaveType(position, value) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
146 |
slave_type = self.CTNParent.GetSlaveType(self.GetSlavePos()) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
147 |
value = (slave_type["device_type"], slave_type) |
2067
04cc0295e2c4
Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents:
2066
diff
changeset
|
148 |
if self._View is not None: |
04cc0295e2c4
Fix bug slave information panel not refreshed when slave type changed
Laurent Bessard
parents:
2066
diff
changeset
|
149 |
wx.CallAfter(self._View.RefreshSlaveInfos) |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
150 |
return value, True |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
151 |
elif path == "SlaveParams.Alias": |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
152 |
self.CTNParent.SetSlaveAlias(position, value) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
153 |
return value, True |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
154 |
|
2080 | 155 |
value, refresh = ConfigTreeNode.SetParamsAttribute(self, path, value) |
156 |
||
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
157 |
# Filter IEC_Channel, Slave_Type and Alias that have specific behavior |
2080 | 158 |
if path == "BaseParams.IEC_Channel" and value != position: |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
159 |
self.CTNParent.SetSlavePosition(position, value) |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
160 |
|
2080 | 161 |
return value, refresh |
162 |
||
2034 | 163 |
def GetSlaveInfos(self): |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
164 |
return self.CTNParent.GetSlaveInfos(self.GetSlavePos()) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
165 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
166 |
def GetSlaveVariables(self, limits): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
167 |
return self.CTNParent.GetSlaveVariables(self.GetSlavePos(), limits) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
168 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
169 |
def GetVariableLocationTree(self): |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
170 |
return {"name": self.BaseParams.getName(), |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
171 |
"type": LOCATION_CONFNODE, |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
172 |
"location": self.GetFullIEC_Channel(), |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
173 |
"children": self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(), self.GetCurrentLocation(), self.BaseParams.getName()) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
174 |
} |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
175 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
176 |
def CTNGenerate_C(self, buildpath, locations): |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
177 |
""" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
178 |
Generate C code |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
179 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
180 |
@param locations: List of complete variables locations \ |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
181 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
182 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
183 |
"DIR" : direction "Q","I" or "M" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
184 |
"SIZE" : size "X", "B", "W", "D", "L" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
185 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
186 |
}, ...] |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
187 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
188 |
""" |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
189 |
return [],"",False |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
190 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
191 |
#-------------------------------------------------- |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2042
diff
changeset
|
192 |
# Ethercat CIA402 Node |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
193 |
#-------------------------------------------------- |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
194 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
195 |
if HAS_MCL: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
196 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
197 |
NODE_VARIABLES = [ |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
198 |
("ControlWord", 0x6040, 0x00, "UINT", "Q"), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
199 |
("TargetPosition", 0x607a, 0x00, "DINT", "Q"), |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
200 |
("ModesOfOperation", 0x06060, 0x00, "SINT", "Q"), |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
201 |
("StatusWord", 0x6041, 0x00, "UINT", "I"), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
202 |
("ModesOfOperationDisplay", 0x06061, 0x00, "SINT", "I"), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
203 |
("ActualPosition", 0x6064, 0x00, "DINT", "I"), |
2091
d964dbc2c7b0
Adding support for extracting ActualVelocity from CIA402 nodes PDOs
Laurent Bessard
parents:
2088
diff
changeset
|
204 |
("ActualVelocity", 0x606C, 0x00, "DINT", "I"), |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
205 |
] |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
206 |
|
2085 | 207 |
DEFAULT_RETRIEVE = " __CIA402Node_%(location)s.axis->%(name)s = *(__CIA402Node_%(location)s.%(name)s);" |
208 |
DEFAULT_PUBLISH = " *(__CIA402Node_%(location)s.%(name)s) = __CIA402Node_%(location)s.axis->%(name)s;" |
|
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
209 |
|
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
210 |
EXTRA_NODE_VARIABLES = [ |
2096
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
211 |
("ErrorCode", [ |
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
212 |
{"description": ("ErrorCode", 0x603F, 0x00, "UINT", "I"), |
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
213 |
"publish": None} |
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
214 |
]), |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
215 |
("DigitalInputs", [ |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
216 |
{"description": ("DigitalInputs", 0x60FD, 0x00, "UDINT", "I"), |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
217 |
"publish": None} |
2096
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
218 |
]), |
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
219 |
("DigitalOutputs", [ |
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
220 |
{"description": ("DigitalOutputs", 0x60FE, 0x00, "UDINT", "Q"), |
c9b0340ea0f5
Added support for MC_*DigitalOutput, MC_ReadAxisInfo and MC_ReadAxisError blocks from MCL in DS402 nodes generated code
Laurent Bessard
parents:
2094
diff
changeset
|
221 |
"retrieve": None} |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
222 |
]) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
223 |
] |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
224 |
EXTRA_NODE_VARIABLES_DICT = dict([("Enable" + name, value) for name, value in EXTRA_NODE_VARIABLES]) |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
225 |
|
2094
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2093
diff
changeset
|
226 |
BLOCK_INPUT_TEMPLATE = " __SET_VAR(%(blockname)s->,%(input_name)s, %(input_value)s);" |
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2093
diff
changeset
|
227 |
BLOCK_OUTPUT_TEMPLATE = " __SET_VAR(data__->,%(output_name)s, __GET_VAR(%(blockname)s->%(output_name)s));" |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
228 |
|
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
229 |
BLOCK_FUNCTION_TEMPLATE = """ |
2093
3fdf9d56d803
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2092
diff
changeset
|
230 |
extern void ETHERLAB%(ucase_blocktype)s_body__(ETHERLAB%(ucase_blocktype)s* data__); |
3fdf9d56d803
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2092
diff
changeset
|
231 |
void __%(blocktype)s_%(location)s(MC_%(ucase_blocktype)s *data__) { |
2094
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2093
diff
changeset
|
232 |
__DECLARE_GLOBAL_PROTOTYPE(ETHERLAB%(ucase_blocktype)s, %(blockname)s); |
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2093
diff
changeset
|
233 |
ETHERLAB%(ucase_blocktype)s* %(blockname)s = __GET_GLOBAL_%(blockname)s(); |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
234 |
%(extract_inputs)s |
2094
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2093
diff
changeset
|
235 |
ETHERLAB%(ucase_blocktype)s_body__(%(blockname)s); |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
236 |
%(return_outputs)s |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
237 |
} |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
238 |
""" |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
239 |
|
2094
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2093
diff
changeset
|
240 |
BLOCK_FUNTION_DEFINITION_TEMPLATE = """ if (!__CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s) |
72b74099b873
Fix bug in support for Etherlab specific fieldbus interface function blocks
Laurent Bessard
parents:
2093
diff
changeset
|
241 |
__CIA402Node_%(location)s.axis->__mcl_func_MC_%(blocktype)s = __%(blocktype)s_%(location)s;""" |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
242 |
|
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
243 |
GLOBAL_INSTANCES = [ |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
244 |
{"blocktype": "GetTorqueLimit", |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
245 |
"inputs": [], |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
246 |
"outputs": [{"name": "TorqueLimitPos", "type": "UINT"}, |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
247 |
{"name": "TorqueLimitNeg", "type": "UINT"}]}, |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
248 |
{"blocktype": "SetTorqueLimit", |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
249 |
"inputs": [{"name": "TorqueLimitPos", "type": "UINT"}, |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
250 |
{"name": "TorqueLimitNeg", "type": "UINT"}], |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
251 |
"outputs": []}, |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
252 |
] |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
253 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
254 |
class _EthercatCIA402SlaveCTN(_EthercatSlaveCTN): |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
255 |
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
256 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2042
diff
changeset
|
257 |
<xsd:element name="CIA402SlaveParams"> |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
258 |
<xsd:complexType> |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
259 |
%s |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
260 |
</xsd:complexType> |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
261 |
</xsd:element> |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
262 |
</xsd:schema> |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
263 |
""" % ("\n".join(['<xsd:attribute name="Enable%s" type="xsd:boolean" use="optional" default="false"/>' % category |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
264 |
for category, variables in EXTRA_NODE_VARIABLES]) + AxisXSD) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
265 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
266 |
NODE_PROFILE = 402 |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2042
diff
changeset
|
267 |
EditorType = CIA402NodeEditor |
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2042
diff
changeset
|
268 |
|
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
269 |
ConfNodeMethods = [ |
2068
05a267b1a362
Adding support using plcopeneditor bitmap library for icon request
Laurent Bessard
parents:
2067
diff
changeset
|
270 |
{"bitmap" : "CIA402AxisRef", |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
271 |
"name" : _("Axis Ref"), |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
272 |
"tooltip" : _("Initiate Drag'n drop of Axis ref located variable"), |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
273 |
"method" : "_getCIA402AxisRef", |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
274 |
"push": True}, |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
275 |
] |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
276 |
|
2068
05a267b1a362
Adding support using plcopeneditor bitmap library for icon request
Laurent Bessard
parents:
2067
diff
changeset
|
277 |
def GetIconName(self): |
05a267b1a362
Adding support using plcopeneditor bitmap library for icon request
Laurent Bessard
parents:
2067
diff
changeset
|
278 |
return "CIA402Slave" |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
279 |
|
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
280 |
def SetParamsAttribute(self, path, value): |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
281 |
if path == "CIA402SlaveParams.Type": |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
282 |
path = "SlaveParams.Type" |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
283 |
elif path == "CIA402SlaveParams.Alias": |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
284 |
path = "SlaveParams.Alias" |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
285 |
return _EthercatSlaveCTN.SetParamsAttribute(self, path, value) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
286 |
|
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
287 |
def GetVariableLocationTree(self): |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
288 |
axis_name = self.CTNName() |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
289 |
current_location = self.GetCurrentLocation() |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
290 |
children = [{"name": "%s Axis Ref" % (axis_name), |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
291 |
"type": LOCATION_VAR_INPUT, |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
292 |
"size": "W", |
2083
0f7ab170c862
Fix Axis_Ref type defined in VariableLocationTree
Laurent Bessard
parents:
2082
diff
changeset
|
293 |
"IEC_type": "AXIS_REF", |
2063
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
294 |
"var_name": axis_name, |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
295 |
"location": "%%IW%s.0" % (".".join(map(str, current_location))), |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
296 |
"description": "", |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
297 |
"children": []}] |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
298 |
children.extend(self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(), current_location, axis_name)) |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
299 |
return {"name": axis_name, |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
300 |
"type": LOCATION_CONFNODE, |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
301 |
"location": self.GetFullIEC_Channel(), |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
302 |
"children": children, |
c9a1c5bb51cd
Fix bug with AXIS_REF located variable drag'n drop and disable dynamic PDOs support
Laurent Bessard
parents:
2062
diff
changeset
|
303 |
} |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
304 |
|
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
305 |
def CTNGlobalInstances(self): |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
306 |
current_location = self.GetCurrentLocation() |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
307 |
return [("%s_%s" % (block_infos["blocktype"], "_".join(map(str, current_location))), |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
308 |
"EtherLab%s" % block_infos["blocktype"]) for block_infos in GLOBAL_INSTANCES] |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
309 |
|
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
310 |
def _getCIA402AxisRef(self): |
2074
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
311 |
data = wx.TextDataObject(str(("%%IW%s.0" % ".".join(map(str, self.GetCurrentLocation())), |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
312 |
"location", "AXIS_REF", self.CTNName(), ""))) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
313 |
dragSource = wx.DropSource(self.GetCTRoot().AppFrame) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
314 |
dragSource.SetData(data) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
315 |
dragSource.DoDragDrop() |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
316 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
317 |
def CTNGenerate_C(self, buildpath, locations): |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
318 |
""" |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
319 |
Generate C code |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
320 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
321 |
@param locations: List of complete variables locations \ |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
322 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
323 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
324 |
"DIR" : direction "Q","I" or "M" |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
325 |
"SIZE" : size "X", "B", "W", "D", "L" |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
326 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
327 |
}, ...] |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
328 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
329 |
""" |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
330 |
current_location = self.GetCurrentLocation() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
331 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
332 |
location_str = "_".join(map(lambda x:str(x), current_location)) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
333 |
|
2045 | 334 |
plc_cia402node_filepath = os.path.join(os.path.split(__file__)[0], "plc_cia402node.c") |
335 |
plc_cia402node_file = open(plc_cia402node_filepath, 'r') |
|
336 |
plc_cia402node_code = plc_cia402node_file.read() |
|
337 |
plc_cia402node_file.close() |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
338 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
339 |
str_completion = { |
2088
c0952932d74b
Adding support for using Etherlab SDO function blocks in MCL
Laurent Bessard
parents:
2086
diff
changeset
|
340 |
"slave_pos": self.GetSlavePos(), |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
341 |
"location": location_str, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
342 |
"MCL_headers": Headers, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
343 |
"extern_located_variables_declaration": [], |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
344 |
"fieldbus_interface_declaration": [], |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
345 |
"fieldbus_interface_definition": [], |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
346 |
"entry_variables": [], |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
347 |
"init_axis_params": [], |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
348 |
"init_entry_variables": [], |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
349 |
"extra_variables_retrieve": [], |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
350 |
"extra_variables_publish": [] |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
351 |
} |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
352 |
|
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
353 |
for blocktype_infos in GLOBAL_INSTANCES: |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
354 |
texts = { |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
355 |
"blocktype": blocktype_infos["blocktype"], |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
356 |
"ucase_blocktype": blocktype_infos["blocktype"].upper(), |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
357 |
"location": "_".join(map(str, current_location)) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
358 |
} |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
359 |
texts["blockname"] = "%(ucase_blocktype)s_%(location)s" % texts |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
360 |
|
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
361 |
inputs = [{"input_name": "POS", "input_value": str(self.GetSlavePos())}, |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
362 |
{"input_name": "EXECUTE", "input_value": "__GET_VAR(data__->EXECUTE)"}] +\ |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
363 |
[{"input_name": input["name"].upper(), |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
364 |
"input_value": "__GET_VAR(data__->%s)" % input["name"].upper()} |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
365 |
for input in blocktype_infos["inputs"]] |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
366 |
input_texts = [] |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
367 |
for input_infos in inputs: |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
368 |
input_infos.update(texts) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
369 |
input_texts.append(BLOCK_INPUT_TEMPLATE % input_infos) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
370 |
texts["extract_inputs"] = "\n".join(input_texts) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
371 |
|
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
372 |
outputs = [{"output_name": output} for output in ["DONE", "BUSY", "ERROR"]] + \ |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
373 |
[{"output_name": output["name"].upper()} for output in blocktype_infos["outputs"]] |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
374 |
output_texts = [] |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
375 |
for output_infos in outputs: |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
376 |
output_infos.update(texts) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
377 |
output_texts.append(BLOCK_OUTPUT_TEMPLATE % output_infos) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
378 |
texts["return_outputs"] = "\n".join(output_texts) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
379 |
|
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
380 |
str_completion["fieldbus_interface_declaration"].append( |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
381 |
BLOCK_FUNCTION_TEMPLATE % texts) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
382 |
|
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
383 |
str_completion["fieldbus_interface_definition"].append( |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
384 |
BLOCK_FUNTION_DEFINITION_TEMPLATE % texts) |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
385 |
|
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
386 |
variables = NODE_VARIABLES[:] |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
387 |
|
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
388 |
params = self.CTNParams[1].getElementInfos(self.CTNParams[0]) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
389 |
for param in params["children"]: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
390 |
if param["name"] in EXTRA_NODE_VARIABLES_DICT: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
391 |
if param["value"]: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
392 |
extra_variables = EXTRA_NODE_VARIABLES_DICT.get(param["name"]) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
393 |
for variable_infos in extra_variables: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
394 |
var_infos = { |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
395 |
"location": location_str, |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
396 |
"name": variable_infos["description"][0] |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
397 |
} |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
398 |
variables.append(variable_infos["description"]) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
399 |
retrieve_template = variable_infos.get("retrieve", DEFAULT_RETRIEVE) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
400 |
publish_template = variable_infos.get("publish", DEFAULT_PUBLISH) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
401 |
|
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
402 |
if retrieve_template is not None: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
403 |
str_completion["extra_variables_retrieve"].append( |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
404 |
retrieve_template % var_infos) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
405 |
if publish_template is not None: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
406 |
str_completion["extra_variables_publish"].append( |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
407 |
publish_template % var_infos) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
408 |
elif param["value"] is not None: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
409 |
param_infos = { |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
410 |
"location": location_str, |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
411 |
"param_name": param["name"], |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
412 |
} |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
413 |
if param["type"] == "boolean": |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
414 |
param_infos["param_value"] = {True: "true", False: "false"}[param["value"]] |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
415 |
else: |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
416 |
param_infos["param_value"] = str(param["value"]) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
417 |
str_completion["init_axis_params"].append( |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
418 |
" __CIA402Node_%(location)s.axis->%(param_name)s = %(param_value)s;" % param_infos) |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
419 |
|
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
420 |
for variable in variables: |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
421 |
var_infos = dict(zip(["name", "index", "subindex", "var_type", "dir"], variable)) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
422 |
var_infos["location"] = location_str |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
423 |
var_infos["var_size"] = self.GetSizeOfType(var_infos["var_type"]) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
424 |
var_infos["var_name"] = "__%(dir)s%(var_size)s%(location)s_%(index)d_%(subindex)d" % var_infos |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
425 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
426 |
str_completion["extern_located_variables_declaration"].append( |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
427 |
"IEC_%(var_type)s *%(var_name)s;" % var_infos) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
428 |
str_completion["entry_variables"].append( |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
429 |
" IEC_%(var_type)s *%(name)s;" % var_infos) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
430 |
str_completion["init_entry_variables"].append( |
2043
27d4cb689a79
Adding plugin icons and replacing reference to DS402 by CIA402
laurent
parents:
2042
diff
changeset
|
431 |
" __CIA402Node_%(location)s.%(name)s = %(var_name)s;" % var_infos) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
432 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
433 |
self.CTNParent.FileGenerator.DeclareVariable( |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
434 |
self.GetSlavePos(), var_infos["index"], var_infos["subindex"], |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
435 |
var_infos["var_type"], var_infos["dir"], var_infos["var_name"]) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
436 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
437 |
for element in ["extern_located_variables_declaration", |
2092
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
438 |
"fieldbus_interface_declaration", |
c9776ae8b5d0
Adding support for Etherlab specific function blocks for MCL fieldbus interface function blocks
Laurent Bessard
parents:
2091
diff
changeset
|
439 |
"fieldbus_interface_definition", |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
440 |
"entry_variables", |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
441 |
"init_axis_params", |
2084
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
442 |
"init_entry_variables", |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
443 |
"extra_variables_retrieve", |
579af800b359
Adding support to enable CIA402 slave digital inputs
Laurent Bessard
parents:
2083
diff
changeset
|
444 |
"extra_variables_publish"]: |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
445 |
str_completion[element] = "\n".join(str_completion[element]) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
446 |
|
2045 | 447 |
Gen_CIA402Nodefile_path = os.path.join(buildpath, "cia402node_%s.c"%location_str) |
448 |
cia402nodefile = open(Gen_CIA402Nodefile_path, 'w') |
|
449 |
cia402nodefile.write(plc_cia402node_code % str_completion) |
|
450 |
cia402nodefile.close() |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
451 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
452 |
return [(Gen_CIA402Nodefile_path, '"-I%s"'%os.path.abspath(self.GetCTRoot().GetIECLibPath()))],"",True |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
453 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
454 |
#-------------------------------------------------- |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
455 |
# Ethercat MASTER |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
456 |
#-------------------------------------------------- |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
457 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
458 |
EtherCATConfigClasses = GenerateClassesFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATConfig.xsd")) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
459 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
460 |
def ExtractHexDecValue(value): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
461 |
try: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
462 |
return int(value) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
463 |
except: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
464 |
pass |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
465 |
try: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
466 |
return int(value.replace("#", "0"), 16) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
467 |
except: |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
468 |
raise ValueError, "Invalid value for HexDecValue \"%s\"" % value |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
469 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
470 |
def GenerateHexDecValue(value, base=10): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
471 |
if base == 10: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
472 |
return str(value) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
473 |
elif base == 16: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
474 |
return "#x%.8x" % value |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
475 |
else: |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
476 |
raise ValueError, "Not supported base" |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
477 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
478 |
def sort_commands(x, y): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
479 |
if x["Index"] == y["Index"]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
480 |
return cmp(x["Subindex"], y["Subindex"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
481 |
return cmp(x["Index"], y["Index"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
482 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
483 |
cls = EtherCATConfigClasses.get("Config_Slave", None) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
484 |
if cls: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
485 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
486 |
def getType(self): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
487 |
slave_info = self.getInfo() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
488 |
return {"device_type": slave_info.getName(), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
489 |
"vendor": GenerateHexDecValue(slave_info.getVendorId()), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
490 |
"product_code": GenerateHexDecValue(slave_info.getProductCode(), 16), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
491 |
"revision_number": GenerateHexDecValue(slave_info.getRevisionNo(), 16)} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
492 |
setattr(cls, "getType", getType) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
493 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
494 |
def setType(self, type_infos): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
495 |
slave_info = self.getInfo() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
496 |
slave_info.setName(type_infos["device_type"]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
497 |
slave_info.setVendorId(ExtractHexDecValue(type_infos["vendor"])) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
498 |
slave_info.setProductCode(ExtractHexDecValue(type_infos["product_code"])) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
499 |
slave_info.setRevisionNo(ExtractHexDecValue(type_infos["revision_number"])) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
500 |
setattr(cls, "setType", setType) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
501 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
502 |
def getInitCmds(self, create_default=False): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
503 |
Mailbox = self.getMailbox() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
504 |
if Mailbox is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
505 |
if create_default: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
506 |
self.addMailbox() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
507 |
Mailbox = self.getMailbox() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
508 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
509 |
return None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
510 |
CoE = Mailbox.getCoE() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
511 |
if CoE is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
512 |
if create_default: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
513 |
Mailbox.addCoE() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
514 |
CoE = Mailbox.getCoE() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
515 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
516 |
return None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
517 |
InitCmds = CoE.getInitCmds() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
518 |
if InitCmds is None and create_default: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
519 |
CoE.addInitCmds() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
520 |
InitCmds = CoE.getInitCmds() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
521 |
return InitCmds |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
522 |
setattr(cls, "getInitCmds", getInitCmds) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
523 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
524 |
def getStartupCommands(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
525 |
pos = self.getInfo().getPhysAddr() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
526 |
InitCmds = self.getInitCmds() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
527 |
if InitCmds is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
528 |
return [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
529 |
commands = [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
530 |
for idx, InitCmd in enumerate(InitCmds.getInitCmd()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
531 |
comment = InitCmd.getComment() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
532 |
if comment is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
533 |
comment = "" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
534 |
commands.append({ |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
535 |
"command_idx": idx, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
536 |
"Position": pos, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
537 |
"Index": InitCmd.getIndex(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
538 |
"Subindex": InitCmd.getSubIndex(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
539 |
"Value": InitCmd.getData(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
540 |
"Description": comment}) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
541 |
commands.sort(sort_commands) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
542 |
return commands |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
543 |
setattr(cls, "getStartupCommands", getStartupCommands) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
544 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
545 |
def appendStartupCommand(self, command_infos): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
546 |
InitCmds = self.getInitCmds(True) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
547 |
command = EtherCATConfigClasses["InitCmds_InitCmd"]() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
548 |
command.setIndex(command_infos["Index"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
549 |
command.setSubIndex(command_infos["Subindex"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
550 |
command.setData(command_infos["Value"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
551 |
command.setComment(command_infos["Description"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
552 |
InitCmds.appendInitCmd(command) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
553 |
return len(InitCmds.getInitCmd()) - 1 |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
554 |
setattr(cls, "appendStartupCommand", appendStartupCommand) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
555 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
556 |
def setStartupCommand(self, command_infos): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
557 |
InitCmds = self.getInitCmds() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
558 |
if InitCmds is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
559 |
commands = InitCmds.getInitCmd() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
560 |
if command_infos["command_idx"] < len(commands): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
561 |
command = commands[command_infos["command_idx"]] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
562 |
command.setIndex(command_infos["Index"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
563 |
command.setSubIndex(command_infos["Subindex"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
564 |
command.setData(command_infos["Value"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
565 |
command.setComment(command_infos["Description"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
566 |
setattr(cls, "setStartupCommand", setStartupCommand) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
567 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
568 |
def removeStartupCommand(self, command_idx): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
569 |
InitCmds = self.getInitCmds() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
570 |
if InitCmds is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
571 |
if command_idx < len(InitCmds.getInitCmd()): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
572 |
InitCmds.removeInitCmd(command_idx) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
573 |
setattr(cls, "removeStartupCommand", removeStartupCommand) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
574 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
575 |
ProcessVariablesXSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
576 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
577 |
<xsd:element name="ProcessVariables"> |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
578 |
<xsd:complexType> |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
579 |
<xsd:sequence> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
580 |
<xsd:element name="variable" minOccurs="0" maxOccurs="unbounded"> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
581 |
<xsd:complexType> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
582 |
<xsd:sequence> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
583 |
<xsd:element name="ReadFrom" type="LocationDesc" minOccurs="0"/> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
584 |
<xsd:element name="WriteTo" type="LocationDesc" minOccurs="0"/> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
585 |
</xsd:sequence> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
586 |
<xsd:attribute name="Name" type="xsd:string" use="required"/> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
587 |
<xsd:attribute name="Comment" type="xsd:string" use="required"/> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
588 |
</xsd:complexType> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
589 |
</xsd:element> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
590 |
</xsd:sequence> |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
591 |
</xsd:complexType> |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
592 |
</xsd:element> |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
593 |
<xsd:complexType name="LocationDesc"> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
594 |
<xsd:attribute name="Position" type="xsd:integer" use="required"/> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
595 |
<xsd:attribute name="Index" type="xsd:integer" use="required"/> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
596 |
<xsd:attribute name="SubIndex" type="xsd:integer" use="required"/> |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
597 |
</xsd:complexType> |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
598 |
</xsd:schema> |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
599 |
""" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
600 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
601 |
ProcessVariablesClasses = GenerateClassesFromXSDstring(ProcessVariablesXSD) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
602 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
603 |
class _EthercatCTN: |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
604 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
605 |
CTNChildrenTypes = [("EthercatSlave", _EthercatSlaveCTN, "Ethercat Slave")] |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
606 |
if HAS_MCL: |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
607 |
CTNChildrenTypes.append(("EthercatCIA402Slave", _EthercatCIA402SlaveCTN, "Ethercat CIA402 Slave")) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
608 |
EditorType = MasterEditor |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
609 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
610 |
def __init__(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
611 |
config_filepath = self.ConfigFileName() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
612 |
config_is_saved = False |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
613 |
self.Config = EtherCATConfigClasses["EtherCATConfig"]() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
614 |
if os.path.isfile(config_filepath): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
615 |
config_xmlfile = open(config_filepath, 'r') |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
616 |
config_tree = minidom.parse(config_xmlfile) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
617 |
config_xmlfile.close() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
618 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
619 |
for child in config_tree.childNodes: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
620 |
if child.nodeType == config_tree.ELEMENT_NODE and child.nodeName == "EtherCATConfig": |
2051 | 621 |
self.Config.loadXMLTree(child) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
622 |
config_is_saved = True |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
623 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
624 |
process_filepath = self.ProcessVariablesFileName() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
625 |
process_is_saved = False |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
626 |
self.ProcessVariables = ProcessVariablesClasses["ProcessVariables"]() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
627 |
if os.path.isfile(process_filepath): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
628 |
process_xmlfile = open(process_filepath, 'r') |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
629 |
process_tree = minidom.parse(process_xmlfile) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
630 |
process_xmlfile.close() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
631 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
632 |
for child in process_tree.childNodes: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
633 |
if child.nodeType == process_tree.ELEMENT_NODE and child.nodeName == "ProcessVariables": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
634 |
self.ProcessVariables.loadXMLTree(child) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
635 |
process_is_saved = True |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
636 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
637 |
if config_is_saved and process_is_saved: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
638 |
self.CreateBuffer(True) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
639 |
else: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
640 |
self.CreateBuffer(False) |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
641 |
self.OnCTNSave() |
2102
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
642 |
|
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
643 |
def GetContextualMenuItems(self): |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
644 |
return [("Add Ethercat Slave", "Add Ethercat Slave to Master", self.OnAddEthercatSlave)] |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
645 |
|
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
646 |
def OnAddEthercatSlave(self, event): |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
647 |
app_frame = self.GetCTRoot().AppFrame |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
648 |
dialog = BrowseValuesLibraryDialog(app_frame, |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
649 |
"Ethercat Slave Type", self.GetSlaveTypesLibrary()) |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
650 |
if dialog.ShowModal() == wx.ID_OK: |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
651 |
type_infos = dialog.GetValueInfos() |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
652 |
device, alignment = self.GetModuleInfos(type_infos) |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
653 |
if device is not None: |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
654 |
if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
655 |
ConfNodeType = "EthercatCIA402Slave" |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
656 |
else: |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
657 |
ConfNodeType = "EthercatSlave" |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
658 |
new_child = self.CTNAddChild("%s_0" % ConfNodeType, ConfNodeType) |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
659 |
new_child.SetParamsAttribute("SlaveParams.Type", type_infos) |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
660 |
self.CTNRequestSave() |
2105
a62c0de6986f
Fixed bugs in Network Configuration Editor
Laurent Bessard
parents:
2103
diff
changeset
|
661 |
new_child._OpenView() |
2102
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
662 |
app_frame._Refresh(TITLE, FILEMENU, PROJECTTREE) |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
663 |
dialog.Destroy() |
90031b8db62d
Added specific add menu for directly choose slave type while adding new slave
Laurent Bessard
parents:
2101
diff
changeset
|
664 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
665 |
def ExtractHexDecValue(self, value): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
666 |
return ExtractHexDecValue(value) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
667 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
668 |
def GetSizeOfType(self, type): |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
669 |
return TYPECONVERSION.get(self.GetCTRoot().GetBaseType(type), None) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
670 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
671 |
def ConfigFileName(self): |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
672 |
return os.path.join(self.CTNPath(), "config.xml") |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
673 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
674 |
def ProcessVariablesFileName(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
675 |
return os.path.join(self.CTNPath(), "process_variables.xml") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
676 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
677 |
def FilterSlave(self, slave, vendor=None, slave_pos=None, slave_profile=None): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
678 |
if slave_pos is not None and slave.getInfo().getPhysAddr() != slave_pos: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
679 |
return False |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
680 |
type_infos = slave.getType() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
681 |
if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
682 |
return False |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
683 |
device, alignment = self.GetModuleInfos(type_infos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
684 |
if slave_profile is not None and slave_profile not in device.GetProfileNumbers(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
685 |
return False |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
686 |
return True |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
687 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
688 |
def GetSlaves(self, vendor=None, slave_pos=None, slave_profile=None): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
689 |
slaves = [] |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
690 |
for slave in self.Config.getConfig().getSlave(): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
691 |
if self.FilterSlave(slave, vendor, slave_pos, slave_profile): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
692 |
slaves.append(slave.getInfo().getPhysAddr()) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
693 |
slaves.sort() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
694 |
return slaves |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
695 |
|
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
696 |
def GetSlave(self, slave_pos): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
697 |
for slave in self.Config.getConfig().getSlave(): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
698 |
slave_info = slave.getInfo() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
699 |
if slave_info.getPhysAddr() == slave_pos: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
700 |
return slave |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
701 |
return None |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
702 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
703 |
def GetStartupCommands(self, vendor=None, slave_pos=None, slave_profile=None): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
704 |
commands = [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
705 |
for slave in self.Config.getConfig().getSlave(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
706 |
if self.FilterSlave(slave, vendor, slave_pos, slave_profile): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
707 |
commands.append((slave.getInfo().getPhysAddr(), slave.getStartupCommands())) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
708 |
commands.sort() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
709 |
return reduce(lambda x, y: x + y[1], commands, []) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
710 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
711 |
def AppendStartupCommand(self, command_infos): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
712 |
slave = self.GetSlave(command_infos["Position"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
713 |
if slave is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
714 |
command_idx = slave.appendStartupCommand(command_infos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
715 |
self.BufferModel() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
716 |
return command_idx |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
717 |
return None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
718 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
719 |
def SetStartupCommandInfos(self, command_infos): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
720 |
slave = self.GetSlave(command_infos["Position"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
721 |
if slave is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
722 |
slave.setStartupCommand(command_infos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
723 |
self.BufferModel() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
724 |
|
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
725 |
def RemoveStartupCommand(self, slave_pos, command_idx, buffer=True): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
726 |
slave = self.GetSlave(slave_pos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
727 |
if slave is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
728 |
slave.removeStartupCommand(command_idx) |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
729 |
if buffer: |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
730 |
self.BufferModel() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
731 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
732 |
def SetProcessVariables(self, variables): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
733 |
vars = [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
734 |
for var in variables: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
735 |
variable = ProcessVariablesClasses["ProcessVariables_variable"]() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
736 |
variable.setName(var["Name"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
737 |
variable.setComment(var["Description"]) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
738 |
if var["ReadFrom"] != "": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
739 |
position, index, subindex = var["ReadFrom"] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
740 |
if variable.getReadFrom() is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
741 |
variable.addReadFrom() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
742 |
read_from = variable.getReadFrom() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
743 |
read_from.setPosition(position) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
744 |
read_from.setIndex(index) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
745 |
read_from.setSubIndex(subindex) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
746 |
elif variable.getReadFrom() is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
747 |
variable.deleteReadFrom() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
748 |
if var["WriteTo"] != "": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
749 |
position, index, subindex = var["WriteTo"] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
750 |
if variable.getWriteTo() is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
751 |
variable.addWriteTo() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
752 |
write_to = variable.getWriteTo() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
753 |
write_to.setPosition(position) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
754 |
write_to.setIndex(index) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
755 |
write_to.setSubIndex(subindex) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
756 |
elif variable.getWriteTo() is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
757 |
variable.deleteWriteTo() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
758 |
vars.append(variable) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
759 |
self.ProcessVariables.setvariable(vars) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
760 |
self.BufferModel() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
761 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
762 |
def GetProcessVariables(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
763 |
variables = [] |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
764 |
idx = 0 |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
765 |
for variable in self.ProcessVariables.getvariable(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
766 |
var = {"Name": variable.getName(), |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
767 |
"Number": idx, |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
768 |
"Description": variable.getComment()} |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
769 |
read_from = variable.getReadFrom() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
770 |
if read_from is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
771 |
var["ReadFrom"] = (read_from.getPosition(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
772 |
read_from.getIndex(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
773 |
read_from.getSubIndex()) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
774 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
775 |
var["ReadFrom"] = "" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
776 |
write_to = variable.getWriteTo() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
777 |
if write_to is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
778 |
var["WriteTo"] = (write_to.getPosition(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
779 |
write_to.getIndex(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
780 |
write_to.getSubIndex()) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
781 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
782 |
var["WriteTo"] = "" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
783 |
variables.append(var) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
784 |
idx += 1 |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
785 |
return variables |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
786 |
|
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
787 |
def _ScanNetwork(self): |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
788 |
app_frame = self.GetCTRoot().AppFrame |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
789 |
|
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
790 |
execute = True |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
791 |
if len(self.Children) > 0: |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
792 |
dialog = wx.MessageDialog(app_frame, |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
793 |
_("The current network configuration will be deleted.\nDo you want to continue?"), |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
794 |
_("Scan Network"), |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
795 |
wx.YES_NO|wx.ICON_QUESTION) |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
796 |
execute = dialog.ShowModal() == wx.ID_YES |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
797 |
dialog.Destroy() |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
798 |
|
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
799 |
if execute: |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
800 |
error, returnVal = self.RemoteExec(SCAN_COMMAND, returnVal = None) |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
801 |
if error != 0: |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
802 |
dialog = wx.MessageDialog(app_frame, returnVal, "Error", wx.OK|wx.ICON_ERROR) |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
803 |
dialog.ShowModal() |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
804 |
dialog.Destroy() |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
805 |
elif returnVal is not None: |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
806 |
for child in self.IECSortedChildren(): |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
807 |
self._doRemoveChild(child) |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
808 |
|
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
809 |
for slave in returnVal: |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
810 |
type_infos = { |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
811 |
"vendor": slave["vendor_id"], |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
812 |
"product_code": slave["product_code"], |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
813 |
"revision_number":slave["revision_number"], |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
814 |
} |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
815 |
device, alignment = self.GetModuleInfos(type_infos) |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
816 |
if device is not None: |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
817 |
if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
818 |
CTNType = "EthercatCIA402Slave" |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
819 |
else: |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
820 |
CTNType = "EthercatSlave" |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
821 |
self.CTNAddChild("slave%s" % slave["idx"], CTNType, slave["idx"]) |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
822 |
self.SetSlaveAlias(slave["idx"], slave["alias"]) |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
823 |
type_infos["device_type"] = device.getType().getcontent() |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
824 |
self.SetSlaveType(slave["idx"], type_infos) |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
825 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
826 |
def CTNAddChild(self, CTNName, CTNType, IEC_Channel=0): |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
827 |
""" |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
828 |
Create the confnodes that may be added as child to this node self |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
829 |
@param CTNType: string desining the confnode class name (get name from CTNChildrenTypes) |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
830 |
@param CTNName: string for the name of the confnode instance |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
831 |
""" |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
832 |
newConfNodeOpj = ConfigTreeNode.CTNAddChild(self, CTNName, CTNType, IEC_Channel) |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
833 |
|
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
834 |
slave = self.GetSlave(newConfNodeOpj.BaseParams.getIEC_Channel()) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
835 |
if slave is None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
836 |
slave = EtherCATConfigClasses["Config_Slave"]() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
837 |
slave_infos = slave.getInfo() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
838 |
slave_infos.setName("undefined") |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
839 |
slave_infos.setPhysAddr(newConfNodeOpj.BaseParams.getIEC_Channel()) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
840 |
slave_infos.setAutoIncAddr(0) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
841 |
self.Config.getConfig().appendSlave(slave) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
842 |
self.BufferModel() |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
843 |
self.OnCTNSave() |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
844 |
|
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
845 |
return newConfNodeOpj |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
846 |
|
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
847 |
def _doRemoveChild(self, CTNInstance): |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
848 |
slave_pos = CTNInstance.GetSlavePos() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
849 |
config = self.Config.getConfig() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
850 |
for idx, slave in enumerate(config.getSlave()): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
851 |
slave_infos = slave.getInfo() |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
852 |
if slave_infos.getPhysAddr() == slave_pos: |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
853 |
config.removeSlave(idx) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
854 |
self.BufferModel() |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
855 |
self.OnCTNSave() |
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
856 |
ConfigTreeNode._doRemoveChild(self, CTNInstance) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
857 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
858 |
def SetSlavePosition(self, slave_pos, new_pos): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
859 |
slave = self.GetSlave(slave_pos) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
860 |
if slave is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
861 |
slave_info = slave.getInfo() |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
862 |
slave_info.setPhysAddr(new_pos) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
863 |
for variable in self.ProcessVariables.getvariable(): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
864 |
read_from = variable.getReadFrom() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
865 |
if read_from is not None and read_from.getPosition() == slave_pos: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
866 |
read_from.setPosition(new_pos) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
867 |
write_to = variable.getWriteTo() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
868 |
if write_to is not None and write_to.getPosition() == slave_pos: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
869 |
write_to.setPosition(new_pos) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
870 |
self.CreateBuffer(True) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
871 |
self.OnCTNSave() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
872 |
if self._View is not None: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
873 |
self._View.RefreshView() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
874 |
self._View.RefreshBuffer() |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
875 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
876 |
def GetSlaveAlias(self, slave_pos): |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
877 |
slave = self.GetSlave(slave_pos) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
878 |
if slave is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
879 |
slave_info = slave.getInfo() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
880 |
return slave_info.getAutoIncAddr() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
881 |
return None |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
882 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
883 |
def SetSlaveAlias(self, slave_pos, alias): |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
884 |
slave = self.GetSlave(slave_pos) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
885 |
if slave is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
886 |
slave_info = slave.getInfo() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
887 |
slave_info.setAutoIncAddr(alias) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
888 |
self.BufferModel() |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
889 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
890 |
def GetSlaveType(self, slave_pos): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
891 |
slave = self.GetSlave(slave_pos) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
892 |
if slave is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
893 |
return slave.getType() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
894 |
return None |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
895 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
896 |
def SetSlaveType(self, slave_pos, type_infos): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
897 |
slave = self.GetSlave(slave_pos) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
898 |
if slave is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
899 |
slave.setType(type_infos) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
900 |
self.BufferModel() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
901 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
902 |
def GetSlaveInfos(self, slave_pos): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
903 |
slave = self.GetSlave(slave_pos) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
904 |
if slave is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
905 |
type_infos = slave.getType() |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
906 |
device, alignment = self.GetModuleInfos(type_infos) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
907 |
if device is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
908 |
infos = type_infos.copy() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
909 |
infos.update({"physics": device.getPhysics(), |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
910 |
"sync_managers": device.GetSyncManagers(), |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
911 |
"entries": self.GetSlaveVariables(device)}) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
912 |
return infos |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
913 |
return None |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
914 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
915 |
def GetSlaveVariables(self, slave_pos=None, limits=None, device=None): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
916 |
if device is None and slave_pos is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
917 |
slave = self.GetSlave(slave_pos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
918 |
if slave is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
919 |
type_infos = slave.getType() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
920 |
device, alignment = self.GetModuleInfos(type_infos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
921 |
if device is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
922 |
entries = device.GetEntriesList(limits) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
923 |
entries_list = entries.items() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
924 |
entries_list.sort() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
925 |
entries = [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
926 |
current_index = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
927 |
current_entry = None |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
928 |
for (index, subindex), entry in entries_list: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
929 |
entry["children"] = [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
930 |
if slave_pos is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
931 |
entry["Position"] = str(slave_pos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
932 |
entry |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
933 |
if index != current_index: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
934 |
current_index = index |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
935 |
current_entry = entry |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
936 |
entries.append(entry) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
937 |
elif current_entry is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
938 |
current_entry["children"].append(entry) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
939 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
940 |
entries.append(entry) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
941 |
return entries |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
942 |
return [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
943 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
944 |
def GetSlaveVariableDataType(self, slave_pos, index, subindex): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
945 |
slave = self.GetSlave(slave_pos) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
946 |
if slave is not None: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
947 |
device, alignment = self.GetModuleInfos(slave.getType()) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
948 |
if device is not None: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
949 |
entries = device.GetEntriesList() |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
950 |
entry_infos = entries.get((index, subindex)) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
951 |
if entry_infos is not None: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
952 |
return entry_infos["Type"] |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
953 |
return None |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
954 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
955 |
def GetNodesVariables(self, vendor=None, slave_pos=None, slave_profile=None, limits=None): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
956 |
entries = [] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
957 |
for slave_position in self.GetSlaves(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
958 |
if slave_pos is not None and slave_position != slave_pos: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
959 |
continue |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
960 |
slave = self.GetSlave(slave_position) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
961 |
type_infos = slave.getType() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
962 |
if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
963 |
continue |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
964 |
device, alignment = self.GetModuleInfos(type_infos) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
965 |
if slave_profile is not None and slave_profile not in device.GetProfileNumbers(): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
966 |
continue |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
967 |
entries.extend(self.GetSlaveVariables(slave_position, limits, device)) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
968 |
return entries |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
969 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
970 |
def GetModuleInfos(self, type_infos): |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
971 |
return self.CTNParent.GetModuleInfos(type_infos) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
972 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
973 |
def GetSlaveTypesLibrary(self, profile_filter=None): |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
974 |
return self.CTNParent.GetModulesLibrary(profile_filter) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
975 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
976 |
def GetLibraryVendors(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
977 |
return self.CTNParent.GetVendors() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
978 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
979 |
def GetDeviceLocationTree(self, slave_pos, current_location, device_name): |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
980 |
slave = self.GetSlave(slave_pos) |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
981 |
vars = [] |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
982 |
if slave is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
983 |
type_infos = slave.getType() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
984 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
985 |
device, alignment = self.GetModuleInfos(type_infos) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
986 |
if device is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
987 |
sync_managers = [] |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
988 |
for sync_manager in device.getSm(): |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
989 |
sync_manager_control_byte = ExtractHexDecValue(sync_manager.getControlByte()) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
990 |
sync_manager_direction = sync_manager_control_byte & 0x0c |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
991 |
if sync_manager_direction: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
992 |
sync_managers.append(LOCATION_VAR_OUTPUT) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
993 |
else: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
994 |
sync_managers.append(LOCATION_VAR_INPUT) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
995 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
996 |
entries = device.GetEntriesList().items() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
997 |
entries.sort() |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
998 |
for (index, subindex), entry in entries: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
999 |
var_size = self.GetSizeOfType(entry["Type"]) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1000 |
if var_size is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1001 |
var_class = VARCLASSCONVERSION.get(entry["PDOMapping"], None) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1002 |
if var_class is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1003 |
if var_class == LOCATION_VAR_INPUT: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1004 |
var_dir = "%I" |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1005 |
else: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1006 |
var_dir = "%Q" |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1007 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1008 |
vars.append({"name": "0x%4.4x-0x%2.2x: %s" % (index, subindex, entry["Name"]), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1009 |
"type": var_class, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1010 |
"size": var_size, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1011 |
"IEC_type": entry["Type"], |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1012 |
"var_name": "%s_%4.4x_%2.2x" % ("_".join(device_name.split()), index, subindex), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1013 |
"location": "%s%s%s"%(var_dir, var_size, ".".join(map(str, current_location + |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1014 |
(index, subindex)))), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1015 |
"description": "", |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1016 |
"children": []}) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1017 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1018 |
return vars |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1019 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1020 |
def CTNTestModified(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1021 |
return self.ChangesToSave or not self.ModelIsSaved() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1022 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1023 |
def OnCTNSave(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1024 |
config_filepath = self.ConfigFileName() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1025 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1026 |
config_text = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1027 |
config_extras = {"xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance", |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1028 |
"xsi:noNamespaceSchemaLocation" : "EtherCATInfo.xsd"} |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1029 |
config_text += self.Config.generateXMLText("EtherCATConfig", 0, config_extras) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1030 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1031 |
config_xmlfile = open(config_filepath,"w") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1032 |
config_xmlfile.write(config_text.encode("utf-8")) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1033 |
config_xmlfile.close() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1034 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1035 |
process_filepath = self.ProcessVariablesFileName() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1036 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1037 |
process_text = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1038 |
process_extras = {"xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance"} |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1039 |
process_text += self.ProcessVariables.generateXMLText("ProcessVariables", 0, process_extras) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1040 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1041 |
process_xmlfile = open(process_filepath,"w") |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1042 |
process_xmlfile.write(process_text.encode("utf-8")) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1043 |
process_xmlfile.close() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1044 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1045 |
self.Buffer.CurrentSaved() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1046 |
return True |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1047 |
|
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1048 |
def GetProcessVariableName(self, location, var_type): |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1049 |
return "__M%s_%s" % (self.GetSizeOfType(var_type), "_".join(map(str, location))) |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1050 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1051 |
def _Generate_C(self, buildpath, locations): |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1052 |
current_location = self.GetCurrentLocation() |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1053 |
# define a unique name for the generated C file |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1054 |
location_str = "_".join(map(lambda x:str(x), current_location)) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1055 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1056 |
Gen_Ethercatfile_path = os.path.join(buildpath, "ethercat_%s.c"%location_str) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1057 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1058 |
self.FileGenerator = _EthercatCFileGenerator(self) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1059 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1060 |
LocationCFilesAndCFLAGS, LDFLAGS, extra_files = ConfigTreeNode._Generate_C(self, buildpath, locations) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1061 |
|
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1062 |
for idx, variable in enumerate(self.ProcessVariables.getvariable()): |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1063 |
name = None |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1064 |
var_type = None |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1065 |
read_from = variable.getReadFrom() |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1066 |
write_to = variable.getWriteTo() |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1067 |
if read_from is not None: |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1068 |
pos = read_from.getPosition() |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1069 |
index = read_from.getIndex() |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1070 |
subindex = read_from.getSubIndex() |
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1071 |
location = current_location + (idx, ) |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1072 |
var_type = self.GetSlaveVariableDataType(pos, index, subindex) |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1073 |
name = self.FileGenerator.DeclareVariable( |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1074 |
pos, index, subindex, var_type, "I", |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1075 |
self.GetProcessVariableName(location, var_type)) |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1076 |
if write_to is not None: |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1077 |
pos = write_to.getPosition() |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1078 |
index = write_to.getIndex() |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1079 |
subindex = write_to.getSubIndex() |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1080 |
if name is None: |
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1081 |
location = current_location + (idx, ) |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1082 |
var_type = self.GetSlaveVariableDataType(pos, index, subindex) |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1083 |
name = self.GetProcessVariableName(location, var_type) |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1084 |
self.FileGenerator.DeclareVariable( |
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1085 |
pos, index, subindex, var_type, "Q", name, True) |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1086 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1087 |
self.FileGenerator.GenerateCFile(Gen_Ethercatfile_path, location_str, self.BaseParams.getIEC_Channel()) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1088 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1089 |
LocationCFilesAndCFLAGS.append( |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1090 |
(current_location, |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1091 |
[(Gen_Ethercatfile_path, '"-I%s"'%os.path.abspath(self.GetCTRoot().GetIECLibPath()))], |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1092 |
True)) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1093 |
LDFLAGS.append("-lethercat -lrtdm") |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1094 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1095 |
return LocationCFilesAndCFLAGS, LDFLAGS, extra_files |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1096 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1097 |
ConfNodeMethods = [ |
2068
05a267b1a362
Adding support using plcopeneditor bitmap library for icon request
Laurent Bessard
parents:
2067
diff
changeset
|
1098 |
{"bitmap" : "ScanNetwork", |
2042
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
1099 |
"name" : _("Scan Network"), |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
1100 |
"tooltip" : _("Scan Network"), |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
1101 |
"method" : "_ScanNetwork"}, |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
1102 |
] |
563ccc918ded
Adding support for remotely scanning Etherlab network and automatically configure it
laurent
parents:
2041
diff
changeset
|
1103 |
|
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1104 |
def CTNGenerate_C(self, buildpath, locations): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1105 |
""" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1106 |
Generate C code |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1107 |
@param current_location: Tupple containing confnode IEC location : %I0.0.4.5 => (0,0,4,5) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1108 |
@param locations: List of complete variables locations \ |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1109 |
[{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1110 |
"NAME" : name of the variable (generally "__IW0_1_2" style) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1111 |
"DIR" : direction "Q","I" or "M" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1112 |
"SIZE" : size "X", "B", "W", "D", "L" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1113 |
"LOC" : tuple of interger for IEC location (0,1,2,...) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1114 |
}, ...] |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1115 |
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1116 |
""" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1117 |
current_location = self.GetCurrentLocation() |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1118 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1119 |
slaves = self.GetSlaves() |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1120 |
for slave_pos in slaves: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1121 |
slave = self.GetSlave(slave_pos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1122 |
if slave is not None: |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1123 |
self.FileGenerator.DeclareSlave(slave_pos, slave) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1124 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1125 |
for location in locations: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1126 |
loc = location["LOC"][len(current_location):] |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1127 |
slave_pos = loc[0] |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1128 |
if slave_pos in slaves and len(loc) == 3 and location["DIR"] != "M": |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1129 |
self.FileGenerator.DeclareVariable( |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1130 |
slave_pos, loc[1], loc[2], location["IEC_TYPE"], location["DIR"], location["NAME"]) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1131 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1132 |
return [],"",False |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1133 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1134 |
#------------------------------------------------------------------------------- |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1135 |
# Current Buffering Management Functions |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1136 |
#------------------------------------------------------------------------------- |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1137 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1138 |
""" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1139 |
Return a copy of the config |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1140 |
""" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1141 |
def Copy(self, model): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1142 |
return cPickle.loads(cPickle.dumps(model)) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1143 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1144 |
def CreateBuffer(self, saved): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1145 |
self.Buffer = UndoBuffer(cPickle.dumps((self.Config, self.ProcessVariables)), saved) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1146 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1147 |
def BufferModel(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1148 |
self.Buffer.Buffering(cPickle.dumps((self.Config, self.ProcessVariables))) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1149 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1150 |
def ModelIsSaved(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1151 |
if self.Buffer is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1152 |
return self.Buffer.IsCurrentSaved() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1153 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1154 |
return True |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1155 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1156 |
def LoadPrevious(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1157 |
self.Config, self.ProcessVariables = cPickle.loads(self.Buffer.Previous()) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1158 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1159 |
def LoadNext(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1160 |
self.Config, self.ProcessVariables = cPickle.loads(self.Buffer.Next()) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1161 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1162 |
def GetBufferState(self): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1163 |
first = self.Buffer.IsFirst() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1164 |
last = self.Buffer.IsLast() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1165 |
return not first, not last |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1166 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1167 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1168 |
SLAVE_PDOS_CONFIGURATION_DECLARATION = """ |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1169 |
/* Slave %(slave)d, "%(device_type)s" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1170 |
* Vendor ID: 0x%(vendor).8x |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1171 |
* Product code: 0x%(product_code).8x |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1172 |
* Revision number: 0x%(revision_number).8x |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1173 |
*/ |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1174 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1175 |
ec_pdo_entry_info_t slave_%(slave)d_pdo_entries[] = { |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1176 |
%(pdos_entries_infos)s |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1177 |
}; |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1178 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1179 |
ec_pdo_info_t slave_%(slave)d_pdos[] = { |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1180 |
%(pdos_infos)s |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1181 |
}; |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1182 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1183 |
ec_sync_info_t slave_%(slave)d_syncs[] = { |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1184 |
%(pdos_sync_infos)s |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1185 |
{0xff} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1186 |
}; |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1187 |
""" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1188 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1189 |
SLAVE_CONFIGURATION_TEMPLATE = """ |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1190 |
if (!(slave%(slave)d = ecrt_master_slave_config(master, %(alias)d, %(position)d, 0x%(vendor).8x, 0x%(product_code).8x))) { |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1191 |
fprintf(stderr, "Failed to get slave %(device_type)s configuration at alias %(alias)d and position %(position)d.\\n"); |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1192 |
return -1; |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1193 |
} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1194 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1195 |
if (ecrt_slave_config_pdos(slave%(slave)d, EC_END, slave_%(slave)d_syncs)) { |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1196 |
fprintf(stderr, "Failed to configure PDOs for slave %(device_type)s at alias %(alias)d and position %(position)d.\\n"); |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1197 |
return -1; |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1198 |
} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1199 |
""" |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1200 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1201 |
SLAVE_INITIALIZATION_TEMPLATE = """ |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1202 |
{ |
2081
b1801bf4365c
Fix bug in endianization in value transmit and received by SDO
Laurent Bessard
parents:
2080
diff
changeset
|
1203 |
uint8_t value[%(data_size)d]; |
b1801bf4365c
Fix bug in endianization in value transmit and received by SDO
Laurent Bessard
parents:
2080
diff
changeset
|
1204 |
EC_WRITE_%(data_type)s((uint8_t *)value, %(data)s); |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1205 |
if (ecrt_master_sdo_download(master, %(slave)d, 0x%(index).4x, 0x%(subindex).2x, (uint8_t *)value, %(data_size)d, &abort_code)) { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1206 |
fprintf(stderr, "Failed to initialize slave %(device_type)s at alias %(alias)d and position %(position)d.\\nError: %%d\\n", abort_code); |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1207 |
return -1; |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1208 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1209 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1210 |
""" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1211 |
|
2039
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1212 |
SLAVE_OUTPUT_PDO_DEFAULT_VALUE = """ |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1213 |
{ |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1214 |
uint8_t value[%(data_size)d]; |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1215 |
if (ecrt_master_sdo_upload(master, %(slave)d, 0x%(index).4x, 0x%(subindex).2x, (uint8_t *)value, %(data_size)d, &result_size, &abort_code)) { |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1216 |
fprintf(stderr, "Failed to get default value for output PDO in slave %(device_type)s at alias %(alias)d and position %(position)d.\\nError: %%d\\n", abort_code); |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1217 |
return -1; |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1218 |
} |
2081
b1801bf4365c
Fix bug in endianization in value transmit and received by SDO
Laurent Bessard
parents:
2080
diff
changeset
|
1219 |
%(real_var)s = EC_READ_%(data_type)s((uint8_t *)value); |
2039
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1220 |
} |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1221 |
""" |
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1222 |
|
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1223 |
def ConfigureVariable(entry_infos, str_completion): |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1224 |
entry_infos["data_type"] = DATATYPECONVERSION.get(entry_infos["var_type"], None) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1225 |
if entry_infos["data_type"] is None: |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1226 |
raise ValueError, _("Type of location \"%s\" not yet supported!") % entry_infos["var_name"] |
2039
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1227 |
|
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1228 |
if not entry_infos.get("no_decl", False): |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1229 |
if entry_infos.has_key("real_var"): |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1230 |
str_completion["located_variables_declaration"].append( |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1231 |
"IEC_%(var_type)s %(real_var)s;" % entry_infos) |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1232 |
else: |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1233 |
entry_infos["real_var"] = "beremiz" + entry_infos["var_name"] |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1234 |
str_completion["located_variables_declaration"].extend( |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1235 |
["IEC_%(var_type)s %(real_var)s;" % entry_infos, |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1236 |
"IEC_%(var_type)s *%(var_name)s = &%(real_var)s;" % entry_infos]) |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1237 |
for declaration in entry_infos.get("extra_declarations", []): |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1238 |
entry_infos["extra_decl"] = declaration |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1239 |
str_completion["located_variables_declaration"].append( |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1240 |
"IEC_%(var_type)s *%(extra_decl)s = &%(real_var)s;" % entry_infos) |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1241 |
elif not entry_infos.has_key("real_var"): |
2039
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1242 |
entry_infos["real_var"] = "beremiz" + entry_infos["var_name"] |
2034 | 1243 |
|
1244 |
str_completion["used_pdo_entry_offset_variables_declaration"].append( |
|
1245 |
"unsigned int slave%(slave)d_%(index).4x_%(subindex).2x;" % entry_infos) |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1246 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1247 |
if entry_infos["data_type"] == "BIT": |
2034 | 1248 |
str_completion["used_pdo_entry_offset_variables_declaration"].append( |
1249 |
"unsigned int slave%(slave)d_%(index).4x_%(subindex).2x_bit;" % entry_infos) |
|
1250 |
||
1251 |
str_completion["used_pdo_entry_configuration"].append( |
|
1252 |
(" {%(alias)d, %(position)d, 0x%(vendor).8x, 0x%(product_code).8x, " + |
|
1253 |
"0x%(index).4x, %(subindex)d, &slave%(slave)d_%(index).4x_%(subindex).2x, " + |
|
1254 |
"&slave%(slave)d_%(index).4x_%(subindex).2x_bit},") % entry_infos) |
|
1255 |
||
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1256 |
if entry_infos["dir"] == "I": |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1257 |
str_completion["retrieve_variables"].append( |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1258 |
(" %(real_var)s = EC_READ_BIT(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " + |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1259 |
"slave%(slave)d_%(index).4x_%(subindex).2x_bit);") % entry_infos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1260 |
elif entry_infos["dir"] == "Q": |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1261 |
str_completion["publish_variables"].append( |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1262 |
(" EC_WRITE_BIT(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " + |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1263 |
"slave%(slave)d_%(index).4x_%(subindex).2x_bit, %(real_var)s);") % entry_infos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1264 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1265 |
else: |
2034 | 1266 |
str_completion["used_pdo_entry_configuration"].append( |
1267 |
(" {%(alias)d, %(position)d, 0x%(vendor).8x, 0x%(product_code).8x, 0x%(index).4x, " + |
|
1268 |
"%(subindex)d, &slave%(slave)d_%(index).4x_%(subindex).2x},") % entry_infos) |
|
1269 |
||
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1270 |
if entry_infos["dir"] == "I": |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1271 |
str_completion["retrieve_variables"].append( |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1272 |
(" %(real_var)s = EC_READ_%(data_type)s(domain1_pd + " + |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1273 |
"slave%(slave)d_%(index).4x_%(subindex).2x);") % entry_infos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1274 |
elif entry_infos["dir"] == "Q": |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1275 |
str_completion["publish_variables"].append( |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1276 |
(" EC_WRITE_%(data_type)s(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " + |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1277 |
"%(real_var)s);") % entry_infos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1278 |
|
2082
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1279 |
def ExclusionSortFunction(x, y): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1280 |
if x["matching"] == y["matching"]: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1281 |
if x["assigned"] and not y["assigned"]: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1282 |
return -1 |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1283 |
elif not x["assigned"] and y["assigned"]: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1284 |
return 1 |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1285 |
return cmp(x["count"], y["count"]) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1286 |
return -cmp(x["matching"], y["matching"]) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1287 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1288 |
class _EthercatCFileGenerator: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1289 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1290 |
def __init__(self, controler): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1291 |
self.Controler = controler |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1292 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1293 |
self.Slaves = [] |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1294 |
self.UsedVariables = {} |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1295 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1296 |
def __del__(self): |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1297 |
self.Controler = None |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1298 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1299 |
def DeclareSlave(self, slave_index, slave): |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1300 |
self.Slaves.append((slave_index, slave.getInfo().getAutoIncAddr(), slave)) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1301 |
|
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1302 |
def DeclareVariable(self, slave_index, index, subindex, iec_type, dir, name, no_decl=False): |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1303 |
slave_variables = self.UsedVariables.setdefault(slave_index, {}) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1304 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1305 |
entry_infos = slave_variables.get((index, subindex), None) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1306 |
if entry_infos is None: |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1307 |
slave_variables[(index, subindex)] = { |
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1308 |
"infos": (iec_type, dir, name, no_decl, []), |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1309 |
"mapped": False} |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1310 |
return name |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1311 |
elif entry_infos["infos"][:2] == (iec_type, dir): |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1312 |
if name != entry_infos["infos"][2]: |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1313 |
if dir == "I": |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1314 |
entry_infos["infos"][3].append(name) |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1315 |
return entry_infos["infos"][2] |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1316 |
else: |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1317 |
raise ValueError, _("Output variables can't be defined with different locations (%s and %s)") % (entry_infos["infos"][2], name) |
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1318 |
else: |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1319 |
raise ValueError, _("Definition conflict for location \"%s\"") % name |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1320 |
|
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1321 |
def GenerateCFile(self, filepath, location_str, master_number): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1322 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1323 |
# Extract etherlab master code template |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1324 |
plc_etherlab_filepath = os.path.join(os.path.split(__file__)[0], "plc_etherlab.c") |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1325 |
plc_etherlab_file = open(plc_etherlab_filepath, 'r') |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1326 |
plc_etherlab_code = plc_etherlab_file.read() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1327 |
plc_etherlab_file.close() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1328 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1329 |
# Initialize strings for formatting master code template |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1330 |
str_completion = { |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1331 |
"location": location_str, |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1332 |
"master_number": master_number, |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1333 |
"located_variables_declaration": [], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1334 |
"used_pdo_entry_offset_variables_declaration": [], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1335 |
"used_pdo_entry_configuration": [], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1336 |
"pdos_configuration_declaration": "", |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1337 |
"slaves_declaration": "", |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1338 |
"slaves_configuration": "", |
2039
3a218f6bd805
Adding support for uploading default value for unused entries in output pdos from slaves before starting master
laurent
parents:
2038
diff
changeset
|
1339 |
"slaves_output_pdos_default_values_extraction": "", |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1340 |
"slaves_initialization": "", |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1341 |
"retrieve_variables": [], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1342 |
"publish_variables": [], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1343 |
} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1344 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1345 |
# Initialize variable storing variable mapping state |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1346 |
for slave_entries in self.UsedVariables.itervalues(): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1347 |
for entry_infos in slave_entries.itervalues(): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1348 |
entry_infos["mapped"] = False |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1349 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1350 |
# Sort slaves by position (IEC_Channel) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1351 |
self.Slaves.sort() |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1352 |
# Initialize dictionary storing alias auto-increment position values |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1353 |
alias = {} |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1354 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1355 |
# Generating code for each slave |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1356 |
for (slave_idx, slave_alias, slave) in self.Slaves: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1357 |
type_infos = slave.getType() |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1358 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1359 |
# Defining slave alias and auto-increment position |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1360 |
if alias.get(slave_alias) is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1361 |
alias[slave_alias] += 1 |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1362 |
else: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1363 |
alias[slave_alias] = 0 |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1364 |
slave_pos = (slave_alias, alias[slave_alias]) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1365 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1366 |
# Extract slave device informations |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1367 |
device, alignment = self.Controler.GetModuleInfos(type_infos) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1368 |
if device is not None: |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1369 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1370 |
# Extract slaves variables to be mapped |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
1371 |
slave_variables = self.UsedVariables.get(slave_idx, {}) |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1372 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1373 |
# Extract slave device object dictionary entries |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1374 |
device_entries = device.GetEntriesList() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1375 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1376 |
# Adding code for declaring slave in master code template strings |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1377 |
for element in ["vendor", "product_code", "revision_number"]: |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1378 |
type_infos[element] = ExtractHexDecValue(type_infos[element]) |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1379 |
type_infos.update(dict(zip(["slave", "alias", "position"], (slave_idx,) + slave_pos))) |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1380 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1381 |
# Extract slave device CoE informations |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1382 |
device_coe = device.getCoE() |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1383 |
if device_coe is not None: |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1384 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1385 |
# If device support CanOpen over Ethernet, adding code for calling |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1386 |
# init commands when initializing slave in master code template strings |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1387 |
initCmds = [] |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1388 |
for initCmd in device_coe.getInitCmd(): |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1389 |
initCmds.append({ |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1390 |
"Index": ExtractHexDecValue(initCmd.getIndex()), |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1391 |
"Subindex": ExtractHexDecValue(initCmd.getSubIndex()), |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1392 |
"Value": initCmd.getData().getcontent()}) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1393 |
initCmds.extend(slave.getStartupCommands()) |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1394 |
for initCmd in initCmds: |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1395 |
index = initCmd["Index"] |
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1396 |
subindex = initCmd["Subindex"] |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1397 |
entry = device_entries.get((index, subindex), None) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1398 |
if entry is not None: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1399 |
data_size = entry["BitSize"] / 8 |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1400 |
data_str = ("0x%%.%dx" % (data_size * 2)) % initCmd["Value"] |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1401 |
init_cmd_infos = { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1402 |
"index": index, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1403 |
"subindex": subindex, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1404 |
"data": data_str, |
2081
b1801bf4365c
Fix bug in endianization in value transmit and received by SDO
Laurent Bessard
parents:
2080
diff
changeset
|
1405 |
"data_type": DATATYPECONVERSION.get(entry["Type"]), |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1406 |
"data_size": data_size |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1407 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1408 |
init_cmd_infos.update(type_infos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1409 |
str_completion["slaves_initialization"] += SLAVE_INITIALIZATION_TEMPLATE % init_cmd_infos |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1410 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1411 |
# Extract slave device PDO configuration capabilities |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1412 |
PdoAssign = device_coe.getPdoAssign() |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1413 |
PdoConfig = device_coe.getPdoConfig() |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1414 |
else: |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1415 |
PdoAssign = PdoConfig = False |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1416 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1417 |
# Test if slave has a configuration or need one |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1418 |
if len(device.getTxPdo() + device.getRxPdo()) > 0 or len(slave_variables) > 0 and PdoConfig and PdoAssign: |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1419 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1420 |
str_completion["slaves_declaration"] += "static ec_slave_config_t *slave%(slave)d = NULL;\n" % type_infos |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1421 |
str_completion["slaves_configuration"] += SLAVE_CONFIGURATION_TEMPLATE % type_infos |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1422 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1423 |
# Initializing |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1424 |
pdos_infos = { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1425 |
"pdos_entries_infos": [], |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1426 |
"pdos_infos": [], |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1427 |
"pdos_sync_infos": [], |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1428 |
} |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1429 |
pdos_infos.update(type_infos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1430 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1431 |
sync_managers = [] |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1432 |
for sync_manager_idx, sync_manager in enumerate(device.getSm()): |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1433 |
sync_manager_infos = { |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1434 |
"index": sync_manager_idx, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1435 |
"name": sync_manager.getcontent(), |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1436 |
"slave": slave_idx, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1437 |
"pdos": [], |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1438 |
"pdos_number": 0, |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1439 |
} |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1440 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1441 |
sync_manager_control_byte = ExtractHexDecValue(sync_manager.getControlByte()) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1442 |
sync_manager_direction = sync_manager_control_byte & 0x0c |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1443 |
sync_manager_watchdog = sync_manager_control_byte & 0x40 |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1444 |
if sync_manager_direction: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1445 |
sync_manager_infos["sync_manager_type"] = "EC_DIR_OUTPUT" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1446 |
else: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1447 |
sync_manager_infos["sync_manager_type"] = "EC_DIR_INPUT" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1448 |
if sync_manager_watchdog: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1449 |
sync_manager_infos["watchdog"] = "EC_WD_ENABLE" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1450 |
else: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1451 |
sync_manager_infos["watchdog"] = "EC_WD_DISABLE" |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1452 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1453 |
sync_managers.append(sync_manager_infos) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1454 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1455 |
pdos_index = [] |
2082
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1456 |
exclusive_pdos = {} |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1457 |
selected_pdos = [] |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1458 |
for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] + |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1459 |
[(pdo, "Outputs") for pdo in device.getRxPdo()]): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1460 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1461 |
pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1462 |
pdos_index.append(pdo_index) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1463 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1464 |
excluded_list = pdo.getExclude() |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1465 |
if len(excluded_list) > 0: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1466 |
exclusion_list = [pdo_index] |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1467 |
for excluded in excluded_list: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1468 |
exclusion_list.append(ExtractHexDecValue(excluded.getcontent())) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1469 |
exclusion_list.sort() |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1470 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1471 |
exclusion_scope = exclusive_pdos.setdefault(tuple(exclusion_list), []) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1472 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1473 |
entries = pdo.getEntry() |
2082
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1474 |
pdo_mapping_match = { |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1475 |
"index": pdo_index, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1476 |
"matching": 0, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1477 |
"count": len(entries), |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1478 |
"assigned": pdo.getSm() is not None |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1479 |
} |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1480 |
exclusion_scope.append(pdo_mapping_match) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1481 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1482 |
for entry in entries: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1483 |
index = ExtractHexDecValue(entry.getIndex().getcontent()) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1484 |
subindex = ExtractHexDecValue(entry.getSubIndex()) |
2082
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1485 |
if slave_variables.get((index, subindex), None) is not None: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1486 |
pdo_mapping_match["matching"] += 1 |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1487 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1488 |
elif pdo.getMandatory(): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1489 |
selected_pdos.append(pdo_index) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1490 |
|
2082
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1491 |
excluded_pdos = [] |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1492 |
for exclusion_scope in exclusive_pdos.itervalues(): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1493 |
exclusion_scope.sort(ExclusionSortFunction) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1494 |
start_excluding_index = 0 |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1495 |
if exclusion_scope[0]["matching"] > 0: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1496 |
selected_pdos.append(exclusion_scope[0]["index"]) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1497 |
start_excluding_index = 1 |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1498 |
excluded_pdos.extend([pdo["index"] for pdo in exclusion_scope[start_excluding_index:] if PdoAssign or not pdo["assigned"]]) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1499 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1500 |
for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] + |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1501 |
[(pdo, "Outputs") for pdo in device.getRxPdo()]): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1502 |
entries = pdo.getEntry() |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1503 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1504 |
pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1505 |
if pdo_index in excluded_pdos: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1506 |
continue |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1507 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1508 |
pdo_needed = pdo_index in selected_pdos |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1509 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1510 |
entries_infos = [] |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1511 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1512 |
for entry in entries: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1513 |
index = ExtractHexDecValue(entry.getIndex().getcontent()) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1514 |
subindex = ExtractHexDecValue(entry.getSubIndex()) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1515 |
entry_infos = { |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1516 |
"index": index, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1517 |
"subindex": subindex, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1518 |
"name": ExtractName(entry.getName()), |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1519 |
"bitlen": entry.getBitLen(), |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1520 |
} |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1521 |
entry_infos.update(type_infos) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1522 |
entries_infos.append(" {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1523 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1524 |
entry_declaration = slave_variables.get((index, subindex), None) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1525 |
if entry_declaration is not None and not entry_declaration["mapped"]: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1526 |
pdo_needed = True |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1527 |
|
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1528 |
entry_infos.update(dict(zip(["var_type", "dir", "var_name", "no_decl", "extra_declarations"], |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1529 |
entry_declaration["infos"]))) |
2082
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1530 |
entry_declaration["mapped"] = True |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1531 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1532 |
entry_type = entry.getDataType().getcontent() |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1533 |
if entry_infos["var_type"] != entry_type: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1534 |
message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"] |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1535 |
if (self.Controler.GetSizeOfType(entry_infos["var_type"]) != |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1536 |
self.Controler.GetSizeOfType(entry_type)): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1537 |
raise ValueError, message |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1538 |
else: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1539 |
self.Controler.GetCTRoot().logger.write_warning(_("Warning: ") + message + "\n") |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1540 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1541 |
if (entry_infos["dir"] == "I" and pdo_type != "Inputs" or |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1542 |
entry_infos["dir"] == "Q" and pdo_type != "Outputs"): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1543 |
raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"] |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1544 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1545 |
ConfigureVariable(entry_infos, str_completion) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1546 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1547 |
elif pdo_type == "Outputs" and entry.getDataType() is not None and device_coe is not None: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1548 |
data_type = entry.getDataType().getcontent() |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1549 |
entry_infos["dir"] = "Q" |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1550 |
entry_infos["data_size"] = max(1, entry_infos["bitlen"] / 8) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1551 |
entry_infos["data_type"] = DATATYPECONVERSION.get(data_type) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1552 |
entry_infos["var_type"] = data_type |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1553 |
entry_infos["real_var"] = "slave%(slave)d_%(index).4x_%(subindex).2x_default" % entry_infos |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1554 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1555 |
ConfigureVariable(entry_infos, str_completion) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1556 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1557 |
str_completion["slaves_output_pdos_default_values_extraction"] += \ |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1558 |
SLAVE_OUTPUT_PDO_DEFAULT_VALUE % entry_infos |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1559 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1560 |
if pdo_needed: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1561 |
for excluded in pdo.getExclude(): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1562 |
excluded_index = ExtractHexDecValue(excluded.getcontent()) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1563 |
if excluded_index not in excluded_pdos: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1564 |
excluded_pdos.append(excluded_index) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1565 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1566 |
sm = pdo.getSm() |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1567 |
if sm is None: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1568 |
for sm_idx, sync_manager in enumerate(sync_managers): |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1569 |
if sync_manager["name"] == pdo_type: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1570 |
sm = sm_idx |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1571 |
if sm is None: |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1572 |
raise ValueError, _("No sync manager available for %s pdo!") % pdo_type |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1573 |
|
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1574 |
sync_managers[sm]["pdos_number"] += 1 |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1575 |
sync_managers[sm]["pdos"].append( |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1576 |
{"slave": slave_idx, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1577 |
"index": pdo_index, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1578 |
"name": ExtractName(pdo.getName()), |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1579 |
"type": pdo_type, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1580 |
"entries": entries_infos, |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1581 |
"entries_number": len(entries_infos), |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1582 |
"fixed": pdo.getFixed() == True}) |
caae3ad2d03b
Adding support for selecting a PDO in a list of mutually exclusive configured PDOs in Ethercat Network Configurator
Laurent Bessard
parents:
2081
diff
changeset
|
1583 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1584 |
if PdoConfig and PdoAssign: |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1585 |
dynamic_pdos = {} |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1586 |
dynamic_pdos_number = 0 |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1587 |
for category, min_index, max_index in [("Inputs", 0x1600, 0x1800), |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1588 |
("Outputs", 0x1a00, 0x1C00)]: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1589 |
for sync_manager in sync_managers: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1590 |
if sync_manager["name"] == category: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1591 |
category_infos = dynamic_pdos.setdefault(category, {}) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1592 |
category_infos["sync_manager"] = sync_manager |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1593 |
category_infos["pdos"] = [pdo for pdo in category_infos["sync_manager"]["pdos"] |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1594 |
if not pdo["fixed"] and pdo["type"] == category] |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1595 |
category_infos["current_index"] = min_index |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1596 |
category_infos["max_index"] = max_index |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1597 |
break |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1598 |
|
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1599 |
for (index, subindex), entry_declaration in slave_variables.iteritems(): |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1600 |
|
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1601 |
if not entry_declaration["mapped"]: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1602 |
entry = device_entries.get((index, subindex), None) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1603 |
if entry is None: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1604 |
raise ValueError, _("Unknown entry index 0x%4.4x, subindex 0x%2.2x for device %s") % \ |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1605 |
(index, subindex, type_infos["device_type"]) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1606 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1607 |
entry_infos = { |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1608 |
"index": index, |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1609 |
"subindex": subindex, |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1610 |
"name": entry["Name"], |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1611 |
"bitlen": entry["BitSize"], |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1612 |
} |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1613 |
entry_infos.update(type_infos) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1614 |
|
2103
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1615 |
entry_infos.update(dict(zip(["var_type", "dir", "var_name", "no_decl", "extra_declarations"], |
5a82d40c4b04
Fixed bugs in process variables generated code
Laurent Bessard
parents:
2102
diff
changeset
|
1616 |
entry_declaration["infos"]))) |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1617 |
entry_declaration["mapped"] = True |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1618 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1619 |
if entry_infos["var_type"] != entry["Type"]: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1620 |
message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"] |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1621 |
if (self.Controler.GetSizeOfType(entry_infos["var_type"]) != |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1622 |
self.Controler.GetSizeOfType(entry["Type"])): |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1623 |
raise ValueError, message |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1624 |
else: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1625 |
self.Controler.GetCTRoot().logger.write_warning(message + "\n") |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1626 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1627 |
if entry_infos["dir"] == "I" and entry["PDOMapping"] in ["T", "RT"]: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1628 |
pdo_type = "Inputs" |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1629 |
elif entry_infos["dir"] == "Q" and entry["PDOMapping"] in ["R", "RT"]: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1630 |
pdo_type = "Outputs" |
2045 | 1631 |
else: |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1632 |
raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"] |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1633 |
|
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1634 |
if not dynamic_pdos.has_key(pdo_type): |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1635 |
raise ValueError, _("No Sync manager defined for %s!") % pdo_type |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1636 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1637 |
ConfigureVariable(entry_infos, str_completion) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1638 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1639 |
if len(dynamic_pdos[pdo_type]["pdos"]) > 0: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1640 |
pdo = dynamic_pdos[pdo_type]["pdos"][0] |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1641 |
else: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1642 |
while dynamic_pdos[pdo_type]["current_index"] in pdos_index: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1643 |
dynamic_pdos[pdo_type]["current_index"] += 1 |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1644 |
if dynamic_pdos[pdo_type]["current_index"] >= dynamic_pdos[pdo_type]["max_index"]: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1645 |
raise ValueError, _("No more free PDO index available for %s!") % pdo_type |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1646 |
pdos_index.append(dynamic_pdos[pdo_type]["current_index"]) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1647 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1648 |
dynamic_pdos_number += 1 |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1649 |
pdo = {"slave": slave_idx, |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1650 |
"index": dynamic_pdos[pdo_type]["current_index"], |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1651 |
"name": "Dynamic PDO %d" % dynamic_pdos_number, |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1652 |
"type": pdo_type, |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1653 |
"entries": [], |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1654 |
"entries_number": 0, |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1655 |
"fixed": False} |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1656 |
dynamic_pdos[pdo_type]["sync_manager"]["pdos_number"] += 1 |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1657 |
dynamic_pdos[pdo_type]["sync_manager"]["pdos"].append(pdo) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1658 |
dynamic_pdos[pdo_type]["pdos"].append(pdo) |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1659 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1660 |
pdo["entries"].append(" {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1661 |
if entry_infos["bitlen"] < alignment: |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
1662 |
print (alignment, entry_infos["bitlen"]) |
2099
ea5384ab152c
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2098
diff
changeset
|
1663 |
pdo["entries"].append(" {0x0000, 0x00, %d}, /* None */" % (alignment - entry_infos["bitlen"])) |
2062
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1664 |
pdo["entries_number"] += 1 |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1665 |
|
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1666 |
if pdo["entries_number"] == 255: |
c485269ec443
Adding support for getting CIA402 slave AXIS_REF located variables and disabling dynamic PDO mapping algorithm for drives than doesn't support this functionality
Laurent Bessard
parents:
2057
diff
changeset
|
1667 |
dynamic_pdos[pdo_type]["pdos"].pop(0) |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1668 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1669 |
pdo_offset = 0 |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1670 |
entry_offset = 0 |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1671 |
for sync_manager_infos in sync_managers: |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1672 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1673 |
for pdo_infos in sync_manager_infos["pdos"]: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1674 |
pdo_infos["offset"] = entry_offset |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1675 |
pdo_entries = pdo_infos["entries"] |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1676 |
pdos_infos["pdos_infos"].append( |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1677 |
(" {0x%(index).4x, %(entries_number)d, " + |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1678 |
"slave_%(slave)d_pdo_entries + %(offset)d}, /* %(name)s */") % pdo_infos) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1679 |
entry_offset += len(pdo_entries) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1680 |
pdos_infos["pdos_entries_infos"].extend(pdo_entries) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1681 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1682 |
sync_manager_infos["offset"] = pdo_offset |
2047
b0b7bd288b6e
Fixed wrong PDO in unused sync managers\nFix higen drive ethercat example
edouard_and_laurent
parents:
2045
diff
changeset
|
1683 |
pdo_offset_shift = sync_manager_infos["pdos_number"] |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1684 |
pdos_infos["pdos_sync_infos"].append( |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1685 |
(" {%(index)d, %(sync_manager_type)s, %(pdos_number)d, " + |
2047
b0b7bd288b6e
Fixed wrong PDO in unused sync managers\nFix higen drive ethercat example
edouard_and_laurent
parents:
2045
diff
changeset
|
1686 |
("slave_%(slave)d_pdos + %(offset)d" if pdo_offset_shift else "NULL") + |
b0b7bd288b6e
Fixed wrong PDO in unused sync managers\nFix higen drive ethercat example
edouard_and_laurent
parents:
2045
diff
changeset
|
1687 |
", %(watchdog)s},") % sync_manager_infos) |
b0b7bd288b6e
Fixed wrong PDO in unused sync managers\nFix higen drive ethercat example
edouard_and_laurent
parents:
2045
diff
changeset
|
1688 |
pdo_offset += pdo_offset_shift |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1689 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1690 |
for element in ["pdos_entries_infos", "pdos_infos", "pdos_sync_infos"]: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1691 |
pdos_infos[element] = "\n".join(pdos_infos[element]) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1692 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1693 |
str_completion["pdos_configuration_declaration"] += SLAVE_PDOS_CONFIGURATION_DECLARATION % pdos_infos |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1694 |
|
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1695 |
for (index, subindex), entry_declaration in slave_variables.iteritems(): |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1696 |
if not entry_declaration["mapped"]: |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1697 |
message = _("Entry index 0x%4.4x, subindex 0x%2.2x not mapped for device %s") % \ |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1698 |
(index, subindex, type_infos["device_type"]) |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1699 |
self.Controler.GetCTRoot().logger.write_warning(_("Warning: ") + message + "\n") |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1700 |
|
2023
f9f884cf3033
Adding support for not configuring pdos when not mandatory and not needed by locations defined in PLC program. Adding support for displaying locations tree in Topology panel and BrowseLocationsDialog. Merging pdos grid and variables grid into one single grid in slave infos panel.
laurent
parents:
2022
diff
changeset
|
1701 |
for element in ["used_pdo_entry_offset_variables_declaration", |
f9f884cf3033
Adding support for not configuring pdos when not mandatory and not needed by locations defined in PLC program. Adding support for displaying locations tree in Topology panel and BrowseLocationsDialog. Merging pdos grid and variables grid into one single grid in slave infos panel.
laurent
parents:
2022
diff
changeset
|
1702 |
"used_pdo_entry_configuration", |
f9f884cf3033
Adding support for not configuring pdos when not mandatory and not needed by locations defined in PLC program. Adding support for displaying locations tree in Topology panel and BrowseLocationsDialog. Merging pdos grid and variables grid into one single grid in slave infos panel.
laurent
parents:
2022
diff
changeset
|
1703 |
"located_variables_declaration", |
f9f884cf3033
Adding support for not configuring pdos when not mandatory and not needed by locations defined in PLC program. Adding support for displaying locations tree in Topology panel and BrowseLocationsDialog. Merging pdos grid and variables grid into one single grid in slave infos panel.
laurent
parents:
2022
diff
changeset
|
1704 |
"retrieve_variables", |
f9f884cf3033
Adding support for not configuring pdos when not mandatory and not needed by locations defined in PLC program. Adding support for displaying locations tree in Topology panel and BrowseLocationsDialog. Merging pdos grid and variables grid into one single grid in slave infos panel.
laurent
parents:
2022
diff
changeset
|
1705 |
"publish_variables"]: |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1706 |
str_completion[element] = "\n".join(str_completion[element]) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1707 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1708 |
etherlabfile = open(filepath, 'w') |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1709 |
etherlabfile.write(plc_etherlab_code % str_completion) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1710 |
etherlabfile.close() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1711 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1712 |
#-------------------------------------------------- |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
1713 |
# Ethercat ConfNode |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1714 |
#-------------------------------------------------- |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1715 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1716 |
EtherCATInfoClasses = GenerateClassesFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATInfo.xsd")) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1717 |
|
2074
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1718 |
cls = EtherCATInfoClasses["EtherCATBase.xsd"].get("DictionaryType", None) |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1719 |
if cls: |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1720 |
cls.loadXMLTreeArgs = None |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1721 |
|
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1722 |
setattr(cls, "_loadXMLTree", getattr(cls, "loadXMLTree")) |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1723 |
|
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1724 |
def loadXMLTree(self, *args): |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1725 |
self.loadXMLTreeArgs = args |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1726 |
setattr(cls, "loadXMLTree", loadXMLTree) |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1727 |
|
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1728 |
def load(self): |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1729 |
if self.loadXMLTreeArgs is not None: |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1730 |
self._loadXMLTree(*self.loadXMLTreeArgs) |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1731 |
self.loadXMLTreeArgs = None |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1732 |
setattr(cls, "load", load) |
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1733 |
|
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1734 |
cls = EtherCATInfoClasses["EtherCATInfo.xsd"].get("DeviceType", None) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1735 |
if cls: |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1736 |
cls.DataTypes = None |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1737 |
|
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1738 |
def GetProfileNumbers(self): |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1739 |
profiles = [] |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1740 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1741 |
for profile in self.getProfile(): |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1742 |
profile_content = profile.getcontent() |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1743 |
if profile_content is None: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1744 |
continue |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1745 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1746 |
for content_element in profile_content["value"]: |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1747 |
if content_element["name"] == "ProfileNo": |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1748 |
profiles.append(content_element["value"]) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1749 |
|
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1750 |
return profiles |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1751 |
setattr(cls, "GetProfileNumbers", GetProfileNumbers) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1752 |
|
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1753 |
def GetProfileDictionaries(self): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1754 |
dictionaries = [] |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1755 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1756 |
for profile in self.getProfile(): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1757 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1758 |
profile_content = profile.getcontent() |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1759 |
if profile_content is None: |
2031
c6f32810723e
Fix some issues regarding arbitrary variable mapping
laurent
parents:
2030
diff
changeset
|
1760 |
continue |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1761 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1762 |
for content_element in profile_content["value"]: |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1763 |
if content_element["name"] == "Dictionary": |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1764 |
dictionaries.append(content_element["value"]) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1765 |
elif content_element["name"] == "DictionaryFile": |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1766 |
raise ValueError, "DictionaryFile for defining Device Profile is not yet supported!" |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1767 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1768 |
return dictionaries |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1769 |
setattr(cls, "GetProfileDictionaries", GetProfileDictionaries) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1770 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1771 |
def ExtractDataTypes(self): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1772 |
self.DataTypes = {} |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1773 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1774 |
for dictionary in self.GetProfileDictionaries(): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1775 |
dictionary.load() |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1776 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1777 |
datatypes = dictionary.getDataTypes() |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1778 |
if datatypes is not None: |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1779 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1780 |
for datatype in datatypes.getDataType(): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1781 |
content = datatype.getcontent() |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1782 |
if content is not None and content["name"] == "SubItem": |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1783 |
self.DataTypes[datatype.getName()] = datatype |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1784 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1785 |
setattr(cls, "ExtractDataTypes", ExtractDataTypes) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1786 |
|
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1787 |
def getCoE(self): |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1788 |
mailbox = self.getMailbox() |
2079
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1789 |
if mailbox is not None: |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1790 |
return mailbox.getCoE() |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1791 |
return None |
49242019a9ca
Fix C code Generator to use CoE section contained in the slave ESI file for defining Ethercat network configuration
Laurent Bessard
parents:
2077
diff
changeset
|
1792 |
setattr(cls, "getCoE", getCoE) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1793 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1794 |
def GetEntriesList(self, limits=None): |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1795 |
if self.DataTypes is None: |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1796 |
self.ExtractDataTypes() |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1797 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1798 |
entries = {} |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1799 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1800 |
for dictionary in self.GetProfileDictionaries(): |
2074
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
1801 |
dictionary.load() |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1802 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1803 |
for object in dictionary.getObjects().getObject(): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1804 |
entry_index = object.getIndex().getcontent() |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1805 |
index = ExtractHexDecValue(entry_index) |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1806 |
if limits is None or limits[0] <= index <= limits[1]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1807 |
entry_type = object.getType() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1808 |
entry_name = ExtractName(object.getName()) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1809 |
|
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1810 |
entry_type_infos = self.DataTypes.get(entry_type, None) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1811 |
if entry_type_infos is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1812 |
content = entry_type_infos.getcontent() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1813 |
for subitem in content["value"]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1814 |
entry_subidx = subitem.getSubIdx() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1815 |
if entry_subidx is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1816 |
entry_subidx = "0" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1817 |
subidx = ExtractHexDecValue(entry_subidx) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1818 |
subitem_access = "" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1819 |
subitem_pdomapping = "" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1820 |
subitem_flags = subitem.getFlags() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1821 |
if subitem_flags is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1822 |
access = subitem_flags.getAccess() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1823 |
if access is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1824 |
subitem_access = access.getcontent() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1825 |
pdomapping = subitem_flags.getPdoMapping() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1826 |
if pdomapping is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1827 |
subitem_pdomapping = pdomapping.upper() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1828 |
entries[(index, subidx)] = { |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1829 |
"Index": entry_index, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1830 |
"SubIndex": entry_subidx, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1831 |
"Name": "%s - %s" % |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1832 |
(entry_name.decode("utf-8"), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1833 |
ExtractName(subitem.getDisplayName(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1834 |
subitem.getName()).decode("utf-8")), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1835 |
"Type": subitem.getType(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1836 |
"BitSize": subitem.getBitSize(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1837 |
"Access": subitem_access, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1838 |
"PDOMapping": subitem_pdomapping} |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1839 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1840 |
entry_access = "" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1841 |
entry_pdomapping = "" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1842 |
entry_flags = object.getFlags() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1843 |
if entry_flags is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1844 |
access = entry_flags.getAccess() |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1845 |
if access is not None: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1846 |
entry_access = access.getcontent() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1847 |
pdomapping = entry_flags.getPdoMapping() |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
1848 |
if pdomapping is not None: |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1849 |
entry_pdomapping = pdomapping.upper() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1850 |
entries[(index, 0)] = { |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1851 |
"Index": entry_index, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1852 |
"SubIndex": "0", |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1853 |
"Name": entry_name, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1854 |
"Type": entry_type, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1855 |
"BitSize": object.getBitSize(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1856 |
"Access": entry_access, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1857 |
"PDOMapping": entry_pdomapping} |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1858 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1859 |
for TxPdo in self.getTxPdo(): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1860 |
ExtractPdoInfos(TxPdo, "Transmit", entries, limits) |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1861 |
for RxPdo in self.getRxPdo(): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1862 |
ExtractPdoInfos(RxPdo, "Receive", entries, limits) |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1863 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1864 |
return entries |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1865 |
setattr(cls, "GetEntriesList", GetEntriesList) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1866 |
|
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1867 |
def GetSyncManagers(self): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1868 |
sync_managers = [] |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1869 |
for sync_manager in self.getSm(): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1870 |
sync_manager_infos = {} |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1871 |
for name, value in [("Name", sync_manager.getcontent()), |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1872 |
("Start Address", sync_manager.getStartAddress()), |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1873 |
("Default Size", sync_manager.getDefaultSize()), |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1874 |
("Control Byte", sync_manager.getControlByte()), |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1875 |
("Enable", sync_manager.getEnable())]: |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1876 |
if value is None: |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1877 |
value ="" |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1878 |
sync_manager_infos[name] = value |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1879 |
sync_managers.append(sync_manager_infos) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1880 |
return sync_managers |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1881 |
setattr(cls, "GetSyncManagers", GetSyncManagers) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1882 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1883 |
def GroupItemCompare(x, y): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1884 |
if x["type"] == y["type"]: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1885 |
if x["type"] == ETHERCAT_GROUP: |
2031
c6f32810723e
Fix some issues regarding arbitrary variable mapping
laurent
parents:
2030
diff
changeset
|
1886 |
return cmp(x["order"], y["order"]) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1887 |
else: |
2031
c6f32810723e
Fix some issues regarding arbitrary variable mapping
laurent
parents:
2030
diff
changeset
|
1888 |
return cmp(x["name"], y["name"]) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1889 |
elif x["type"] == ETHERCAT_GROUP: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1890 |
return -1 |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1891 |
return 1 |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1892 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1893 |
def SortGroupItems(group): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1894 |
for item in group["children"]: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1895 |
if item["type"] == ETHERCAT_GROUP: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1896 |
SortGroupItems(item) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1897 |
group["children"].sort(GroupItemCompare) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1898 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1899 |
def ExtractName(names, default=None): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1900 |
if len(names) == 1: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1901 |
return names[0].getcontent() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1902 |
else: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1903 |
for name in names: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1904 |
if name.getLcId() == 1033: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1905 |
return name.getcontent() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1906 |
return default |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1907 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1908 |
def ExtractPdoInfos(pdo, pdo_type, entries, limits=None): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1909 |
pdo_index = pdo.getIndex().getcontent() |
2029
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1910 |
pdo_name = ExtractName(pdo.getName()) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1911 |
for pdo_entry in pdo.getEntry(): |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1912 |
entry_index = pdo_entry.getIndex().getcontent() |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1913 |
entry_subindex = pdo_entry.getSubIndex() |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1914 |
index = ExtractHexDecValue(entry_index) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1915 |
subindex = ExtractHexDecValue(entry_subindex) |
7c848efa21c6
Adding support for displaying slave sync managers and profile object dictionary and for arbitrarily mapping variable through variable location
laurent
parents:
2026
diff
changeset
|
1916 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1917 |
if limits is None or limits[0] <= index <= limits[1]: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1918 |
entry = entries.get((index, subindex), None) |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1919 |
if entry is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1920 |
entry["PDO index"] = pdo_index |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1921 |
entry["PDO name"] = pdo_name |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1922 |
entry["PDO type"] = pdo_type |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1923 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1924 |
entry_type = pdo_entry.getDataType() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1925 |
if entry_type is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1926 |
if pdo_type == "Transmit": |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1927 |
access = "ro" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1928 |
pdomapping = "T" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1929 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1930 |
access = "wo" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1931 |
pdomapping = "R" |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1932 |
entries[(index, subindex)] = { |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1933 |
"Index": entry_index, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1934 |
"SubIndex": entry_subindex, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1935 |
"Name": ExtractName(pdo_entry.getName()), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1936 |
"Type": entry_type.getcontent(), |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1937 |
"Access": access, |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1938 |
"PDOMapping": pdomapping} |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1939 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1940 |
DEFAULT_ALIGNMENT = 8 |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1941 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1942 |
class ModulesLibrary: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1943 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1944 |
def __init__(self, path, parent_library=None): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1945 |
self.Path = path |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1946 |
if not os.path.exists(self.Path): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1947 |
os.makedirs(self.Path) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1948 |
self.ParentLibrary = parent_library |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1949 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1950 |
if parent_library is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1951 |
self.LoadModules() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1952 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
1953 |
self.Library = None |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1954 |
self.LoadAlignments() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1955 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1956 |
def GetPath(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1957 |
return self.Path |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1958 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1959 |
def GetAlignmentFilePath(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1960 |
return os.path.join(self.Path, "alignments.cfg") |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1961 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1962 |
def LoadModules(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1963 |
self.Library = {} |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1964 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1965 |
files = os.listdir(self.Path) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1966 |
for file in files: |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1967 |
filepath = os.path.join(self.Path, file) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1968 |
if os.path.isfile(filepath) and os.path.splitext(filepath)[-1] == ".xml": |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1969 |
xmlfile = open(filepath, 'r') |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1970 |
xml_tree = minidom.parse(xmlfile) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1971 |
xmlfile.close() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1972 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1973 |
modules_infos = None |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1974 |
for child in xml_tree.childNodes: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1975 |
if child.nodeType == xml_tree.ELEMENT_NODE and child.nodeName == "EtherCATInfo": |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1976 |
modules_infos = EtherCATInfoClasses["EtherCATInfo.xsd"]["EtherCATInfo"]() |
2051 | 1977 |
modules_infos.loadXMLTree(child) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1978 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1979 |
if modules_infos is not None: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1980 |
vendor = modules_infos.getVendor() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1981 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1982 |
vendor_category = self.Library.setdefault(ExtractHexDecValue(vendor.getId()), |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1983 |
{"name": ExtractName(vendor.getName(), _("Miscellaneous")), |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1984 |
"groups": {}}) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1985 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1986 |
for group in modules_infos.getDescriptions().getGroups().getGroup(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1987 |
group_type = group.getType() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1988 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1989 |
vendor_category["groups"].setdefault(group_type, {"name": ExtractName(group.getName(), group_type), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1990 |
"parent": group.getParentGroup(), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1991 |
"order": group.getSortOrder(), |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1992 |
"devices": []}) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1993 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1994 |
for device in modules_infos.getDescriptions().getDevices().getDevice(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1995 |
device_group = device.getGroupType() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1996 |
if not vendor_category["groups"].has_key(device_group): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1997 |
raise ValueError, "Not such group \"%\"" % device_group |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
1998 |
vendor_category["groups"][device_group]["devices"].append((device.getType().getcontent(), device)) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
1999 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2000 |
def GetModulesLibrary(self, profile_filter=None): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2001 |
if self.Library is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2002 |
self.LoadModules() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2003 |
library = [] |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2004 |
for vendor_id, vendor in self.Library.iteritems(): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2005 |
groups = [] |
2073
d14ab97a452a
Fix bug modules present in all groups with the same name even if they are defined by different vendors
Laurent Bessard
parents:
2069
diff
changeset
|
2006 |
children_dict = {} |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2007 |
for group_type, group in vendor["groups"].iteritems(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2008 |
group_infos = {"name": group["name"], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2009 |
"order": group["order"], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2010 |
"type": ETHERCAT_GROUP, |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2011 |
"infos": None, |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2012 |
"children": children_dict.setdefault(group_type, [])} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2013 |
device_dict = {} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2014 |
for device_type, device in group["devices"]: |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2015 |
if profile_filter is None or profile_filter in device.GetProfileNumbers(): |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2016 |
product_code = device.getType().getProductCode() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2017 |
revision_number = device.getType().getRevisionNo() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2018 |
alignment = self.GetAlignment(vendor_id, product_code, revision_number) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2019 |
device_infos = {"name": ExtractName(device.getName()), |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2020 |
"type": ETHERCAT_DEVICE, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2021 |
"infos": {"device_type": device_type, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2022 |
"vendor": vendor_id, |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2023 |
"product_code": product_code, |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2024 |
"revision_number": revision_number, |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2025 |
"alignment": alignment}, |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2026 |
"children": []} |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2027 |
group_infos["children"].append(device_infos) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2028 |
device_type_occurrences = device_dict.setdefault(device_type, []) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2029 |
device_type_occurrences.append(device_infos) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2030 |
for device_type_occurrences in device_dict.itervalues(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2031 |
if len(device_type_occurrences) > 1: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2032 |
for occurrence in device_type_occurrences: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2033 |
occurrence["name"] += _(" (rev. %s)") % occurrence["infos"]["revision_number"] |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2034 |
if len(group_infos["children"]) > 0: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2035 |
if group["parent"] is not None: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2036 |
parent_children = children_dict.setdefault(group["parent"], []) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2037 |
parent_children.append(group_infos) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2038 |
else: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2039 |
groups.append(group_infos) |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2040 |
if len(groups) > 0: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2041 |
library.append({"name": vendor["name"], |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2042 |
"type": ETHERCAT_VENDOR, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2043 |
"infos": None, |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2044 |
"children": groups}) |
2031
c6f32810723e
Fix some issues regarding arbitrary variable mapping
laurent
parents:
2030
diff
changeset
|
2045 |
library.sort(lambda x, y: cmp(x["name"], y["name"])) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
2046 |
return library |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2047 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2048 |
def GetVendors(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2049 |
return [(vendor_id, vendor["name"]) for vendor_id, vendor in self.Library.items()] |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2050 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2051 |
def GetModuleInfos(self, module_infos): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2052 |
vendor = ExtractHexDecValue(module_infos["vendor"]) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2053 |
vendor_infos = self.Library.get(vendor) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2054 |
if vendor_infos is not None: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2055 |
for group_name, group_infos in vendor_infos["groups"].iteritems(): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2056 |
for device_type, device_infos in group_infos["devices"]: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2057 |
product_code = ExtractHexDecValue(device_infos.getType().getProductCode()) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2058 |
revision_number = ExtractHexDecValue(device_infos.getType().getRevisionNo()) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2059 |
if (product_code == ExtractHexDecValue(module_infos["product_code"]) and |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2060 |
revision_number == ExtractHexDecValue(module_infos["revision_number"])): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2061 |
return device_infos, self.GetAlignment(vendor, product_code, revision_number) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2062 |
return None, None |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2063 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2064 |
def ImportModuleLibrary(self, filepath): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2065 |
if os.path.isfile(filepath): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2066 |
shutil.copy(filepath, self.Path) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2067 |
self.LoadModules() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2068 |
return True |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2069 |
return False |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2070 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2071 |
def LoadAlignments(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2072 |
self.Alignments = {} |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2073 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2074 |
csvfile_path = self.GetAlignmentFilePath() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2075 |
if os.path.exists(csvfile_path): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2076 |
csvfile = open(csvfile_path, "rb") |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2077 |
sample = csvfile.read(1024) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2078 |
csvfile.seek(0) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2079 |
dialect = csv.Sniffer().sniff(sample) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2080 |
has_header = csv.Sniffer().has_header(sample) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2081 |
reader = csv.reader(csvfile, dialect) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2082 |
for row in reader: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2083 |
if has_header: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2084 |
has_header = False |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2085 |
else: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2086 |
try: |
2101
da450992572e
Added code generation for process variables
Laurent Bessard
parents:
2099
diff
changeset
|
2087 |
self.Alignments[tuple(map(int, row[:3]))] = int(row[3]) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2088 |
except: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2089 |
pass |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2090 |
csvfile.close() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2091 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2092 |
def SaveAlignments(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2093 |
csvfile = open(self.GetAlignmentFilePath(), "wb") |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2094 |
writer = csv.writer(csvfile, delimiter=';') |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2095 |
writer.writerow(['Vendor', 'product_code', 'revision_number', 'alignment']) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2096 |
for (vendor, product_code, revision_number), alignment in self.Alignments.iteritems(): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2097 |
writer.writerow([vendor, product_code, revision_number, alignment]) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2098 |
csvfile.close() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2099 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2100 |
def SetAlignment(self, vendor, product_code, revision_number, alignment): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2101 |
vendor = ExtractHexDecValue(vendor) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2102 |
product_code = ExtractHexDecValue(product_code) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2103 |
revision_number = ExtractHexDecValue(revision_number) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2104 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2105 |
self.Alignments[tuple([vendor, product_code, revision_number])] = alignment |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2106 |
self.SaveAlignments() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2107 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2108 |
def GetAlignment(self, vendor, product_code, revision_number): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2109 |
vendor = ExtractHexDecValue(vendor) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2110 |
product_code = ExtractHexDecValue(product_code) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2111 |
revision_number = ExtractHexDecValue(revision_number) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2112 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2113 |
alignment = self.Alignments.get(tuple([vendor, product_code, revision_number])) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2114 |
if alignment is not None: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2115 |
return alignment |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2116 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2117 |
if self.ParentLibrary is not None: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2118 |
return self.ParentLibrary.GetAlignment(vendor, product_code, revision_number) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2119 |
return DEFAULT_ALIGNMENT |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2120 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2121 |
USERDATA_DIR = wx.StandardPaths.Get().GetUserDataDir() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2122 |
if wx.Platform != '__WXMSW__': |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2123 |
USERDATA_DIR += '_files' |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2124 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2125 |
ModulesDatabase = ModulesLibrary( |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2126 |
os.path.join(USERDATA_DIR, "ethercat_modules")) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2127 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2128 |
class RootClass: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2129 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2130 |
CTNChildrenTypes = [("EthercatNode",_EthercatCTN,"Ethercat Master")] |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2131 |
EditorType = LibraryEditor |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2132 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2133 |
def __init__(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2134 |
self.ModulesLibrary = None |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2135 |
self.LoadModulesLibrary() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2136 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2137 |
def GetModulesLibraryPath(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2138 |
return os.path.join(self.CTNPath(), "modules") |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2139 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2140 |
def CTNGenerate_C(self, buildpath, locations): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2141 |
return [],"",False |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2142 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2143 |
def LoadModulesLibrary(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2144 |
if self.ModulesLibrary is None: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2145 |
self.ModulesLibrary = ModulesLibrary(self.GetModulesLibraryPath(), ModulesDatabase) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2146 |
else: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2147 |
self.ModulesLibrary.LoadModulesLibrary() |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2148 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2149 |
def GetModulesDatabaseInstance(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2150 |
return ModulesDatabase |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2151 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2152 |
def GetModulesLibraryInstance(self): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2153 |
return self.ModulesLibrary |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2154 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2155 |
def GetModulesLibrary(self, profile_filter=None): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2156 |
return self.ModulesLibrary.GetModulesLibrary(profile_filter) |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2157 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2158 |
def GetVendors(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2159 |
return self.ModulesLibrary.GetVendors() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
2160 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2161 |
def GetModuleInfos(self, module_infos): |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
2162 |
return self.ModulesLibrary.GetModuleInfos(module_infos) |
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2163 |
|
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
2164 |