81 etherlab_ext_file = open(GetLocalPath("etherlab_ext.c"), 'r') |
81 etherlab_ext_file = open(GetLocalPath("etherlab_ext.c"), 'r') |
82 etherlab_ext_code = etherlab_ext_file.read() |
82 etherlab_ext_code = etherlab_ext_file.read() |
83 etherlab_ext_file.close() |
83 etherlab_ext_file.close() |
84 |
84 |
85 Gen_etherlabfile_path = os.path.join(buildpath, "etherlab_ext.c") |
85 Gen_etherlabfile_path = os.path.join(buildpath, "etherlab_ext.c") |
86 ethelabfile = open(Gen_etherlabfile_path,'w') |
86 ethelabfile = open(Gen_etherlabfile_path, 'w') |
87 ethelabfile.write(etherlab_ext_code) |
87 ethelabfile.write(etherlab_ext_code) |
88 ethelabfile.close() |
88 ethelabfile.close() |
89 |
89 |
90 runtimefile_path = os.path.join(os.path.split(__file__)[0], "runtime_etherlab.py") |
90 runtimefile_path = os.path.join(os.path.split(__file__)[0], "runtime_etherlab.py") |
91 return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", |
91 return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "", |
460 |
460 |
461 for slave in returnVal: |
461 for slave in returnVal: |
462 type_infos = { |
462 type_infos = { |
463 "vendor": slave["vendor_id"], |
463 "vendor": slave["vendor_id"], |
464 "product_code": slave["product_code"], |
464 "product_code": slave["product_code"], |
465 "revision_number":slave["revision_number"], |
465 "revision_number": slave["revision_number"], |
466 } |
466 } |
467 device, module_extra_params = self.GetModuleInfos(type_infos) |
467 device, module_extra_params = self.GetModuleInfos(type_infos) |
468 if device is not None: |
468 if device is not None: |
469 if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
469 if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers(): |
470 CTNType = "EthercatCIA402Slave" |
470 CTNType = "EthercatCIA402Slave" |
676 return self.ChangesToSave or not self.ModelIsSaved() |
676 return self.ChangesToSave or not self.ModelIsSaved() |
677 |
677 |
678 def OnCTNSave(self, from_project_path=None): |
678 def OnCTNSave(self, from_project_path=None): |
679 config_filepath = self.ConfigFileName() |
679 config_filepath = self.ConfigFileName() |
680 |
680 |
681 config_xmlfile = open(config_filepath,"w") |
681 config_xmlfile = open(config_filepath, "w") |
682 config_xmlfile.write(etree.tostring( |
682 config_xmlfile.write(etree.tostring( |
683 self.Config, |
683 self.Config, |
684 pretty_print=True, |
684 pretty_print=True, |
685 xml_declaration=True, |
685 xml_declaration=True, |
686 encoding='utf-8')) |
686 encoding='utf-8')) |
687 config_xmlfile.close() |
687 config_xmlfile.close() |
688 |
688 |
689 process_filepath = self.ProcessVariablesFileName() |
689 process_filepath = self.ProcessVariablesFileName() |
690 |
690 |
691 process_xmlfile = open(process_filepath,"w") |
691 process_xmlfile = open(process_filepath, "w") |
692 process_xmlfile.write(etree.tostring( |
692 process_xmlfile.write(etree.tostring( |
693 self.ProcessVariables, |
693 self.ProcessVariables, |
694 pretty_print=True, |
694 pretty_print=True, |
695 xml_declaration=True, |
695 xml_declaration=True, |
696 encoding='utf-8')) |
696 encoding='utf-8')) |
703 return "__M%s_%s" % (self.GetSizeOfType(var_type), "_".join(map(str, location))) |
703 return "__M%s_%s" % (self.GetSizeOfType(var_type), "_".join(map(str, location))) |
704 |
704 |
705 def _Generate_C(self, buildpath, locations): |
705 def _Generate_C(self, buildpath, locations): |
706 current_location = self.GetCurrentLocation() |
706 current_location = self.GetCurrentLocation() |
707 # define a unique name for the generated C file |
707 # define a unique name for the generated C file |
708 location_str = "_".join(map(lambda x:str(x), current_location)) |
708 location_str = "_".join(map(lambda x: str(x), current_location)) |
709 |
709 |
710 Gen_Ethercatfile_path = os.path.join(buildpath, "ethercat_%s.c" % location_str) |
710 Gen_Ethercatfile_path = os.path.join(buildpath, "ethercat_%s.c" % location_str) |
711 |
711 |
712 self.FileGenerator = _EthercatCFileGenerator(self) |
712 self.FileGenerator = _EthercatCFileGenerator(self) |
713 |
713 |
769 slave_pos = loc[0] |
769 slave_pos = loc[0] |
770 if slave_pos in slaves and len(loc) == 3 and location["DIR"] != "M": |
770 if slave_pos in slaves and len(loc) == 3 and location["DIR"] != "M": |
771 self.FileGenerator.DeclareVariable( |
771 self.FileGenerator.DeclareVariable( |
772 slave_pos, loc[1], loc[2], location["IEC_TYPE"], location["DIR"], location["NAME"]) |
772 slave_pos, loc[1], loc[2], location["IEC_TYPE"], location["DIR"], location["NAME"]) |
773 |
773 |
774 return [],"",False |
774 return [], "", False |
775 |
775 |
776 # ------------------------------------------------------------------------------- |
776 # ------------------------------------------------------------------------------- |
777 # Current Buffering Management Functions |
777 # Current Buffering Management Functions |
778 # ------------------------------------------------------------------------------- |
778 # ------------------------------------------------------------------------------- |
779 |
779 |