![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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. 16, 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 // begin example "wns.queuingsystem.mm1step1.hpp.example" 00029 #ifndef WNS_QUEUINGSYSTEM_MM1STEP1_HPP 00030 #define WNS_QUEUINGSYSTEM_MM1STEP1_HPP 00031 00032 #include <WNS/rng/RNGen.hpp> 00033 #include <WNS/simulator/ISimulator.hpp> 00034 #include <WNS/simulator/ISimulationModel.hpp> 00035 #include <WNS/logger/Logger.hpp> 00036 #include <WNS/IOutputStreamable.hpp> 00037 #include <WNS/pyconfig/View.hpp> 00038 #include <WNS/distribution/Distribution.hpp> 00039 00040 #include <boost/bind.hpp> 00041 00042 // In the OpenWNS we use nested namespaces 00043 // which reflect the directory tree 00044 // This file is in ./src/queuingsystem/ 00045 // so the convention is to use the same namespace: 00046 00047 namespace wns { namespace queuingsystem { 00048 00049 // Simulation model for queueing system tutorial (step 1). 00050 // 00051 // Here We implement our own simulation model. To allow the openwns 00052 // application to load our custom simulation model, we must inherit 00053 // from wns::simulator::ISimulationModel. 00054 // 00061 class SimpleMM1Step1 : 00062 public IOutputStreamable, 00063 public wns::simulator::ISimulationModel 00064 { 00065 public: 00066 // All simulation models must be constructible from a 00067 // wns::pyconfig::View. 00071 explicit 00072 SimpleMM1Step1(const wns::pyconfig::View& configuration); 00073 // ^ The Python class used in MM1Step1.py 00074 // is intentionally called the same. 00075 // The Python view parameter here gets the values set as member 00076 // in the constructor of the Python class. 00077 00078 private: 00079 // Implementation of the ISimulationModel interface. 00080 // The openwns application will call this method to indicate 00081 // that construction of the environment (scheduler, random number 00082 // generator, etc.) has finished. 00083 // 00084 // We will place our own startup code here 00085 virtual void 00086 doStartup(); 00087 00088 // Implementation of the ISimulationModel interface. 00089 // The openwns application will call this method to indicate 00090 // that the simulation ends and the model should shut down. 00091 // 00092 // We will place our own shutdown code here 00093 virtual void 00094 doShutdown(); 00095 00096 // Implementation of the IOutputStreamable interface. 00097 // IOutputStreamable implements the stream output operator for 00098 // us. It will get the contents to output to the stream by 00099 // calling this method. 00100 virtual std::string 00101 doToString() const; 00102 00103 // Generates a new job that enters the queuing system 00104 void 00105 generateNewJob(); 00106 00107 // Excuted after a job has been processed 00108 void 00109 onJobProcessed(); 00110 00111 // Starts processing of the next job if one is available 00112 void 00113 processNextJob(); 00114 00115 // A random number generator object pointer. 00119 wns::distribution::Distribution* jobInterarrivalTime_; 00120 00121 // A random number generator object that creates exponentially 00122 // distributed random numbers. 00123 wns::distribution::Distribution* jobProcessingTime_; 00124 00125 // Counter for the number of jobs in our system 00126 int jobsInSystem_; 00127 00128 // Used to access the logging subsystem 00129 wns::logger::Logger logger_; 00130 }; 00131 } 00132 } 00133 00134 #endif // NOT defined WNS_QUEUINGSYSTEM_MM1STEP1_HPP 00135 // end example 00136 00137 // The following block is meta data used for tha automatic generation of 00138 // documentation by the "Doxygen" system. 00139
1.5.5