speedbrake_pos_pct
=fgGetNode("/surface-positions/speedbrake-pos-norm",true);
spoilers_pos_pct=fgGetNode("/surface-positions/spoilers-pos-norm",true);
+ tailhook_pos_pct=fgGetNode("/gear/tailhook/position-norm",true);
+ wing_fold_pos_pct=fgGetNode("surface-positions/wing-fold-pos-norm",true);
elevator_pos_pct->setDoubleValue(0);
left_aileron_pos_pct->setDoubleValue(0);
fgGetDouble("/fdm/jsbsim/systems/hook/tailhook-offset-x-in", 196),
fgGetDouble("/fdm/jsbsim/systems/hook/tailhook-offset-y-in", 0),
fgGetDouble("/fdm/jsbsim/systems/hook/tailhook-offset-z-in", -16));
+
+ crashed = false;
}
/******************************************************************************/
void FGJSBsim::update( double dt )
{
+ if(crashed) {
+ if(!fgGetBool("/sim/crashed"))
+ fgSetBool("/sim/crashed", true);
+ return;
+ }
+
if (is_suspended())
return;
msg = fdmex->ProcessMessage();
switch (msg->type) {
case FGJSBBase::Message::eText:
+ if (msg->text == "Crash Detected: Simulation FREEZE.")
+ crashed = true;
SG_LOG( SG_FLIGHT, SG_INFO, msg->messageId << ": " << msg->text );
break;
case FGJSBBase::Message::eBool:
flap_pos_pct->setDoubleValue( FCS->GetDfPos(ofNorm) );
speedbrake_pos_pct->setDoubleValue( FCS->GetDsbPos(ofNorm) );
spoilers_pos_pct->setDoubleValue( FCS->GetDspPos(ofNorm) );
+ tailhook_pos_pct->setDoubleValue( FCS->GetTailhookPos() );
+ wing_fold_pos_pct->setDoubleValue( FCS->GetWingFoldPos() );
- // force a sim reset if crashed (altitude AGL < 0)
+ // force a sim crashed if crashed (altitude AGL < 0)
if (get_Altitude_AGL() < -100.0) {
- fgSetBool("/sim/crashed", true);
- SGPropertyNode* node = fgGetNode("/sim/presets", true);
- globals->get_commands()->execute("old-reinit-dialog", node);
+ State->SuspendIntegration();
+ crashed = true;
}
return true;
node->setDoubleValue("position-norm", gear->GetGearUnitPos());
node->setDoubleValue("tire-pressure-norm", gear->GetTirePressure());
node->setDoubleValue("compression-norm", gear->GetCompLen());
+ node->setDoubleValue("compression-ft", gear->GetCompLen());
if ( gear->GetSteerable() )
node->setDoubleValue("steering-norm", gear->GetSteerNorm());
}
node->getChild("position-norm", 0, true)->setDoubleValue(gear->GetGearUnitPos());
gear->SetTirePressure(node->getDoubleValue("tire-pressure-norm"));
node->setDoubleValue("compression-norm", gear->GetCompLen());
+ node->setDoubleValue("compression-ft", gear->GetCompLen());
if ( gear->GetSteerable() )
node->setDoubleValue("steering-norm", gear->GetSteerNorm());
}
SGPropertyNode_ptr spoilers_pos_pct;
SGPropertyNode_ptr gear_pos_pct;
+ SGPropertyNode_ptr wing_fold_pos_pct;
+ SGPropertyNode_ptr tailhook_pos_pct;
SGPropertyNode_ptr temperature;
SGPropertyNode_ptr pressure;
double hook_length;
bool got_wire;
+ bool crashed;
+
void init_gear(void);
void update_gear(void);
string FGColumnVector3::Dump(string delimeter) const
{
char buffer[256];
- sprintf(buffer, "%f%s%f%s%f", Entry(1), delimeter.c_str(), Entry(2), delimeter.c_str(), Entry(3));
+ sprintf(buffer, "%10.3e%s%10.3e%s%10.3e", Entry(1), delimeter.c_str(), Entry(2), delimeter.c_str(), Entry(3));
return string(buffer);
}
PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
GearCmd = GearPos = 1; // default to gear down
LeftBrake = RightBrake = CenterBrake = 0.0;
+ TailhookPos = WingFoldPos = 0.0;
bind();
for (i=0;i<NForms;i++) {
DaCmd = DeCmd = DrCmd = DsCmd = DfCmd = DsbCmd = DspCmd = 0;
PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
+ TailhookPos = WingFoldPos = 0.0;
for (i=0;i<NForms;i++) {
DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
bool FGFCS::Load(Element* el, SystemType systype)
{
- string name, file, fname, interface_property_string, parent_name;
+ string name, file, fname="", interface_property_string, parent_name;
vector <FGFCSComponent*> *Components;
Element *component_element, *property_element, *sensor_element;
Element *channel_element;
if (systype == stSystem) {
file = FindSystemFullPathname(fname);
} else {
- file = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
+ file = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
}
if (fname.empty()) {
cerr << "FCS, Autopilot, or system does not appear to be defined inline nor in a file" << endl;
}
Debug(2);
- // ToDo: How do these get untied?
- // ToDo: Consider having INPUT and OUTPUT interface properties. Would then
- // have to duplicate this block of code after channel read code.
- // Input properties could be write only (nah), and output could be read
- // only.
-
if (document->GetName() == "flight_control") bindModel();
// Interface properties from any autopilot, flight control, or other system are
// all stored in the interface properties array.
property_element = document->FindElement("property");
+ if (property_element) cout << endl << " Declared properties" << endl << endl;
while (property_element) {
double value=0.0;
if ( ! property_element->GetAttributeValue("value").empty())
interface_properties.push_back(new double(value));
interface_property_string = property_element->GetDataLine();
PropertyManager->Tie(interface_property_string, interface_properties.back());
+ cout << " " << interface_property_string << " (initial value: " << value << ")" << endl;
property_element = document->FindNextElement("property");
}
+ // After reading interface properties in a file, read properties in the local
+ // flight_control, autopiot, or system element. This allows general-purpose
+ // systems to be defined in a file, with overrides or initial loaded constants
+ // supplied in the relevant element of the aircraft configuration file.
+
+ if (!fname.empty()) {
+ property_element = el->FindElement("property");
+ if (property_element) cout << endl << " Declared properties" << endl << endl;
+ while (property_element) {
+ double value=0.0;
+ if ( ! property_element->GetAttributeValue("value").empty())
+ value = property_element->GetAttributeValueAsNumber("value");
+
+ interface_property_string = property_element->GetDataLine();
+
+ FGPropertyManager* node = PropertyManager->GetNode(interface_property_string);
+ if (node) {
+ cout << " " << "Overriding value for property " << interface_property_string
+ << " (old value: " << node->getDoubleValue() << " new value: " << value << ")" << endl;
+ node->setDoubleValue(value);
+ } else {
+ interface_properties.push_back(new double(value));
+ PropertyManager->Tie(interface_property_string, interface_properties.back());
+ cout << " " << interface_property_string << " (initial value: " << value << ")" << endl;
+ }
+
+
+ property_element = el->FindNextElement("property");
+ }
+ }
+
// Any sensor elements that are outside of a channel (in either the autopilot
// or the flight_control, or even any possible "system") are placed into the global
// "sensors" array, and are executed prior to any autopilot, flight control, or
channel_element = document->FindElement("channel");
while (channel_element) {
+
+ cout << endl << highint << fgblue << " Channel "
+ << normint << channel_element->GetAttributeValue("name") << reset << endl;
+
component_element = channel_element->GetElement();
while (component_element) {
try {
{
unsigned int comp;
string CompValues = "";
- char buffer[20];
+ char buffer[100];
bool firstime = true;
int total_count=0;
if (firstime) firstime = false;
else CompValues += delimeter;
- sprintf(buffer, "%9.6f", Systems[i]->GetOutput());
+ snprintf(buffer, 100, "%9.6f", Systems[i]->GetOutput());
CompValues += string(buffer);
total_count++;
}
PropertyManager->Tie("fcs/right-brake-cmd-norm", this, &FGFCS::GetRBrake, &FGFCS::SetRBrake);
PropertyManager->Tie("fcs/center-brake-cmd-norm", this, &FGFCS::GetCBrake, &FGFCS::SetCBrake);
PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd);
+
+ PropertyManager->Tie("gear/tailhook-pos-norm", this, &FGFCS::GetTailhookPos, &FGFCS::SetTailhookPos);
+ PropertyManager->Tie("fcs/wing-fold-pos-norm", this, &FGFCS::GetWingFoldPos, &FGFCS::SetWingFoldPos);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@property fcs/spoiler-pos-deg
@property fcs/spoiler-pos-norm
@property fcs/mag-spoiler-pos-rad
+ @property fcs/wing-fold-pos-norm
@property gear/gear-pos-norm
+ @property gear/tailhook-pos-norm
@author Jon S. Berndt
@version $Revision$
@return gear position (0 up, 1 down) */
inline double GetGearPos(void) const { return GearPos; }
+ /** Gets the tailhook position (0 up, 1 down)
+ @return tailhook position (0 up, 1 down) */
+ inline double GetTailhookPos(void) const { return TailhookPos; }
+
+ /** Gets the wing fold position (0 unfolded, 1 folded)
+ @return wing fold position (0 unfolded, 1 folded) */
+ inline double GetWingFoldPos(void) const { return WingFoldPos; }
+
/** Gets the prop pitch position.
@param engine engine ID number
@return prop pitch position for the given engine in range from 0 - 1.0 */
@param gear position 0 up, 1 down */
void SetGearPos(double gearpos) { GearPos = gearpos; }
+ /** Set the tailhook position
+ @param tailhook position 0 up, 1 down */
+ void SetTailhookPos(double hookpos) { TailhookPos = hookpos; }
+
+ /** Set the wing fold position
+ @param wing fold position 0 unfolded, 1 folded */
+ void SetWingFoldPos(double foldpos) { WingFoldPos = foldpos; }
/** Sets the actual prop pitch setting for the specified engine
@param engine engine ID number
vector <double> SteerPosDeg;
double LeftBrake, RightBrake, CenterBrake; // Brake settings
double GearCmd,GearPos;
+ double TailhookPos, WingFoldPos;
typedef vector <FGFCSComponent*> FCSCompVec;
FCSCompVec Systems;
element = el->FindNextElement("pointmass");
}
+ Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetPointMassWeight()
+ + BuoyantForces->GetGasMass()*slugtolb;
+
+ Mass = lbtoslug*Weight;
+
Debug(2);
return true;
}
last2_vLocationDot = last_vLocationDot;
last_vLocationDot = vLocationDot;
+ Debug(2);
return false;
}
if (debug_lvl & 8 ) { // Runtime state variables
}
if (debug_lvl & 16) { // Sanity checking
+ if (from == 2) { // State sanity checking
+ if (fabs(VState.vPQR.Magnitude()) > 1000.0) {
+ cerr << endl << "Vehicle rotation rate is excessive (>1000 rad/sec): " << VState.vPQR.Magnitude() << endl;
+ exit(-1);
+ }
+ if (fabs(VState.vUVW.Magnitude()) > 1.0e10) {
+ cerr << endl << "Vehicle velocity is excessive (>1e10 ft/sec): " << VState.vUVW.Magnitude() << endl;
+ exit(-1);
+ }
+ if (fabs(GetDistanceAGL()) > 1e10) {
+ cerr << endl << "Vehicle altitude is excessive (>1e10 ft): " << GetDistanceAGL() << endl;
+ exit(-1);
+ }
+ }
}
if (debug_lvl & 64) {
if (from == 0) { // Constructor
FGPiston::~FGPiston()
{
- char property_name[80];
-
delete Lookup_Combustion_Efficiency;
delete Power_Mixture_Correlation;
delete Mixture_Efficiency_Correlation;
double T_amb_sea_lev_degF = KelvinToFahrenheit(288);
// FIXME: this needs to be generalized
- double ME, friction, percent_RPM; // Convienience term for use in the calculations
+ double ME, friction, percent_RPM, power; // Convienience term for use in the calculations
ME = Mixture_Efficiency_Correlation->GetValue(m_dot_fuel/m_dot_air);
percent_RPM = RPM/MaxRPM;
friction = 1 - (percent_RPM * percent_RPM * percent_RPM * percent_RPM/10);
if (friction < 0 ) friction = 0;
- Percentage_Power = friction;
+ power = friction;
- if ( Magnetos != 3 ) Percentage_Power *= SparkFailDrop;
+ if ( Magnetos != 3 ) power *= SparkFailDrop;
- HP = (FuelFlow_gph * 6.0 / BSFC )* ME * suction_loss * Percentage_Power;
+ HP = (FuelFlow_gph * 6.0 / BSFC )* ME * suction_loss * power;
} else {
HP = 0.0;
}
}
+ Percentage_Power = HP / MaxHP ;
// cout << "Power = " << HP << " RPM = " << RPM << " Running = " << Running << " Cranking = " << Cranking << endl;
}
OilPressure_psi = Oil_Press_Relief_Valve;
}
- OilPressure_psi += (Design_Oil_Temp - OilTemp_degK) * Oil_Viscosity_Index;
+ OilPressure_psi += (Design_Oil_Temp - OilTemp_degK) * Oil_Viscosity_Index * OilPressure_psi / Oil_Press_Relief_Valve;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-noinst_LIBRARIES = libPropulsion.a
+includedir = @includedir@/JSBSim/models/propulsion
-libPropulsion_a_SOURCES = FGElectric.cpp FGEngine.cpp FGForce.cpp FGNozzle.cpp \
- FGPiston.cpp FGPropeller.cpp FGRocket.cpp FGRotor.cpp \
+LIBRARY_SOURCES = FGElectric.cpp FGEngine.cpp FGForce.cpp FGNozzle.cpp \
+ FGPiston.cpp FGPropeller.cpp FGRocket.cpp \
FGTank.cpp FGThruster.cpp FGTurbine.cpp FGTurboProp.cpp
-noinst_HEADERS = FGElectric.h FGEngine.h FGForce.h FGNozzle.h FGPiston.h \
- FGPropeller.h FGRocket.h FGRotor.h FGTank.h FGThruster.h \
+LIBRARY_INCLUDES = FGElectric.h FGEngine.h FGForce.h FGNozzle.h FGPiston.h \
+ FGPropeller.h FGRocket.h FGTank.h FGThruster.h \
FGTurbine.h FGTurboProp.h
-INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim
+if BUILD_LIBRARIES
+noinst_LTLIBRARIES = libPropulsion.la
+include_HEADERS = $(LIBRARY_INCLUDES)
+libPropulsion_la_SOURCES = $(LIBRARY_SOURCES)
+libPropulsion_la_CXXFLAGS = $(AM_CXXFLAGS)
+else
+noinst_LIBRARIES = libPropulsion.a
+noinst_HEADERS = $(LIBRARY_INCLUDES)
+libPropulsion_a_SOURCES = $(LIBRARY_SOURCES)
+endif
+
+INCLUDES = -I$(top_srcdir)/src -I../../