Skip to content

Commit

Permalink
Convert the flight_control folder to the new logging system.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoconni committed Oct 26, 2024
1 parent 24a7015 commit a9e425d
Show file tree
Hide file tree
Showing 21 changed files with 364 additions and 296 deletions.
15 changes: 9 additions & 6 deletions src/models/atmosphere/FGMSIS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ INCLUDES

#include "FGFDMExec.h"
#include "FGMSIS.h"
#include "input_output/FGLog.h"

using namespace std;

Expand Down Expand Up @@ -212,7 +213,7 @@ void FGMSIS::Compute(double altitude, double& pressure, double& temperature,
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// 1: This value explicitly requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
Expand All @@ -230,14 +231,16 @@ void FGMSIS::Debug(int from)
if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) {} // Constructor
if (from == 3) { // Loading
cout << " NRLMSIS atmosphere model" << endl;
cout << " day: " << day_of_year << endl;
cout << " UTC: " << seconds_in_day << endl << endl;
FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG);
log << " NRLMSIS atmosphere model\n" << fixed;
log << " day: " << day_of_year << "\n";
log << " UTC: " << seconds_in_day << "\n\n";
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) std::cout << "Instantiated: MSIS" << std::endl;
if (from == 1) std::cout << "Destroyed: MSIS" << std::endl;
FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: MSIS\n";
if (from == 1) log << "Destroyed: MSIS\n";

Check warning on line 243 in src/models/atmosphere/FGMSIS.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/atmosphere/FGMSIS.cpp#L241-L243

Added lines #L241 - L243 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
22 changes: 12 additions & 10 deletions src/models/flight_control/FGAccelerometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ CLASS IMPLEMENTATION

FGAccelerometer::FGAccelerometer(FGFCS* fcs, Element* element)
: FGSensor(fcs, element),
FGSensorOrientation(element)
FGSensorOrientation(element, fcs->GetExec()->GetLogger())

Check warning on line 55 in src/models/flight_control/FGAccelerometer.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGAccelerometer.cpp#L55

Added line #L55 was not covered by tests
{
Propagate = fcs->GetExec()->GetPropagate();
Accelerations = fcs->GetExec()->GetAccelerations();
MassBalance = fcs->GetExec()->GetMassBalance();

Element* location_element = element->FindElement("location");
if (location_element)
vLocation = location_element->FindElementTripletConvertTo("IN");
else {
cerr << element->ReadFrom()
<< "No location given for accelerometer. " << endl;
throw("Malformed accelerometer specification");
FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL);
log << "No location given for accelerometer.\n";
throw BaseException(log.str());

Check warning on line 67 in src/models/flight_control/FGAccelerometer.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGAccelerometer.cpp#L65-L67

Added lines #L65 - L67 were not covered by tests
}

vRadius = MassBalance->StructuralToBody(vLocation);
Expand All @@ -86,7 +86,7 @@ bool FGAccelerometer::Run(void )
// There is no input assumed. This is a dedicated acceleration sensor.

vRadius = MassBalance->StructuralToBody(vLocation);

//aircraft forces
vAccel = (Accelerations->GetBodyAccel()
+ Accelerations->GetPQRidot() * vRadius
Expand All @@ -112,7 +112,7 @@ bool FGAccelerometer::Run(void )
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// 1: This value explicitly requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
Expand All @@ -131,12 +131,14 @@ void FGAccelerometer::Debug(int from)

if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " Axis: " << ax[axis] << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
log << " Axis: " << ax[axis] << "\n";

Check warning on line 135 in src/models/flight_control/FGAccelerometer.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGAccelerometer.cpp#L134-L135

Added lines #L134 - L135 were not covered by tests
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGAccelerometer" << endl;
if (from == 1) cout << "Destroyed: FGAccelerometer" << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGAccelerometer\n";
if (from == 1) log << "Destroyed: FGAccelerometer\n";

Check warning on line 141 in src/models/flight_control/FGAccelerometer.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGAccelerometer.cpp#L139-L141

Added lines #L139 - L141 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
26 changes: 15 additions & 11 deletions src/models/flight_control/FGActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ INCLUDES
#include "input_output/FGXMLElement.h"
#include "math/FGParameterValue.h"
#include "models/FGFCS.h"
#include "input_output/FGLog.h"

using namespace std;

Expand Down Expand Up @@ -319,7 +320,7 @@ void FGActuator::InitializeLagCoefficients()
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// 1: This value explicitly requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
Expand All @@ -336,27 +337,30 @@ void FGActuator::Debug(int from)

if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
log << " INPUT: " << InputNodes[0]->GetNameWithSign() << fixed
<< setprecision(4) << "\n";

Check warning on line 342 in src/models/flight_control/FGActuator.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGActuator.cpp#L340-L342

Added lines #L340 - L342 were not covered by tests

if (!OutputNodes.empty()) {
for (auto node: OutputNodes)
cout << " OUTPUT: " << node->GetName() << endl;
log << " OUTPUT: " << node->GetName() << "\n";

Check warning on line 346 in src/models/flight_control/FGActuator.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGActuator.cpp#L346

Added line #L346 was not covered by tests
}
if (bias != 0.0) cout << " Bias: " << bias << endl;
if (bias != 0.0) log << " Bias: " << bias << "\n";

Check warning on line 348 in src/models/flight_control/FGActuator.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGActuator.cpp#L348

Added line #L348 was not covered by tests
if (rate_limit_incr != 0) {
cout << " Increasing rate limit: " << rate_limit_incr->GetName() << endl;
log << " Increasing rate limit: " << rate_limit_incr->GetName() << "\n";

Check warning on line 350 in src/models/flight_control/FGActuator.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGActuator.cpp#L350

Added line #L350 was not covered by tests
}
if (rate_limit_decr != 0) {
cout << " Decreasing rate limit: " << rate_limit_decr->GetName() << endl;
log << " Decreasing rate limit: " << rate_limit_decr->GetName() << "\n";

Check warning on line 353 in src/models/flight_control/FGActuator.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGActuator.cpp#L353

Added line #L353 was not covered by tests
}
if (lag != 0) cout << " Actuator lag: " << lag->GetName() << endl;
if (hysteresis_width != 0) cout << " Hysteresis width: " << hysteresis_width << endl;
if (deadband_width != 0) cout << " Deadband width: " << deadband_width << endl;
if (lag != 0) log << " Actuator lag: " << lag->GetName() << "\n";
if (hysteresis_width != 0) log << " Hysteresis width: " << hysteresis_width << "\n";
if (deadband_width != 0) log << " Deadband width: " << deadband_width << "\n";

Check warning on line 357 in src/models/flight_control/FGActuator.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGActuator.cpp#L355-L357

Added lines #L355 - L357 were not covered by tests
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGActuator" << endl;
if (from == 1) cout << "Destroyed: FGActuator" << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGActuator\n";
if (from == 1) log << "Destroyed: FGActuator\n";

Check warning on line 363 in src/models/flight_control/FGActuator.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGActuator.cpp#L361-L363

Added lines #L361 - L363 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
10 changes: 6 additions & 4 deletions src/models/flight_control/FGAngles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ COMMENTS, REFERENCES, and NOTES
from the current heading. The sense of the rotation to get to that angle is
also calculated (positive 1 for a clockwise rotation, negative 1 for counter-
clockwise).
The angle to the heading is calculated as follows:
Given an angle phi:
Expand Down Expand Up @@ -70,6 +70,7 @@ INCLUDES
#include "FGAngles.h"
#include "models/FGFCS.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGLog.h"

using namespace std;

Expand Down Expand Up @@ -167,7 +168,7 @@ bool FGAngles::Run(void )
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// 1: This value explicitly requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
Expand All @@ -187,8 +188,9 @@ void FGAngles::Debug(int from)
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGAngles" << endl;
if (from == 1) cout << "Destroyed: FGAngles" << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGAngles\n";
if (from == 1) log << "Destroyed: FGAngles\n";

Check warning on line 193 in src/models/flight_control/FGAngles.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGAngles.cpp#L191-L193

Added lines #L191 - L193 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
17 changes: 10 additions & 7 deletions src/models/flight_control/FGDeadBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ INCLUDES
#include "FGDeadBand.h"
#include "models/FGFCS.h"
#include "math/FGParameterValue.h"
#include "input_output/FGLog.h"

using namespace std;

Expand Down Expand Up @@ -110,7 +111,7 @@ bool FGDeadBand::Run(void)
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// 1: This value explicitly requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
Expand All @@ -127,17 +128,19 @@ void FGDeadBand::Debug(int from)

if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " INPUT: " << InputNodes[0]->GetName() << endl;
cout << " DEADBAND WIDTH: " << Width->GetName() << endl;
cout << " GAIN: " << gain << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
log << " INPUT: " << InputNodes[0]->GetName() << "\n";
log << " DEADBAND WIDTH: " << Width->GetName() << "\n";
log << " GAIN: " << fixed << setprecision(4) << gain << "\n";

Check warning on line 134 in src/models/flight_control/FGDeadBand.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDeadBand.cpp#L131-L134

Added lines #L131 - L134 were not covered by tests

for (auto node: OutputNodes)
cout << " OUTPUT: " << node->getNameString() << endl;
log << " OUTPUT: " << node->getNameString() << "\n";

Check warning on line 137 in src/models/flight_control/FGDeadBand.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDeadBand.cpp#L137

Added line #L137 was not covered by tests
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGDeadBand" << endl;
if (from == 1) cout << "Destroyed: FGDeadBand" << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGDeadBand\n";
if (from == 1) log << "Destroyed: FGDeadBand\n";

Check warning on line 143 in src/models/flight_control/FGDeadBand.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDeadBand.cpp#L141-L143

Added lines #L141 - L143 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
27 changes: 15 additions & 12 deletions src/models/flight_control/FGDistributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ Also, see the header file (FGDistributor.h) for further details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

#include "FGDistributor.h"
#include "models/FGFCS.h"
#include "input_output/FGLog.h"

using namespace std;

Expand Down Expand Up @@ -120,7 +121,7 @@ bool FGDistributor::Run(void )
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// 1: This value explicitly requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
Expand All @@ -137,29 +138,31 @@ void FGDistributor::Debug(int from)

if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);

Check warning on line 141 in src/models/flight_control/FGDistributor.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDistributor.cpp#L141

Added line #L141 was not covered by tests
unsigned int ctr=0;
for (auto Case: Cases) {
std::cout << " Case: " << ctr << endl;
log << " Case: " << fixed << ctr << "\n";

Check warning on line 144 in src/models/flight_control/FGDistributor.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDistributor.cpp#L144

Added line #L144 was not covered by tests
if (Case->HasTest()) {
Case->GetTest()->PrintCondition(" ");
} else {
std::cout << " Set these properties by default: " << std::endl;
log << " Set these properties by default: \n";

Check warning on line 148 in src/models/flight_control/FGDistributor.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDistributor.cpp#L148

Added line #L148 was not covered by tests
}
std::cout << std::endl;
log << "\n";

Check warning on line 150 in src/models/flight_control/FGDistributor.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDistributor.cpp#L150

Added line #L150 was not covered by tests
for (auto propVal = Case->IterPropValPairs(); propVal != Case->EndPropValPairs(); ++propVal) {
std::cout << " Set property " << (*propVal)->GetPropName();
if ((*propVal)->GetLateBoundProp()) std::cout << " (late bound)";
std::cout << " to " << (*propVal)->GetValString();
if ((*propVal)->GetLateBoundValue()) std::cout << " (late bound)";
std::cout << std::endl;
log << " Set property " << (*propVal)->GetPropName();
if ((*propVal)->GetLateBoundProp()) log << " (late bound)";
log << " to " << (*propVal)->GetValString();
if ((*propVal)->GetLateBoundValue()) log << " (late bound)";
log << "\n";

Check warning on line 156 in src/models/flight_control/FGDistributor.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDistributor.cpp#L152-L156

Added lines #L152 - L156 were not covered by tests
}
ctr++;
}
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGDistributor" << endl;
if (from == 1) cout << "Destroyed: FGDistributor" << endl;
FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGDistributor\n";
if (from == 1) log << "Destroyed: FGDistributor\n";

Check warning on line 165 in src/models/flight_control/FGDistributor.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/flight_control/FGDistributor.cpp#L163-L165

Added lines #L163 - L165 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
Loading

0 comments on commit a9e425d

Please sign in to comment.