Consumer.cpp
Go to the documentation of this file.
00001 #include "Consumer.hpp"
00002 #include <iostream>
00003 #include <fstream>
00004 
00005 using namespace std;
00006 using namespace data;
00007 
00008 Consumer::Consumer(std::string const& name, TaskCore::TaskState initial_state)
00009     : ConsumerBase(name, initial_state) {}
00010 
00012 // hooks defined by Orocos::RTT. See Consumer.hpp for more detailed
00013 // documentation about them.
00014 
00015 // bool Consumer::configureHook() { return true; }
00016 bool Consumer::startHook() {
00017     outfile = new ofstream("data_trigger.txt");
00018     return true;
00019 }
00020 
00021 void Consumer::updateHook()
00022 {
00023     double value;
00024     bool got_data = false;
00025     while (_input.read(value) == RTT::NewData)
00026     {
00027         got_data = true;
00028         *outfile << value << " " << flush;
00029     }
00030 
00031     if (!got_data)
00032         *outfile << "U " << flush;
00033 }
00034 
00035 // void Consumer::errorHook() {}
00036 void Consumer::stopHook()
00037 {
00038     delete outfile;
00039 }
00040 // void Consumer::cleanupHook() {}
00041 


orogen
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Sat Jun 8 2019 19:52:17