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

# /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Rtapi/MR/Stub/mrRtapiTest.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 "livapi_rt.h"
    00015 #include <Mers/Executives/DeductiveController/Rtapi/MR/MR_rtapi.h>
    00016 #include <Mers/Reconfiguration/Discrete/Stub/MR_stub.h>
    00017 #include <Mers/Executives/DeductiveController/Rtapi/MR/Stub/MR_callback_stub.h>
    00018 #include <Mers/Utils/Lang/Sleep.h>
    00019 #include <Mers/Utils/Logging/logger.h>
    00020
    00021 //#include "userfcns_debug.h"
    00022
    00023 #include <cstdio>
    00024
    00025
    00027
    00028 using namespace Mers::Executives::DeductiveController::Rtapi::MR::Stub;
    00029 using Mers::Executives::DeductiveController::Rtapi::MR::MR_rtapi;
    00030 using Mers::Executives::DeductiveController::Rtapi::MR::Stub::MR_callback_stub;
    00031 using Mers::Reconfiguration::Discrete::Stub::MRStub;
    00032 using Mers::Utils::Lang::sleep;
    00033
    00035
    00036 /*void testAPI(L2_rtapi &rtapi)
    00037 {
    00038   // queue_command
    00039   // queue_observation
    00040   // queue_observations
    00041   // queue_find_candidates
    00042   // queue_start_command_and_time
    00043   // queue_observations_and_time
    00044   // queue_abort_command
    00045   // queue_report_full_state
    00046   printf("Starting Simulation\n");
    00047   rtapi.queue_command(0, 0);
    00048   rtapi.queue_abort_command();
    00049   rtapi.queue_observation(1, 1);
    00050   rtapi.queue_observation(2, 2);
    00051   sleep(1);
    00052   rtapi.queue_observation(2, 3);
    00053   sleep(1);
    00054   rtapi.queue_start_command_and_time(5, 4);
    00055   rtapi.queue_observation(2, 5);
    00056   sleep(5);
    00057   rtapi.queue_observations_and_time(3, 6);
    00058   rtapi.queue_observation(2, 7);
    00059   rtapi.queue_report_full_state();
    00060   sleep(5);
    00061   rtapi.queue_command(3, 8);
    00062   rtapi.queue_observation(7, 9);
    00063   rtapi.queue_find_mode_estimate();
    00064   sleep(3);
    00065   printf("Simulation complete\n");
    00066   return;
    00067 }*/
    00068
    00069 void test_MR_interface(MR_rtapi &mr_rtapi)
    00070 {
    00071         printf("***Testing MR interface***\n");
    00072
    00073         printf("Test: enqueue state update 1 1 \n");
    00074         mr_rtapi.queue_state_update(1,1);
    00075
    00076         printf("Test: enqueue state update 2 1 \n");
    00077         mr_rtapi.queue_state_update(2,1);
    00078
    00079         printf("Test: enqueue goal 2 0\n");
    00080         mr_rtapi.queue_goal(2,0);
    00081
    00082         printf("Test: enqueue goal 3 1\n");
    00083         mr_rtapi.queue_goal(3,1);
    00084
    00085         printf("Test: enqueue state update 7 1 \n");
    00086         mr_rtapi.queue_state_update(7,1);
    00087         sleep(2);
    00088
    00089         printf("Test: Request MR\n");
    00090         mr_rtapi.queue_request_MR();
    00091         sleep(4);
    00092
    00093         printf("Test: end of RT API calls.\n");
    00094         return;
    00095 }
    00096
    00103 int main()
    00104 {
    00105         log4cplus::BasicConfigurator::doConfigure();
    00106
    00107         MRStub *mr;
    00108         MR_callback_stub *mr_cbs;
    00109         MR_rtapi *mr_rtapi;
    00110
    00111         mr = new MRStub();
    00112         mr_cbs = new MR_callback_stub();
    00113         mr_rtapi = new MR_rtapi(mr,mr_cbs);
    00114
    00115         test_MR_interface(*mr_rtapi);
    00116
    00117         delete mr_rtapi; // this will wait for the dispatcher thread to exit
    00118         //delete mr; - already deleted
    00119         delete mr_cbs;
    00120
    00121
    00122 /*
    00123   Tracker * syst;
    00124   ReportTransitionsDebug * rtd;
    00125   L2_rtapi * rtapi;
    00126
    00127   syst = new Tracker();
    00128
    00129   if(!syst)
    00130   {
    00131     perror("failed to create a Tracker object\n");
    00132     return 1;
    00133   }
    00134
    00135   rtd = new ReportTransitionsDebug(syst);
    00136   if(!rtd)
    00137   {
    00138     delete syst;
    00139     perror("failed to create a reporter object\n");
    00140     return 1;
    00141   }
    00142   rtapi = new L2_rtapi(mr, syst, *rtd);
    00143   if(!rtapi)
    00144   {
    00145     delete syst;
    00146     delete rtd;
    00147     perror("failed to create a real time interface\n");
    00148     return 1;
    00149   }
    00150   testAPI(*rtapi);
    00151   delete rtapi;
    00152   delete rtd;
    00153   delete syst;
    00154 */
    00155   return 0;
    00156 }