def convert_compile_load():
    # Comment this if don't wont to compile model again

    # ###################################################
    # # Convert the model
    converter = Converter("psim", netlist_path)
    tse_path = converter.convert_schema(compile_model=False)[0]
    cpd_path = tse_path[:-4] + " Target files\\" + tse_path.split("\\")[-1][:-4] + ".cpd"
    # Open the converted tse file
    model.load(tse_path)
    # Compile the model
    model.compile()
    ###################################################

    # Load to VHIL
    hil.load_model(file=cpd_path, offlineMode=False, vhil_device=vhil)
Пример #2
0
def convert_xml2tse(create_psim_netxml):
    # Converts the psim xml netlist to tse
    netxml_path = create_psim_netxml[1]
    converter = Converter("psim", netxml_path)
    tse_path = converter.convert_schema(compile_model=False)[0]
    return tse_path
Пример #3
0
def convert_slx2tse(slx_path):
    # Converts the Simulink .slx file to .tse
    converter = Converter("simulink", slx_path)
    tse_path = converter.convert_schema(compile_model=False)[0]
    return tse_path
Пример #4
0
def convert_to_tse(source_file_format, input_file_path):
    converter = Converter(source_file_format, input_file_path)
    tse_path = converter.convert_schema(compile_model=False)[0]
    return tse_path
Пример #5
0
    def on_convert_btn_clicked(self):
        self.progress_bar.config(value=20)
        source_type = self.model_source_cb.get()
        try:
            self.converter = \
                Converter(source_file_format=source_type,
                          input_file_path=self.input_file_path)
        except Exception as ex:
            self.progress_bar.config(value=0)
            self.report_text.config(state="normal")
            self.report_text.delete('1.0', tk.END)
            self.report_text.insert(
                tk.END, f"Invalid file selected for "
                f"{source_type} conversion.\n"
                f"Exception thrown: {ex}")
            self.report_text.config(state="disabled")
            return
        device = self.device.replace(" ", "")
        try:
            tse_path, compiled, report_path = \
                self.converter.convert_schema(device_id=device,
                                              config_id=self.configuration_id,
                                              compile_model=True)

        except SchApiException as ex:
            self.progress_bar.config(value=0)
            self.report_text.config(state="normal")
            self.report_text.delete('1.0', tk.END)
            self.report_text.insert(
                tk.END, "Error converting selected netlist."
                "Please check the validity of the file.")
            self.report_text.config(state="disabled")
            return
        self.progress_bar.config(value=100)
        with open(report_path, "r") as report:
            scrollbar = tk.Scrollbar(self.report_area,
                                     command=self.report_text.yview)
            scrollbar.grid(row=0, column=1, sticky="nsew")
            self.report_text.config(yscrollcommand=scrollbar.set)

            self.report_text.config(state="normal")
            self.report_text.delete('1.0', tk.END)
            valid_report = "--------------------------------\n"
            if compiled:
                valid_report += "Model has been compiled successfully."
            else:
                valid_report += "Model compilation failed."
            valid_report += "\n--------------------------------\n\n"
            self.report_text.insert(tk.END, valid_report)
            self.report_text.insert(tk.END, report.read())
            self.report_text.config(state="disabled")
        with open(self.converter.parser.detailed_log_path, "r") as log:
            log_text = log.read()
            # If any errors are present
            if log_text:
                self.report_text.config(state="normal")
                self.report_text.insert(
                    tk.END, "\n\nDetailed error log\n"
                    "--------------------------------\n")
                self.report_text.insert(tk.END, log_text)
                self.report_text.config(state="disabled")
Пример #6
0
                                 f"of the HIL device ."
                                 f"(default: {DEFAULT_CONFIG})",
                            required=False,
                            default=DEFAULT_CONFIG)

    arg_parser.add_argument("--compile",
                            help=f"Should the converted model "
                                 f"be compiled? Allowed values are True "
                                 f"or False (default: {DEFAULT_COMPILE})",
                            type=input_is_true,
                            required=False,
                            default=DEFAULT_COMPILE)

    args = arg_parser.parse_args()
    # All args' (Namespace class) attributes are dynamically added
    # and named by the add_argument method of the arg_parser.
    # The .model attribute holds the path to the input model (netlist) file
    if args.model is None:
        root = tkinter.Tk()
        root.resizable(width=False, height=False)
        MainApplication(root).grid(row=0, column=1)
        root.mainloop()
    else:
        converter = Converter(source_file_format=args.source,
                              input_file_path=args.model,
                              rule_file_path=args.rules)
        converter.convert_schema(device_id=args.device,
                                 config_id=args.config,
                                 compile_model=args.compile)
        print("Done. Check the report.txt file located in "
              "the source file's folder for more info.")