Load pattern file from FG_HOME/antennas
This commit is contained in:
parent
693f868930
commit
6d816823db
2 changed files with 31 additions and 7 deletions
|
@ -22,18 +22,20 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <fstream>
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
#include "antenna.hxx"
|
#include "antenna.hxx"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
FGRadioAntenna::FGRadioAntenna() {
|
FGRadioAntenna::FGRadioAntenna(string type) {
|
||||||
|
|
||||||
_mirror_y = 1;
|
_mirror_y = 1;
|
||||||
_mirror_z = 1;
|
_mirror_z = 1;
|
||||||
_invert_ground = 0;
|
_invert_ground = 0;
|
||||||
|
load_antenna_pattern(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
FGRadioAntenna::~FGRadioAntenna() {
|
FGRadioAntenna::~FGRadioAntenna() {
|
||||||
|
@ -48,6 +50,26 @@ double FGRadioAntenna::calculate_gain(double azimuth, double elevation) {
|
||||||
|
|
||||||
/*** load external plot file generated by NEC4
|
/*** 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,12 @@
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
class FGRadioAntenna
|
class FGRadioAntenna
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void load_antenna_pattern();
|
void load_antenna_pattern(string type);
|
||||||
int _mirror_y;
|
int _mirror_y;
|
||||||
int _mirror_z;
|
int _mirror_z;
|
||||||
int _invert_ground;
|
int _invert_ground;
|
||||||
|
@ -41,13 +43,13 @@ private:
|
||||||
double elevation;
|
double elevation;
|
||||||
double gain;
|
double gain;
|
||||||
};
|
};
|
||||||
|
SGPath _pattern_file;
|
||||||
typedef std::vector<AntennaGain> AntennaPattern;
|
typedef std::vector<AntennaGain> AntennaPattern;
|
||||||
AntennaPattern _pattern;
|
AntennaPattern _pattern;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGRadioAntenna();
|
FGRadioAntenna(string type);
|
||||||
~FGRadioAntenna();
|
~FGRadioAntenna();
|
||||||
double calculate_gain(double azimuth, double elevation);
|
double calculate_gain(double azimuth, double elevation);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue