1
0
Fork 0

Load pattern file from FG_HOME/antennas

This commit is contained in:
adrian 2011-12-04 11:28:59 +02:00
parent 693f868930
commit 6d816823db
2 changed files with 31 additions and 7 deletions

View file

@ -22,18 +22,20 @@
#endif
#include <math.h>
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <Scenery/scenery.hxx>
#include "antenna.hxx"
using namespace std;
FGRadioAntenna::FGRadioAntenna() {
FGRadioAntenna::FGRadioAntenna(string type) {
_mirror_y = 1;
_mirror_z = 1;
_invert_ground = 0;
load_antenna_pattern(type);
}
FGRadioAntenna::~FGRadioAntenna() {
@ -48,6 +50,26 @@ double FGRadioAntenna::calculate_gain(double azimuth, double elevation) {
/*** load external plot file generated by NEC4
***/
void FGRadioAntenna::load_antenna_pattern() {
void FGRadioAntenna::load_antenna_pattern(string type) {
SGPath pattern_file(fgGetString("/sim/fg-home"));
pattern_file.append("antennas");
pattern_file.append(type + ".txt");
if (!pattern_file.exists()) {
return;
}
ifstream file_in(pattern_file.c_str());
int heading, elevation;
double gain;
while(!file_in.eof()) {
file_in >> heading >> elevation >> gain;
cerr << "head: " << heading << " elev: " << elevation << " gain: " << gain << endl;
AntennaGain datapoint;
datapoint.azimuth = heading;
datapoint.elevation = elevation;
datapoint.gain = gain;
_pattern.push_back(datapoint);
}
}

View file

@ -27,10 +27,12 @@
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/debug/logstream.hxx>
using std::string;
class FGRadioAntenna
{
private:
void load_antenna_pattern();
void load_antenna_pattern(string type);
int _mirror_y;
int _mirror_z;
int _invert_ground;
@ -41,13 +43,13 @@ private:
double elevation;
double gain;
};
SGPath _pattern_file;
typedef std::vector<AntennaGain> AntennaPattern;
AntennaPattern _pattern;
public:
FGRadioAntenna();
FGRadioAntenna(string type);
~FGRadioAntenna();
double calculate_gain(double azimuth, double elevation);