![]() |
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 #include <CONSTANZE/DllListenerBinding.hpp> 00029 00030 #include <WNS/StaticFactory.hpp> 00031 #include <WNS/module/Base.hpp> 00032 #include <WNS/service/dll/Address.hpp> 00033 00034 using namespace constanze; 00035 00036 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00037 constanze::DllListenerBinding, 00038 constanze::Binding, 00039 "DllListenerBinding", 00040 wns::PyConfigViewCreator); 00041 00042 DllListenerBinding::DllListenerBinding(const wns::pyconfig::View& _pyco): 00043 pyco(_pyco), 00044 listenDll(pyco.get<long int>("listenDll")), 00045 log(pyco.get("logger")) 00046 { 00047 MESSAGE_BEGIN(NORMAL, log, m, "New DllListenerBinding created for own MACAddress="); 00048 m << listenDll; // own MAC address 00049 MESSAGE_END(); 00050 } 00051 00052 void DllListenerBinding::sendData(const wns::osi::PDUPtr&) 00053 { 00054 // intentionally left empty 00055 } 00056 00057 void DllListenerBinding::registerComponent(wns::node::component::Component* _component) 00058 { 00059 component = _component; 00060 dllNotification = 00061 component->getService<wns::service::dll::Notification*>( 00062 pyco.get<std::string>("dllNotification")); 00063 dllNotification->registerHandler(wns::service::dll::CONSTANZE, this); 00064 } 00065 00066 void DllListenerBinding::onData(const wns::osi::PDUPtr& _data, wns::service::dll::FlowID /*dllFlowID*/) 00067 { 00068 assure(listener, "No listener set."); 00069 MESSAGE_BEGIN(NORMAL, log, m, "Received " << _data->getLengthInBits()/8 << " bytes"); // "from ?" 00070 MESSAGE_END(); 00071 listener->onData(_data); 00072 } 00073 00074 void DllListenerBinding::registerListener(constanze::Listener* _listener) 00075 { 00076 listener = _listener; 00077 } 00078 00079 void DllListenerBinding::initBinding(constanze::StartTrigger* _trigger) 00080 { 00081 _trigger->bindingReady(); 00082 } 00083 00084 void DllListenerBinding::releaseBinding(constanze::StopTrigger* _trigger) 00085 { 00086 _trigger->bindingReady(); 00087 } 00088 00089 std::string DllListenerBinding::printAddress() const 00090 { 00091 std::ostringstream tmp; 00092 tmp << listenDll; 00093 return tmp.str(); 00094 } 00095
1.5.5