48 details_line = details_line.strip() |
48 details_line = details_line.strip() |
49 for header, param in [("Vendor Id:", "vendor_id"), |
49 for header, param in [("Vendor Id:", "vendor_id"), |
50 ("Product code:", "product_code"), |
50 ("Product code:", "product_code"), |
51 ("Revision number:", "revision_number")]: |
51 ("Revision number:", "revision_number")]: |
52 if details_line.startswith(header): |
52 if details_line.startswith(header): |
53 slave[param] = int(details_line.split()[-1], 16) |
53 slave[param] = details_line.split()[-1] |
54 break |
54 break |
55 slaves.append(slave) |
55 slaves.append(slave) |
56 returnVal = slaves |
56 returnVal = slaves |
57 """ |
57 """ |
58 |
58 |
353 for slave in self.Config.getConfig().getSlave(): |
353 for slave in self.Config.getConfig().getSlave(): |
354 slave_info = slave.getInfo() |
354 slave_info = slave.getInfo() |
355 if slave_info.getPhysAddr() == slave_pos: |
355 if slave_info.getPhysAddr() == slave_pos: |
356 return slave |
356 return slave |
357 return None |
357 return None |
|
358 |
|
359 def _ScanNetwork(self): |
|
360 app_frame = self.GetPlugRoot().AppFrame |
|
361 |
|
362 execute = True |
|
363 if len(self.PluggedChilds) > 0: |
|
364 dialog = wx.MessageDialog(app_frame, |
|
365 _("The current network configuration will be deleted.\nDo you want to continue?"), |
|
366 _("Scan Network"), |
|
367 wx.YES_NO|wx.ICON_QUESTION) |
|
368 execute = dialog.ShowModal() == wx.ID_YES |
|
369 dialog.Destroy() |
|
370 |
|
371 if execute: |
|
372 error, returnVal = self.RemoteExec(SCAN_COMMAND, returnVal = None) |
|
373 if error != 0: |
|
374 dialog = wx.MessageDialog(app_frame, returnVal, "Error", wx.OK|wx.ICON_ERROR) |
|
375 dialog.ShowModal() |
|
376 dialog.Destroy() |
|
377 elif returnVal is not None: |
|
378 for child in self.IECSortedChilds(): |
|
379 self._doRemoveChild(child) |
|
380 |
|
381 for slave in returnVal: |
|
382 type_infos = { |
|
383 "vendor": slave["vendor_id"], |
|
384 "product_code": slave["product_code"], |
|
385 "revision_number":slave["revision_number"], |
|
386 } |
|
387 device = self.GetModuleInfos(type_infos) |
|
388 if device is not None: |
|
389 if HAS_MCL and _EthercatDS402SlavePlug.NODE_PROFILE in device.GetProfileNumbers(): |
|
390 PlugType = "EthercatDS402Slave" |
|
391 else: |
|
392 PlugType = "EthercatSlave" |
|
393 self.PlugAddChild("slave%s" % slave["idx"], PlugType, slave["idx"]) |
|
394 self.SetSlaveAlias(slave["idx"], slave["alias"]) |
|
395 type_infos["device_type"] = device.getType().getcontent() |
|
396 self.SetSlaveType(slave["idx"], type_infos) |
358 |
397 |
359 def PlugAddChild(self, PlugName, PlugType, IEC_Channel=0): |
398 def PlugAddChild(self, PlugName, PlugType, IEC_Channel=0): |
360 """ |
399 """ |
361 Create the plugins that may be added as child to this node self |
400 Create the plugins that may be added as child to this node self |
362 @param PlugType: string desining the plugin class name (get name from PlugChildsTypes) |
401 @param PlugType: string desining the plugin class name (get name from PlugChildsTypes) |
534 [(Gen_Ethercatfile_path, '"-I%s"'%os.path.abspath(self.GetPlugRoot().GetIECLibPath()))], |
573 [(Gen_Ethercatfile_path, '"-I%s"'%os.path.abspath(self.GetPlugRoot().GetIECLibPath()))], |
535 True)) |
574 True)) |
536 LDFLAGS.append("-lethercat -lrtdm") |
575 LDFLAGS.append("-lethercat -lrtdm") |
537 |
576 |
538 return LocationCFilesAndCFLAGS, LDFLAGS, extra_files |
577 return LocationCFilesAndCFLAGS, LDFLAGS, extra_files |
|
578 |
|
579 PluginMethods = [ |
|
580 {"bitmap" : os.path.join("images", "Compiler"), |
|
581 "name" : _("Scan Network"), |
|
582 "tooltip" : _("Scan Network"), |
|
583 "method" : "_ScanNetwork"}, |
|
584 ] |
539 |
585 |
540 def PlugGenerate_C(self, buildpath, locations): |
586 def PlugGenerate_C(self, buildpath, locations): |
541 """ |
587 """ |
542 Generate C code |
588 Generate C code |
543 @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) |
589 @param current_location: Tupple containing plugin IEC location : %I0.0.4.5 => (0,0,4,5) |
1366 if vendor is not None: |
1412 if vendor is not None: |
1367 for group_name, group in vendor["groups"].iteritems(): |
1413 for group_name, group in vendor["groups"].iteritems(): |
1368 for device_type, device in group["devices"]: |
1414 for device_type, device in group["devices"]: |
1369 product_code = ExtractHexDecValue(device.getType().getProductCode()) |
1415 product_code = ExtractHexDecValue(device.getType().getProductCode()) |
1370 revision_number = ExtractHexDecValue(device.getType().getRevisionNo()) |
1416 revision_number = ExtractHexDecValue(device.getType().getRevisionNo()) |
1371 if (device_type == type_infos["device_type"] and |
1417 if (product_code == ExtractHexDecValue(type_infos["product_code"]) and |
1372 product_code == ExtractHexDecValue(type_infos["product_code"]) and |
|
1373 revision_number == ExtractHexDecValue(type_infos["revision_number"])): |
1418 revision_number == ExtractHexDecValue(type_infos["revision_number"])): |
1374 return device |
1419 return device |
1375 return None |
1420 return None |
1376 |
1421 |
1377 |
1422 |