91 Gen_etherlabfile_path = os.path.join(buildpath, "etherlab_ext.c") |
91 Gen_etherlabfile_path = os.path.join(buildpath, "etherlab_ext.c") |
92 ethelabfile = open(Gen_etherlabfile_path, 'w') |
92 ethelabfile = open(Gen_etherlabfile_path, 'w') |
93 ethelabfile.write(etherlab_ext_code) |
93 ethelabfile.write(etherlab_ext_code) |
94 ethelabfile.close() |
94 ethelabfile.close() |
95 |
95 |
96 runtimefile_path = os.path.join(os.path.split(__file__)[0], "runtime_etherlab.py") |
|
97 return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", |
96 return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", |
98 ("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py")))) |
97 ("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py")))) |
99 |
98 |
100 # -------------------------------------------------- |
99 # -------------------------------------------------- |
101 # Ethercat MASTER |
100 # Ethercat MASTER |
302 dialog = BrowseValuesLibraryDialog(app_frame, |
301 dialog = BrowseValuesLibraryDialog(app_frame, |
303 "Ethercat Slave Type", |
302 "Ethercat Slave Type", |
304 self.GetSlaveTypesLibrary()) |
303 self.GetSlaveTypesLibrary()) |
305 if dialog.ShowModal() == wx.ID_OK: |
304 if dialog.ShowModal() == wx.ID_OK: |
306 type_infos = dialog.GetValueInfos() |
305 type_infos = dialog.GetValueInfos() |
307 device, module_extra_params = self.GetModuleInfos(type_infos) |
306 device, _module_extra_params = self.GetModuleInfos(type_infos) |
308 if device is not None: |
307 if device is not None: |
309 if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
308 if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
310 ConfNodeType = "EthercatCIA402Slave" |
309 ConfNodeType = "EthercatCIA402Slave" |
311 else: |
310 else: |
312 ConfNodeType = "EthercatSlave" |
311 ConfNodeType = "EthercatSlave" |
333 if slave_pos is not None and slave.getInfo().getPhysAddr() != slave_pos: |
332 if slave_pos is not None and slave.getInfo().getPhysAddr() != slave_pos: |
334 return False |
333 return False |
335 type_infos = slave.getType() |
334 type_infos = slave.getType() |
336 if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor: |
335 if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor: |
337 return False |
336 return False |
338 device, module_extra_params = self.GetModuleInfos(type_infos) |
337 device, _module_extra_params = self.GetModuleInfos(type_infos) |
339 if slave_profile is not None and slave_profile not in device.GetProfileNumbers(): |
338 if slave_profile is not None and slave_profile not in device.GetProfileNumbers(): |
340 return False |
339 return False |
341 return True |
340 return True |
342 |
341 |
343 def GetSlaveName(self, slave_pos): |
342 def GetSlaveName(self, slave_pos): |
472 type_infos = { |
471 type_infos = { |
473 "vendor": slave["vendor_id"], |
472 "vendor": slave["vendor_id"], |
474 "product_code": slave["product_code"], |
473 "product_code": slave["product_code"], |
475 "revision_number": slave["revision_number"], |
474 "revision_number": slave["revision_number"], |
476 } |
475 } |
477 device, module_extra_params = self.GetModuleInfos(type_infos) |
476 device, _module_extra_params = self.GetModuleInfos(type_infos) |
478 if device is not None: |
477 if device is not None: |
479 if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
478 if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
480 CTNType = "EthercatCIA402Slave" |
479 CTNType = "EthercatCIA402Slave" |
481 else: |
480 else: |
482 CTNType = "EthercatSlave" |
481 CTNType = "EthercatSlave" |
566 |
565 |
567 def GetSlaveInfos(self, slave_pos): |
566 def GetSlaveInfos(self, slave_pos): |
568 slave = self.GetSlave(slave_pos) |
567 slave = self.GetSlave(slave_pos) |
569 if slave is not None: |
568 if slave is not None: |
570 type_infos = slave.getType() |
569 type_infos = slave.getType() |
571 device, module_extra_params = self.GetModuleInfos(type_infos) |
570 device, _module_extra_params = self.GetModuleInfos(type_infos) |
572 if device is not None: |
571 if device is not None: |
573 infos = type_infos.copy() |
572 infos = type_infos.copy() |
574 infos.update({"physics": device.getPhysics(), |
573 infos.update({"physics": device.getPhysics(), |
575 "sync_managers": device.GetSyncManagers(), |
574 "sync_managers": device.GetSyncManagers(), |
576 "entries": self.GetSlaveVariables(device)}) |
575 "entries": self.GetSlaveVariables(device)}) |
580 def GetSlaveVariables(self, slave_pos=None, limits=None, device=None): |
579 def GetSlaveVariables(self, slave_pos=None, limits=None, device=None): |
581 if device is None and slave_pos is not None: |
580 if device is None and slave_pos is not None: |
582 slave = self.GetSlave(slave_pos) |
581 slave = self.GetSlave(slave_pos) |
583 if slave is not None: |
582 if slave is not None: |
584 type_infos = slave.getType() |
583 type_infos = slave.getType() |
585 device, module_extra_params = self.GetModuleInfos(type_infos) |
584 device, _module_extra_params = self.GetModuleInfos(type_infos) |
586 if device is not None: |
585 if device is not None: |
587 entries = device.GetEntriesList(limits) |
586 entries = device.GetEntriesList(limits) |
588 entries_list = entries.items() |
587 entries_list = entries.items() |
589 entries_list.sort() |
588 entries_list.sort() |
590 entries = [] |
589 entries = [] |
591 current_index = None |
590 current_index = None |
592 current_entry = {} |
591 current_entry = {} |
593 for (index, subindex), entry in entries_list: |
592 for (index, _subindex), entry in entries_list: |
594 entry["children"] = [] |
593 entry["children"] = [] |
595 if slave_pos is not None: |
594 if slave_pos is not None: |
596 entry["Position"] = str(slave_pos) |
595 entry["Position"] = str(slave_pos) |
597 if index != current_index: |
596 if index != current_index: |
598 current_index = index |
597 current_index = index |
606 return [] |
605 return [] |
607 |
606 |
608 def GetSlaveVariableDataType(self, slave_pos, index, subindex): |
607 def GetSlaveVariableDataType(self, slave_pos, index, subindex): |
609 slave = self.GetSlave(slave_pos) |
608 slave = self.GetSlave(slave_pos) |
610 if slave is not None: |
609 if slave is not None: |
611 device, module_extra_params = self.GetModuleInfos(slave.getType()) |
610 device, _module_extra_params = self.GetModuleInfos(slave.getType()) |
612 if device is not None: |
611 if device is not None: |
613 entries = device.GetEntriesList() |
612 entries = device.GetEntriesList() |
614 entry_infos = entries.get((index, subindex)) |
613 entry_infos = entries.get((index, subindex)) |
615 if entry_infos is not None: |
614 if entry_infos is not None: |
616 return entry_infos["Type"] |
615 return entry_infos["Type"] |
623 continue |
622 continue |
624 slave = self.GetSlave(slave_position) |
623 slave = self.GetSlave(slave_position) |
625 type_infos = slave.getType() |
624 type_infos = slave.getType() |
626 if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor: |
625 if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor: |
627 continue |
626 continue |
628 device, module_extra_params = self.GetModuleInfos(type_infos) |
627 device, _module_extra_params = self.GetModuleInfos(type_infos) |
629 if slave_profile is not None and slave_profile not in device.GetProfileNumbers(): |
628 if slave_profile is not None and slave_profile not in device.GetProfileNumbers(): |
630 continue |
629 continue |
631 entries.extend(self.GetSlaveVariables(slave_position, limits, device)) |
630 entries.extend(self.GetSlaveVariables(slave_position, limits, device)) |
632 return entries |
631 return entries |
633 |
632 |
644 slave = self.GetSlave(slave_pos) |
643 slave = self.GetSlave(slave_pos) |
645 vars = [] |
644 vars = [] |
646 if slave is not None: |
645 if slave is not None: |
647 type_infos = slave.getType() |
646 type_infos = slave.getType() |
648 |
647 |
649 device, module_extra_params = self.GetModuleInfos(type_infos) |
648 device, _module_extra_params = self.GetModuleInfos(type_infos) |
650 if device is not None: |
649 if device is not None: |
651 sync_managers = [] |
650 sync_managers = [] |
652 for sync_manager in device.getSm(): |
651 for sync_manager in device.getSm(): |
653 sync_manager_control_byte = ExtractHexDecValue(sync_manager.getControlByte()) |
652 sync_manager_control_byte = ExtractHexDecValue(sync_manager.getControlByte()) |
654 sync_manager_direction = sync_manager_control_byte & 0x0c |
653 sync_manager_direction = sync_manager_control_byte & 0x0c |