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)
def run_add_two_numbers_tests(): # NON-Deterministic try: call_add_two_numbers_test() except RunError as run_error: print("Something Non-deterministic went wrong:" + str(run_error)) # DETERMINISTIC try: realtimesequencetools.run_py_as_rtseq(call_add_two_numbers_test) except RunError as run_error: print("Something Deterministic went wrong:" + str(run_error))
def test_run_py_as_rts(func_name, params, expected_result): if inspect.isclass(expected_result) and issubclass(expected_result, VeristandError): with pytest.raises(expected_result): realtimesequencetools.run_py_as_rtseq(func_name) else: actual = realtimesequencetools.run_py_as_rtseq(func_name) # some of these functions are time sensitive so we can't know what to expect # so if the expected result is None we just check that a non-zero value got returned if expected_result is None: assert actual >= 0 else: assert actual == expected_result
def test_run_multiple_top_level_seqs(): assert len(get_scheduler()._task_dict) == 0 for func, params, expected in run_tests: actual = realtimesequencetools.run_py_as_rtseq(func) assert actual == expected # check that the scheduler is empty after every run. assert len(get_scheduler()._task_dict) == 0
def run_deterministic(func): """Compile the sequence and run it deterministically inside the VeriStand engine. As the actual sequence won't be executed by python, debugging won't be available. Also, only functions marked as @nivs_rt_sequence will be accepted. """ # The run_py_as_rtseq function takes as a parameter the function that should be called. result = realtimesequencetools.run_py_as_rtseq(func) print("Function " + func.__name__ + "(Deterministic):" + str(result))
def test_run_py_as_rts(func_name, params, expected_result): with pytest.raises(expected_result): realtimesequencetools.run_py_as_rtseq(func_name)
def test_gen_continue_no_fail(): assert _generate_continue_no_fail() == 2 assert rtseqrunner.run_rtseq_in_VM(_generate_continue_no_fail) == 2 assert realtimesequencetools.run_py_as_rtseq(_generate_continue_no_fail) == 2
def test_run_py_as_rts(func_name, params, expected_result): actual = realtimesequencetools.run_py_as_rtseq(func_name) assert actual == expected_result
def run_func_helper(func): actual = realtimesequencetools.run_py_as_rtseq(func) thread_results[func] = (thread_results[func], actual)
def test_channel_ref_for_vector_channel(): with pytest.raises(errors.VeristandError): realtimesequencetools.run_py_as_rtseq( testfunctions.channel_ref_for_vector_channel)
def test_run_py_as_rtseq_wrong_parameter_data_type(): with pytest.raises(VeristandError): realtimesequencetools.run_py_as_rtseq(func2, {"p": DoubleValue(2.3)})
def test_run_py_as_rtseq_missing_by_value_parameter(): actual = realtimesequencetools.run_py_as_rtseq(func2, {}) assert actual == 1.2
def test_run_py_as_rtseq_missing_by_ref_parameter(): with pytest.raises(VeristandError): realtimesequencetools.run_py_as_rtseq(func1, {})
def test_run_py_as_rtseq_invalid_extra_parameter(): with pytest.raises(VeristandError): realtimesequencetools.run_py_as_rtseq(func1, {"p": DoubleValue(2.3), "pp": DoubleValue(3.4)})
def test_run_py_as_rtseq_channel_reference_param(): desired_rpm = ChannelReference('Aliases/DesiredRPM') desired_rpm.value = 100.101 actual = realtimesequencetools.run_py_as_rtseq(func1, {"p": desired_rpm}) assert actual == 100.101
def test_run_py_as_rtseq_numeric_param(): actual = realtimesequencetools.run_py_as_rtseq(func1, {"p": DoubleValue(2.3)}) assert actual == 2.3