Wiselib
wiselib.testing/algorithms/metrics/one_hop_link/one_hop_link_metrics_request.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  ** This file is part of the generic algorithm library Wiselib.           **
00003  ** Copyright (C) 2008,2009 by the Wisebed (www.wisebed.eu) project.      **
00004  **                                                                       **
00005  ** The Wiselib is free software: you can redistribute it and/or modify   **
00006  ** it under the terms of the GNU Lesser General Public License as        **
00007  ** published by the Free Software Foundation, either version 3 of the    **
00008  ** License, or (at your option) any later version.                       **
00009  **                                                                       **
00010  ** The Wiselib is distributed in the hope that it will be useful,        **
00011  ** but WITHOUT ANY WARRANTY; without even the implied warranty of        **
00012  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         **
00013  ** GNU Lesser General Public License for more details.                   **
00014  **                                                                       **
00015  ** You should have received a copy of the GNU Lesser General Public      **
00016  ** License along with the Wiselib.                                       **
00017  ** If not, see <http://www.gnu.org/licenses/>.                           **
00018  ***************************************************************************/
00019 #ifndef __ALGORITHMS_METRICS_ONE_HOP_LINK_METRICS_REQUEST_MSG_H__
00020 #define __ALGORITHMS_METRICS_ONE_HOP_LINK_METRICS_REQUEST_MSG_H__
00021 
00022 #include "util/serialization/simple_types.h"
00023 
00024 namespace wiselib
00025 {
00026 
00027    template<typename OsModel_P,
00028             typename Radio_P>
00029    class OneHopLinkMetricsRequestMessage
00030    {
00031    public:
00032       typedef OsModel_P OsModel;
00033       typedef Radio_P Radio;
00034       typedef typename Radio::node_id_t node_id_t;
00035       typedef typename Radio::block_data_t block_data_t;
00036       typedef typename Radio::size_t size_t;
00037       // --------------------------------------------------------------------
00043       inline OneHopLinkMetricsRequestMessage( uint8_t id, uint16_t sink,
00044                                     uint16_t pts, uint16_t ps, uint32_t ti );
00045       // --------------------------------------------------------------------
00046       inline uint8_t msg_id()
00047       { return read<OsModel, block_data_t, uint8_t>( buffer ); }
00048       // --------------------------------------------------------------------
00049       inline void set_msg_id( uint8_t id )
00050       { write<OsModel, block_data_t, uint8_t>( buffer, id ); }
00051       // --------------------------------------------------------------------
00052       inline uint16_t sink()
00053       { return read<OsModel, block_data_t, uint16_t>(buffer + SINK_POS); }
00054       // --------------------------------------------------------------------
00055       inline void set_sink( uint16_t sink )
00056       { write<OsModel, block_data_t, uint16_t>(buffer + SINK_POS, sink); }
00057       // --------------------------------------------------------------------
00058       inline uint16_t pts()
00059       { return read<OsModel, block_data_t, uint16_t>(buffer + PTS_POS); }
00060       // --------------------------------------------------------------------
00061       inline void set_pts( uint16_t pts )
00062       { write<OsModel, block_data_t, uint16_t>(buffer + PTS_POS, pts); }
00063       // --------------------------------------------------------------------
00064       inline uint16_t ps()
00065       { return read<OsModel, block_data_t, uint16_t>(buffer + PS_POS); }
00066       // --------------------------------------------------------------------
00067       inline void set_ps( uint16_t ps )
00068       { write<OsModel, block_data_t, uint16_t>(buffer + PS_POS, ps); }
00069       // --------------------------------------------------------------------
00070       inline uint32_t ti()
00071       { return read<OsModel, block_data_t, uint32_t>(buffer + TI_POS); }
00072       // --------------------------------------------------------------------
00073       inline void set_ti( uint32_t ti )
00074       { write<OsModel, block_data_t, uint32_t>(buffer + TI_POS, ti); }
00075       // --------------------------------------------------------------------
00076       inline size_t buffer_size()
00077       { return MESSAGE_SIZE; }
00078 
00079    private:
00080 
00081       enum data_positions
00082       {
00083          MSG_ID_POS   = 0,
00084          SINK_POS     = 1,
00085          PTS_POS      = SINK_POS + sizeof(uint16_t),
00086          PS_POS       = PTS_POS + 2,
00087          TI_POS       = PS_POS + 2,
00088          MESSAGE_SIZE = TI_POS + 4
00089       };
00090 
00091       uint8_t buffer[MESSAGE_SIZE];
00092    };
00093    // -----------------------------------------------------------------------
00094    // -----------------------------------------------------------------------
00095    // -----------------------------------------------------------------------
00096    template<typename OsModel_P,
00097             typename Radio_P>
00098    OneHopLinkMetricsRequestMessage<OsModel_P, Radio_P>::
00099    OneHopLinkMetricsRequestMessage( uint8_t id, uint16_t sink,
00100                                     uint16_t pts, uint16_t ps, uint32_t ti )
00101    {
00102       set_msg_id( id );
00103       set_sink( sink );
00104       set_pts( pts );
00105       set_ps( ps );
00106       set_ti( ti );
00107    }
00108 
00109 }
00110 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines