CyclingManager.cpp
Go to the documentation of this file.
00001 /*
00002  *      This file is part of qpOASES.
00003  *
00004  *      qpOASES -- An Implementation of the Online Active Set Strategy.
00005  *      Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved.
00006  *
00007  *      qpOASES is free software; you can redistribute it and/or
00008  *      modify it under the terms of the GNU Lesser General Public
00009  *      License as published by the Free Software Foundation; either
00010  *      version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *      qpOASES is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *      Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with qpOASES; if not, write to the Free Software
00019  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020  *
00021  */
00022 
00023 
00036 #include <CyclingManager.hpp>
00037 
00038 
00039 /*****************************************************************************
00040  *  P U B L I C                                                              *
00041  *****************************************************************************/
00042 
00043 
00044 /*
00045  *      C y c l i n g M a n a g e r
00046  */
00047 CyclingManager::CyclingManager( ) :     nV( 0 ),
00048                                                                         nC( 0 )
00049 {
00050         cyclingDetected = BT_FALSE;
00051 }
00052 
00053 
00054 /*
00055  *      C y c l i n g M a n a g e r
00056  */
00057 CyclingManager::CyclingManager( const CyclingManager& rhs ) :   nV( rhs.nV ),
00058                                                                                                                                 nC( rhs.nC ),
00059                                                                                                                                 cyclingDetected( rhs.cyclingDetected )
00060 {
00061         int i;
00062 
00063         for( i=0; i<nV+nC; ++i )
00064                 status[i] = rhs.status[i];
00065 }
00066 
00067 
00068 /*
00069  *      ~ C y c l i n g M a n a g e r
00070  */
00071 CyclingManager::~CyclingManager( )
00072 {
00073 }
00074 
00075 
00076 /*
00077  *      o p e r a t o r =
00078  */
00079 CyclingManager& CyclingManager::operator=( const CyclingManager& rhs )
00080 {
00081         int i;
00082 
00083         if ( this != &rhs )
00084         {
00085                 nV = rhs.nV;
00086                 nC = rhs.nC;
00087 
00088                 for( i=0; i<nV+nC; ++i )
00089                         status[i] = rhs.status[i];
00090 
00091                 cyclingDetected = rhs.cyclingDetected;
00092         }
00093 
00094         return *this;
00095 }
00096 
00097 
00098 
00099 /*
00100  *      i n i t
00101  */
00102 returnValue CyclingManager::init( int _nV, int _nC )
00103 {
00104         nV = _nV;
00105         nC = _nC;
00106 
00107         cyclingDetected = BT_FALSE;
00108 
00109         return SUCCESSFUL_RETURN;
00110 }
00111 
00112 
00113 
00114 /*
00115  *      s e t C y c l i n g S t a t u s
00116  */
00117 returnValue CyclingManager::setCyclingStatus(   int number,
00118                                                                                                 BooleanType isBound, CyclingStatus _status
00119                                                                                                 )
00120 {
00121         if ( isBound == BT_TRUE )
00122         {
00123                 /* Set cycling status of a bound. */
00124                 if ( ( number >= 0 ) && ( number < nV ) )
00125                 {
00126                         status[number] = _status;
00127                         return SUCCESSFUL_RETURN;
00128                 }
00129                 else
00130                         return THROWERROR( RET_INDEX_OUT_OF_BOUNDS );
00131         }
00132         else
00133         {
00134                 /* Set cycling status of a constraint. */
00135                 if ( ( number >= 0 ) && ( number < nC ) )
00136                 {
00137                         status[nV+number] = _status;
00138                         return SUCCESSFUL_RETURN;
00139                 }
00140                 else
00141                         return THROWERROR( RET_INDEX_OUT_OF_BOUNDS );
00142         }
00143 }
00144 
00145 
00146 /*
00147  *      g e t C y c l i n g S t a t u s
00148  */
00149 CyclingStatus CyclingManager::getCyclingStatus( int number, BooleanType isBound ) const
00150 {
00151         if ( isBound == BT_TRUE )
00152         {
00153                 /* Return cycling status of a bound. */
00154                 if ( ( number >= 0 ) && ( number < nV ) )
00155                         return status[number];
00156         }
00157         else
00158         {
00159                 /* Return cycling status of a constraint. */
00160                 if ( ( number >= 0 ) && ( number < nC ) )
00161                         return status[nV+number];
00162         }
00163 
00164         return CYC_NOT_INVOLVED;
00165 }
00166 
00167 
00168 /*
00169  *      c l e a r C y c l i n g D a t a
00170  */
00171 returnValue CyclingManager::clearCyclingData( )
00172 {
00173         int i;
00174 
00175         /* Reset all status values ... */
00176         for( i=0; i<nV+nC; ++i )
00177                 status[i] = CYC_NOT_INVOLVED;
00178 
00179         /* ... and the main cycling flag. */
00180         cyclingDetected = BT_FALSE;
00181 
00182         return SUCCESSFUL_RETURN;
00183 }
00184 
00185 
00186 /*
00187  *      end of file
00188  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:04