55 #include "FGExternalForce.h" 56 #include "input_output/FGXMLElement.h" 63 IDENT(IdSrc,
"$Id: FGExternalForce.cpp,v 1.16 2014/12/18 09:56:05 andgi Exp $");
64 IDENT(IdHdr,ID_EXTERNALFORCE);
75 string BasePropertyName;
77 Magnitude_Function = 0;
83 BasePropertyName =
"external_reactions/" + Name;
91 if (function_element) {
92 Magnitude_Function =
new FGFunction(PropertyManager, function_element);
94 PropertyManager->
Tie( BasePropertyName +
"/magnitude",(
FGExternalForce*)
this, &FGExternalForce::GetMagnitude, &FGExternalForce::SetMagnitude);
100 if (sFrame.empty()) {
101 cerr <<
"No frame specified for external force, \"" << Name <<
"\"." << endl;
102 cerr <<
"Frame set to Body" << endl;
104 }
else if (sFrame ==
"BODY") {
106 }
else if (sFrame ==
"LOCAL") {
108 PropertyManager->
Tie( BasePropertyName +
"/azimuth", (
FGExternalForce*)
this, &FGExternalForce::GetAzimuth, &FGExternalForce::SetAzimuth);
109 }
else if (sFrame ==
"WIND") {
112 cerr <<
"Invalid frame specified for external force, \"" << Name <<
"\"." << endl;
113 cerr <<
"Frame set to Body" << endl;
116 PropertyManager->
Tie( BasePropertyName +
"/x", (
FGExternalForce*)
this, &FGExternalForce::GetX, &FGExternalForce::SetX);
117 PropertyManager->
Tie( BasePropertyName +
"/y", (
FGExternalForce*)
this, &FGExternalForce::GetY, &FGExternalForce::SetY);
118 PropertyManager->
Tie( BasePropertyName +
"/z", (
FGExternalForce*)
this, &FGExternalForce::GetZ, &FGExternalForce::SetZ);
121 if (!location_element) {
122 cerr <<
"No location element specified in force object." << endl;
125 SetLocation(location);
127 PropertyManager->
Tie( BasePropertyName +
"/location-x-in", (
FGExternalForce*)
this, &FGExternalForce::GetLocX, &FGExternalForce::SetLocX);
128 PropertyManager->
Tie( BasePropertyName +
"/location-y-in", (
FGExternalForce*)
this, &FGExternalForce::GetLocY, &FGExternalForce::SetLocY);
129 PropertyManager->
Tie( BasePropertyName +
"/location-z-in", (
FGExternalForce*)
this, &FGExternalForce::GetLocZ, &FGExternalForce::SetLocZ);
132 if (!direction_element) {
133 cerr <<
"No direction element specified in force object. Default is (0,0,0)." << endl;
147 magnitude = extForce.magnitude;
148 Frame = extForce.Frame;
149 vDirection = extForce.vDirection;
150 Name = extForce.Name;
157 delete Magnitude_Function;
163 void FGExternalForce::SetMagnitude(
double mag)
166 vFn = vDirection*mag;
173 if (Magnitude_Function) {
174 double mag = Magnitude_Function->
GetValue();
178 return FGForce::GetBodyForces();
200 void FGExternalForce::Debug(
int from)
202 if (debug_lvl <= 0)
return;
206 cout <<
" " << Name << endl;
207 cout <<
" Frame: " << Frame << endl;
208 cout <<
" Location: (" << vXYZn(eX) <<
", " << vXYZn(eY) <<
", " << vXYZn(eZ) <<
")" << endl;
211 if (debug_lvl & 2 ) {
212 if (from == 0) cout <<
"Instantiated: FGExternalForce" << endl;
213 if (from == 1) cout <<
"Destroyed: FGExternalForce" << endl;
215 if (debug_lvl & 4 ) {
217 if (debug_lvl & 8 ) {
219 if (debug_lvl & 16) {
221 if (debug_lvl & 64) {
223 cout << IdSrc << endl;
224 cout << IdHdr << endl;
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
Encapsulates code that models an individual arbitrary force.
FGColumnVector3 & Normalize(void)
Normalize.
Element * FindElement(const std::string &el="")
Searches for a specified element.
double GetValue(void) const
Retrieves the value of the function object.
FGPropertyManager * GetPropertyManager(void)
Returns a pointer to the property manager object.
void Tie(const std::string &name, bool *pointer, bool useDefault=true)
Tie a property to an external bool variable.
Represents a mathematical function.
This class implements a 3 element column vector.
FGExternalForce(FGFDMExec *FDMExec)
Constructor.
~FGExternalForce()
Destructor.
Encapsulates the JSBSim simulation executive.
Utility class that aids in the conversion of forces between coordinate systems and calculation of mom...
FGColumnVector3 FindElementTripletConvertTo(const std::string &target_units)
Composes a 3-element column vector for the supplied location or orientation.