1048 def SetEEPROMData(self): |
1048 def SetEEPROMData(self): |
1049 """ |
1049 """ |
1050 Set data based on slave EEPROM. |
1050 Set data based on slave EEPROM. |
1051 """ |
1051 """ |
1052 # sii_dict = { Parameter : (WordAddress, WordSize) } |
1052 # sii_dict = { Parameter : (WordAddress, WordSize) } |
1053 sii_dict= { 'PDIControl' : ( '0', 1), |
1053 sii_dict = { |
1054 'PDIConfiguration' : ( '1', 1), |
1054 'PDIControl' : ( '0', 1), |
1055 'PulseLengthOfSYNCSignals' : ( '2', 1), |
1055 'PDIConfiguration' : ( '1', 1), |
1056 'ExtendedPDIConfiguration' : ( '3', 1), |
1056 'PulseLengthOfSYNCSignals' : ( '2', 1), |
1057 'ConfiguredStationAlias' : ( '4', 1), |
1057 'ExtendedPDIConfiguration' : ( '3', 1), |
1058 'Checksum' : ( '7', 1), |
1058 'ConfiguredStationAlias' : ( '4', 1), |
1059 'VendorID' : ( '8', 2), |
1059 'Checksum' : ( '7', 1), |
1060 'ProductCode' : ( 'a', 2), |
1060 'VendorID' : ( '8', 2), |
1061 'RevisionNumber' : ( 'c', 2), |
1061 'ProductCode' : ( 'a', 2), |
1062 'SerialNumber' : ( 'e', 2), |
1062 'RevisionNumber' : ( 'c', 2), |
1063 'Execution Delay' : ('10', 1), |
1063 'SerialNumber' : ( 'e', 2), |
1064 'Port0Delay' : ('11', 1), |
1064 'Execution Delay' : ('10', 1), |
1065 'Port1Delay' : ('12', 1), |
1065 'Port0Delay' : ('11', 1), |
1066 'BootstrapReceiveMailboxOffset' : ('14', 1), |
1066 'Port1Delay' : ('12', 1), |
1067 'BootstrapReceiveMailboxSize' : ('15', 1), |
1067 'BootstrapReceiveMailboxOffset' : ('14', 1), |
1068 'BootstrapSendMailboxOffset' : ('16', 1), |
1068 'BootstrapReceiveMailboxSize' : ('15', 1), |
1069 'BootstrapSendMailboxSize' : ('17', 1), |
1069 'BootstrapSendMailboxOffset' : ('16', 1), |
1070 'StandardReceiveMailboxOffset' : ('18', 1), |
1070 'BootstrapSendMailboxSize' : ('17', 1), |
1071 'StandardReceiveMailboxSize' : ('19', 1), |
1071 'StandardReceiveMailboxOffset' : ('18', 1), |
1072 'StandardSendMailboxOffset' : ('1a', 1), |
1072 'StandardReceiveMailboxSize' : ('19', 1), |
1073 'StandardSendMailboxSize' : ('1b', 1), |
1073 'StandardSendMailboxOffset' : ('1a', 1), |
1074 'MailboxProtocol' : ('1c', 1), |
1074 'StandardSendMailboxSize' : ('1b', 1), |
1075 'Size' : ('3e', 1), |
1075 'MailboxProtocol' : ('1c', 1), |
1076 'Version' : ('3f', 1), |
1076 'Size' : ('3e', 1), |
1077 'First Category Type/Vendor Specific' : ('40', 1), |
1077 'Version' : ('3f', 1), |
1078 'Following Category Word Size' : ('41', 1), |
1078 'First Category Type/Vendor Specific' : ('40', 1), |
1079 'Category Data' : ('42', 1), |
1079 'Following Category Word Size' : ('41', 1), |
1080 } |
1080 'Category Data' : ('42', 1), |
|
1081 } |
1081 |
1082 |
1082 # Config Data: EEPROM Size, PDI Type, Device Emulation |
1083 # Config Data: EEPROM Size, PDI Type, Device Emulation |
1083 # EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1 |
1084 # EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1 |
1084 eeprom_size = str((int(self.GetWordAddressData( sii_dict.get('Size'), 10 ))+1)/8*1024) |
1085 eeprom_size = str((int(self.GetWordAddressData( sii_dict.get('Size'), 10 ))+1)/8*1024) |
1085 # Find PDI Type in pdiType dictionary |
1086 # Find PDI Type in pdiType dictionary |
1108 # Mailbox |
1109 # Mailbox |
1109 # EEORPOM's word address '1c' indicates supported mailbox protocol. |
1110 # EEORPOM's word address '1c' indicates supported mailbox protocol. |
1110 # each value of mailbox protocol : |
1111 # each value of mailbox protocol : |
1111 # VoE(0x0020), SoE(0x0010), FoE(0x0008), CoE(0x0004), EoE(0x0002), AoE(0x0001) |
1112 # VoE(0x0020), SoE(0x0010), FoE(0x0008), CoE(0x0004), EoE(0x0002), AoE(0x0001) |
1112 supported_mailbox = "" |
1113 supported_mailbox = "" |
1113 mailbox_protocol=["VoE, ", "SoE, ", "FoE, ", "CoE, ", "EoE, ", "AoE, "] |
1114 mailbox_protocol = ["VoE, ", "SoE, ", "FoE, ", "CoE, ", "EoE, ", "AoE, "] |
1114 mailbox_data = "{:0>8b}".format(int(self.GetWordAddressData( sii_dict.get('MailboxProtocol'), 16 ), 16)) |
1115 mailbox_data = "{:0>8b}".format(int(self.GetWordAddressData( sii_dict.get('MailboxProtocol'), 16 ), 16)) |
1115 for protocol in range(6): |
1116 for protocol in range(6): |
1116 if mailbox_data[protocol+2] == '1': |
1117 if mailbox_data[protocol+2] == '1': |
1117 supported_mailbox += mailbox_protocol[protocol] |
1118 supported_mailbox += mailbox_protocol[protocol] |
1118 supported_mailbox = supported_mailbox.strip(", ") |
1119 supported_mailbox = supported_mailbox.strip(", ") |
2029 |
2030 |
2030 # reg_write |
2031 # reg_write |
2031 # ex) ethercat reg_write -p 0 -t uint16 0x0000 0x0000 |
2032 # ex) ethercat reg_write -p 0 -t uint16 0x0000 0x0000 |
2032 return_val = self.Controler.CommonMethod.RegWrite('0x'+self.GetRowLabelValue(event.GetRow()), dlg.GetValue()) |
2033 return_val = self.Controler.CommonMethod.RegWrite('0x'+self.GetRowLabelValue(event.GetRow()), dlg.GetValue()) |
2033 |
2034 |
2034 if len(return_val)==0: |
2035 if len(return_val) == 0: |
2035 # set dec |
2036 # set dec |
2036 self.SetCellValue(event.GetRow(), 1, str(int(dlg.GetValue(), 0))) |
2037 self.SetCellValue(event.GetRow(), 1, str(int(dlg.GetValue(), 0))) |
2037 # set hex |
2038 # set hex |
2038 hex_data = '0x'+"{:0>4x}".format(int(dlg.GetValue(), 0)) |
2039 hex_data = '0x'+"{:0>4x}".format(int(dlg.GetValue(), 0)) |
2039 self.SetCellValue(event.GetRow(), 2, hex_data) |
2040 self.SetCellValue(event.GetRow(), 2, hex_data) |
2040 # set char |
2041 # set char |
2041 char_data = "" |
2042 char_data = "" |
2042 # If hex_data is been able to convert to ascii code, append ascii code. |
2043 # If hex_data is been able to convert to ascii code, append ascii code. |
2043 for iter in range(2): |
2044 for iter in range(2): |
2044 if int(hex_data[(iter+1)*2:(iter+2)*2], 16)>=32 and int(hex_data[(iter+1)*2:(iter+2)*2], 16)<=126: |
2045 if int(hex_data[(iter+1)*2:(iter+2)*2], 16) >= 32 and int(hex_data[(iter+1)*2:(iter+2)*2], 16) <= 126: |
2045 char_data = char_data + chr(int(hex_data[(iter+1)*2:(iter+2)*2], 16)) |
2046 char_data = char_data + chr(int(hex_data[(iter+1)*2:(iter+2)*2], 16)) |
2046 else: |
2047 else: |
2047 char_data = char_data + "." |
2048 char_data = char_data + "." |
2048 |
2049 |
2049 self.SetCellValue(event.GetRow(), 3, char_data) |
2050 self.SetCellValue(event.GetRow(), 3, char_data) |