User Manual, Developers Guide and API Documentation

BeaconCollector.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiMeMac                                                                    *
00003  * This file is part of openWNS (open Wireless Network Simulator)
00004  * _____________________________________________________________________________
00005  *
00006  * Copyright (C) 2004-2011
00007  * Chair of Communication Networks (ComNets)
00008  * Kopernikusstr. 5, D-52074 Aachen, Germany
00009  * phone: ++49-241-80-27910,
00010  * fax: ++49-241-80-22242
00011  * email: info@openwns.org
00012  * www: http://www.openwns.org
00013  * _____________________________________________________________________________
00014  *
00015  * openWNS is free software; you can redistribute it and/or modify it under the
00016  * terms of the GNU Lesser General Public License version 2 as published by the
00017  * Free Software Foundation;
00018  *
00019  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00020  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00021  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00022  * details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00026  *
00027  ******************************************************************************/
00028  
00029 #ifndef WIMEMAC_FRAME_BEACONCOLLECTOR_H
00030 #define WIMEMAC_FRAME_BEACONCOLLECTOR_H
00031 
00032 #include <WNS/ldk/fcf/CompoundCollector.hpp>
00033 #include <WNS/ldk/FunctionalUnit.hpp>
00034 #include <WNS/events/CanTimeout.hpp>
00035 #include <WNS/logger/Logger.hpp>
00036 #include <WIMEMAC/management/IBeaconBuilderServices.hpp>
00037 #include <WIMEMAC/lowerMAC/IManagerServices.hpp>
00038 #include <boost/bind.hpp>
00039 #include <WNS/events/scheduler/Callable.hpp>
00040 
00041 namespace wimemac {
00042 namespace frame {
00043 
00044 
00045 
00046     /*
00047         * @brief The BeaconCollector is the first phase within the WiMedia superframe.
00048     * Its length in time depends on active devices. 
00049     * It's mandatory to send a beacon inside the BP, hence the length of the BP is variable. 
00050     * If BeaconPhase has started, an offset timer is set (BeaconScheduler). When the selected offset
00051     * time has expired, a beacon compound is created. 
00052     * - # sending mode: build beacon compound, send broadcast beacon
00053     * - # receiving mode: forward compound to BeaconBuilder for evaluating
00054     * If BP is over, then trigger BeaconBuilder to create a DataTransferPeriodMap (DTPmap).
00055     * After beacon evaluating the DTPmap holds the upcoming reservation events
00056     */
00057 
00058     class BeaconCollector :
00059         public wns::ldk::fcf::CompoundCollector,
00060         public wns::ldk::CommandTypeSpecifier<wns::ldk::EmptyCommand>,
00061         public wns::ldk::HasConnector<>,
00062         public wns::ldk::HasReceptor<>,
00063         public wns::ldk::HasDeliverer<>,
00064         public wns::Cloneable<BeaconCollector>,
00065         public wns::events::CanTimeout        
00066     {
00067         public:
00068             BeaconCollector(wns::ldk::fun::FUN* fun, const 
00069                 wns::pyconfig::View& config );
00070 
00071             void doOnData(const wns::ldk::CompoundPtr& );
00072             void doSendData(const wns::ldk::CompoundPtr& );
00073 
00074             /*@brief accept beacon compound if in sending mode only */
00075             bool doIsAccepting(const wns::ldk::CompoundPtr& compound) const;
00076 
00077             void doWakeup();
00078             void doStart(int);
00079 
00080             void doStartCollection(int){}
00081             void finishCollection(){}
00082 
00083             /*@brief offset timer has expired, build beacon compound and send it */
00084             void TimeToTransmit();
00085 
00086             wns::simulator::Time getCurrentDuration() const{return getMaximumDuration();}
00087 
00088         protected:
00089 
00090             virtual void onFUNCreated();
00091 
00092         private:
00093 
00094             wns::logger::Logger logger;
00095             wns::simulator::Time duration;
00096             wns::simulator::Time BeaconSlotDuration;
00097             void onTimeout();
00098             bool gotWakeup;
00099             bool sending;
00100             int BeaconSlot;
00101             wns::simulator::Time BPStart;
00102 
00103 
00104             /*@brief BeaconScheduler calculates offset time. Offset time depends on the
00105             * chosen beacon slot */
00106             //BeaconScheduler beaconscheduler;
00107             const std::string managerName;
00108 
00109             /*@brief This upper fu creates and evaluates beacon compounds */
00110 
00111             struct Friends
00112             {
00113                 wimemac::management::IBeaconBuilderServices* beaconbuilder;
00114                 wimemac::lowerMAC::IManagerServices* manager;
00115             } friends;
00116     };
00117 
00118 }
00119 }
00120 #endif

Generated on Mon May 21 03:32:18 2012 for openWNS by  doxygen 1.5.5