User Manual, Developers Guide and API Documentation

TimingScheduler.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #ifndef LTE_TIMING_TIMINGSCHEDULER_HPP
00029 #define LTE_TIMING_TIMINGSCHEDULER_HPP
00030 
00031 #include <LTE/helper/HasModeName.hpp>
00032 
00033 #include <DLL/services/control/Association.hpp>
00034 
00035 #include <WNS/ldk/ManagementServiceInterface.hpp>
00036 #include <WNS/ldk/fun/FUN.hpp>
00037 #include <WNS/pyconfig/View.hpp>
00038 #include <WNS/pyconfig/Sequence.hpp>
00039 #include <WNS/events/PeriodicTimeout.hpp>
00040 #include <WNS/events/EventFactory.hpp>
00041 #include <WNS/logger/Logger.hpp>
00042 #include <WNS/Enum.hpp>
00043 #include <WNS/container/Registry.hpp>
00044 
00045 #include <WNS/service/dll/Address.hpp>
00046 
00047 #include <vector>
00048 #include <cstdlib>
00049 
00050 namespace lte {
00051     namespace controlplane {
00052         class MapHandler;
00053         namespace associationHandler {
00054             class AssociationHandler;
00055         }
00056     }
00057     namespace timing {
00058         namespace events {
00059             class Base;
00060         }
00061 
00064         // e.g. lte::timing::StationTasks::RAP()
00065         ENUM_BEGIN(StationTasks);
00066         ENUM(RAP, 1);
00067         ENUM(UT, 2);
00068         ENUM(IDLE, 3);
00069         ENUM(INVALID, 4);
00070         ENUM_END();
00071         typedef int StationTask;
00072 
00074         ENUM_BEGIN(DuplexSchemes);
00075         ENUM(TDD, 1);
00076         ENUM(FDD, 2);
00077         ENUM_END();
00078         typedef int DuplexScheme;
00079 
00080         class FrameStartNotificationInterface
00081         {
00082         public:
00083             virtual
00084             ~FrameStartNotificationInterface(){}
00085 
00086             virtual void
00087             onFrameStart() = 0;
00088         };
00089 
00090         class SuperFrameStartNotificationInterface
00091         {
00092         public:
00093             virtual
00094             ~SuperFrameStartNotificationInterface(){}
00095 
00096             virtual void
00097             onSuperFrameStart() = 0;
00098         };
00099 
00103         class TimingScheduler :
00104                 public wns::ldk::ManagementService,
00105                 public wns::events::PeriodicTimeout,
00106                 public lte::helper::HasModeName,
00107                 public dll::services::control::AssociationObserver,
00108                 public wns::Subject<FrameStartNotificationInterface>,
00109                 public wns::Subject<SuperFrameStartNotificationInterface>
00110         {
00111             friend class controlplane::associationHandler::AssociationHandler;
00112 
00113         public:
00114             TimingScheduler(wns::ldk::ManagementServiceRegistry* msr,
00115                             wns::pyconfig::View _config);
00116 
00117             virtual
00118             ~TimingScheduler();
00119 
00121             virtual void periodically();
00122 
00124             bool isPeerListeningAt(const wns::service::dll::UnicastAddress& peerAddress, const int frameNr);
00125 
00128             bool canReceiveMapNow(const wns::service::dll::UnicastAddress& address);
00129 
00131             void onMSRCreated();
00132 
00134             void onWorldCreated();
00135 
00140             lte::timing::StationTask
00141             stationTaskAtOffset(const simTimeType offset) const;
00142 
00144             lte::timing::StationTask
00145             stationTaskAtFrame(int frameNr) const;
00146 
00148             void
00149             initStationTaskPhases();
00150 
00152             uint32_t
00153             phaseNumberAtOffset(const simTimeType offset) const;
00154 
00156             uint32_t
00157             phaseNumberAtFrame(int frameNr) const;
00158 
00159             virtual void onDisassociated(wns::service::dll::UnicastAddress userAdr,
00160                                          wns::service::dll::UnicastAddress dstAdr);
00161 
00162             virtual void onAssociated(wns::service::dll::UnicastAddress userAdr,
00163                                       wns::service::dll::UnicastAddress dstAdr);
00164 
00165             void
00166             superFrameTrigger();
00167 
00168             void
00169             frameTrigger();
00170 
00173         private:
00174             dll::ILayer2* layer2;
00175             wns::ldk::fun::FUN* fun;
00176             wns::pyconfig::View config;
00177             wns::logger::Logger logger;
00178 
00180             struct Friends {
00181                 lte::controlplane::MapHandler* mapHandler;
00182             } friends;
00183 
00185             simTimeType superFrameLength;
00187             simTimeType superFrameStartTime;
00189             struct TimingEvent {
00190                 simTimeType timeOffset;
00191                 lte::timing::events::Base* event;
00192             };
00193             typedef std::vector<TimingEvent> EventContainer;
00194             struct StationTaskPhase {
00195                 simTimeType startTime; // relative to superframe start
00196                 simTimeType duration; // [s]
00197                 StationTask task;
00198             };
00199             typedef std::vector<StationTaskPhase> StationTaskPhaseContainer;
00200             typedef wns::container::Registry<wns::service::dll::UnicastAddress, EventContainer> PeerTiming;
00201             typedef wns::container::Registry<wns::service::dll::UnicastAddress, TimingScheduler*> PeerTimingSchedulers;
00202 
00203             EventContainer eventContainer;
00204             StationTaskPhaseContainer stationTaskPhaseContainer;
00205             PeerTiming peerTiming;
00206             PeerTimingSchedulers peerTimingSchedulers;
00207 
00208             wns::events::scheduler::Interface* es;
00209 
00212             void readEvents(std::string viewName);
00214             void readStationTaskPhases(std::string viewName);
00215 
00217             void
00218             addPeerTimingScheduler(wns::service::dll::UnicastAddress peerAddress, TimingScheduler* _timingScheduler);
00219             void
00220             removePeerTimingScheduler(wns::service::dll::UnicastAddress peerAddress);
00221 
00222             simTimeType startOfFirstFrame;
00223             simTimeType frameLength;
00224             int schedulingOffset;
00225             int numberOfFramesToSchedule;
00226             int framesPerSuperFrame;
00227         public:
00229             simTimeType switchingPointOffset;
00231             lte::timing::DuplexScheme duplex;
00232             int getSchedulingOffset() const;
00233             int getNumberOfFramesToSchedule() const;
00234         }; // TimingScheduler
00235     } //timing
00236 } // lte
00237 
00238 #endif // NOT defined LTE_TIMING_TIMINGSCHEDULER_HPP

Generated on Sat May 26 03:32:03 2012 for openWNS by  doxygen 1.5.5