5 # |
5 # |
6 # Copyright (C) 2013: Real-Time & Embedded Systems (RTES) Lab., University of Seoul |
6 # Copyright (C) 2013: Real-Time & Embedded Systems (RTES) Lab., University of Seoul |
7 # |
7 # |
8 # See COPYING file for copyrights details. |
8 # See COPYING file for copyrights details. |
9 |
9 |
10 from __future__ import absolute_import |
10 |
11 from __future__ import division |
11 |
12 import os |
12 import os |
13 import string |
13 import string |
14 from xml.dom import minidom |
14 from xml.dom import minidom |
15 |
15 |
16 import wx |
16 import wx |
329 @param controler: _EthercatSlaveCTN class in EthercatSlave.py |
329 @param controler: _EthercatSlaveCTN class in EthercatSlave.py |
330 """ |
330 """ |
331 wx.Panel.__init__(self, parent, -1) |
331 wx.Panel.__init__(self, parent, -1) |
332 |
332 |
333 self.DatatypeDescription, self.CommunicationObject, self.ManufacturerSpecific, \ |
333 self.DatatypeDescription, self.CommunicationObject, self.ManufacturerSpecific, \ |
334 self.ProfileSpecific, self.Reserved, self.AllSDOData = range(6) |
334 self.ProfileSpecific, self.Reserved, self.AllSDOData = list(range(6)) |
335 |
335 |
336 self.Controler = controler |
336 self.Controler = controler |
337 |
337 |
338 self.SDOMonitorEntries = {} |
338 self.SDOMonitorEntries = {} |
339 #----------------------------- SDO Monitor -------------------------------# |
339 #----------------------------- SDO Monitor -------------------------------# |
416 There are two selections that are on and off. |
416 There are two selections that are on and off. |
417 If the on is selected, the monitor thread begins to run. |
417 If the on is selected, the monitor thread begins to run. |
418 If the off is selected, the monitor thread gets off. |
418 If the off is selected, the monitor thread gets off. |
419 @param event: wx.EVT_RADIOBOX object |
419 @param event: wx.EVT_RADIOBOX object |
420 """ |
420 """ |
421 on, off = range(2) |
421 on, off = list(range(2)) |
422 |
422 |
423 if event.GetInt() == on: |
423 if event.GetInt() == on: |
424 CheckThreadFlag = self.SDOMonitoringThreadOn() |
424 CheckThreadFlag = self.SDOMonitoringThreadOn() |
425 if not CheckThreadFlag: |
425 if not CheckThreadFlag: |
426 self.SDOMonitorRB.SetSelection(off) |
426 self.SDOMonitorRB.SetSelection(off) |
453 self.Controler.GetCTRoot()._connector.SetSDOTraceValues(SDOMonitorEntries, SlavePos) |
453 self.Controler.GetCTRoot()._connector.SetSDOTraceValues(SDOMonitorEntries, SlavePos) |
454 |
454 |
455 def SDOMonitorThreadProc(self): |
455 def SDOMonitorThreadProc(self): |
456 while self.SDOMonitoringFlag and self.Controler.GetCTRoot()._connector.PLCStatus != "Started": |
456 while self.SDOMonitoringFlag and self.Controler.GetCTRoot()._connector.PLCStatus != "Started": |
457 self.SDOValuesList = self.Controler.GetCTRoot()._connector.GetSDOData() |
457 self.SDOValuesList = self.Controler.GetCTRoot()._connector.GetSDOData() |
458 LocalData = self.SDOValuesList[0].items() |
458 LocalData = list(self.SDOValuesList[0].items()) |
459 LocalData.sort() |
459 LocalData.sort() |
460 if self.SDOValuesList[1] != self.Controler.GetSlavePos(): |
460 if self.SDOValuesList[1] != self.Controler.GetSlavePos(): |
461 continue |
461 continue |
462 row = 0 |
462 row = 0 |
463 for (idx, subidx), data in LocalData: |
463 for (idx, subidx), data in LocalData: |
506 def SDOParserXML(self, entries): |
506 def SDOParserXML(self, entries): |
507 """ |
507 """ |
508 Parse SDO data set that obtain "ESI file" |
508 Parse SDO data set that obtain "ESI file" |
509 @param entries: SDO entry list |
509 @param entries: SDO entry list |
510 """ |
510 """ |
511 entries_list = entries.items() |
511 entries_list = list(entries.items()) |
512 entries_list.sort() |
512 entries_list.sort() |
513 self.ForDefaultValueFlag = False |
513 self.ForDefaultValueFlag = False |
514 self.CompareValue = "" |
514 self.CompareValue = "" |
515 self.sub_entry_value_list = [] |
515 self.sub_entry_value_list = [] |
516 |
516 |
517 for (index, subidx), entry in entries_list: |
517 for (index, subidx), entry in entries_list: |
518 # exclude entry that isn't in the objects |
518 # exclude entry that isn't in the objects |
519 check_mapping = entry["PDOMapping"] |
519 check_mapping = entry["PDOMapping"] |
520 if check_mapping is "T" or check_mapping is "R": |
520 if check_mapping is "T" or check_mapping is "R": |
521 if "PDO index" not in entry.keys(): |
521 if "PDO index" not in list(entry.keys()): |
522 continue |
522 continue |
523 |
523 |
524 idx = "0" + entry["Index"].strip("#") |
524 idx = "0" + entry["Index"].strip("#") |
525 #subidx = hex(int(entry["SubIndex"], 0)) |
525 #subidx = hex(int(entry["SubIndex"], 0)) |
526 try : |
526 try : |
791 pass |
791 pass |
792 |
792 |
793 SDOPanel.SDOMonitorGrid.AppendRows(len(SDOPanel.SDOMonitorEntries)) |
793 SDOPanel.SDOMonitorGrid.AppendRows(len(SDOPanel.SDOMonitorEntries)) |
794 SDOPanel.SetSDOTraceValues(SDOPanel.SDOMonitorEntries) |
794 SDOPanel.SetSDOTraceValues(SDOPanel.SDOMonitorEntries) |
795 |
795 |
796 SME_list = SDOPanel.SDOMonitorEntries.items() |
796 SME_list = list(SDOPanel.SDOMonitorEntries.items()) |
797 SME_list.sort() |
797 SME_list.sort() |
798 |
798 |
799 gridRow = 0 |
799 gridRow = 0 |
800 for (idx, subIdx), entry in SME_list: |
800 for (idx, subIdx), entry in SME_list: |
801 SDOPanel.SDOMonitorGrid.SetCellValue(gridRow, 0, str(idx)) |
801 SDOPanel.SDOMonitorGrid.SetCellValue(gridRow, 0, str(idx)) |
1545 Set data based on XML initially |
1545 Set data based on XML initially |
1546 """ |
1546 """ |
1547 # Config Data: EEPROM Size, PDI Type, Device Emulation |
1547 # Config Data: EEPROM Size, PDI Type, Device Emulation |
1548 # Find PDI Type in pdiType dictionary |
1548 # Find PDI Type in pdiType dictionary |
1549 cnt_pdi_type = self.Controler.CommonMethod.SmartViewInfosFromXML["pdi_type"] |
1549 cnt_pdi_type = self.Controler.CommonMethod.SmartViewInfosFromXML["pdi_type"] |
1550 for i in self.PDIType.keys(): |
1550 for i in list(self.PDIType.keys()): |
1551 if cnt_pdi_type == i: |
1551 if cnt_pdi_type == i: |
1552 cnt_pdi_type = self.PDIType[i][0] |
1552 cnt_pdi_type = self.PDIType[i][0] |
1553 break |
1553 break |
1554 # Set Config Data |
1554 # Set Config Data |
1555 for treelist, data in [("EEPROM Size (Bytes)", |
1555 for treelist, data in [("EEPROM Size (Bytes)", |
1625 # Config Data: EEPROM Size, PDI Type, Device Emulation |
1625 # Config Data: EEPROM Size, PDI Type, Device Emulation |
1626 # EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1 |
1626 # EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1 |
1627 eeprom_size = str((int(self.GetWordAddressData(sii_dict.get('Size'), 10))+1)//8*1024) |
1627 eeprom_size = str((int(self.GetWordAddressData(sii_dict.get('Size'), 10))+1)//8*1024) |
1628 # Find PDI Type in pdiType dictionary |
1628 # Find PDI Type in pdiType dictionary |
1629 cnt_pdi_type = int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16).split('x')[1][2:4], 16) |
1629 cnt_pdi_type = int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16).split('x')[1][2:4], 16) |
1630 for i in self.PDIType.keys(): |
1630 for i in list(self.PDIType.keys()): |
1631 if cnt_pdi_type == i: |
1631 if cnt_pdi_type == i: |
1632 cnt_pdi_type = self.PDIType[i][0] |
1632 cnt_pdi_type = self.PDIType[i][0] |
1633 break |
1633 break |
1634 # Get Device Emulation |
1634 # Get Device Emulation |
1635 device_emulation = str(bool(int("{:0>16b}".format(int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16), 16))[7]))) |
1635 device_emulation = str(bool(int("{:0>16b}".format(int(self.GetWordAddressData(sii_dict.get('PDIControl'), 16), 16))[7]))) |
2104 # If it depends on the property(ESC type, PDI type, FMMU number, SM number) |
2104 # If it depends on the property(ESC type, PDI type, FMMU number, SM number) |
2105 for property, type, value in [("esc", "type", self.ESCType), |
2105 for property, type, value in [("esc", "type", self.ESCType), |
2106 ("pdi", "type", self.PDIType), |
2106 ("pdi", "type", self.PDIType), |
2107 ("fmmu", "number", self.FMMUNumber), |
2107 ("fmmu", "number", self.FMMUNumber), |
2108 ("sm", "number", self.SMNumber)]: |
2108 ("sm", "number", self.SMNumber)]: |
2109 if property in register.attributes.keys(): |
2109 if property in list(register.attributes.keys()): |
2110 if type == "type": |
2110 if type == "type": |
2111 if register.attributes[property].value == value: |
2111 if register.attributes[property].value == value: |
2112 self.GetRegisterInfo(reg_info_tree, register) |
2112 self.GetRegisterInfo(reg_info_tree, register) |
2113 break |
2113 break |
2114 else: # type == "number" |
2114 else: # type == "number" |
2151 # If it depends on the property(ESC type, PDI type, FMMU number, SM number) |
2151 # If it depends on the property(ESC type, PDI type, FMMU number, SM number) |
2152 for property, type, value in [("esc", "type", self.ESCType), |
2152 for property, type, value in [("esc", "type", self.ESCType), |
2153 ("pdi", "type", self.PDIType), |
2153 ("pdi", "type", self.PDIType), |
2154 ("fmmu", "number", self.FMMUNumber), |
2154 ("fmmu", "number", self.FMMUNumber), |
2155 ("sm", "number", self.SMNumber)]: |
2155 ("sm", "number", self.SMNumber)]: |
2156 if property in detail.attributes.keys(): |
2156 if property in list(detail.attributes.keys()): |
2157 if type == "type": |
2157 if type == "type": |
2158 if detail.attributes[property].value == value: |
2158 if detail.attributes[property].value == value: |
2159 self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail) |
2159 self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail) |
2160 break |
2160 break |
2161 else: # type == "number" |
2161 else: # type == "number" |
2520 |
2520 |
2521 address = self.GetRowLabelValue(event.GetRow()) |
2521 address = self.GetRowLabelValue(event.GetRow()) |
2522 |
2522 |
2523 reg_sub_grid_data = [] |
2523 reg_sub_grid_data = [] |
2524 |
2524 |
2525 BIT_RANGE, NAME, DESCRIPTIONS = range(3) |
2525 BIT_RANGE, NAME, DESCRIPTIONS = list(range(3)) |
2526 |
2526 |
2527 # Check if this register's detail description is exist or not, |
2527 # Check if this register's detail description is exist or not, |
2528 # and create data structure for the detail description table ; sub grid |
2528 # and create data structure for the detail description table ; sub grid |
2529 if address in self.RegisterAccessPanel.RegisterSubGridDict: |
2529 if address in self.RegisterAccessPanel.RegisterSubGridDict: |
2530 for element in self.RegisterAccessPanel.RegisterSubGridDict[address]: |
2530 for element in self.RegisterAccessPanel.RegisterSubGridDict[address]: |