473 type_infos = slave.getType() |
475 type_infos = slave.getType() |
474 device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
476 device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
475 |
477 |
476 # 'device' represents current slave device selected by user |
478 # 'device' represents current slave device selected by user |
477 if device is not None: |
479 if device is not None: |
478 for eeprom_element in device.getEeprom().getcontent()["value"]: |
480 for eeprom_element in device.getEeprom().getcontent(): |
479 # get EEPROM size; <Device>-<Eeprom>-<ByteSize> |
481 # get EEPROM size; <Device>-<Eeprom>-<ByteSize> |
480 if eeprom_element["name"] == "ByteSize": |
482 if eeprom_element["name"] == "ByteSize": |
481 smartview_infos["eeprom_size"] = eeprom_element["value"] |
483 smartview_infos["eeprom_size"] = eeprom_element |
482 |
484 |
483 elif eeprom_element["name"] == "ConfigData": |
485 elif eeprom_element["name"] == "ConfigData": |
484 configData_data = self.DecimalToHex(eeprom_element["value"]) |
486 configData_data = self.DecimalToHex(eeprom_element) |
485 # get PDI type; <Device>-<Eeprom>-<ConfigData> address 0x00 |
487 # get PDI type; <Device>-<Eeprom>-<ConfigData> address 0x00 |
486 smartview_infos["pdi_type"] = int(configData_data[0:2], 16) |
488 smartview_infos["pdi_type"] = int(configData_data[0:2], 16) |
487 # get state of device emulation; <Device>-<Eeprom>-<ConfigData> address 0x01 |
489 # get state of device emulation; <Device>-<Eeprom>-<ConfigData> address 0x01 |
488 if "{:0>8b}".format(int(configData_data[2:4], 16))[7] == '1': |
490 if "{:0>8b}".format(int(configData_data[2:4], 16))[7] == '1': |
489 smartview_infos["device_emulation"] = "True" |
491 smartview_infos["device_emulation"] = "True" |
490 |
492 |
491 elif eeprom_element["name"] == "BootStrap": |
493 elif eeprom_element["name"] == "BootStrap": |
492 bootstrap_data = "{:0>16x}".format(eeprom_element["value"]) |
494 bootstrap_data = "{:0>16x}".format(eeprom_element) |
493 # get bootstrap configuration; <Device>-<Eeprom>-<BootStrap> |
495 # get bootstrap configuration; <Device>-<Eeprom>-<BootStrap> |
494 for cfg, iter in [("mailbox_bootstrapconf_outstart", 0), |
496 for cfg, iter in [("mailbox_bootstrapconf_outstart", 0), |
495 ("mailbox_bootstrapconf_outlength", 1), |
497 ("mailbox_bootstrapconf_outlength", 1), |
496 ("mailbox_bootstrapconf_instart", 2), |
498 ("mailbox_bootstrapconf_instart", 2), |
497 ("mailbox_bootstrapconf_inlength", 3)]: |
499 ("mailbox_bootstrapconf_inlength", 3)]: |
498 smartview_infos[cfg] = str(int(bootstrap_data[4*iter+2:4*(iter+1)]+bootstrap_data[4*iter:4*iter+2], 16)) |
500 smartview_infos[cfg] = str(int(bootstrap_data[4*iter+2:4*(iter+1)]+bootstrap_data[4*iter:4*iter+2], 16)) |
499 |
501 |
500 # get protocol (profile) types supported by mailbox; <Device>-<Mailbox> |
502 # get protocol (profile) types supported by mailbox; <Device>-<Mailbox> |
501 for mailbox_protocol in ["VoE", "SoE", "FoE", "CoE", "EoE", "AoE"]: |
503 mb = device.getMailbox() |
502 if eval("device.getMailbox().get%s()"%mailbox_protocol) is not None: |
504 if mb is not None: |
503 smartview_infos["supported_mailbox"] += "%s, "%mailbox_protocol |
505 for mailbox_protocol in mailbox_protocols: |
|
506 if getattr(mb,"get%s"%mailbox_protocol)() is not None: |
|
507 smartview_infos["supported_mailbox"] += "%s, "%mailbox_protocol |
504 smartview_infos["supported_mailbox"] = smartview_infos["supported_mailbox"].strip(", ") |
508 smartview_infos["supported_mailbox"] = smartview_infos["supported_mailbox"].strip(", ") |
505 |
509 |
506 # get standard configuration of mailbox; <Device>-<Sm> |
510 # get standard configuration of mailbox; <Device>-<Sm> |
507 for sm_element in device.getSm(): |
511 for sm_element in device.getSm(): |
508 if sm_element.getcontent() == "MBoxOut": |
512 if sm_element.getcontent() == "MBoxOut": |
680 type_infos = slave.getType() |
684 type_infos = slave.getType() |
681 device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
685 device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos) |
682 |
686 |
683 if device is not None: |
687 if device is not None: |
684 # get ConfigData for EEPROM offset 0x0000-0x000d; <Device>-<Eeprom>-<ConfigData> |
688 # get ConfigData for EEPROM offset 0x0000-0x000d; <Device>-<Eeprom>-<ConfigData> |
685 for eeprom_element in device.getEeprom().getcontent()["value"]: |
689 for eeprom_element in device.getEeprom().getcontent(): |
686 if eeprom_element["name"] == "ConfigData": |
690 if eeprom_element["name"] == "ConfigData": |
687 data = self.DecimalToHex(eeprom_element["value"]) |
691 data = self.DecimalToHex(eeprom_element) |
688 eeprom += self.GenerateEEPROMList(data, 0, 28) |
692 eeprom += self.GenerateEEPROMList(data, 0, 28) |
689 |
693 |
690 # calculate CRC for EEPROM offset 0x000e-0x000f |
694 # calculate CRC for EEPROM offset 0x000e-0x000f |
691 crc = 0x48 |
695 crc = 0x48 |
692 for segment in eeprom: |
696 for segment in eeprom: |
743 eeprom.append("00") |
747 eeprom.append("00") |
744 eeprom.append("00") |
748 eeprom.append("00") |
745 |
749 |
746 # get BootStrap for EEPROM offset 0x0028-0x002e; <Device>-<Eeprom>-<BootStrap> |
750 # get BootStrap for EEPROM offset 0x0028-0x002e; <Device>-<Eeprom>-<BootStrap> |
747 data = "" |
751 data = "" |
748 for eeprom_element in device.getEeprom().getcontent()["value"]: |
752 for eeprom_element in device.getEeprom().getcontent(): |
749 if eeprom_element["name"] == "BootStrap": |
753 if eeprom_element["name"] == "BootStrap": |
750 data = "{:0>16x}".format(eeprom_element["value"]) |
754 data = "{:0>16x}".format(eeprom_element) |
751 eeprom += self.GenerateEEPROMList(data, 0, 16) |
755 eeprom += self.GenerateEEPROMList(data, 0, 16) |
752 |
756 |
753 # get Standard Mailbox for EEPROM offset 0x0030-0x0037; <Device>-<sm> |
757 # get Standard Mailbox for EEPROM offset 0x0030-0x0037; <Device>-<sm> |
754 data = "" |
758 data = "" |
|
759 standard_send_mailbox_offset = None |
|
760 standard_send_mailbox_size = None |
|
761 standard_receive_mailbox_offset = None |
|
762 standard_receive_mailbox_size = None |
755 for sm_element in device.getSm(): |
763 for sm_element in device.getSm(): |
756 if sm_element.getcontent() == "MBoxOut": |
764 if sm_element.getcontent() == "MBoxOut": |
757 standard_receive_mailbox_offset = "{:0>4x}".format(ExtractHexDecValue(sm_element.getStartAddress())) |
765 standard_receive_mailbox_offset = "{:0>4x}".format(ExtractHexDecValue(sm_element.getStartAddress())) |
758 standard_receive_mailbox_size = "{:0>4x}".format(ExtractHexDecValue(sm_element.getDefaultSize())) |
766 standard_receive_mailbox_size = "{:0>4x}".format(ExtractHexDecValue(sm_element.getDefaultSize())) |
759 elif sm_element.getcontent() == "MBoxIn": |
767 elif sm_element.getcontent() == "MBoxIn": |
785 eeprom.append(standard_send_mailbox_size[2:4]) |
793 eeprom.append(standard_send_mailbox_size[2:4]) |
786 eeprom.append(standard_send_mailbox_size[0:2]) |
794 eeprom.append(standard_send_mailbox_size[0:2]) |
787 |
795 |
788 # get supported mailbox protocols for EEPROM offset 0x0038-0x0039; |
796 # get supported mailbox protocols for EEPROM offset 0x0038-0x0039; |
789 data = 0 |
797 data = 0 |
790 for mbox, bit in [(device.getMailbox().getAoE(), 0), |
798 mb = device.getMailbox() |
791 (device.getMailbox().getEoE(), 1), |
799 if mb is not None : |
792 (device.getMailbox().getCoE(), 2), |
800 for bit,mbprot in enumerate(mailbox_protocols): |
793 (device.getMailbox().getFoE(), 3), |
801 if getattr(mb,"get%s"%mbprot)() is not None: |
794 (device.getMailbox().getSoE(), 4), |
802 data += 1<<bit |
795 (device.getMailbox().getVoE(), 5)]: |
|
796 if mbox is not None: |
|
797 data += 1<<bit |
|
798 data = "{:0>4x}".format(data) |
803 data = "{:0>4x}".format(data) |
799 eeprom.append(data[2:4]) |
804 eeprom.append(data[2:4]) |
800 eeprom.append(data[0:2]) |
805 eeprom.append(data[0:2]) |
801 |
806 |
802 # resereved for EEPROM offset 0x003a-0x007b; |
807 # resereved for EEPROM offset 0x003a-0x007b; |
803 for i in range(0x007b-0x003a+0x0001): |
808 for i in range(0x007b-0x003a+0x0001): |
804 eeprom.append("00") |
809 eeprom.append("00") |
805 |
810 |
806 # get EEPROM size for EEPROM offset 0x007c-0x007d; |
811 # get EEPROM size for EEPROM offset 0x007c-0x007d; |
807 data = "" |
812 data = "" |
808 for eeprom_element in device.getEeprom().getcontent()["value"]: |
813 for eeprom_element in device.getEeprom().getcontent(): |
809 if eeprom_element["name"] == "ByteSize": |
814 if eeprom_element["name"] == "ByteSize": |
810 eeprom_size = int(str(eeprom_element["value"])) |
815 eeprom_size = int(str(eeprom_element)) |
811 data = "{:0>4x}".format(int(eeprom_element["value"])/1024*8-1) |
816 data = "{:0>4x}".format(int(eeprom_element)/1024*8-1) |
812 |
817 |
813 if data == "": |
818 if data == "": |
814 eeprom.append("00") |
819 eeprom.append("00") |
815 eeprom.append("00") |
820 eeprom.append("00") |
816 else: |
821 else: |
1023 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
1028 if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None: |
1024 for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
1029 for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems(): |
1025 for group_type, group_etc in vendor["groups"].iteritems(): |
1030 for group_type, group_etc in vendor["groups"].iteritems(): |
1026 for device_item in group_etc["devices"]: |
1031 for device_item in group_etc["devices"]: |
1027 if device == device_item[1]: |
1032 if device == device_item[1]: |
1028 data = group_etc["value"] |
1033 data = group_etc |
1029 if data is not None and type(data) == unicode: |
1034 if data is not None and type(data) == unicode: |
1030 for vendor_spec_string in vendor_spec_strings: |
1035 for vendor_spec_string in vendor_spec_strings: |
1031 if data == vendor_spec_string: |
1036 if data == vendor_spec_string: |
1032 self.ImgIdx = vendor_spec_strings.index(data)+1 |
1037 self.ImgIdx = vendor_spec_strings.index(data)+1 |
1033 imageflag = True |
1038 imageflag = True |
1181 |
1186 |
1182 # word 3 : Physical Layer Port info. and CoE Details |
1187 # word 3 : Physical Layer Port info. and CoE Details |
1183 eeprom.append("01") # Physical Layer Port info - assume 01 |
1188 eeprom.append("01") # Physical Layer Port info - assume 01 |
1184 # CoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE> |
1189 # CoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE> |
1185 coe_details = 0 |
1190 coe_details = 0 |
1186 if device.getMailbox().getCoE() is not None: |
1191 mb = device.getMailbox() |
1187 coe_details = 1 # sdo enabled |
1192 coe_details = 1 # sdo enabled |
1188 for attr, bit in [(device.getMailbox().getCoE().getSdoInfo(), 1), |
1193 if mb is not None : |
1189 (device.getMailbox().getCoE().getPdoAssign(), 2), |
1194 coe = mb.getCoE() |
1190 (device.getMailbox().getCoE().getPdoConfig(), 3), |
1195 if coe is not None: |
1191 (device.getMailbox().getCoE().getPdoUpload(), 4), |
1196 for bit,flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig", |
1192 (device.getMailbox().getCoE().getCompleteAccess(), 5)]: |
1197 "PdoUpload", "CompleteAccess"]): |
1193 if attr==1 or attr==True: |
1198 if getattr(coe,"get%s"%flag)() is not None: |
1194 coe_details += 1<<bit |
1199 coe_details += 1<<bit |
1195 eeprom.append("{:0>2x}".format(coe_details)) |
1200 eeprom.append("{:0>2x}".format(coe_details)) |
1196 |
1201 |
1197 # word 4 : FoE Details and EoE Details |
1202 # word 4 : FoE Details and EoE Details |
1198 # FoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<FoE> |
1203 # FoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<FoE> |
1199 if device.getMailbox().getFoE() is not None: |
1204 if mb is not None and mb.getFoE() is not None: |
1200 eeprom.append("01") |
1205 eeprom.append("01") |
1201 else: |
1206 else: |
1202 eeprom.append("00") |
1207 eeprom.append("00") |
1203 # EoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<EoE> |
1208 # EoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<EoE> |
1204 if device.getMailbox().getEoE() is not None: |
1209 if mb is not None and mb.getEoE() is not None: |
1205 eeprom.append("01") |
1210 eeprom.append("01") |
1206 else: |
1211 else: |
1207 eeprom.append("00") |
1212 eeprom.append("00") |
1208 |
1213 |
1209 # word 5 : SoE Channels(reserved) and DS402 Channels |
1214 # word 5 : SoE Channels(reserved) and DS402 Channels |
1210 # SoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<SoE> |
1215 # SoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<SoE> |
1211 if device.getMailbox().getSoE() is not None: |
1216 if mb is not None and mb.getSoE() is not None: |
1212 eeprom.append("01") |
1217 eeprom.append("01") |
1213 else: |
1218 else: |
1214 eeprom.append("00") |
1219 eeprom.append("00") |
1215 # DS402Channels; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE>: DS402Channels |
1220 # DS402Channels; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE>: DS402Channels |
1216 if device.getMailbox().getCoE().getDS402Channels() == True \ |
1221 ds402ch = False |
1217 or device.getMailbox().getCoE().getDS402Channels() == 1: |
1222 if mb is not None : |
1218 eeprom.append("01") |
1223 coe = mb.getCoE() |
1219 else: |
1224 if coe is not None : |
1220 eeprom.append("00") |
1225 ds402ch = coe.getDS402Channels() |
|
1226 eeprom.append("01" if ds402ch in [True,1] else "00") |
1221 |
1227 |
1222 # word 6 : SysmanClass(reserved) and Flags |
1228 # word 6 : SysmanClass(reserved) and Flags |
1223 eeprom.append("00") # reserved |
1229 eeprom.append("00") # reserved |
1224 # Flags |
1230 # Flags |
1225 en_safeop = False |
1231 en_safeop = False |