OneCompiler

run1

143

Example heading with h2 size

Example heading with h3 size

Following is sample java code.

import sys
import os
import time

import win32com
from win32com.client import Dispatch
import common_defination as common_def
from Auto import model_root

# clr.AddReference("ASAM.XIL.Implementation.TestbenchFactory, Version=2.1.0.0, Culture=neutral, PublicKeyToken=fc9d65855b27d387")
# clr.AddReference("ASAM.XIL.Interfaces, Version=2.1.0.0, Culture=neutral, PublicKeyToken=bf471dff114ae984")
# clr.AddReference("ASAM.XIL.Implementation.FrameworkFactory, Version=2.1.0.0, Culture=neutral, PublicKeyToken=d64b0277da8a2c74")
#
# #Import XIL API.NET classes from the .NET assemblies
# from ASAM.XIL.Implementation.TestbenchFactory.Testbench import TestbenchFactory
# from ASAM.XIL.Interfaces.Testbench.Common.Error import TestbenchPortException
# from ASAM.XIL.Interfaces.Testbench.MAPort.Enum import MAPortState
#
# MAPortConfigFile = "D:\AUD_FRAMEWORK\python_files\MAPortConfigSCALEXIO.xml"
#
# # batteryvolt = "Model Root/I0UserInterface/IO_PAR/Simulator/Power_Supply/Voltage_Out/Value"
# # batteryread = 'Model Root/IOUserInterface/IO_DISP/Simulator/Power_Supply/Simulator_Voltage_In/In1'
#
# WorkingDir = os.path.dirname(sys.argv[0])
# if not os.path.isdir(WorkingDir):
#     WorkingDir = os.getcwd()
# if not os.path.isdir(WorkingDir):
#     os.mkdir(WorkingDir)
#
# MAPortConfigFile = os.path.join(WorkingDir, MAPortConfigFile)

if __name__ == "main":

    # DemoMAPort = None

    try:
        # MyTestbenchFactory = TestbenchFactory()
        # MyTestbench = MyTestbenchFactory.CreateVendorSpecificTestbench("dSPACE GmbH", "XIL API", "2018-B")
        # MyMAPortFactory = MyTestbench.MAPortFactory
        # MyValueFactory = MyTestbench.ValueFactory
        # print("Creating MAPort instance...")
        # # Create an MAPort object using the MAPortFactory
        # DemoMAPort = MyMAPortFactory.CreateMAPort("DemoMAPort")
        # print("...done.\n")
        #
        # # Load the MAPort configuration
        # print("Configuring MAPort...")
        # DemoMAPortConfig = DemoMAPort.LoadConfiguration(MAPortConfigFile)
        # # Apply the MAPort configuration
        # DemoMAPort.Configure(DemoMAPortConfig, False)
        # print("...done.\n")
        # if DemoMAPort.State != MAPortState.eSIMULATION_RUNNING:
        #     # Start the simulation
        #     print("Starting simulation...")
        #     DemoMAPort.StartSimulation()
        #     print("...done.\n")

        excel = win32com.client.Dispatch("Excel.Application")
        excel.Visible = False
        workbook = excel.Workbooks.Open(model_root.ExcelFilePath)
        for sheet in workbook.Sheets:
            print(f"Sheet: {sheet.Name}")
            used_range = sheet.UsedRange

            num_rows = used_range.Rows.Count
            num_columns = used_range.Columns.Count

            start_row = 4  # Corresponding to row C4
            start_col = 3  # Corresponding to column C


            for row in range(start_row, num_rows + 1):
                first_cell_value = used_range.Cells(row, start_col).Value
                print(row, start_col)


                if first_cell_value.conatains("read"):
                    path,value = common_def.performTask(first_cell_value,row)
                    print("read")
                    print(path,value)
                    #DemoMAPort.Write(path, MyValueFactory.CreateFloatValue(value))
                elif first_cell_value.conatains("write") or first_cell_value.conatains("on") or first_cell_value.conatains("off"):
                    path, value = common_def.performTask(first_cell_value, row)
                    print("write or on or off")
                    print(path, value)
                    #DemoMAPort.Read(path, MyValueFactory.CreateFloatValue(value))

        # volt = [10.00, 8.7, 12.0, 9.0, 14.0]
    #
    # for i in range(len(volt)):
    #     DemoMAPort.Write(batteryvolt, MyValueFactory.CreateFloatValue(volt[i]))
    #     print("Writing value voltage to %s\n" % batteryvolt)
    #
    #     NewReadVal = DemoMAPort.Read(batteryread)
    #
    #     print("Read battery voltage now is: %s %s\n" % (batteryread, NewReadVal.Value))
    #
    #     time.sleep(5)

        # KL30_off_path,KL30_off_value = common_def.KL30_off()
        # DemoMAPort.Write(KL30_off_path, MyValueFactory.CreateIntValue(KL30_off_value))
        # KL30_on_path,KL30_on_value = common_def.KL30_on()
        # DemoMAPort.Write(KL30_on_path, MyValueFactory.CreateIntValue(KL30_on_value))
        # can_write_path,can_Write_value = common_def.can_write()
        # DemoMAPort.Write(can_write_path,MyValueFactory.CreateIntValue(can_Write_value))
        # LED_read_path,LED_read_Value = common_def.SLML_STATUS_FD_LEFT()
        # DemoMAPort.Read(LED_read_path, MyValueFactory.CreateFloatValue(KL30_on_value))

        print("Demo successfully finished!")

    # except TestbenchPortException as ex:
    #     print("A TestbenchPortException occurred:")
    #     print("CodeDescription: %s" % ex.CodeDescription)
    #     print("VendorCodeDescription: %s" % ex.VendorCodeDescription)
    #     raise

    finally:
        print()
    #     if DemoMAPort is not None:
    #         DemoMAPort.Dispose()
    #         DemoMAPort = None