Beispiel #1
0
double Controller::getNextSamplingInstant(	double currentTime
											)
{
	double nextControlLaw = INFTY;
	double nextEstimator  = INFTY;

	if ( controlLaw != 0 )
	{
		if ( acadoIsInteger( (currentTime-0.0) / getSamplingTimeControlLaw( ) ) == BT_TRUE )
			nextControlLaw = currentTime + getSamplingTimeControlLaw( );
		else
			nextControlLaw = ceil( (currentTime-0.0) / getSamplingTimeControlLaw( ) ) * getSamplingTimeControlLaw( );
	}

	if ( estimator != 0 )
	{
		if ( acadoIsInteger( (currentTime-0.0) / getSamplingTimeEstimator( ) ) == BT_TRUE )
			nextEstimator = currentTime + getSamplingTimeEstimator( );
		else
			nextEstimator = ceil( (currentTime-0.0) / getSamplingTimeEstimator( ) ) * getSamplingTimeEstimator( );
	}

	return acadoMin( nextControlLaw,nextEstimator );
}
Beispiel #2
0
returnValue PlotWindow::getAutoScaleYLimits(	const VariablesGrid& dataGridY,
												PlotFormat plotFormat,
												double& lowerLimit,
												double& upperLimit
												) const
{
	double maxValue  = dataGridY.getMax( );
	double minValue  = dataGridY.getMin( );
	double meanValue = dataGridY.getMean( );

	if ( ( acadoIsZero( maxValue ) == BT_TRUE ) && ( acadoIsZero( minValue ) == BT_TRUE ) )
		meanValue = 0.1 / 0.025;

	lowerLimit = minValue - 0.1*( maxValue-minValue ) - 0.025*meanValue - 1.0e-8;
	upperLimit = maxValue + 0.1*( maxValue-minValue ) + 0.025*meanValue + 1.0e-8;

	
	if ( ( plotFormat == PF_LOG ) || ( plotFormat == PF_LOG_LOG ) )
	{
		if ( ( acadoIsStrictlyGreater( minValue,0.0, ZERO ) == BT_TRUE ) && ( acadoIsGreater( lowerLimit,0.0, ZERO ) == BT_FALSE ) )
		{
			lowerLimit = ( minValue + acadoMin( minValue,EPS ) ) / sqrt(10.0);
			upperLimit = upperLimit * sqrt(10.0);
		}
	}
	else
	{
		if ( ( acadoIsStrictlyGreater( minValue,0.0, ZERO ) == BT_TRUE ) && ( acadoIsGreater( lowerLimit,0.0, ZERO ) == BT_FALSE ) )
			lowerLimit = 0.0;

		if ( ( acadoIsStrictlySmaller( maxValue,0.0 ) == BT_TRUE ) && ( acadoIsSmaller( upperLimit,0.0 ) == BT_FALSE ) )
			upperLimit = 0.0;
	}
	
	return SUCCESSFUL_RETURN;
}