44 #include "FGMagnetometer.h" 45 #include "simgear/magvar/coremag.hxx" 46 #include "input_output/FGXMLElement.h" 47 #include "models/FGFCS.h" 53 IDENT(IdSrc,
"$Id: FGMagnetometer.cpp,v 1.10 2015/07/12 19:34:08 bcoconni Exp $");
54 IDENT(IdHdr,ID_MAGNETOMETER);
61 FGMagnetometer::FGMagnetometer(FGFCS* fcs, Element* element) : FGSensor(fcs, element),
62 FGSensorOrientation(element),
64 INERTIAL_UPDATE_RATE(1000)
66 Propagate = fcs->GetExec()->GetPropagate();
67 MassBalance = fcs->GetExec()->GetMassBalance();
68 Inertial = fcs->GetExec()->GetInertial();
70 Element* location_element = element->FindElement(
"location");
71 if (location_element) vLocation = location_element->FindElementTripletConvertTo(
"IN");
72 else {cerr <<
"No location given for magnetometer. " << endl; exit(-1);}
74 vRadius = MassBalance->StructuralToBody(vLocation);
80 tm * ptm = gmtime ( &rawtime );
82 int year = ptm->tm_year;
88 date = (yymmdd_to_julian_days(ptm->tm_year,ptm->tm_mon,ptm->tm_mday));
95 FGMagnetometer::~FGMagnetometer()
101 void FGMagnetometer::updateInertialMag(
void)
104 if (counter > INERTIAL_UPDATE_RATE)
108 usedLat = (Propagate->GetGeodLatitudeRad());
109 usedLon = (Propagate->GetLongitude());
110 usedAlt = (Propagate->GetGeodeticAltitude()*fttom*0.001);
113 calc_magvar( usedLat,
123 bool FGMagnetometer::Run(
void )
127 vRadius = MassBalance->StructuralToBody(vLocation);
132 vMag = Propagate->GetTl2b() * FGColumnVector3(field[3], field[4], field[5]);
139 ProcessSensorSignal();
141 if (IsOutput) SetOutput();
165 void FGMagnetometer::Debug(
int from)
167 string ax[4] = {
"none",
"X",
"Y",
"Z"};
169 if (debug_lvl <= 0)
return;
173 cout <<
" Axis: " << ax[axis] << endl;
176 if (debug_lvl & 2 ) {
177 if (from == 0) cout <<
"Instantiated: FGMagnetometer" << endl;
178 if (from == 1) cout <<
"Destroyed: FGMagnetometer" << endl;
180 if (debug_lvl & 4 ) {
182 if (debug_lvl & 8 ) {
184 if (debug_lvl & 16) {
186 if (debug_lvl & 64) {
188 cout << IdSrc << endl;
189 cout << IdHdr << endl;