/** @details -# If real-time synchronization has been enabled: -# Set the active flag to true. -# If real-time synchronization has been disabled set the active flag to false. */ int Trick::RealtimeSync::initialize() { if ( enable_flag ) { active = true ; enable_flag = false ; } if ( disable_flag ) { active = false ; disable_flag = false ; } tics_per_sec = exec_get_time_tic_value(); /* Start the sleep timer hardware if realtime is active */ start_sleep_timer(); if ( align_sim_to_wall_clock ) { 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 ) ; if ( exec_get_mode() == Freeze ) { rt_clock->clock_spin(exec_get_freeze_time_tics()) ; } else { rt_clock->clock_spin(exec_get_time_tics()) ; } } return(0) ; }
int Trick::VariableServerThread::var_set_copy_mode(int mode) { if ( mode >= VS_COPY_ASYNC and mode <= VS_COPY_TOP_OF_FRAME ) { copy_mode = (VS_COPY_MODE)mode ; if ( copy_mode == VS_COPY_SCHEDULED ) { long long sim_time_tics ; sim_time_tics = exec_get_time_tics() ; // round the next call time to a multiple of the cycle sim_time_tics -= sim_time_tics % cycle_tics ; next_tics = sim_time_tics + cycle_tics ; sim_time_tics = exec_get_freeze_time_tics() ; // round the next call time to a multiple of the cycle sim_time_tics -= sim_time_tics % cycle_tics ; freeze_next_tics = sim_time_tics + cycle_tics ; } else { next_tics = TRICK_MAX_LONG_LONG ; } return 0 ; } return -1 ; }