Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
channelfilterbase.hpp
00001 
00002 #ifndef DDF_CHANNELFILTERBASE_HPP
00003 #define DDF_CHANNELFILTERBASE_HPP
00004 
00005 #include <deque>
00006 #include <iostream>
00007 #include <fstream>
00008 
00009 #include "commbase.hpp"
00010 #include "infocontainer.hpp"
00011 #include "predictenginebase.hpp"
00012 
00013 namespace jafar
00014 { 
00015   namespace ddf
00016   {
00017 
00028     class ChannelFilterBase
00029     {
00030       typedef enum {EVENT_OUT, EVENT_SYNC, EVENT_NOSYNC} EVENT;
00031    
00032       CommBase             *m_comm;          // communication channel (the channel filter is in charge of deleting the communication object)
00033       InfoContainer        m_info_ij;        // common information between node i and j
00034       InfoContainer        m_new_ji;         // new information that node i does not yet have (that comes from node j)
00035       InfoContainer        m_pred_j;         // Yj(hori, hori-aj)... (see equation 17)
00036       PredictionEngineBase *m_pred_engine;   // prediction engine for synchronization to the next time horizon
00037       unsigned short       m_link_with_node; // tells with which node it is connected to
00038       unsigned short       m_belongs_to_node;
00039       time                 m_time_orig;      // only for logging purpose
00040       bool                 m_do_log;         // if true then log
00041       std::ofstream        m_dump_file;      // logfile
00042 
00043       void LogHeader();
00044       void DumpState(EVENT const& event, InfoContainer const& send_rec);
00045    
00046     public:
00047 
00048       ChannelFilterBase(unsigned short sv_size, unsigned short belongs_to_node, unsigned short link_with, CommBase *comm,
00049                     PredictionEngineBase *pred_engine, InfoContainer const& info_init);
00050 
00051       virtual ~ChannelFilterBase();
00052 
00053       // Set/get functions
00054       unsigned short GetLinkWithNode() const { return m_link_with_node; }
00055       InfoContainer const& GetNewInfo() const { return m_new_ji; }
00056       void SetCommonInfoTime(time const& t) { m_info_ij.SetTime(t); }
00057       
00061       void SetNow(time const& now) { m_time_orig = now; }
00062       bool Sync_Ok() const { return m_comm->Sync_Ok(); }
00063 
00064       void ResetJustReceived() { m_comm->ResetJustReceived(); }
00065 
00068       bool HasJustReceivedInfo() const { return m_comm->HasJustReceivedInfo(); }
00069 
00072       void SetLog(bool log) { if(!m_do_log && log) InitLog(); m_do_log = log; }
00073 
00074       // Main functions
00077       void  OutputInfoToOtherNode(InfoContainer const& to_j);
00078 
00085       bool Sync(time const& horizon);
00086       void PrintPredModel() { m_pred_engine->PrintModel(); }
00087 
00088       // Other
00089       void CloseLogFile();
00090    
00091     private:
00092       void InitLog();
00093     };
00094 
00095 
00096   } // namespace ddf
00097 } // namespace jafar
00098 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:17 for Jafar by doxygen 1.7.6.1
LAAS-CNRS