From d0511e8fb9120d61fc10057c17300804c27e0424 Mon Sep 17 00:00:00 2001 From: Scott Fennell Date: Fri, 28 Oct 2022 17:19:54 -0500 Subject: [PATCH] 1372 use temporary job pointer instead of modifying curr_job in exec_set_time_tic_value * add integration test sim SIM_exec_set_time_tic_value * use temporary job pointer instead of modifying curr_job in exec_set_time_tic_value closes #1372 --- include/trick/Executive.hh | 2 +- .../RUN_test/unit_test.py | 4 ++++ test/SIM_exec_set_time_tic_value/S_define | 21 +++++++++++++++++++ .../S_overrides.mk | 3 +++ .../models/ttvtest.cpp | 6 ++++++ .../models/ttvtest.h | 12 +++++++++++ test/makefile | 1 + .../Executive_set_time_tic_value.cpp | 6 ++++-- 8 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 test/SIM_exec_set_time_tic_value/RUN_test/unit_test.py create mode 100644 test/SIM_exec_set_time_tic_value/S_define create mode 100644 test/SIM_exec_set_time_tic_value/S_overrides.mk create mode 100644 test/SIM_exec_set_time_tic_value/models/ttvtest.cpp create mode 100644 test/SIM_exec_set_time_tic_value/models/ttvtest.h diff --git a/include/trick/Executive.hh b/include/trick/Executive.hh index 4b849581..b7f89b85 100644 --- a/include/trick/Executive.hh +++ b/include/trick/Executive.hh @@ -207,7 +207,7 @@ namespace Trick { /** Queue to hold unfreeze jobs.\n */ Trick::ScheduledJobQueue unfreeze_queue ; /**< trick_io(**) */ - /** Queue to hold unfreeze jobs.\n */ + /** Queue to hold time_tic_changed jobs.\n */ Trick::ScheduledJobQueue time_tic_changed_queue ; /**< trick_io(**) */ /** Enough threads to accomodate the number of children specified in the S_define file.\n */ diff --git a/test/SIM_exec_set_time_tic_value/RUN_test/unit_test.py b/test/SIM_exec_set_time_tic_value/RUN_test/unit_test.py new file mode 100644 index 00000000..5b5b48ba --- /dev/null +++ b/test/SIM_exec_set_time_tic_value/RUN_test/unit_test.py @@ -0,0 +1,4 @@ + + +trick.stop(1.0); +trick.exec_set_time_tic_value(10000000) diff --git a/test/SIM_exec_set_time_tic_value/S_define b/test/SIM_exec_set_time_tic_value/S_define new file mode 100644 index 00000000..261f24a4 --- /dev/null +++ b/test/SIM_exec_set_time_tic_value/S_define @@ -0,0 +1,21 @@ +/************************TRICK HEADER************************* +PURPOSE: + () +LIBRARY DEPENDENCIES: +*************************************************************/ + +#include "sim_objects/default_trick_sys.sm" + +##include "ttvtest.h" + +class TTVTestSimObject : public Trick::SimObject { + + public: + TTVTest ttvtest; + + TTVTestSimObject() { + (0.0078125, "scheduled") trick_ret = ttvtest.scheduled(); + } +}; + +TTVTestSimObject ttvtestSimObject; diff --git a/test/SIM_exec_set_time_tic_value/S_overrides.mk b/test/SIM_exec_set_time_tic_value/S_overrides.mk new file mode 100644 index 00000000..6ca9ea96 --- /dev/null +++ b/test/SIM_exec_set_time_tic_value/S_overrides.mk @@ -0,0 +1,3 @@ + +TRICK_CFLAGS += -I./models +TRICK_CXXFLAGS += -I./models diff --git a/test/SIM_exec_set_time_tic_value/models/ttvtest.cpp b/test/SIM_exec_set_time_tic_value/models/ttvtest.cpp new file mode 100644 index 00000000..4b343eb5 --- /dev/null +++ b/test/SIM_exec_set_time_tic_value/models/ttvtest.cpp @@ -0,0 +1,6 @@ +#include +#include "ttvtest.h" +int TTVTest::scheduled() { + //message_publish(MSG_NORMAL, "Hello World!\n"); + return 0; +} diff --git a/test/SIM_exec_set_time_tic_value/models/ttvtest.h b/test/SIM_exec_set_time_tic_value/models/ttvtest.h new file mode 100644 index 00000000..e5ab5fed --- /dev/null +++ b/test/SIM_exec_set_time_tic_value/models/ttvtest.h @@ -0,0 +1,12 @@ +/************************************************************************* +PURPOSE: (Starter class) +LIBRARY DEPENDENCY: + ( + (ttvtest.cpp) + ) +**************************************************************************/ + +class TTVTest { +public: + int scheduled(); +}; \ No newline at end of file diff --git a/test/makefile b/test/makefile index f68e4f08..8daf93fb 100644 --- a/test/makefile +++ b/test/makefile @@ -25,6 +25,7 @@ SIMS_TO_COMPILE_ONLY = \ SIMS_TO_COMPILE_AND_RUN = \ SIM_demo_sdefine \ SIM_events \ + SIM_exec_set_time_tic_value \ SIM_python_namespace \ SIM_rti \ SIM_stls \ diff --git a/trick_source/sim_services/Executive/Executive_set_time_tic_value.cpp b/trick_source/sim_services/Executive/Executive_set_time_tic_value.cpp index d90b5c51..0806c78d 100644 --- a/trick_source/sim_services/Executive/Executive_set_time_tic_value.cpp +++ b/trick_source/sim_services/Executive/Executive_set_time_tic_value.cpp @@ -50,8 +50,10 @@ int Trick::Executive::set_time_tic_value(int in_tics) { /* call jobs for other objects that need to know the time_tic changed. */ time_tic_changed_queue.reset_curr_index() ; - while ( (curr_job = time_tic_changed_queue.get_next_job()) != NULL ) { - ret = curr_job->call() ; + /* job pointer for each job in time_tic_changed_queue */ + JobData* next_job; + while ( (next_job = time_tic_changed_queue.get_next_job()) != NULL ) { + ret = next_job->call() ; if ( ret != 0 ) { message_publish(MSG_ERROR, "ERROR: time_tic_changed job: %s FAILED.\n", curr_job->name.c_str()) ; return(ret) ;