author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Mon, 25 Nov 2019 08:26:55 +0100 | |
branch | ethercat_from_kosmos |
changeset 2642 | 65701f40d970 |
parent 2641 | c9deff128c37 |
child 2643 | b98d9e08231f |
permissions | -rw-r--r-- |
2165
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
1 |
#!/usr/bin/env python |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
3 |
|
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
4 |
# This file is part of Beremiz |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
5 |
# |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
6 |
# Copyright (C) 2011-2014: Laurent BESSARD, Edouard TISSERANT |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
7 |
# RTES Lab : CRKim, JBLee, youcu |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
8 |
# Higen Motor : Donggu Kang |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
9 |
# |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
02a2b5dee5e3
Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2162
diff
changeset
|
11 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
12 |
import os, shutil |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
13 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
14 |
#from xml.dom import minidom |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
15 |
from lxml import etree |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
16 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
17 |
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
|
18 |
import csv |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
19 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
20 |
from xmlclass import * |
2111 | 21 |
|
2160
75349c51a34b
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
2159
diff
changeset
|
22 |
from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
23 |
from PLCControler import UndoBuffer, LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
2111 | 24 |
|
25 |
from EthercatSlave import ExtractHexDecValue, ExtractName |
|
26 |
from EthercatMaster import _EthercatCTN |
|
27 |
from ConfigEditor import LibraryEditor, ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
28 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
29 |
ScriptDirectory = os.path.split(os.path.realpath(__file__))[0] |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
30 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
31 |
#-------------------------------------------------- |
2048
5726f2bbdace
reflected changes in beremiz extension mechanism
Edouard Tisserant
parents:
2047
diff
changeset
|
32 |
# Ethercat ConfNode |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
33 |
#-------------------------------------------------- |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
34 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
35 |
EtherCATInfoParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATInfo.xsd")) |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
36 |
EtherCATInfo_XPath = lambda xpath: etree.XPath(xpath) |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
37 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
38 |
EtherCATBaseParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATBase.xsd")) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
39 |
EtherCATBase_XPath = lambda xpath1: etree.XPath(xpath1) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
40 |
|
2162
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
41 |
def HexDecValue(context, *args): |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
42 |
return str(ExtractHexDecValue(args[0][0])) |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
43 |
|
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
44 |
def EntryName(context, *args): |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
45 |
return ExtractName(args[0], |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
46 |
args[1][0] if len(args) > 1 else None) |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
47 |
|
2162
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
48 |
ENTRY_INFOS_KEYS = [ |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
49 |
("Index", lambda x: "#x%4.4X" % int(x), "#x0000"), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
50 |
("SubIndex", str, "0"), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
51 |
("Name", str, ""), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
52 |
("Type", str, ""), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
53 |
("BitSize", int, 0), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
54 |
("Access", str, ""), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
55 |
("PDOMapping", str, ""), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
56 |
("PDO index", str, ""), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
57 |
("PDO name", str, ""), |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
58 |
("PDO type", str, "")] |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
59 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
60 |
# Read DefaultValue from ESI file |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
61 |
# Add by jblee 151229 |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
62 |
ENTRY_INFOS_KEYS_FOR_DV = [ |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
63 |
("Index", lambda x: "#x%4.4X" % int(x), "#x0000"), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
64 |
("SubIndex", str, "0"), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
65 |
("Name", str, ""), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
66 |
("Type", str, ""), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
67 |
("BitSize", int, 0), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
68 |
("Access", str, ""), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
69 |
("PDOMapping", str, ""), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
70 |
("DefaultValue", str, ""), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
71 |
("Sub_entry_flag", str, "0")] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
72 |
|
2162
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
73 |
class EntryListFactory: |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
74 |
|
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
75 |
def __init__(self, entries): |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
76 |
self.Entries = entries |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
77 |
|
2162
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
78 |
def AddEntry(self, context, *args): |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
79 |
index, subindex = map(lambda x: int(x[0]), args[:2]) |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
80 |
if len(args) > 9: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
81 |
new_entry_infos = { |
2162
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
82 |
key: translate(arg[0]) if len(arg) > 0 else default |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
83 |
for (key, translate, default), arg |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
84 |
in zip(ENTRY_INFOS_KEYS, args)} |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
85 |
else: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
86 |
new_entry_infos = { |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
87 |
key: translate(arg[0]) if len(arg) > 0 else default |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
88 |
for (key, translate, default), arg |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
89 |
in zip(ENTRY_INFOS_KEYS_FOR_DV, args)} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
90 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
91 |
if (index, subindex) != (0, 0): |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
92 |
entry_infos = self.Entries.get((index, subindex)) |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
93 |
if entry_infos is not None: |
2162
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
94 |
for param in ["PDO index", "PDO name", "PDO type"]: |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
95 |
value = new_entry_infos.get(param) |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
96 |
if value is not None: |
43ab74687f45
Fixed xslt stylesheet for extracting entries defined in module, rewiting xslt stylesheet to yslt
Laurent Bessard
parents:
2160
diff
changeset
|
97 |
entry_infos[param] = value |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
98 |
else: |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
99 |
self.Entries[(index, subindex)] = new_entry_infos |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
100 |
|
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
101 |
entries_list_xslt = etree.parse( |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
102 |
os.path.join(ScriptDirectory, "entries_list.xslt")) |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
103 |
|
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
104 |
cls = EtherCATInfoParser.GetElementClass("DeviceType") |
2074
bf2fa4cb62a9
Adding support for loading Profile dictionaries only if needed
Laurent Bessard
parents:
2073
diff
changeset
|
105 |
if cls: |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
106 |
cls.DataTypes = None |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
107 |
|
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
108 |
profile_numbers_xpath = EtherCATInfo_XPath("Profile/ProfileNo") |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
109 |
def GetProfileNumbers(self): |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
110 |
return [number.text for number in profile_numbers_xpath(self)] |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
111 |
setattr(cls, "GetProfileNumbers", GetProfileNumbers) |
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
112 |
|
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
|
113 |
def getCoE(self): |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
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
|
118 |
setattr(cls, "getCoE", getCoE) |
2032
766078d83e22
Adding support for DS402 node subplugin (only simple state transition implemented)
laurent
parents:
2031
diff
changeset
|
119 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
120 |
# Modify by jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
121 |
def ExtractDataTypes(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
122 |
#self.DataTypes = {} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
123 |
#self.DT = {} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
124 |
DT = {} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
125 |
objects = [] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
126 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
127 |
# get Profile Field |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
128 |
for profile in self.getProfile(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
129 |
# get each (ProfileNo, Dictionary) Field as child |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
130 |
for child in profile.getchildren(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
131 |
# child.text is not None -> ProfileNo, is None -> Dictionary |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
132 |
if child.text is None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
133 |
# get each (DataTypes, Objects) Field |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
134 |
dataTypes = child.getDataTypes() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
135 |
objects = child.getObjects() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
136 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
137 |
for dataType in dataTypes.getDataType(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
138 |
#if dataType.getName() is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
139 |
# print dataType.getName(), dataType |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
140 |
DT[dataType.getName()] = dataType |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
141 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
142 |
return DT, objects |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
143 |
setattr(cls, "ExtractDataTypes", ExtractDataTypes) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
144 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
145 |
def GetEntriesList(self, limits=None): |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
146 |
DataTypes, objects = self.ExtractDataTypes() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
147 |
|
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
|
148 |
entries = {} |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
149 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
150 |
# get each Object Field |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
151 |
for object in objects: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
152 |
# Object Field mendatory : Index, Name, Type, BitSize |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
153 |
# Frequently Use : Info, Flags |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
154 |
# Info Field -> DefaultData, SubItem |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
155 |
# Flags Field -> Access, Category, PdoMapping |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
156 |
object_index = object.getIndex().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
157 |
index = ExtractHexDecValue(object_index) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
158 |
if limits is None or limits[0] <= index <= limits[1]: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
159 |
object_type = object.getType() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
160 |
object_name = ExtractName(object.getName()) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
161 |
object_size = object.getBitSize() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
162 |
defaultData = "" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
163 |
object_access = "" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
164 |
object_PDOMapping_data = "" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
165 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
166 |
object_type_infos = DataTypes.get(object_type, None) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
167 |
subItem_infos = object_type_infos.getchildren() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
168 |
countSubIndex = 0 |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
169 |
if len(subItem_infos) > 2: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
170 |
for subItem_info in subItem_infos: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
171 |
if subItem_info.tag == "SubItem" : |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
172 |
subItemName = subItem_info.getName() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
173 |
subIdx = subItem_info.getSubIdx() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
174 |
if subIdx is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
175 |
object_subidx = ExtractHexDecValue(subIdx) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
176 |
else: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
177 |
object_subidx = ExtractHexDecValue(countSubIndex) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
178 |
subType = subItem_info.getType() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
179 |
subBitSize = subItem_info.getBitSize() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
180 |
subFlags = subItem_info.getFlags() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
181 |
subAccess = "" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
182 |
subPDOMapping_data = "" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
183 |
if subFlags is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
184 |
subAccess = subFlags.getAccess().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
185 |
subPDOMapping = subFlags.getPdoMapping() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
186 |
if subPDOMapping is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
187 |
subPDOMapping_data = subFlags.getPdoMapping().upper() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
188 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
189 |
entries[(index, object_subidx)] = { |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
190 |
"Index": object_index, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
191 |
"SubIndex": subIdx, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
192 |
"Name": "%s - %s" % |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
193 |
(object_name.decode("utf-8"), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
194 |
subItemName.decode("utf-8")), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
195 |
"Type": subType, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
196 |
"BitSize": subBitSize, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
197 |
"Access": subAccess, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
198 |
"PDOMapping": subPDOMapping_data} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
199 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
200 |
countSubIndex += 1 |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
201 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
202 |
info = object.getInfo() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
203 |
# subItemTest : check subItem |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
204 |
countSubIndex = 0 |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
205 |
if info is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
206 |
subItems = info.getchildren() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
207 |
if len(subItems) > 1: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
208 |
for subItem in subItems: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
209 |
defaultdata_subidx = ExtractHexDecValue(countSubIndex) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
210 |
defaultData = subItem.getchildren()[1].findtext("DefaultData") |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
211 |
entry = entries.get((index, defaultdata_subidx), None) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
212 |
if entry is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
213 |
entry["DefaultData"] = defaultData |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
214 |
countSubIndex += 1 |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
215 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
216 |
else : |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
217 |
info = object.getInfo() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
218 |
if info is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
219 |
subItems = info.getchildren() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
220 |
if len(subItems) <= 1: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
221 |
defaultData = subItems[0].text |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
222 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
223 |
object_flag = object.getFlags() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
224 |
object_access = object_flag.getAccess().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
225 |
object_PDOMapping = object_flag.getPdoMapping() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
226 |
if object_PDOMapping is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
227 |
object_PDOMapping_data = object_flag.getPdoMapping().upper() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
228 |
entries[(index, 0)] = { |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
229 |
"Index": object_index, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
230 |
"SubIndex": "0", |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
231 |
"Name": object_name, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
232 |
"Type": object_type, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
233 |
"BitSize": object_size, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
234 |
"DefaultData" : defaultData, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
235 |
"Access": object_access, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
236 |
"PDOMapping": object_PDOMapping_data} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
237 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
238 |
for TxPdo in self.getTxPdo(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
239 |
ExtractPdoInfos(TxPdo, "Transmit", entries, limits) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
240 |
for RxPdo in self.getRxPdo(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
241 |
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
|
242 |
|
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
|
243 |
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
|
244 |
setattr(cls, "GetEntriesList", GetEntriesList) |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
245 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
246 |
# def GetEntriesList(self, limits=None): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
247 |
# entries = {} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
248 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
249 |
# factory = EntryListFactory(entries) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
250 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
251 |
# entries_list_xslt_tree = etree.XSLT( |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
252 |
# entries_list_xslt, extensions = { |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
253 |
# ("entries_list_ns", "AddEntry"): factory.AddEntry, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
254 |
# ("entries_list_ns", "HexDecValue"): HexDecValue, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
255 |
# ("entries_list_ns", "EntryName"): EntryName}) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
256 |
# entries_list_xslt_tree(self, **dict(zip( |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
257 |
# ["min_index", "max_index"], |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
258 |
# map(lambda x: etree.XSLT.strparam(str(x)), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
259 |
# limits if limits is not None else [0x0000, 0xFFFF]) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
260 |
# ))) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
261 |
# |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
262 |
# return entries |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
263 |
# setattr(cls, "GetEntriesList", GetEntriesList) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
264 |
|
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
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
("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
|
271 |
("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
|
272 |
("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
|
273 |
("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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
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
|
280 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
281 |
cls2 = EtherCATInfoParser.GetElementClass("DeviceType") |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
282 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
283 |
def GroupItemCompare(x, y): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
284 |
if x["type"] == y["type"]: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
285 |
if x["type"] == ETHERCAT_GROUP: |
2031
c6f32810723e
Fix some issues regarding arbitrary variable mapping
laurent
parents:
2030
diff
changeset
|
286 |
return cmp(x["order"], y["order"]) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
287 |
else: |
2031
c6f32810723e
Fix some issues regarding arbitrary variable mapping
laurent
parents:
2030
diff
changeset
|
288 |
return cmp(x["name"], y["name"]) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
289 |
elif x["type"] == ETHERCAT_GROUP: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
290 |
return -1 |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
291 |
return 1 |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
292 |
|
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
293 |
def SortGroupItems(group): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
294 |
for item in group["children"]: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
295 |
if item["type"] == ETHERCAT_GROUP: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
296 |
SortGroupItems(item) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
297 |
group["children"].sort(GroupItemCompare) |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
298 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
299 |
def ExtractPdoInfos(pdo, pdo_type, entries, limits=None): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
300 |
pdo_index = pdo.getIndex().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
301 |
pdo_name = ExtractName(pdo.getName()) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
302 |
exclude = pdo.getExclude() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
303 |
for pdo_entry in pdo.getEntry(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
304 |
entry_index = pdo_entry.getIndex().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
305 |
entry_subindex = pdo_entry.getSubIndex() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
306 |
index = ExtractHexDecValue(entry_index) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
307 |
subindex = ExtractHexDecValue(entry_subindex) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
308 |
object_size = pdo_entry.getBitLen() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
309 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
310 |
if limits is None or limits[0] <= index <= limits[1]: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
311 |
entry = entries.get((index, subindex), None) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
312 |
if entry is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
313 |
entry["PDO index"] = pdo_index |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
314 |
entry["PDO name"] = pdo_name |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
315 |
entry["PDO type"] = pdo_type |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
316 |
else: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
317 |
entry_type = pdo_entry.getDataType() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
318 |
if entry_type is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
319 |
if pdo_type == "Transmit": |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
320 |
access = "ro" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
321 |
pdomapping = "T" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
322 |
else: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
323 |
access = "wo" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
324 |
pdomapping = "R" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
325 |
entries[(index, subindex)] = { |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
326 |
"Index": entry_index, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
327 |
"SubIndex": entry_subindex, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
328 |
"Name": ExtractName(pdo_entry.getName()), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
329 |
"Type": entry_type.getcontent(), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
330 |
"BitSize": object_size, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
331 |
"Access": access, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
332 |
"PDOMapping": pdomapping} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
333 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
334 |
#cls3 = EtherCATBaseParser.GetElementClass("ModuleType") |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
335 |
#if cls3: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
336 |
# module_xpath = EtherCATBase_XPath("Descriptions/Modules/Module") |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
337 |
# def test(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
338 |
# print module_xpath |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
339 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
340 |
# setattr(cls, "test", test) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
341 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
342 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
343 |
class ModulesLibrary: |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
344 |
|
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
345 |
MODULES_EXTRA_PARAMS = [ |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
346 |
("pdo_alignment", { |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
347 |
"column_label": _("PDO alignment"), |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
348 |
"column_size": 150, |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
349 |
"default": 8, |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
350 |
"description": _( |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
351 |
"Minimal size in bits between 2 pdo entries")}), |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
352 |
("max_pdo_size", { |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
353 |
"column_label": _("Max entries by PDO"), |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
354 |
"column_size": 150, |
2139
1565239349a8
Added support for module extra params in EthercatCFileGenerator
Laurent Bessard
parents:
2138
diff
changeset
|
355 |
"default": 255, |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
356 |
"description": _( |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
357 |
"""Maximal number of entries mapped in a PDO |
2139
1565239349a8
Added support for module extra params in EthercatCFileGenerator
Laurent Bessard
parents:
2138
diff
changeset
|
358 |
including empty entries used for PDO alignment""")}), |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
359 |
("add_pdo", { |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
360 |
"column_label": _("Creating new PDO"), |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
361 |
"column_size": 150, |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
362 |
"default": 0, |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
363 |
"description": _( |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
364 |
"""Adding a PDO not defined in default configuration |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
365 |
for mapping needed location variables |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
366 |
(1 if possible)""")}) |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
367 |
] |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
368 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
369 |
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
|
370 |
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
|
371 |
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
|
372 |
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
|
373 |
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
|
374 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
375 |
if parent_library is not None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
376 |
self.LoadModules() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
377 |
else: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
378 |
self.Library = None |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
379 |
self.LoadModulesExtraParams() |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
380 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
381 |
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
|
382 |
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
|
383 |
|
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
384 |
def GetModulesExtraParamsFilePath(self): |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
385 |
return os.path.join(self.Path, "modules_extra_params.cfg") |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
386 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
387 |
groups_xpath = EtherCATInfo_XPath("Descriptions/Groups/Group") |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
388 |
devices_xpath = EtherCATInfo_XPath("Descriptions/Devices/Device") |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
389 |
module_xpath = EtherCATBase_XPath("Descriptions/Modules/Module") |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
390 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
391 |
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
|
392 |
self.Library = {} |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
393 |
# add by jblee for Modular Device Profile |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
394 |
self.MDPList = [] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
395 |
self.ModuleList = [] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
396 |
self.MDPEntryList = {} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
397 |
dtDic = {} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
398 |
self.idxIncrement = 0 |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
399 |
self.slotIncrement = 0 |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
400 |
# add by jblee for PDO Mapping |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
401 |
self.DataTypes = {} |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
402 |
self.ObjectDictionary = {} |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
403 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
404 |
files = os.listdir(self.Path) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
405 |
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
|
406 |
filepath = os.path.join(self.Path, file) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
407 |
if os.path.isfile(filepath) and os.path.splitext(filepath)[-1] == ".xml": |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
408 |
self.modules_infos = None |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
409 |
|
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
410 |
xmlfile = open(filepath, 'r') |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
411 |
try: |
2160
75349c51a34b
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
2159
diff
changeset
|
412 |
self.modules_infos, error = EtherCATInfoParser.LoadXMLString(xmlfile.read()) |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
413 |
#if error is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
414 |
# self.GetCTRoot().logger.write_warning( |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
415 |
# XSDSchemaErrorMessage % (filepath + error)) |
2160
75349c51a34b
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
2159
diff
changeset
|
416 |
except Exception, exc: |
75349c51a34b
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
2159
diff
changeset
|
417 |
self.modules_infos, error = None, unicode(exc) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
418 |
xmlfile.close() |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
419 |
|
2152
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2149
diff
changeset
|
420 |
if self.modules_infos is not None: |
e6946c298a42
Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
2149
diff
changeset
|
421 |
vendor = self.modules_infos.getVendor() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
422 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
423 |
vendor_category = self.Library.setdefault( |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
424 |
ExtractHexDecValue(vendor.getId()), |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
425 |
{"name": ExtractName(vendor.getName(), _("Miscellaneous")), |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
426 |
"groups": {}}) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
427 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
428 |
for group in self.groups_xpath(self.modules_infos): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
429 |
group_type = group.getType() |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
430 |
# add for XmlToEeprom Func by jblee. |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
431 |
self.LcId_data = group.getchildren()[1] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
432 |
self.Image16x14_data = group.getchildren()[2] |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
433 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
434 |
vendor_category["groups"].setdefault(group_type, |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
435 |
{"name": ExtractName(group.getName(), group_type), |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
436 |
"parent": group.getParentGroup(), |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
437 |
"order": group.getSortOrder(), |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
438 |
"devices": [], |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
439 |
# add jblee for support Moduler Device Profile (MDP) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
440 |
"modules": []}) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
441 |
|
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
442 |
for device in self.devices_xpath(self.modules_infos): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
443 |
device_group = device.getGroupType() |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
444 |
if not vendor_category["groups"].has_key(device_group): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
445 |
raise ValueError, "Not such group \"%\"" % device_group |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
446 |
vendor_category["groups"][device_group]["devices"].append( |
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
447 |
(device.getType().getcontent(), device)) |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
448 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
449 |
# ------------------ Test Section --------------------# |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
450 |
slots = device.getSlots() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
451 |
if slots is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
452 |
for slot in slots.getSlot(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
453 |
self.idxIncrement = slot.getSlotIndexIncrement() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
454 |
self.slotIncrement = slot.getSlotPdoIncrement() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
455 |
for child in slot.getchildren(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
456 |
if child.tag == "ModuleClass": |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
457 |
child_class = child.getClass() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
458 |
child_name = child.getName() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
459 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
460 |
# -------------------- Test Section ----------------------------------# |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
461 |
LocalMDPList = [] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
462 |
for module in self.module_xpath(self.modules_infos): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
463 |
module_type = module.getType().getModuleClass() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
464 |
module_name = module.getName() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
465 |
LocalMDPData = ExtractName(module_name) + " (" + module_type + ")" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
466 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
467 |
self.ModuleList.append(module) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
468 |
try : |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
469 |
module_pdos = module.getTxPdo() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
470 |
module_pdos += module.getRxPdo() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
471 |
for module_pdo in module_pdos: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
472 |
device_name = ExtractName(module_name) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
473 |
pdo_index = module_pdo.getIndex().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
474 |
pdo_name = ExtractName(module_pdo.getName()) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
475 |
pdo_entry = module_pdo.getEntry() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
476 |
if module_pdo.tag == "TxPdo": |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
477 |
mapping_type = "T" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
478 |
else : |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
479 |
mapping_type = "R" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
480 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
481 |
LocalMDPEntry = [] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
482 |
for entry in pdo_entry: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
483 |
entry_index = entry.getIndex().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
484 |
entry_subidx = entry.getSubIndex() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
485 |
entry_name = ExtractName(entry.getName()) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
486 |
entry_bitsize = entry.getBitLen() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
487 |
try : |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
488 |
entry_type = entry.getDataType().getcontent() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
489 |
except : |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
490 |
entry_type = "" |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
491 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
492 |
LocalMDPEntry.append({ |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
493 |
"Index": entry_index, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
494 |
"SubIndex": entry_subidx, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
495 |
"Name": "%s - %s" % (pdo_name, entry_name), |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
496 |
"Type": entry_type, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
497 |
"BitSize": entry_bitsize, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
498 |
"Access": "", |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
499 |
"PDOMapping": mapping_type}) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
500 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
501 |
self.MDPEntryList[device_name] = LocalMDPEntry |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
502 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
503 |
LocalMDPList.append([LocalMDPData, module, LocalMDPEntry]) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
504 |
except : |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
505 |
LocalMDPList.append([LocalMDPData, module, []]) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
506 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
507 |
if LocalMDPList: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
508 |
vendor_category["groups"][device_group]["modules"].append( |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
509 |
(device.getType().getcontent(), LocalMDPList, self.idxIncrement, self.slotIncrement)) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
510 |
#self.MDPList.append([device.getType().getcontent(), LocalMDPList, |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
511 |
# self.idxIncrement, self.slotIncrement]) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
512 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
513 |
# --------------------------------------------------------------------- # |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
514 |
|
2160
75349c51a34b
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
2159
diff
changeset
|
515 |
else: |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
516 |
pass |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
517 |
#self.GetCTRoot().logger.write_error( |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
518 |
# _("Couldn't load %s XML file:\n%s") % (filepath, error)) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
519 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
520 |
#print self.ObjectDictionary |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
521 |
return self.Library ## add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
522 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
523 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
524 |
def GetMDPList(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
525 |
return self.MDPList |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
526 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
527 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
528 |
def GetSelectModule(self, idx): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
529 |
return self.ModuleList[idx] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
530 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
531 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
532 |
def GetModuleEntryList(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
533 |
return self.MDPEntryList |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
534 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
535 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
536 |
def GetModuleIncrement(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
537 |
return (self.idxIncrement, self.slotIncrement) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
538 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
539 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
540 |
#def GetEntriesList(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
541 |
# return self.ObjectDictionary |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
542 |
|
2041
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
543 |
def GetModulesLibrary(self, profile_filter=None): |
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
544 |
if self.Library is None: |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
545 |
self.LoadModules() |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
546 |
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
|
547 |
for vendor_id, vendor in self.Library.iteritems(): |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
548 |
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
|
549 |
children_dict = {} |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
550 |
for group_type, group in vendor["groups"].iteritems(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
551 |
group_infos = {"name": group["name"], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
552 |
"order": group["order"], |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
553 |
"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
|
554 |
"infos": None, |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
555 |
"children": children_dict.setdefault(group_type, [])} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
556 |
device_dict = {} |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
557 |
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
|
558 |
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
|
559 |
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
|
560 |
revision_number = device.getType().getRevisionNo() |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
561 |
module_infos = {"device_type": device_type, |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
562 |
"vendor": vendor_id, |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
563 |
"product_code": product_code, |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
564 |
"revision_number": revision_number} |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
565 |
module_infos.update(self.GetModuleExtraParams(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
|
566 |
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
|
567 |
"type": ETHERCAT_DEVICE, |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
568 |
"infos": 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
|
569 |
"children": []} |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
570 |
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
|
571 |
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
|
572 |
device_type_occurrences.append(device_infos) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
573 |
for device_type_occurrences in device_dict.itervalues(): |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
574 |
if len(device_type_occurrences) > 1: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
575 |
for occurrence in device_type_occurrences: |
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
576 |
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
|
577 |
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
|
578 |
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
|
579 |
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
|
580 |
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
|
581 |
else: |
ce3727171207
Defining all slaves as Etherlab master subplugin instead of editing them in an editor with vertical notebook
laurent
parents:
2039
diff
changeset
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
"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
|
586 |
"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
|
587 |
"children": groups}) |
2031
c6f32810723e
Fix some issues regarding arbitrary variable mapping
laurent
parents:
2030
diff
changeset
|
588 |
library.sort(lambda x, y: cmp(x["name"], y["name"])) |
2022
c2295d311402
First working implementation of Beremiz plugin for etherlab
laurent
parents:
diff
changeset
|
589 |
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
|
590 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
591 |
def GetVendors(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
592 |
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
|
593 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
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
|
598 |
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
|
599 |
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
|
600 |
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
|
601 |
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
|
602 |
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
|
603 |
revision_number == ExtractHexDecValue(module_infos["revision_number"])): |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
604 |
self.cntdevice = device_infos ## add by hwang 13.05.01. |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
605 |
self.cntdeviceType = device_type ## add by hwang 13.05.01. |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
606 |
return device_infos, self.GetModuleExtraParams(vendor, product_code, revision_number) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
607 |
return None, None |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
608 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
609 |
# add jblee for MDP |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
610 |
def GetMDPInfos(self, module_infos): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
611 |
vendor = ExtractHexDecValue(module_infos["vendor"]) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
612 |
vendor_infos = self.Library.get(vendor) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
613 |
if vendor_infos is not None: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
614 |
for group_name, group_infos in vendor_infos["groups"].iteritems(): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
615 |
return group_infos["modules"] |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
616 |
#for device_type, module_list, idx_inc, slot_inc in group_infos["modules"]: |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
617 |
# return module_list, idx_inc, slot_inc |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
618 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
619 |
#return None, None, 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
|
620 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
621 |
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
|
622 |
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
|
623 |
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
|
624 |
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
|
625 |
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
|
626 |
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
|
627 |
|
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
628 |
def LoadModulesExtraParams(self): |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
629 |
self.ModulesExtraParams = {} |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
630 |
|
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
631 |
csvfile_path = self.GetModulesExtraParamsFilePath() |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
632 |
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
|
633 |
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
|
634 |
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
|
635 |
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
|
636 |
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
|
637 |
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
|
638 |
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
|
639 |
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
|
640 |
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
|
641 |
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
|
642 |
else: |
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
643 |
params_values = {} |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
644 |
for (param, param_infos), value in zip( |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
645 |
self.MODULES_EXTRA_PARAMS, row[3:]): |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
646 |
if value != "": |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
647 |
params_values[param] = int(value) |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
648 |
self.ModulesExtraParams[ |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
649 |
tuple(map(int, row[:3]))] = params_values |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
650 |
csvfile.close() |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
651 |
|
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
652 |
def SaveModulesExtraParams(self): |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
653 |
csvfile = open(self.GetModulesExtraParamsFilePath(), "wb") |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
654 |
extra_params = [param for param, params_infos in self.MODULES_EXTRA_PARAMS] |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
655 |
writer = csv.writer(csvfile, delimiter=';') |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
656 |
writer.writerow(['Vendor', 'product_code', 'revision_number'] + extra_params) |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
657 |
for (vendor, product_code, revision_number), module_extra_params in self.ModulesExtraParams.iteritems(): |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
658 |
writer.writerow([vendor, product_code, revision_number] + |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
659 |
[module_extra_params.get(param, '') |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
660 |
for param in extra_params]) |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
661 |
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
|
662 |
|
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
663 |
def SetModuleExtraParam(self, vendor, product_code, revision_number, param, value): |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
664 |
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
|
665 |
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
|
666 |
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
|
667 |
|
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
668 |
module_infos = (vendor, product_code, revision_number) |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
669 |
self.ModulesExtraParams.setdefault(module_infos, {}) |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
670 |
self.ModulesExtraParams[module_infos][param] = value |
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
671 |
|
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
672 |
self.SaveModulesExtraParams() |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
673 |
|
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
674 |
def GetModuleExtraParams(self, vendor, product_code, revision_number): |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
675 |
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
|
676 |
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
|
677 |
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
|
678 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
679 |
if self.ParentLibrary is not None: |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
680 |
extra_params = self.ParentLibrary.GetModuleExtraParams(vendor, product_code, revision_number) |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
681 |
else: |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
682 |
extra_params = {} |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
683 |
|
2138
79dc2d15c580
Fixed support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2137
diff
changeset
|
684 |
extra_params.update(self.ModulesExtraParams.get((vendor, product_code, revision_number), {})) |
2137
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
685 |
|
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
686 |
for param, param_infos in self.MODULES_EXTRA_PARAMS: |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
687 |
extra_params.setdefault(param, param_infos["default"]) |
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
688 |
|
b65abacdbdf9
Added support for multiple module extra params in ModulesLibrary
Laurent Bessard
parents:
2133
diff
changeset
|
689 |
return extra_params |
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
690 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
691 |
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
|
692 |
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
|
693 |
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
|
694 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
695 |
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
|
696 |
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
|
697 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
698 |
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
|
699 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
700 |
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
|
701 |
EditorType = LibraryEditor |
2157
a2385e535cf5
Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
2152
diff
changeset
|
702 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
703 |
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
|
704 |
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
|
705 |
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
|
706 |
|
2149
7f473761c932
Added icon for Ethercat extension root and Ethercat master node
Laurent Bessard
parents:
2139
diff
changeset
|
707 |
def GetIconName(self): |
7f473761c932
Added icon for Ethercat extension root and Ethercat master node
Laurent Bessard
parents:
2139
diff
changeset
|
708 |
return "Ethercat" |
7f473761c932
Added icon for Ethercat extension root and Ethercat master node
Laurent Bessard
parents:
2139
diff
changeset
|
709 |
|
2133 | 710 |
def GetModulesLibraryPath(self, project_path=None): |
711 |
if project_path is None: |
|
712 |
project_path = self.CTNPath() |
|
713 |
return os.path.join(project_path, "modules") |
|
714 |
||
715 |
def OnCTNSave(self, from_project_path=None): |
|
716 |
if from_project_path is not None: |
|
717 |
shutil.copytree(self.GetModulesLibraryPath(from_project_path), |
|
718 |
self.GetModulesLibraryPath()) |
|
719 |
return True |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
720 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
721 |
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
|
722 |
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
|
723 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
724 |
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
|
725 |
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
|
726 |
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
|
727 |
else: |
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
728 |
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
|
729 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
730 |
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
|
731 |
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
|
732 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
733 |
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
|
734 |
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
|
735 |
|
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
736 |
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
|
737 |
return self.ModulesLibrary.GetModulesLibrary(profile_filter) |
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
738 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
739 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
740 |
def GetMDPList(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
741 |
return self.ModulesLibrary.GetMDPList() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
742 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
743 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
744 |
def GetSelectModule(self, idx): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
745 |
return self.ModulesLibrary.GetSelectModule(idx) |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
746 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
747 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
748 |
def GetModuleEntryList(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
749 |
return self.ModulesLibrary.GetModuleEntryList() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
750 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
751 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
752 |
def GetModuleIncrement(self): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
753 |
return self.ModulesLibrary.GetModuleIncrement() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
754 |
|
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
755 |
# add jblee |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
756 |
#def GetEntriesList(self, limits = None): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
757 |
# return self.ModulesLibrary.GetEntriesList() |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
758 |
|
2098
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
759 |
def GetVendors(self): |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
760 |
return self.ModulesLibrary.GetVendors() |
392791b5cc04
Improved Ethercat Network Configurator panels
Laurent Bessard
parents:
2097
diff
changeset
|
761 |
|
2097
58d07e039896
Added panel for managing ESI files from project and from database including module PDO alignment setting
Laurent Bessard
parents:
2096
diff
changeset
|
762 |
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
|
763 |
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
|
764 |
|
2641
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
765 |
def GetMDPInfos(self, module_infos): |
c9deff128c37
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2165
diff
changeset
|
766 |
return self.ModulesLibrary.GetMDPInfos(module_infos) |