tasks_multiple_test.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 10 15:59:18 CET 2005  tasks_multiple_test.hpp
00003 
00004                         tasks_multiple_test.hpp -  description
00005                            -------------------
00006     begin                : Mon January 10 2005
00007     copyright            : (C) 2005 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 
00020 
00021 #ifndef TASKS_MULTIPLE_TEST_HPP
00022 #define TASKS_MULTIPLE_TEST_HPP
00023 
00024 #include <extras/PeriodicActivity.hpp>
00025 #include <rtt-detail-fwd.hpp>
00026 using namespace RTT::detail;
00027 
00028 using namespace RTT;
00029 
00030 
00031 template<class T>
00032 class DummyTask : public T
00033 {
00034     unsigned int inits;
00035     unsigned int steps;
00036     unsigned int fins;
00037 
00038     unsigned int starts;
00039     unsigned int stops;
00040     unsigned int okstarts;
00041     unsigned int okstops;
00042 public:
00043     DummyTask(int prio, double period)
00044         : T(prio, period),
00045           inits(0), steps(0), fins(0),
00046           starts(0), stops(0),
00047           okstarts(0), okstops(0) {}
00048 
00049     bool start() {
00050         ++starts;
00051         if ( T::start() ) {
00052             ++okstarts;
00053             return true;
00054         }
00055         return false;
00056     }
00057     bool stop() {
00058         ++stops;
00059         if ( T::stop() ) {
00060             ++okstops;
00061             return true;
00062         }
00063         return false;
00064     }
00065     bool initialize() { ++inits; return true;}
00066     void step() { ++steps; }
00067     void finalize() { ++fins; }
00068     unsigned int nrOfStarts() { return starts;}
00069     unsigned int nrOfOKStarts() { return okstarts;}
00070     unsigned int nrOfInits() { return inits;}
00071     unsigned int nrOfSteps() { return steps;}
00072     unsigned int nrOfFinals() { return fins;}
00073     unsigned int nrOfStops() { return stops;}
00074     unsigned int nrOfOKStops() { return okstops;}
00075 };
00076 
00077 typedef DummyTask<PeriodicActivity> DummyPTask;
00078 typedef DummyTask<PeriodicActivity> DummyNPTask;
00079 
00083 class ActivitiesMultipleTest
00084 
00085 {
00086 public:
00087         ActivitiesMultipleTest(){setUp();};
00088         ~ActivitiesMultipleTest(){tearDown();};
00089 
00090         void setUp();
00091 
00092     void testMultiple();
00093 
00094     void tearDown();
00095 
00096     std::vector<DummyNPTask*> np_tasks;
00097 
00098     typedef std::vector<DummyNPTask*>::iterator NPI;
00099     typedef std::vector<DummyPTask*>::iterator PI;
00100 
00101     std::vector<DummyPTask*> p_tasks;
00102 
00103     unsigned int nr_of_p;
00104     unsigned int nr_of_np;
00105 
00106     unsigned int runningP;
00107     unsigned int runningNp;
00108 
00109     std::string errInitNP;
00110     std::string errStepNP;
00111     std::string errFinNP;
00112     std::string errInitP;
00113     std::string errStepP;
00114     std::string errFinP;
00115 };
00116 
00117 #endif


rtt
Author(s): RTT Developers
autogenerated on Fri Sep 9 2016 04:02:15