|
solarpowerlog trunk
|
00001 /* ---------------------------------------------------------------------------- 00002 solarpowerlog 00003 Copyright (C) 2009 Tobias Frost 00004 00005 This file is part of solarpowerlog. 00006 00007 Solarpowerlog is free software; However, it is dual-licensed 00008 as described in the file "COPYING". 00009 00010 For this file (CCSVOutputFilter.h), the license terms are: 00011 00012 You can redistribute it and/or modify it under the terms of the GNU Lesser 00013 General Public License (LGPL) as published by the Free Software Foundation; 00014 either version 3 of the License, or (at your option) any later version. 00015 00016 This program is distributed in the hope that it will be useful, but 00017 WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Library General Public 00022 License along with this proramm; if not, see 00023 <http://www.gnu.org/licenses/>. 00024 ---------------------------------------------------------------------------- 00025 */ 00026 00200 #ifndef CCSVOUTPUTFILTER_H_ 00201 #define CCSVOUTPUTFILTER_H_ 00202 00203 #ifdef HAVE_CONFIG_H 00204 #include "config.h" 00205 #endif 00206 00207 #ifdef HAVE_FILTER_CSVDUMP 00208 00209 #include <fstream> 00210 #include <list> 00211 #include "boost/date_time/local_time/local_time.hpp" 00212 00213 #include "DataFilters/interfaces/IDataFilter.h" 00214 00215 00224 class CCSVOutputFilter : public IDataFilter 00225 { 00226 00227 protected: 00228 friend class IDataFilterFactory; 00229 CCSVOutputFilter( const string &name, const string & configurationpath ); 00230 00231 public: 00232 virtual ~CCSVOutputFilter(); 00233 00234 virtual bool CheckConfig(); 00235 00236 virtual void Update( const IObserverSubject *subject ); 00237 00238 virtual void ExecuteCommand( const ICommand *cmd ); 00239 00240 00241 private: 00242 00243 IInverterBase *oursource; 00244 fstream file; 00245 00254 void DoINITCmd (const ICommand *); 00255 00264 void DoCYCLICmd(const ICommand *); 00265 00266 enum Commands 00267 { 00268 CMD_INIT, 00269 CMD_CYCLIC, 00270 CMD_ROTATE 00271 }; 00272 00273 00275 bool headerwritten; 00276 00278 bool datavalid; 00279 00281 bool capsupdated; 00282 00284 list<string> CSVCapas; 00285 00286 00287 // Helpers to shrink some functions... 00297 bool CMDCyclic_CheckCapas(void); 00298 00302 bool search_list(const string id) const; 00303 00305 std::string last_line; 00306 }; 00307 00308 #endif 00309 00310 #endif /* CCSVOUTPUTFILTER_H_ */