![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WNS (Wireless Network Simulator) * 00003 * __________________________________________________________________________ * 00004 * * 00005 * Copyright (C) 2004-2006 * 00006 * Chair of Communication Networks (ComNets) * 00007 * Kopernikusstr. 16, D-52074 Aachen, Germany * 00008 * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242 * 00009 * email: wns@comnets.rwth-aachen.de * 00010 * www: http://wns.comnets.rwth-aachen.de * 00011 ******************************************************************************/ 00012 00013 #include <GLUE/arqfsm/selectiverepeat/FSMFU.hpp> 00014 #include <GLUE/arqfsm/selectiverepeat/ReadyForTransmissionBufferEmpty.hpp> 00015 00016 #include <iostream> 00017 00018 using namespace glue::arqfsm::selectiverepeat; 00019 using namespace wns::ldk; 00020 00021 STATIC_FACTORY_REGISTER_WITH_CREATOR(FSMFU, FunctionalUnit, "glue.arqfsm.selectiverepeat.FSMFU", FUNConfigCreator); 00022 00023 FSMFU::FSMFU(fun::FUN* fun, const wns::pyconfig::View& _config) : 00024 MyFUInterface(Variables(_config)), 00025 wns::ldk::CommandTypeSpecifier<SelectiveRepeatCommand>(fun), 00026 wns::ldk::HasReceptor<>(), 00027 wns::ldk::HasConnector<>(), 00028 wns::ldk::HasDeliverer<>(), 00029 wns::ldk::SuspendSupport(fun, _config), 00030 wns::Cloneable<FSMFU>(), 00031 wns::events::MultipleTimeout<CompoundPtr>(), 00032 config(_config), 00033 bitsPerIFrame(config.get<int>("bitsPerIFrame")), 00034 bitsPerACKFrame(config.get<int>("bitsPerACKFrame")) 00035 { 00036 changeState(createState<ReadyForTransmissionBufferEmpty>()); 00037 } // FSMFU 00038 00039 00040 void 00041 FSMFU::calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& sduSize) const 00042 { 00043 // What are the sizes in the upper FUs? 00044 getFUN()->calculateSizes(commandPool, commandPoolSize, sduSize, this); 00045 00046 SelectiveRepeatCommand* command = getCommand(commandPool); 00047 switch(command->peer.type) { 00048 case SelectiveRepeatCommand::I: 00049 commandPoolSize += bitsPerIFrame; 00050 break; 00051 case SelectiveRepeatCommand::ACK: 00052 commandPoolSize += bitsPerACKFrame; 00053 break; 00054 } 00055 } // calculateSizes 00056 00057 00058 void 00059 FSMFU::onTimeout(const CompoundPtr& compound) 00060 { 00061 assureType(this->getState(), BaseState*); 00062 00063 BaseState* bs = dynamic_cast<BaseState*>(this->getState()); 00064 00065 do 00066 { 00067 ++inAction; 00068 BaseFSM::StateInterface* stateInterface = bs->onTimeout(compound); 00069 --inAction; 00070 this->changeState(stateInterface); 00071 } 00072 while (linkHandler()); 00073 return; 00074 } // onTimeout 00075 00076 00077 bool 00078 FSMFU::onSuspend() const 00079 { 00080 return getStateName() == std::string("glue_arqfsm_selectiverepeat_ReadyForTransmissionBufferEmpty"); 00081 } // onSuspend 00082 00083 00084 void 00085 FSMFU::doDelayDelivery() 00086 { 00087 getVariables().delayingDelivery = true; 00088 } // doDelayDelivery 00089 00090 00091 void 00092 FSMFU::doDeliver() 00093 { 00094 getVariables().delayingDelivery = false; 00095 00096 assureType(this->getState(), BaseState*); 00097 BaseState* bs = dynamic_cast<BaseState*>(this->getState()); 00098 00099 bs->deliverCompounds(); 00100 } // doDeliver 00101 00102 00103
1.5.5