Time tic precision fix and test (#1428)

This commit is contained in:
Jacqueline Deans 2023-01-16 08:29:41 -06:00 committed by GitHub
parent 97cf685b6a
commit 77fa8d78b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 5 deletions

View File

@ -1,4 +1,4 @@
trick.stop(1.0); trick.stop(1.0);
trick.exec_set_time_tic_value(10000000) trick.exec_set_time_tic_value(100000000)

View File

@ -1,6 +1,8 @@
/************************TRICK HEADER************************* /************************TRICK HEADER*************************
PURPOSE: PURPOSE:
() (Test that the time tic value can be changed and that
warnings about the resolution of the cycle are displayed
properly. Scheduled2 should produce a warning.)
LIBRARY DEPENDENCIES: LIBRARY DEPENDENCIES:
*************************************************************/ *************************************************************/
@ -15,6 +17,9 @@ class TTVTestSimObject : public Trick::SimObject {
TTVTestSimObject() { TTVTestSimObject() {
(0.0078125, "scheduled") trick_ret = ttvtest.scheduled(); (0.0078125, "scheduled") trick_ret = ttvtest.scheduled();
(0.000078125, "scheduled") ttvtest.scheduled2();
(50, "scheduled") ttvtest.scheduled3();
(100, "scheduled") ttvtest.scheduled4();
} }
}; };

View File

@ -4,3 +4,18 @@ int TTVTest::scheduled() {
//message_publish(MSG_NORMAL, "Hello World!\n"); //message_publish(MSG_NORMAL, "Hello World!\n");
return 0; return 0;
} }
int TTVTest::scheduled2() {
//message_publish(MSG_NORMAL, "Hello World!\n");
return 0;
}
int TTVTest::scheduled3() {
//message_publish(MSG_NORMAL, "Hello World!\n");
return 0;
}
int TTVTest::scheduled4() {
//message_publish(MSG_NORMAL, "Hello World!\n");
return 0;
}

View File

@ -9,4 +9,7 @@ LIBRARY DEPENDENCY:
class TTVTest { class TTVTest {
public: public:
int scheduled(); int scheduled();
int scheduled2();
int scheduled3();
int scheduled4();
}; };

View File

@ -48,12 +48,12 @@ int Trick::Executive::check_all_job_cycle_times() {
Trick::JobData * temp_job = all_jobs_vector[ii] ; Trick::JobData * temp_job = all_jobs_vector[ii] ;
double test_rem ; double test_rem ;
/* calculate the floating point remainder when cycle is divided by 1/time_tic_value. Normalize result to 1.0 */ /* Calculate the if the cycle_tics would be a whole number */
test_rem = fmod(temp_job->cycle , 1.0 / time_tic_value ) * time_tic_value ; test_rem = fmod(temp_job->cycle * (double)time_tic_value , 1.0 ) ;
if ( test_rem > 0.001 ) { if ( test_rem > 0.001 ) {
message_publish(MSG_WARNING,"Cycle for (%s) cannot be exactly scheduled with time tic value. " message_publish(MSG_WARNING,"Cycle for (%s) cannot be exactly scheduled with time tic value. "
"cycle = %16.12f, cycle_tics = %d , time_tic = %16.12f\n", "cycle = %16.12f, cycle_tics = %lld , time_tic = %16.12f\n",
temp_job->name.c_str() , temp_job->cycle, temp_job->cycle_tics , 1.0 / time_tic_value ) ; temp_job->name.c_str() , temp_job->cycle, temp_job->cycle_tics , 1.0 / time_tic_value ) ;
ret = -1 ; ret = -1 ;
} }