32 # -------------------------------------------------- |
32 # -------------------------------------------------- |
33 |
33 |
34 EtherCATInfoParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATInfo.xsd")) |
34 EtherCATInfoParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATInfo.xsd")) |
35 EtherCATInfo_XPath = lambda xpath: etree.XPath(xpath) |
35 EtherCATInfo_XPath = lambda xpath: etree.XPath(xpath) |
36 |
36 |
|
37 |
37 def HexDecValue(context, *args): |
38 def HexDecValue(context, *args): |
38 return str(ExtractHexDecValue(args[0][0])) |
39 return str(ExtractHexDecValue(args[0][0])) |
|
40 |
39 |
41 |
40 def EntryName(context, *args): |
42 def EntryName(context, *args): |
41 return ExtractName(args[0], |
43 return ExtractName(args[0], |
42 args[1][0] if len(args) > 1 else None) |
44 args[1][0] if len(args) > 1 else None) |
43 |
45 |
50 ("Access", str, ""), |
52 ("Access", str, ""), |
51 ("PDOMapping", str, ""), |
53 ("PDOMapping", str, ""), |
52 ("PDO index", str, ""), |
54 ("PDO index", str, ""), |
53 ("PDO name", str, ""), |
55 ("PDO name", str, ""), |
54 ("PDO type", str, "")] |
56 ("PDO type", str, "")] |
|
57 |
55 |
58 |
56 class EntryListFactory: |
59 class EntryListFactory: |
57 |
60 |
58 def __init__(self, entries): |
61 def __init__(self, entries): |
59 self.Entries = entries |
62 self.Entries = entries |
126 sync_manager_infos[name] = value |
129 sync_manager_infos[name] = value |
127 sync_managers.append(sync_manager_infos) |
130 sync_managers.append(sync_manager_infos) |
128 return sync_managers |
131 return sync_managers |
129 setattr(cls, "GetSyncManagers", GetSyncManagers) |
132 setattr(cls, "GetSyncManagers", GetSyncManagers) |
130 |
133 |
|
134 |
131 def GroupItemCompare(x, y): |
135 def GroupItemCompare(x, y): |
132 if x["type"] == y["type"]: |
136 if x["type"] == y["type"]: |
133 if x["type"] == ETHERCAT_GROUP: |
137 if x["type"] == ETHERCAT_GROUP: |
134 return cmp(x["order"], y["order"]) |
138 return cmp(x["order"], y["order"]) |
135 else: |
139 else: |
136 return cmp(x["name"], y["name"]) |
140 return cmp(x["name"], y["name"]) |
137 elif x["type"] == ETHERCAT_GROUP: |
141 elif x["type"] == ETHERCAT_GROUP: |
138 return -1 |
142 return -1 |
139 return 1 |
143 return 1 |
140 |
144 |
|
145 |
141 def SortGroupItems(group): |
146 def SortGroupItems(group): |
142 for item in group["children"]: |
147 for item in group["children"]: |
143 if item["type"] == ETHERCAT_GROUP: |
148 if item["type"] == ETHERCAT_GROUP: |
144 SortGroupItems(item) |
149 SortGroupItems(item) |
145 group["children"].sort(GroupItemCompare) |
150 group["children"].sort(GroupItemCompare) |
|
151 |
146 |
152 |
147 class ModulesLibrary: |
153 class ModulesLibrary: |
148 |
154 |
149 MODULES_EXTRA_PARAMS = [ |
155 MODULES_EXTRA_PARAMS = [ |
150 ("pdo_alignment", { |
156 ("pdo_alignment", { |
382 USERDATA_DIR += '_files' |
388 USERDATA_DIR += '_files' |
383 |
389 |
384 ModulesDatabase = ModulesLibrary( |
390 ModulesDatabase = ModulesLibrary( |
385 os.path.join(USERDATA_DIR, "ethercat_modules")) |
391 os.path.join(USERDATA_DIR, "ethercat_modules")) |
386 |
392 |
|
393 |
387 class RootClass: |
394 class RootClass: |
388 |
395 |
389 CTNChildrenTypes = [("EthercatNode",_EthercatCTN,"Ethercat Master")] |
396 CTNChildrenTypes = [("EthercatNode",_EthercatCTN,"Ethercat Master")] |
390 EditorType = LibraryEditor |
397 EditorType = LibraryEditor |
391 |
398 |