Esempio n. 1
0
def test_save_creates_file():
    try:
        tempfolder = tempfile.mkdtemp()
        rtseq.save_py_as_rtseq(testfuncs.empty_func, tempfolder)
        exp_path = os.path.join(tempfolder,
                                testfuncs.empty_func.__name__ + ".nivsseq")
        assert os.path.isfile(exp_path)
    finally:
        shutil.rmtree(tempfolder, ignore_errors=True)
Esempio n. 2
0
def run_rtseq_in_VM(func, deltat=1):
    from NationalInstruments.VeriStand.Data import VoidValue
    filename = realtimesequencetools.save_py_as_rtseq(func, None)
    rtseq_result = run_rtseq_local(filename, deltat=deltat)
    if isinstance(rtseq_result, VoidValue):
        return None
    return rtseq_result.Value
Esempio n. 3
0
def assert_run_python_equals_rtseq(func, expected):
    tempfolder = tempfile.mkdtemp()
    filename = realtimesequencetools.save_py_as_rtseq(func, tempfolder)
    rtseq_result = run_rtseq_local(filename)
    py_result = func()
    if isinstance(py_result, DataType):
        py_result = py_result.value
    assert py_result == expected
    assert rtseq_result.Value == py_result
Esempio n. 4
0
def _save_debug_helper(func):
    """Save a sequence so it can be inspected manually."""
    tempfolder = tempfile.mkdtemp()
    print(tempfolder)
    rtseq.save_py_as_rtseq(func, tempfolder)
Esempio n. 5
0
def test_save_invalid_folder_throws():
    tempfolder = tempfile.mkdtemp()
    shutil.rmtree(tempfolder, ignore_errors=True)
    with pytest.raises(IOError):
        rtseq.save_py_as_rtseq(testfuncs.empty_func, tempfolder)
Esempio n. 6
0
def run_non_deterministic():
    """Runs the sequence non-deterministically.

    This function executes the RT Sequence on the host using the public ClientAPI
    that installs with VeriStand. This function communicates with the gateway to set and get channel values.

    If you use a Python integrated developer environment (IDE),
    you can debug this function like a normal Python function.
    """
    run_engine_demo()


def run_deterministic():
    """Compiles the sequence and runs it deterministically inside the VeriStand engine.

    You cannot use debugging tools at this stage because VeriStand executes the sequence, not Python.
    If you do not mark the functions as @nivs_rt_sequence, Python will raise a :any:`niveristand.errors.VeristandError`.
    """
    # The run_py_as_rtseq function accepts, as a parameter, the Python function you want to call as an RT sequence.
    realtimesequencetools.run_py_as_rtseq(run_engine_demo)


if __name__ == '__main__':
    realtimesequencetools.save_py_as_rtseq(run_engine_demo,
                                           'D:\\niveristand_python')
    run_non_deterministic()
    print('Finished non-deterministic')
    run_deterministic()
    print('Finished deterministic')
Esempio n. 7
0
def run_non_deterministic():
    """Runs the sequence non-deterministically.

    This function executes the RT Sequence on the host using the public ClientAPI
    that installs with VeriStand. This function communicates with the gateway to set and get channel values.

    If you use a Python integrated developer environment (IDE),
    you can debug this function like a normal Python function.
    """
    run_engine_demo()


def run_deterministic():
    """Compiles the sequence and runs it deterministically inside the VeriStand engine.

    You cannot use debugging tools at this stage because VeriStand executes the sequence, not Python.
    If you do not mark the functions as @nivs_rt_sequence, Python will raise a :any:`niveristand.errors.VeristandError`.
    """
    # The run_py_as_rtseq function accepts, as a parameter, the Python function you want to call as an RT sequence.
    realtimesequencetools.run_py_as_rtseq(run_engine_demo)


if __name__ == '__main__':
    realtimesequencetools.save_py_as_rtseq(run_engine_demo,
                                           'd:\\share\\temp\\demo')
    run_non_deterministic()
    print('Finished non-deterministic')
    run_deterministic()
    print('Finished deterministic')
Esempio n. 8
0
def test_run_simple():
    tempfolder = tempfile.mkdtemp()
    filename = realtimesequencetools.save_py_as_rtseq(simple, tempfolder)
    rtseq_result = rtseqrunner.run_rtseq_local(filename, [], [])
    py_result = simple()
    assert rtseq_result.Value == py_result