SimApi Timer setStepSizeInSeconds

From SIMboxWiki
Jump to navigation Jump to search



Icon attributes.pngstatic void SimApi::Timer::setStepSizeInSeconds(double i_rSeconds)

    Description

    Sets the step size in seconds for the simulation timer

    Parameters

    i_rSeconds - - step size in seconds for the simulation timer

    Remarks
    

The Timer class provides step forward and backward functionality. This functionality enables SIMBox extensions to advance the simulation time one step forward or backward based on some logic. The logic can be a control, event callback function, attribute change call back and more. This function sets the step size. Example: Setting the step size to 1.5 seconds will cause every call for step forward to advance the simulation playback 1.5. seconds. The same functionality applies also for step backward.


    Code Sample
    

void main()
{
	SimApi::Timer::SetTime(0);
	double stepSizeinSeconds = 5;
	double currenTime = SimApi::Timer::time();
	
	cout << " Current Time  = " << currenTime  << endl;
	
	SimApi::Timer::setStepSizeInSeconds(stepSizeinSeconds);
	SimApi::Timer::stepForward();
	double newCurrentTIme = SimApi::Timer::time();
	
	cout << "new Time = " << newCurrentTIme  << endl;
}

OUTPUT
-------
Current Time = 0;
New Time = 5;


    See Also

     getStepSizeInSeconds

     getStepSizeInSeconds

     stepBackward

     stepForward

    Related Links

     Recommended: Simulation Time Overview