Libbarrett  1.2.4
include/barrett/systems/triggered_data_logger.h
00001 /*
00002         Copyright 2009, 2010 Barrett Technology <support@barrett.com>
00003 
00004         This file is part of libbarrett.
00005 
00006         This version of libbarrett is free software: you can redistribute it
00007         and/or modify it under the terms of the GNU General Public License as
00008         published by the Free Software Foundation, either version 3 of the
00009         License, or (at your option) any later version.
00010 
00011         This version of libbarrett is distributed in the hope that it will be
00012         useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00013         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014         GNU General Public License for more details.
00015 
00016         You should have received a copy of the GNU General Public License along
00017         with this version of libbarrett.  If not, see
00018         <http://www.gnu.org/licenses/>.
00019 
00020         Further, non-binding information about licensing is available at:
00021         <http://wiki.barrett.com/libbarrett/wiki/LicenseNotes>
00022 */
00023 
00024 /*
00025  * triggered_data_logger.h
00026  *
00027  *  Created on: Dec 24, 2009
00028  *      Author: dc
00029  */
00030 
00031 #ifndef TRIGGERED_DATA_LOGGER_H_
00032 #define TRIGGERED_DATA_LOGGER_H_
00033 
00034 
00035 #include <barrett/detail/ca_macro.h>
00036 #include <barrett/log/real_time_writer.h>
00037 #include <barrett/systems/periodic_data_logger.h>
00038 
00039 
00040 namespace barrett {
00041 namespace systems {
00042 
00043 
00044 // TODO(dc): add a configuration file interface
00045 
00046 template<typename T, typename LogWriterType = log::RealTimeWriter<T> >
00047 class TriggeredDataLogger : public PeriodicDataLogger<T, LogWriterType> {
00048 // IO
00049 public: System::Input<bool> triggerInput;
00050 
00051 
00052 public:
00053         TriggeredDataLogger(ExecutionManager* em, LogWriterType* logWriter, const std::string& sysName = "TriggeredDataLogger") :
00054                         PeriodicDataLogger<T, LogWriterType>(em, logWriter, 1, sysName),
00055                         triggerInput(this) {}
00056         virtual ~TriggeredDataLogger() { this->mandatoryCleanUp(); }
00057 
00058 protected:
00059         virtual bool inputsValid() {
00060                 return  this->logging  &&  triggerInput.valueDefined()  &&
00061                                 triggerInput.getValue() == true  &&  this->input.valueDefined();
00062         }
00063 
00064 private:
00065         DISALLOW_COPY_AND_ASSIGN(TriggeredDataLogger);
00066 };
00067 
00068 
00069 }
00070 }
00071 
00072 
00073 #endif /* TRIGGERED_DATA_LOGGER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines