1
/*******************************************************************************
2
* This file is part of openWNS (open Wireless Network Simulator)
3
* _____________________________________________________________________________
5
* Copyright (C) 2004-2009
6
* Chair of Communication Networks (ComNets)
7
* Kopernikusstr. 5, D-52074 Aachen, Germany
8
* phone: ++49-241-80-27910,
9
* fax: ++49-241-80-22242
10
* email: info@openwns.org
11
* www: http://www.openwns.org
12
* _____________________________________________________________________________
14
* openWNS is free software; you can redistribute it and/or modify it under the
15
* terms of the GNU Lesser General Public License version 2 as published by the
16
* Free Software Foundation;
18
* openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
19
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
23
* You should have received a copy of the GNU Lesser General Public License
24
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26
******************************************************************************/
28
#include <WIMAC/scheduler/ULCallback.hpp>
29
#include <WNS/ldk/Layer.hpp>
30
#include <WNS/scheduler/RegistryProxyInterface.hpp>
31
#include <WIMAC/Logger.hpp>
32
#include <WIMAC/PhyAccessFunc.hpp>
33
#include <WIMAC/PhyUserCommand.hpp>
34
#include <WIMAC/PhyUser.hpp>
37
STATIC_FACTORY_REGISTER_WITH_CREATOR(
38
wimac::scheduler::ULCallback,
39
wimac::scheduler::Callback,
40
"wimac.scheduler.ULCallback",
41
wns::ldk::FUNConfigCreator );
43
using namespace wimac::scheduler;
45
ULCallback::ULCallback(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& /*config*/) :
51
ULCallback::callBack(wns::scheduler::MapInfoEntryPtr mapInfoEntry)
53
simTimeType startTime = mapInfoEntry->start;
54
simTimeType endTime = mapInfoEntry->end;
55
wns::scheduler::UserID user = mapInfoEntry->user;
56
int userID = user->getNodeID();
57
int fSlot = mapInfoEntry->subBand;
58
int beam = mapInfoEntry->beam;
59
wns::Power txPower = mapInfoEntry->txPower;
60
wns::service::phy::phymode::PhyModeInterfacePtr phyModePtr = mapInfoEntry->phyModePtr;
61
wns::service::phy::ofdma::PatternPtr pattern = mapInfoEntry->pattern;
62
wns::CandI estimatedCandI = mapInfoEntry->estimatedCandI;
63
std::list<wns::ldk::CompoundPtr> compounds = mapInfoEntry->compounds;
65
double rate = phyModePtr->getDataRate();
67
assure(compounds.size() > 0, "Empty compound list");
68
simTimeType pduEndTime = (*(compounds.begin()))->getLengthInBits() / rate;
69
simTimeType pduStartTime = 0.0;
71
// iterate over all compounds in list:
72
for (wns::scheduler::CompoundList::iterator iter=compounds.begin(); iter!=compounds.end(); ++iter)
74
wns::ldk::CompoundPtr pdu = *iter;
76
assure(pdu != wns::ldk::CompoundPtr(), "Invalid PDU");
78
#ifndef WNS_NO_LOGGING
80
m << ": direction: UL \n"
81
<< " PDU scheduled for user: " << colleagues.registry->getNameForUser(user) << "\n"
82
<< " Frequency Slot: " << fSlot << "\n"
83
<< " StartTime: " << pduStartTime << "\n"
84
<< " EndTime: " << pduEndTime << "\n"
85
// << " Beamforming: " << beamforming << "\n"
86
<< " Beam: " << beam << "\n"
87
<< " Tx Power: " << txPower;
88
LOG_INFO(fun_->getLayer()->getName(), m.str());
93
/// @todo enable frame plotting again
95
// // substr(19,2) should deliver the "subscriber station xy"
97
// std::string printID;
99
// if (uplink || measureInterference)
100
// printID = colleagues.registry->getNameForUser(user);
102
// printID = std::string("");
103
// *plotFiles[fSlot] << startTime << "\t" << endTime << "\t"
104
// << float(beam) << "\t" << cidColor/2.0 << "\t\"" << printID << "\"\n";
109
//only in beamforming case receive pattern need to be set
110
PatternSetterPhyAccessFunc* patternFunc =
111
new PatternSetterPhyAccessFunc;
112
patternFunc->destination_ = user;
113
patternFunc->patternStart_ = pduStartTime;
114
patternFunc->patternEnd_ = pduEndTime;
115
patternFunc->pattern_ = pattern;
117
// set PhyUser command
118
wimac::PhyUserCommand* phyCommand = dynamic_cast<wimac::PhyUserCommand*>(
119
fun_->getProxy()->activateCommand( pdu->getCommandPool(), friends_.phyUser ) );
121
phyCommand->local.pAFunc_.reset( patternFunc );
123
phyCommand->peer.destination_ = user;
124
wimac::Component* wimacComponent = dynamic_cast<wimac::Component*>(fun_->getLayer());
125
phyCommand->peer.cellID_ = wimacComponent->getCellID();
126
phyCommand->peer.source_ = wimacComponent->getNode();
127
phyCommand->peer.phyModePtr = phyModePtr;
128
// (wns::SmartPtr<const wns::service::phy::phymode::PhyModeInterface>
129
// (dynamic_cast<const wns::service::phy::phymode::PhyModeInterface*>(phyMode.clone())));
131
phyCommand->peer.measureInterference_ = true; //measureInterference;
132
phyCommand->peer.estimatedCandI_ = estimatedCandI;
133
phyCommand->magic.sourceComponent_ = wimacComponent;
135
/// @todo enable pduWatch
136
//this->pduWatch(pdu); // Watch for special compounds to inform its observer
138
scheduledPDUs.push(pdu);
140
simTimeType oldEnd = pduEndTime;
141
pduEndTime = pduEndTime + pdu->getLengthInBits() / rate;
142
pduStartTime = oldEnd;
146
void ULCallback::deliverNow(wns::ldk::Connector* connector)
149
simTimeType now = wns::simulator::getEventScheduler()->getTime();
153
while( !scheduledPDUs.empty())
155
wns::ldk::CompoundPtr compound =
156
scheduledPDUs.front();
157
PhyUserCommand* phyUserCommand =
158
friends_.phyUser->getCommand( compound->getCommandPool() );
160
PatternSetterPhyAccessFunc* func =
161
dynamic_cast<PatternSetterPhyAccessFunc*>(phyUserCommand->local.pAFunc_.get());
163
func->patternStart_ += now;
164
func->patternEnd_ += now;
166
if ( connector->hasAcceptor(scheduledPDUs.front() ) )
168
connector->getAcceptor(scheduledPDUs.front())->sendData(scheduledPDUs.front());
173
throw wns::Exception( "Lower FU is not accepting scheduled PDU but is supposed to do so" );