def mix_legacy_and_rtseq_run():
    """Combines the legacy API with Python real-time sequences to run a deterministic test."""
    # Ensures NI VeriStand is running.
    NIVeriStand.LaunchNIVeriStand()
    # Uses the ClientAPI interface to get a reference to Workspace2
    workspace = NIVeriStand.Workspace2("localhost")
    engine_demo_path = os.path.join(os.path.expanduser("~"), 'Documents',
                                    'National Instruments', 'VeriStand 2018',
                                    'Examples', 'Stimulus Profile',
                                    'Engine Demo', 'Engine Demo.nivssdf')
    # Deploys the system definition.
    workspace.ConnectToSystem(engine_demo_path, True, 60000)
    try:
        # Uses Python real-time sequences to run a test.
        run_py_as_rtseq(run_engine_demo)
        print("Test Success")
    except RunError as e:
        print("Test Failed: %d -  %s" %
              (int(e.error.error_code), e.error.message))
    finally:
        # You can now disconnect from the system, so the next test can run.
        workspace.DisconnectFromSystem('', True)
def test_run_engine_set_points_profile_deterministic():
    set_engine_power(True)
    setpoints = DoubleValueArray([2500, 6000, 3000])
    try:
        for setpoint in setpoints:
            test_passed = run_py_as_rtseq(
                measure_set_point_response, {
                    "setpoint": setpoint,
                    "timeout": DoubleValue(60),
                    "tolerance": DoubleValue(100)
                })
            assert 0 < test_passed <= 60, "Setpoint %d failed" % setpoint
    finally:
        set_engine_power(False)
Beispiel #3
0
def mix_legacy_and_rtseq_run():
    """Combines the legacy API with Python real-time sequences to run a deterministic test."""
    # Ensures NI VeriStand is running.
    NIVeriStand.LaunchNIVeriStand()
    # Wait 30 seconds for the gateway to start
    time.sleep(30)
    engine_demo_path = Path(r"C:\Users\Public\Documents\National Instruments\NI VeriStand 2020\Examples\Stimulus Profile\Engine Demo\Engine Demo.nivssdf")
    if not engine_demo_path.exists():
        print("Error! System definition not found!")
        return
    # Uses the ClientAPI interface to get a reference to Workspace2
    workspace = NIVeriStand.Workspace2("localhost")
    # engine_demo_path = os.path.join("c:/", "users", "public", "Documents", "National Instruments", "VeriStand 2020", "Examples", "Stimulus Profile", "Engine Demo", "Engine Demo.nivssdf")
    # Deploys the system definition.
    workspace.ConnectToSystem(str(engine_demo_path), True, 60000)
    try:
        # Uses Python real-time sequences to run a test.
        run_py_as_rtseq(run_engine_demo)
        print("Test Success")
    except RunError as e:
        print("Test Failed: %d -  %s" % (int(e.error.error_code), e.error.message))
    finally:
        # You can now disconnect from the system, so the next test can run.
        workspace.DisconnectFromSystem('', True)
Beispiel #4
0
def run_deterministic():
    return run_py_as_rtseq(run_engine_demo_advanced)
Beispiel #5
0
#Start NI VeriStand
os.startfile(file_path)
sleep(17)

#Open the Workspace, this is to use the Legacy functionality to manipulate the controls and indicators in the project
workspace = NIVeriStand.Workspace2('localhost')

#engine_demo_path = r'C:\Users\Public\Documents\National Instruments\NI VeriStand 2020\Examples\Stimulus Profile\Engine Demo\Engine Demo.nivssdf'
engine_demo_path = r'C:\Users\ahidalgo\Documents\VeriStand Projects\Engine Demo\Engine Demo.nivssdf'

try:
    #Initiate Connection and Deploy a Sysem Definition File
    workspace.ConnectToSystem(engine_demo_path, True, 60000)
    sleep(4)

    run_py_as_rtseq(run_engine_demo)
    print("Test Success")

    run_py_as_rtseq(run_engine_demo_advanced)
    print("Advanced Test Success")
    # #Turn on the Engine
    # workspace.SetSingleChannelValue("EnginePower", 1)
    # #Iterate 10 time, changing the desired RPM and reading the actual value
    # for i in range(10):
    #     workspace.SetSingleChannelValue("DesiredRPM", setRPM)
    #     #Give time for the model to process the change and report back
    #     sleep(1)
    #     #Read the Actual RPM Indicator
    #     ActualRPM = workspace.GetSingleChannelValue("ActualRPM")
    #     print("ActualRPM: ", ActualRPM)
    #     #Increase the Desired RPM
def test_run_engine_set_points_profile_deterministic():
    result = run_py_as_rtseq(engine_set_points_profile)
    assert result is True