Setting initial sim time causes lockup

Found two issues.  First is that the next call times for
all of the jobs was not calculated correctly.  Second is
that the if the user wants to sync the sim to a real time
clock interval, the initial sync to the real time clock was pausing
the full starting sim time instead of syncing to the clock
interval.

refs #99
This commit is contained in:
Alex Lin 2015-08-04 16:36:19 -05:00
parent 5778add741
commit e692b81fdb
2 changed files with 10 additions and 13 deletions

View File

@ -272,17 +272,14 @@ void Trick::Executive::reset_job_call_times() {
unsigned int ii ;
for ( ii = 0 ; ii < all_jobs_vector.size() ; ii++ ) {
Trick::JobData * temp_job = all_jobs_vector[ii] ;
temp_job->start_tics = (long long)round((double)temp_job->start_tics / old_time_tic_value * time_tic_value) ;
temp_job->start_tics = (long long)round((double)temp_job->start_tics / old_time_tic_value * time_tic_value) + time_tics ;
if ( temp_job->disabled == false and
(!temp_job->system_job_class or !temp_job->job_class_name.compare("system_advance_sim_time")) ) {
if ( time_tics <= temp_job->start_tics ) {
if ( ! temp_job->job_class_name.compare("integ_loop")) {
temp_job->next_tics = time_tics + temp_job->cycle_tics + temp_job->start_tics ;
} else {
temp_job->next_tics = time_tics + temp_job->start_tics ;
}
if ( ! temp_job->job_class_name.compare("integ_loop")) {
temp_job->next_tics = temp_job->cycle_tics + temp_job->start_tics ;
} else {
temp_job->next_tics = time_tics + temp_job->cycle_tics ;
temp_job->next_tics = temp_job->start_tics ;
}
}
}
@ -348,9 +345,7 @@ int Trick::Executive::set_terminate_time(double in_time) {
}
int Trick::Executive::set_time(double in_time) {
sim_start = in_time ;
time_tics = (long long)(in_time * time_tic_value) ;
next_frame_check_tics = (long long)(time_tics + software_frame_tics) ;
for (unsigned int ii = 0 ; ii < threads.size() ; ii++ ) {
threads[ii]->curr_time_tics = time_tics ;
}

View File

@ -129,12 +129,14 @@ int Trick::RealtimeSync::initialize() {
start_sleep_timer();
if ( align_sim_to_wall_clock ) {
rt_clock->clock_reset(0) ;
rt_clock->sync_to_wall_clock( align_tic_mult , tics_per_sec ) ;
message_publish(MSG_INFO, "Syncing sim to %f second wall clock interval\n", align_tic_mult ) ;
rt_clock->clock_spin(0) ;
if ( exec_get_mode() == Freeze ) {
rt_clock->clock_spin(exec_get_freeze_time_tics()) ;
rt_clock->clock_reset(exec_get_freeze_time_tics()) ;
} else {
rt_clock->clock_spin(exec_get_time_tics()) ;
rt_clock->clock_reset(exec_get_time_tics()) ;
}
}
@ -203,7 +205,7 @@ int Trick::RealtimeSync::start_realtime(double in_frame_time , long long ref_tim
if ( active ) {
/* Only run in real time when sim time reaches 0.0 */
if (exec_get_time_tics() >= 0) {
if (ref_time >= 0) {
/* Reset the clock reference time to the desired reference time */
rt_clock->clock_reset(ref_time) ;