00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_STATS_DELIMITER_FRAMES_HXX_
00023 # define WIFI_STATS_DELIMITER_FRAMES_HXX_
00024
00025 # include <boost/date_time/posix_time/posix_time_duration.hpp>
00026 # include <boost/date_time/posix_time/ptime.hpp>
00027 # include <boost/date_time/posix_time/time_formatters.hpp>
00028
00029 # include <wipal/wifi/stats/delimiter_frames.hh>
00030
00031 namespace wpl
00032 {
00033
00034 namespace wifi
00035 {
00036
00037 namespace stats
00038 {
00039
00040 inline
00041 delimiter_frames::delimiter_frames(const void*)
00042 {
00043 }
00044
00045 template <class Frame>
00046 void
00047 delimiter_frames::
00048 account_frame(const Frame& frame,
00049 const size_t& ,
00050 const type::frame_type& ,
00051 const unsigned& ,
00052 const bool& ,
00053 const addr* const& ,
00054 const addr* const& ,
00055 const bool& )
00056 {
00057 const tool::microseconds& phy_stamp = frame.microseconds();
00058 const struct timeval& meta_stamp = frame.meta().ts;
00059
00060 if (not earliest_ or earliest_->first > phy_stamp)
00061 earliest_ = stamp_pair (phy_stamp, meta_stamp);
00062
00063 if (not latest_ or latest_->first < phy_stamp)
00064 latest_ = stamp_pair (phy_stamp, meta_stamp);
00065 }
00066
00067 inline
00068 std::ostream&
00069 delimiter_frames::print(std::ostream& o) const
00070 {
00071 print(o, "earliest frame TOA", earliest_, false);
00072 print(o, "latest frame TOA", latest_, false);
00073 print(o, "smallest timestamp", earliest_, true);
00074 print(o, "greatest timestamp", latest_, true);
00075 return o << std::flush;
00076 }
00077
00078 inline
00079 void
00080 delimiter_frames::restart()
00081 {
00082 earliest_ = latest_ = boost::none_t ();
00083 }
00084
00085 std::ostream&
00086 delimiter_frames::print(std::ostream& o,
00087 const std::string& name,
00088 const optional_stamp_pair& value,
00089 const bool phy)
00090 {
00091 o << name << ": ";
00092 if (not value)
00093 o << "NA";
00094 else
00095 if (phy)
00096 o << value->first;
00097 else
00098 {
00099 using namespace boost::gregorian;
00100 using namespace boost::posix_time;
00101
00102 const ptime t (date(1970, Jan, 01),
00103 seconds (value->second.tv_sec) +
00104 microseconds (value->second.tv_usec));
00105
00106 o << to_simple_string(t) << " UTC";
00107 }
00108 return o << '\n';
00109 }
00110
00111 }
00112
00113 }
00114
00115 }
00116
00117 #endif // ! WIFI_STATS_DELIMITER_FRAMES_HXX_