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

# /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Rtapi/Standalone/stub_test.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
    00016 #include <Mers/Estimation/Discrete/Stub/ME_stub.h>
    00017 #include <Mers/Reconfiguration/Discrete/Stub/MR_stub.h>
    00018 #include <Mers/Executives/DeductiveController/Stub/DCCallbackStub.h>
    00019 #include <Mers/Executives/DeductiveController/DCInterface.h>
    00020 #include <Mers/Utils/Lang/Sleep.h>
    00021 #include <pthread.h>
    00022
    00023 //#include "../rtapi/userfcns_debug.h"
    00024
    00026
    00027 using Mers::Executives::DeductiveController::DCInterface;
    00028 using Mers::Executives::DeductiveController::Stub::DCCallbackStub;
    00029 using Mers::Estimation::Discrete::Stub::MEStub;
    00030 using Mers::Reconfiguration::Discrete::Stub::MRStub;
    00031 using Mers::Utils::Containers::intList;
    00032 using Mers::Utils::Lang::sleep;
    00033
    00035
    00036 void test_titanPropulsion_interface(DCInterface &DC_interface)
    00037 {
    00038         printf("Testing the DC Propulsion Module\n");
    00039
    00040         //DC_interface.queue_state_update(1, 1);
    00041         //DC_interface.queue_goal(2,1);
    00042         //DC_interface.queue_request_MR();
    00043         DC_interface.queue_state_update(0, 4);
    00044         DC_interface.queue_state_update(5, 4);
    00045         DC_interface.queue_state_update(10, 3);
    00046         DC_interface.queue_state_update(16, 2);
    00047
    00048         // give it the final goal
    00049         // the goal is that the driver is off and the valves are open and
    00050         // and the thruster is on
    00051         DC_interface.queue_goal(0, 3);
    00052         DC_interface.queue_goal(5, 3);
    00053         DC_interface.queue_goal(10, 2);
    00054         DC_interface.queue_goal(16, 2);
    00055
    00056         DC_interface.queue_request_MR();
    00057         //command (31, 0)
    00058
    00059         DC_interface.queue_state_update(16, 1);
    00060         DC_interface.queue_request_MR();
    00061         //command (29, 0)
    00062
    00063         DC_interface.queue_state_update(0, 3);
    00064         DC_interface.queue_request_MR();
    00065         // command should be (30, 0) indicating that valve1 should be
    00066
    00067         DC_interface.queue_state_update(5, 3);
    00068         DC_interface.queue_request_MR();
    00069         // command should be (28, 0) indicating that thruster should be
    00070
    00071         DC_interface.queue_state_update(10, 2);
    00072         DC_interface.queue_request_MR();
    00073         // command should be (31, 1) indicating that DCIU should be
    00074
    00075         DC_interface.queue_state_update(16, 2);
    00076         DC_interface.queue_request_MR();
    00077         // No command is required
    00078
    00079         // our new states indicate the driver is unknown and the thruster is off
    00080         //
    00081         // our desired goal of keeping the driver off and the valve closed can
    00082         // no longer be reached
    00083         // so RequestMR will return an error that the goal cannot be reached
    00084         // reversably
    00085         DC_interface.queue_state_update(10, 3);
    00086         DC_interface.queue_state_update(16, 0);
    00087         DC_interface.queue_request_MR();
    00088         // Failed
    00089
    00090         return;
    00091 }
    00092
    00100 int main()
    00101 {
    00102         //-----------------------
    00103         // Create mrInterface
    00104         //-------------------------
    00105         MEStub *                        me_interface_p = new MEStub();
    00106         MRStub *                        mr_interface_p = new MRStub();
    00107         DCCallbackStub *        DC_callback_p = new DCCallbackStub();
    00108
    00109         intList temp_intlist;
    00110         temp_intlist.push_back(1);
    00111         temp_intlist.push_back(2);
    00112         temp_intlist.push_back(3);
    00113         DC_callback_p->execute_command(temp_intlist);
    00114
    00115         DCInterface *DC_interface_p =
    00116                 new DCInterface(DC_callback_p, me_interface_p, mr_interface_p);
    00117
    00118         test_titanPropulsion_interface(*DC_interface_p);
    00119
    00120         //DC_interface.queue_find_mode_estimate();
    00121         //DC_interface.queue_request_MR();
    00122
    00123         // sleep(1);
    00124
    00125         printf("Done with information source\n");
    00126         fflush(stdout);
    00127         fflush(stderr);
    00128
    00129         delete DC_interface_p;
    00130
    00131         delete DC_callback_p;
    00132
    00133         pthread_exit(NULL);
    00134 }