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
00013
00014
00015
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
00036 void Consumer::stopHook()
00037 {
00038 delete outfile;
00039 }
00040
00041