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

# /Users/fpy/titan-1-5-MBARI/Mers/Reconfiguration/Discrete/Stub/MR_stub.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
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #include <cstdio>
    00015 #ifdef _MSC_VER
    00016 //#include <Mers/Executives/DeductiveController/win32/unistd.h>
    00017 #else
    00018 #ifdef TARGET_DSPBIOS
    00019 #include "unistd_dspbios.h"
    00020 #else
    00021 #include <unistd.h>
    00022 #endif
    00023 #endif
    00024
    00025 #include "MR_stub.h"
    00026
    00028
    00029 using namespace Mers::Reconfiguration::Discrete::Stub;
    00030 using Mers::Utils::Containers::intList;
    00031 using std::cout;
    00032 using std::endl;
    00033 using std::cerr;
    00034
    00036
    00037 void MRStub::update_current_state(unsigned int state_index,
    00038                                                                   unsigned int value_index) const
    00039 {
    00040         printf("MR engine: state update %d %d \n",state_index,value_index);
    00041 }
    00042
    00043 intList MRStub::generate_commands(intList& goals)
    00044 {
    00045         printf("MR engine: MR requested, goals %d \n",goals.size());
    00046         int var,val;
    00047         intList list;
    00048
    00049         cout << "MR engine stub: " << goals.size() << " goals" << endl;
    00050
    00051 //      return list;
    00052
    00053         while (!goals.empty())
    00054         {
    00055                 var = goals.front();
    00056                 goals.pop_front();
    00058                 if (goals.empty())
    00059                 {
    00060                         cerr << "Error in MRStub::generate_commands(): "
    00061                                 << "goallist has odd number of elements!"
    00062                                 << endl;
    00063                         break;
    00064                 }
    00065                 val = goals.front();
    00066                 goals.pop_front();
    00067
    00068                 printf("MR engine: goal %d %d \n",var,val);
    00069         }
    00070         list.push_back(1); // a single command
    00071         list.push_back(5); // variable
    00072         list.push_back(3); // value
    00073
    00074 //      sleep(2);
    00075         return list;
    00076 }
    00077