User Manual, Developers Guide and API Documentation

FSMFU.cpp

Go to the documentation of this file.
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/stopandwait/FSMFU.hpp>
00014 #include <GLUE/arqfsm/stopandwait/ReadyForTransmission.hpp>
00015 
00016 using namespace glue::arqfsm::stopandwait;
00017 using namespace wns::ldk;
00018 
00019 STATIC_FACTORY_REGISTER_WITH_CREATOR(FSMFU, FunctionalUnit, "glue.arqfsm.stopandwait.FSMFU", FUNConfigCreator);
00020 
00021 FSMFU::FSMFU(fun::FUN* fun, const wns::pyconfig::View& _config) :
00022     MyFUInterface(Variables(_config)),
00023     wns::ldk::CommandTypeSpecifier<StopAndWaitCommand>(fun),
00024     wns::ldk::HasReceptor<>(),
00025     wns::ldk::HasConnector<>(),
00026     wns::ldk::HasDeliverer<>(),
00027     wns::ldk::SuspendSupport(fun, _config),
00028     wns::Cloneable<FSMFU>(),
00029     config(_config),
00030     bitsPerIFrame(config.get<int>("bitsPerIFrame")),
00031     bitsPerRRFrame(config.get<int>("bitsPerRRFrame"))
00032 {
00033     changeState(createState<ReadyForTransmission>());
00034 } // FSMFU
00035 
00036 
00037 void
00038 FSMFU::calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& sduSize) const
00039 {
00040     // What are the sizes in the upper FUs?
00041     getFUN()->calculateSizes(commandPool, commandPoolSize, sduSize, this);
00042 
00043     StopAndWaitCommand* command = getCommand(commandPool);
00044     switch(command->peer.type) {
00045     case StopAndWaitCommand::I:
00046         commandPoolSize += bitsPerIFrame;
00047         break;
00048     case StopAndWaitCommand::ACK:
00049         commandPoolSize += bitsPerRRFrame;
00050         break;
00051     }
00052 } // calculateSizes
00053 
00054 
00055 void
00056 FSMFU::onTimeout()
00057 {
00058     assureType(this->getState(), BaseState*);
00059 
00060         BaseState* bs = dynamic_cast<BaseState*>(this->getState());
00061 
00062         do
00063     {
00064         ++inAction;
00065                 BaseFSM::StateInterface* stateInterface = bs->onTimeout();
00066         --inAction;
00067         this->changeState(stateInterface);
00068     }
00069         while (linkHandler());
00070         return;
00071 } // onTimeout
00072 
00073 
00074 bool
00075 FSMFU::onSuspend() const
00076 {
00077     return getStateName() == std::string("glue_arqfsm_stopandwait_ReadyForTransmission");
00078 } // onSuspend
00079 
00080 
00081 

Generated on Sun May 27 03:31:58 2012 for openWNS by  doxygen 1.5.5