equal
deleted
inserted
replaced
4 import wx |
4 import wx |
5 import csv |
5 import csv |
6 |
6 |
7 from xmlclass import * |
7 from xmlclass import * |
8 |
8 |
9 from ConfigTreeNode import ConfigTreeNode |
9 from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage |
10 from PLCControler import UndoBuffer, LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
10 from PLCControler import UndoBuffer, LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
11 |
11 |
12 from EthercatSlave import ExtractHexDecValue, ExtractName |
12 from EthercatSlave import ExtractHexDecValue, ExtractName |
13 from EthercatMaster import _EthercatCTN |
13 from EthercatMaster import _EthercatCTN |
14 from ConfigEditor import LibraryEditor, ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE |
14 from ConfigEditor import LibraryEditor, ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE |
201 if os.path.isfile(filepath) and os.path.splitext(filepath)[-1] == ".xml": |
201 if os.path.isfile(filepath) and os.path.splitext(filepath)[-1] == ".xml": |
202 self.modules_infos = None |
202 self.modules_infos = None |
203 |
203 |
204 xmlfile = open(filepath, 'r') |
204 xmlfile = open(filepath, 'r') |
205 try: |
205 try: |
206 self.modules_infos = etree.fromstring( |
206 self.modules_infos, error = EtherCATInfoParser.LoadXMLString(xmlfile.read()) |
207 xmlfile.read(), EtherCATInfoParser) |
207 if error is not None: |
208 except: |
208 self.GetCTRoot().logger.write_warning( |
209 pass |
209 XSDSchemaErrorMessage % (filepath + error)) |
|
210 except Exception, exc: |
|
211 self.modules_infos, error = None, unicode(exc) |
210 xmlfile.close() |
212 xmlfile.close() |
211 |
213 |
212 if self.modules_infos is not None: |
214 if self.modules_infos is not None: |
213 vendor = self.modules_infos.getVendor() |
215 vendor = self.modules_infos.getVendor() |
214 |
216 |
231 device_group = device.getGroupType() |
233 device_group = device.getGroupType() |
232 if not vendor_category["groups"].has_key(device_group): |
234 if not vendor_category["groups"].has_key(device_group): |
233 raise ValueError, "Not such group \"%\"" % device_group |
235 raise ValueError, "Not such group \"%\"" % device_group |
234 vendor_category["groups"][device_group]["devices"].append( |
236 vendor_category["groups"][device_group]["devices"].append( |
235 (device.getType().getcontent(), device)) |
237 (device.getType().getcontent(), device)) |
236 |
238 |
237 return self.Library |
239 else: |
|
240 |
|
241 self.GetCTRoot().logger.write_error( |
|
242 _("Couldn't load %s XML file:\n%s") % (filepath, error)) |
|
243 |
|
244 return self.Library |
238 |
245 |
239 def GetModulesLibrary(self, profile_filter=None): |
246 def GetModulesLibrary(self, profile_filter=None): |
240 if self.Library is None: |
247 if self.Library is None: |
241 self.LoadModules() |
248 self.LoadModules() |
242 library = [] |
249 library = [] |