![]() |
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. 5, 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 #include <WNS/ldk/SuspendSupport.hpp> 00029 #include <WNS/ldk/SuspendedInterface.hpp> 00030 #include <WNS/ldk/Layer.hpp> 00031 #include <WNS/ldk/fun/FUN.hpp> 00032 #include <WNS/probe/bus/utils.hpp> 00033 00034 #include <WNS/Assure.hpp> 00035 00036 00037 using namespace wns::ldk; 00038 00039 SuspendSupport::SuspendSupport(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& _config) : 00040 suspending(false), 00041 suspended(false), 00042 si(NULL), 00043 suspendStartTime(0.0), 00044 useProbe(_config.get<bool>("useSuspendProbe")), 00045 timeBufferEmpty(wns::probe::bus::collector(_fun->getLayer()->getContextProviderCollection(), 00046 _config, 00047 "suspendProbeName")), 00048 fun(_fun), 00049 config(_config) 00050 { 00051 } // SuspendSupport 00052 00053 00054 SuspendSupport::SuspendSupport(const SuspendSupport& other) : 00055 SuspendableInterface(), 00056 suspending(other.suspending), 00057 suspended(other.suspended), 00058 si(other.si), 00059 suspendStartTime(other.suspendStartTime), 00060 useProbe(other.useProbe), 00061 timeBufferEmpty(wns::probe::bus::collector(other.fun->getLayer()->getContextProviderCollection(), 00062 other.config, 00063 "suspendProbeName")), 00064 fun(other.fun), 00065 config(other.config) 00066 { 00067 } // SuspendSupport 00068 00069 00070 SuspendSupport::~SuspendSupport() 00071 {} // ~SuspendSupport 00072 00073 00074 void 00075 SuspendSupport::doSuspend(SuspendedInterface* _si) 00076 { 00077 assure(_si, "SuspendedInterface not set"); 00078 00079 si = _si; 00080 suspending = true; 00081 suspended = false; 00082 00083 suspendStartTime = wns::simulator::getEventScheduler()->getTime(); 00084 00085 trySuspend(); 00086 } // doSuspend 00087 00088 00089 bool 00090 SuspendSupport::isSuspending() const 00091 { 00092 return suspending; 00093 } // isSuspending 00094 00095 00096 void 00097 SuspendSupport::trySuspend() const 00098 { 00099 if (suspending && onSuspend() && !suspended) 00100 { 00101 suspended = true; 00102 00103 if (useProbe) 00104 { 00105 timeBufferEmpty->put(static_cast<double>(wns::simulator::getEventScheduler()->getTime() - suspendStartTime)); 00106 } 00107 00108 si->suspended(this); 00109 } 00110 } // trySuspend 00111 00112 00113
1.5.5