User Manual, Developers Guide and API Documentation

ReadyForTransmissionBufferEmpty.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/selectiverepeat/ReadyForTransmissionBufferEmpty.hpp>
00014 #include <GLUE/arqfsm/selectiverepeat/ReadyForTransmissionBufferPartlyFilled.hpp>
00015 
00016 #include <WNS/Assure.hpp>
00017 
00018 using namespace glue::arqfsm::selectiverepeat;
00019 using namespace wns::ldk;
00020 
00021 STATIC_FACTORY_REGISTER_WITH_CREATOR(ReadyForTransmissionBufferEmpty,
00022                      StateInterface,
00023                      "glue_arqfsm_selectiverepeat_ReadyForTransmissionBufferEmpty",
00024                      wns::fsm::FSMConfigCreator);
00025 
00026 void
00027 ReadyForTransmissionBufferEmpty::onInitState()
00028 {
00029     assureType(getFU(), wns::ldk::SuspendSupport*);
00030     dynamic_cast<wns::ldk::SuspendSupport*>(getFU())->trySuspend();
00031 } // onInitState
00032 
00033 
00034 StateInterface*
00035 ReadyForTransmissionBufferEmpty::onSendData(const CompoundPtr& compound)
00036 {
00037     SelectiveRepeatCommand* command = dynamic_cast<SelectiveRepeatCommand*>(getFU()->activateCommand(compound->getCommandPool()));
00038     assure(command, "Command is not a SelectiveRepeatCommand.");
00039 
00040     command->peer.type = SelectiveRepeatCommand::I;
00041     command->peer.NS = vars().NS;
00042 
00043     MESSAGE_BEGIN(NORMAL, vars().logger, m, getFUNName());
00044     m << " processOutgoing"
00045       << " NS -> " << command->peer.NS;
00046     MESSAGE_END();
00047 
00048     vars().sentCompounds[vars().NS] = compound;
00049 
00050     vars().NS = (vars().NS + 1) % vars().sequenceNumberSize;
00051     ++vars().levelSendBuffer;
00052 
00053     vars().pendingCompoundsQueue.push_back(compound);
00054 
00055     tryToSendIs();
00056 
00057     return getFSM()->createState<ReadyForTransmissionBufferPartlyFilled>();
00058 } // onSendData
00059 
00060 
00061 StateInterface*
00062 ReadyForTransmissionBufferEmpty::onACK(int)
00063 {
00064     MESSAGE_BEGIN(NORMAL, vars().logger, m, getFUNName());
00065     m << " ignoring unexpected ACK";
00066     MESSAGE_END();
00067 
00068     return this;
00069 } // onACK
00070 
00071 
00072 StateInterface*
00073 ReadyForTransmissionBufferEmpty::onWakeup()
00074 {
00075     tryToSendACKs();
00076     sendWakeup();
00077     return this;
00078 } // onWakeup
00079 
00080 
00081 void
00082 ReadyForTransmissionBufferEmpty::onIsAccepting(bool& accepting) const
00083 {
00084     accepting = true;
00085 } // onIsAccepting
00086 
00087 
00088 StateInterface*
00089 ReadyForTransmissionBufferEmpty::onTimeout(const CompoundPtr&)
00090 {
00091     assure(false, "Invalid timeout signal!");
00092     return this;
00093 } // onTimeout
00094 
00095 
00096 

Generated on Fri May 25 03:31:59 2012 for openWNS by  doxygen 1.5.5