![]() |
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 <RISE/antenna/pattern/kernel/ThreeDimensional.hpp> 00029 00030 #include <fstream> 00031 00032 using namespace rise::antenna::pattern::kernel; 00033 00034 ThreeDimensional::ThreeDimensional() 00035 : Kernel(), 00036 pd_pattern3DVector(181, Double64Vector(361)) 00037 {} 00038 00039 ThreeDimensional::ThreeDimensional(const std::string type, 00040 const std::string pattern) 00041 : Kernel(type, pattern), 00042 pd_pattern3DVector(181, Double64Vector(361)) 00043 {} 00044 00045 wns::Ratio ThreeDimensional::getGain(const wns::Direction& direction) 00046 { 00047 unsigned long int elevation_index = (unsigned long int)(direction.getElevation() * 180 / M_PI); 00048 unsigned long int azimuth_index = (unsigned long int)(direction.getAzimuth() * 180 / M_PI); 00049 wns::Ratio directivity; 00050 directivity.set_dB(pd_pattern3DVector[elevation_index][azimuth_index] 00051 + pd_gain); 00052 return directivity; 00053 } 00054 00055 Kernel* ThreeDimensional::createPatternKernel(const std::string type, 00056 const std::string pattern) 00057 { 00058 ThreeDimensional* pk = new ThreeDimensional (type, pattern); 00059 pk -> readPattern(); 00060 return pk; 00061 } 00062 void ThreeDimensional::readPattern() 00063 { 00064 MESSAGE_BEGIN(NORMAL, log, m,"Reading new pattern from file: "); 00065 m << pattern << "... "; 00066 MESSAGE_END(); 00067 std::ifstream patternfile; 00068 patternfile.open(pattern.c_str()); 00069 if(patternfile.good() == false) 00070 { 00071 MESSAGE_BEGIN(NORMAL, log, m,"The following file could not be open: "); 00072 m << ". Check if the file name is correct. Exiting..."; 00073 MESSAGE_END(); 00074 exit(0); 00075 } 00076 std::string tmp_string = ""; 00077 double elevation_index = 0, azimuth_index = 0, directivity = 0; 00078 00079 while (tmp_string != "GAIN") 00080 patternfile >> tmp_string; 00081 wns::Ratio r; 00082 patternfile >> r; 00083 pd_gain = r.get_dB(); 00084 00085 for (int j = -180; j<= 180; j++) 00086 for (int i = 0; i<= 180; i++) 00087 { 00088 patternfile >> elevation_index; 00089 patternfile >> azimuth_index; 00090 patternfile >> directivity; 00091 patternfile >> tmp_string; 00092 if (j < 0) 00093 pd_pattern3DVector[i][j+360] = directivity; 00094 else 00095 pd_pattern3DVector[i][j] = directivity; 00096 } 00097 patternfile.close(); 00098 MESSAGE_BEGIN(NORMAL, log, m,"Pattern read."); 00099 MESSAGE_END(); 00100 } 00101 00102
1.5.5