- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Estimation/Discrete/MEInterface.cpp

    00001 //=============================================================================
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems (MERS) group
    00007 // does not assume any responsibility.
    00008 //
    00009 // AUTHOR:                      Oliver B. Martin
    00010 //
    00011 // ORGANIZATION:        Model-based Embedded and Robotic Systems Group
    00012 //                                      Massachusetts Institute of Technology
    00013 //
    00014 // FILE:                        MEInterface.cpp
    00015 //
    00016 // DESCRIPTION:
    00017 //
    00018 //=============================================================================
    00019
    00020 #include "MEInterface.h"
    00021
    00022 #ifdef _MSC_VER
    00023 #pragma warning( disable : 4786 )
    00024 #endif
    00025
    00026 #include <cstdio>
    00027 #include <cassert>
    00028 #include <iostream>
    00029 #include <Mers/Utils/Containers/intList.h>
    00030 #include "ModeEstimatorBase.h"
    00031
    00032 using namespace Mers::Estimation::Discrete;
    00033 using Mers::Utils::Containers::intList;
    00034 using std::ostream;
    00035 using std::endl;
    00036
    00037
    00038
    00039 //----------------------------------------------------------------------------------------
    00040 // Public Constructors, Copy Constructors, & Destructors
    00041 //----------------------------------------------------------------------------------------
    00042
    00043 MEInterface::MEInterface(ModeEstimatorBase * mode_estimator_p)
    00044 {
    00045         assert(mode_estimator_p);
    00046         modeEstimator_p = mode_estimator_p;
    00047 }
    00048
    00049
    00050 MEInterface::~MEInterface()
    00051 {
    00052         if(modeEstimator_p)
    00053                 delete modeEstimator_p;
    00054 }
    00055
    00056 //----------------------------------------------------------------------------------------
    00057 // Public Function Members
    00058 //----------------------------------------------------------------------------------------
    00059
    00060 bool
    00061 MEInterface::progress(unsigned int cmd_index, unsigned int value_index)
    00062 {
    00063         return modeEstimator_p->command(cmd_index, value_index);
    00064 }
    00065
    00066
    00067 bool
    00068 MEInterface::observe(unsigned int obs_index, unsigned int value_index)
    00069 {
    00070         return modeEstimator_p->observe(obs_index, value_index);
    00071 }
    00072
    00073 bool
    00074 MEInterface::set_initial_state(unsigned int state_index, unsigned int value_index)
    00075 {
    00076         return modeEstimator_p->setCurrentState(state_index, value_index);
    00077 }
    00078
    00079 intList const *
    00080 MEInterface::find_mode_estimate()
    00081 {
    00082         intList const *int_list_p = modeEstimator_p->findModeEstimateIntList(false);
    00083         if (int_list_p == NULL)
    00084         {
    00085                 return NULL;
    00086         }
    00087         modeEstimator_p->progressToEstimate();
    00088         return int_list_p;
    00089 }
    00090
    00091
    00092 intList const *
    00093 MEInterface::get_full_state()
    00094 {
    00095         intList const *int_list_p = modeEstimator_p->findModeEstimateIntList(true);
    00096         if (int_list_p == NULL)
    00097         {
    00098                 return NULL;
    00099         }
    00100         modeEstimator_p->progressToEstimate();
    00101         return int_list_p;
    00102 }
    00103
    00104
    00105 bool
    00106 MEInterface::progress_to_estimate()
    00107 {
    00108         if(modeEstimator_p->progressToEstimate())
    00109                 return true;
    00110         return false;
    00111 }
    00112
    00114
    00115 bool MEInterface::printStateVars( ostream &out ) const
    00116 {
    00117         modeEstimator_p->showStateVars( out );
    00118         return true;
    00119 }
    00120
    00122
    00123 bool MEInterface::printCommandVars( ostream &out ) const
    00124 {
    00125         modeEstimator_p->showCommandVars( out );
    00126         return true;
    00127 }
    00128
    00130
    00131 bool MEInterface::printObservationVars( ostream &out ) const
    00132 {
    00133         modeEstimator_p->showObservationVars( out );
    00134         return true;
    00135 }
    00136
    00138
    00139 bool MEInterface::printAllVars( ostream &out ) const
    00140 {
    00141         modeEstimator_p->showAllVars( out );
    00142         return true;
    00143 }
    00144
    00146
    00147
    00148 //----------------------------------------------------------------------------------------
    00149 // Public Operators
    00150 //----------------------------------------------------------------------------------------
    00151
    00152 ostream &
    00153 Mers::Estimation::Discrete::operator <<(ostream &stream, MEInterface const &me_interface)
    00154 {
    00155         stream << "MEInterface ModeEstimator:" << endl;
    00156         stream << *(me_interface.modeEstimator_p);
    00157         return stream;
    00158 }
    00159