1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Model the flight controls
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This class models the flight controls for a specific airplane
33 --------------------------------------------------------------------------------
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 #include "FGFDMExec.h"
46 #include "FGPropertyManager.h"
48 #include "filtersjb/FGFilter.h"
49 #include "filtersjb/FGDeadBand.h"
50 #include "filtersjb/FGGain.h"
51 #include "filtersjb/FGGradient.h"
52 #include "filtersjb/FGSwitch.h"
53 #include "filtersjb/FGSummer.h"
54 #include "filtersjb/FGKinemat.h"
58 static const char *IdSrc = "$Id$";
59 static const char *IdHdr = ID_FCS;
61 #if defined(WIN32) && !defined(__CYGWIN__)
62 #define snprintf _snprintf
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69 FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
74 DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0.0;
75 AP_DaCmd = AP_DeCmd = AP_DrCmd = AP_ThrottleCmd = 0.0;
76 PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
77 GearCmd = GearPos = 1; // default to gear down
78 LeftBrake = RightBrake = CenterBrake = 0.0;
79 APAttitudeSetPt = APAltitudeSetPt = APHeadingSetPt = APAirspeedSetPt = 0.0;
83 for (i=0;i<=NForms;i++) {
84 DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
85 DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
88 for (i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
92 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 unbind( PropertyManager->GetNode("fcs") );
97 unbind( PropertyManager->GetNode("ap") );
98 PropertyManager->Untie( "gear/gear-cmd-norm" );
99 PropertyManager->Untie( "gear/gear-pos-norm" );
105 PropAdvanceCmd.clear();
111 for (i=0;i<APComponents.size();i++) delete APComponents[i];
112 for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
117 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 bool FGFCS::Run(void)
123 if (FGModel::Run()) return true; // fast exit if nothing to do
125 // Set the default engine commands
126 for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
127 for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
128 for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
130 // Set the default steering angle
131 for (i=0; i<SteerPosDeg.size(); i++) {
132 FGLGear* gear = GroundReactions->GetGearUnit(i);
133 SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() );
136 for (i=0; i<APComponents.size(); i++) APComponents[i]->Run(); // cycle AP components
137 for (i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); // cycle FCS components
139 if (DoNormalize) Normalize();
144 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 void FGFCS::SetThrottleCmd(int engineNum, double setting)
150 if (engineNum < (int)ThrottlePos.size()) {
152 for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
154 ThrottleCmd[engineNum] = setting;
157 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
158 << " engines exist, but attempted throttle command is for engine "
159 << engineNum << endl;
163 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 void FGFCS::SetThrottlePos(int engineNum, double setting)
169 if (engineNum < (int)ThrottlePos.size()) {
171 for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
173 ThrottlePos[engineNum] = setting;
176 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
177 << " engines exist, but attempted throttle position setting is for engine "
178 << engineNum << endl;
182 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 double FGFCS::GetThrottleCmd(int engineNum) const
186 if (engineNum < (int)ThrottlePos.size()) {
188 cerr << "Cannot get throttle value for ALL engines" << endl;
190 return ThrottleCmd[engineNum];
193 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
194 << " engines exist, but throttle setting for engine " << engineNum
195 << " is selected" << endl;
200 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 double FGFCS::GetThrottlePos(int engineNum) const
204 if (engineNum < (int)ThrottlePos.size()) {
206 cerr << "Cannot get throttle value for ALL engines" << endl;
208 return ThrottlePos[engineNum];
211 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
212 << " engines exist, but attempted throttle position setting is for engine "
213 << engineNum << endl;
218 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 void FGFCS::SetMixtureCmd(int engineNum, double setting)
224 if (engineNum < (int)ThrottlePos.size()) {
226 for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
228 MixtureCmd[engineNum] = setting;
233 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
235 void FGFCS::SetMixturePos(int engineNum, double setting)
239 if (engineNum < (int)ThrottlePos.size()) {
241 for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
243 MixturePos[engineNum] = setting;
248 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
250 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
254 if (engineNum < (int)ThrottlePos.size()) {
256 for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
258 PropAdvanceCmd[engineNum] = setting;
263 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 void FGFCS::SetPropAdvance(int engineNum, double setting)
269 if (engineNum < (int)ThrottlePos.size()) {
271 for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
273 PropAdvance[engineNum] = setting;
278 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 bool FGFCS::Load(FGConfigFile* AC_cfg)
282 string token, delimiter;
283 string name, file, fname;
285 vector <FGFCSComponent*> *Components;
286 FGConfigFile *FCS_cfg;
289 // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
290 // file or in a separate file. Set up the config file class as appropriate.
292 delimiter = AC_cfg->GetValue();
293 name = AC_cfg->GetValue("NAME");
294 fname = AC_cfg->GetValue("FILE");
296 if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
298 cout << " Automatic Control Surface Normalization Disabled" << endl;
302 // file = "control/" + fname + ".xml";
303 file = FDMExec->GetAircraftPath() + "/" + FDMExec->GetModelName() + "/" + fname + ".xml";
305 // file = "control;" + fname + ".xml";
306 file = FDMExec->GetAircraftPath() + ";" + FDMExec->GetModelName() + ";" + fname + ".xml";
312 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
314 FCS_cfg = new FGConfigFile(file);
315 if (!FCS_cfg->IsOpen()) {
316 cerr << "Could not open " << delimiter << " file: " << file << endl;
319 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
320 // file object pointer
324 AC_cfg->GetNextConfigLine();
327 if (delimiter == "AUTOPILOT") {
328 Components = &APComponents;
329 Name = "Autopilot: " + name;
330 } else if (delimiter == "FLIGHT_CONTROL") {
331 Components = &FCSComponents;
332 Name = "FCS: " + name;
334 cerr << endl << "Unknown FCS delimiter" << endl << endl;
337 if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
339 while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
340 if (token == "COMPONENT") {
341 token = AC_cfg->GetValue("TYPE");
342 if (debug_lvl > 0) cout << endl << " Loading Component \""
343 << AC_cfg->GetValue("NAME")
344 << "\" of type: " << token << endl;
345 if ((token == "LAG_FILTER") ||
346 (token == "LEAD_LAG_FILTER") ||
347 (token == "SECOND_ORDER_FILTER") ||
348 (token == "WASHOUT_FILTER") ||
349 (token == "INTEGRATOR") ) {
350 Components->push_back(new FGFilter(this, AC_cfg));
351 } else if ((token == "PURE_GAIN") ||
352 (token == "SCHEDULED_GAIN") ||
353 (token == "AEROSURFACE_SCALE") ) {
355 Components->push_back(new FGGain(this, AC_cfg));
357 } else if (token == "SUMMER") {
358 Components->push_back(new FGSummer(this, AC_cfg));
359 } else if (token == "DEADBAND") {
360 Components->push_back(new FGDeadBand(this, AC_cfg));
361 } else if (token == "GRADIENT") {
362 Components->push_back(new FGGradient(this, AC_cfg));
363 } else if (token == "SWITCH") {
364 Components->push_back(new FGSwitch(this, AC_cfg));
365 } else if (token == "KINEMAT") {
366 Components->push_back(new FGKinemat(this, AC_cfg));
368 cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
371 if (AC_cfg->GetNextConfigLine() == "EOF") break;
375 //collect information for normalizing control surfaces
378 for (i=0; i<Components->size(); i++) {
380 if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE"
381 || ((*Components)[i])->GetType() == "KINEMAT")
382 && ((*Components)[i])->GetOutputNode() ) {
383 nodeName = ((*Components)[i])->GetOutputNode()->GetName();
384 if ( nodeName == "elevator-pos-rad" ) {
386 } else if ( nodeName == "left-aileron-pos-rad"
387 || nodeName == "aileron-pos-rad" ) {
389 } else if ( nodeName == "right-aileron-pos-rad" ) {
391 } else if ( nodeName == "rudder-pos-rad" ) {
393 } else if ( nodeName == "speedbrake-pos-rad" ) {
395 } else if ( nodeName == "spoiler-pos-rad" ) {
397 } else if ( nodeName == "flap-pos-deg" ) {
403 if (delimiter == "FLIGHT_CONTROL") bindModel();
408 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
413 case FGLGear::bgLeft:
415 case FGLGear::bgRight:
417 case FGLGear::bgCenter:
420 cerr << "GetBrake asked to return a bogus brake value" << endl;
425 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427 string FGFCS::GetComponentStrings(string delimeter)
430 string CompStrings = "";
431 bool firstime = true;
433 for (comp = 0; comp < FCSComponents.size(); comp++) {
434 if (firstime) firstime = false;
435 else CompStrings += delimeter;
437 CompStrings += FCSComponents[comp]->GetName();
440 for (comp = 0; comp < APComponents.size(); comp++)
442 CompStrings += delimeter;
443 CompStrings += APComponents[comp]->GetName();
449 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451 string FGFCS::GetComponentValues(string delimeter)
454 string CompValues = "";
456 bool firstime = true;
458 for (comp = 0; comp < FCSComponents.size(); comp++) {
459 if (firstime) firstime = false;
460 else CompValues += delimeter;
462 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
463 CompValues += string(buffer);
466 for (comp = 0; comp < APComponents.size(); comp++) {
467 sprintf(buffer, "%s%9.6f", delimeter.c_str(), APComponents[comp]->GetOutput());
468 CompValues += string(buffer);
474 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
476 void FGFCS::AddThrottle(void)
478 ThrottleCmd.push_back(0.0);
479 ThrottlePos.push_back(0.0);
480 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
481 MixturePos.push_back(0.0);
482 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
483 PropAdvance.push_back(0.0);
486 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
488 void FGFCS::AddGear(void)
490 SteerPosDeg.push_back(0.0);
493 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
495 void FGFCS::Normalize(void) {
497 //not all of these are guaranteed to be defined for every model
498 //those that are have an index >=0 in the ToNormalize array
499 //ToNormalize is filled in Load()
501 if ( ToNormalize[iDe] > -1 ) {
502 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
505 if ( ToNormalize[iDaL] > -1 ) {
506 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
509 if ( ToNormalize[iDaR] > -1 ) {
510 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
513 if ( ToNormalize[iDr] > -1 ) {
514 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
517 if ( ToNormalize[iDsb] > -1 ) {
518 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
521 if ( ToNormalize[iDsp] > -1 ) {
522 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
525 if ( ToNormalize[iDf] > -1 ) {
526 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
529 DePos[ofMag] = fabs(DePos[ofRad]);
530 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
531 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
532 DrPos[ofMag] = fabs(DrPos[ofRad]);
533 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
534 DspPos[ofMag] = fabs(DspPos[ofRad]);
535 DfPos[ofMag] = fabs(DfPos[ofRad]);
539 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
541 void FGFCS::bind(void)
543 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
547 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
551 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
555 PropertyManager->Tie("fcs/steer-cmd-norm", this,
559 PropertyManager->Tie("fcs/flap-cmd-norm", this,
563 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
567 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
571 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
572 &FGFCS::GetPitchTrimCmd,
573 &FGFCS::SetPitchTrimCmd,
575 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
576 &FGFCS::GetRollTrimCmd,
577 &FGFCS::SetRollTrimCmd,
579 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
580 &FGFCS::GetYawTrimCmd,
581 &FGFCS::SetYawTrimCmd,
583 PropertyManager->Tie("gear/gear-cmd-norm", this,
588 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
592 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
596 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
601 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
605 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
609 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
614 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
618 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
622 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
627 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
631 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
635 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
640 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
644 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
649 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
653 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
657 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
662 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
666 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
670 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
675 PropertyManager->Tie("gear/gear-pos-norm", this,
680 PropertyManager->Tie("ap/elevator_cmd", this,
685 PropertyManager->Tie("ap/aileron_cmd", this,
690 PropertyManager->Tie("ap/rudder_cmd", this,
695 PropertyManager->Tie("ap/throttle_cmd", this,
696 &FGFCS::GetAPThrottleCmd,
697 &FGFCS::SetAPThrottleCmd,
700 PropertyManager->Tie("ap/attitude_setpoint", this,
701 &FGFCS::GetAPAttitudeSetPt,
702 &FGFCS::SetAPAttitudeSetPt,
705 PropertyManager->Tie("ap/altitude_setpoint", this,
706 &FGFCS::GetAPAltitudeSetPt,
707 &FGFCS::SetAPAltitudeSetPt,
710 PropertyManager->Tie("ap/heading_setpoint", this,
711 &FGFCS::GetAPHeadingSetPt,
712 &FGFCS::SetAPHeadingSetPt,
715 PropertyManager->Tie("ap/airspeed_setpoint", this,
716 &FGFCS::GetAPAirspeedSetPt,
717 &FGFCS::SetAPAirspeedSetPt,
720 PropertyManager->Tie("ap/acquire_attitude", this,
721 &FGFCS::GetAPAcquireAttitude,
722 &FGFCS::SetAPAcquireAttitude,
725 PropertyManager->Tie("ap/acquire_altitude", this,
726 &FGFCS::GetAPAcquireAltitude,
727 &FGFCS::SetAPAcquireAltitude,
730 PropertyManager->Tie("ap/acquire_heading", this,
731 &FGFCS::GetAPAcquireHeading,
732 &FGFCS::SetAPAcquireHeading,
735 PropertyManager->Tie("ap/acquire_airspeed", this,
736 &FGFCS::GetAPAcquireAirspeed,
737 &FGFCS::SetAPAcquireAirspeed,
740 PropertyManager->Tie("ap/attitude_hold", this,
741 &FGFCS::GetAPAttitudeHold,
742 &FGFCS::SetAPAttitudeHold,
745 PropertyManager->Tie("ap/altitude_hold", this,
746 &FGFCS::GetAPAltitudeHold,
747 &FGFCS::SetAPAltitudeHold,
750 PropertyManager->Tie("ap/heading_hold", this,
751 &FGFCS::GetAPHeadingHold,
752 &FGFCS::SetAPHeadingHold,
755 PropertyManager->Tie("ap/airspeed_hold", this,
756 &FGFCS::GetAPAirspeedHold,
757 &FGFCS::SetAPAirspeedHold,
760 PropertyManager->Tie("ap/wingslevel_hold", this,
761 &FGFCS::GetAPWingsLevelHold,
762 &FGFCS::SetAPWingsLevelHold,
766 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
768 void FGFCS::bindModel(void)
773 for (i=0; i<ThrottleCmd.size(); i++) {
774 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
775 PropertyManager->Tie( tmp,this,i,
776 &FGFCS::GetThrottleCmd,
777 &FGFCS::SetThrottleCmd,
779 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
780 PropertyManager->Tie( tmp,this,i,
781 &FGFCS::GetThrottlePos,
782 &FGFCS::SetThrottlePos,
784 if ( MixtureCmd.size() > i ) {
785 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
786 PropertyManager->Tie( tmp,this,i,
787 &FGFCS::GetMixtureCmd,
788 &FGFCS::SetMixtureCmd,
790 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
791 PropertyManager->Tie( tmp,this,i,
792 &FGFCS::GetMixturePos,
793 &FGFCS::SetMixturePos,
796 if ( PropAdvanceCmd.size() > i ) {
797 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
798 PropertyManager->Tie( tmp,this,i,
799 &FGFCS::GetPropAdvanceCmd,
800 &FGFCS::SetPropAdvanceCmd,
802 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
803 PropertyManager->Tie( tmp,this,i,
804 &FGFCS::GetPropAdvance,
805 &FGFCS::SetPropAdvance,
810 for (i=0; i<SteerPosDeg.size(); i++) {
811 if (GroundReactions->GetGearUnit(i)->GetSteerable()) {
812 snprintf(tmp,80,"fcs/steer-pos-deg[%u]",i);
813 PropertyManager->Tie( tmp, this, i,
814 &FGFCS::GetSteerPosDeg,
815 &FGFCS::SetSteerPosDeg,
821 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
823 void FGFCS::unbind(FGPropertyManager *node)
825 int N = node->nChildren();
826 for(int i=0;i<N;i++) {
827 if(node->getChild(i)->nChildren() ) {
828 unbind( (FGPropertyManager*)node->getChild(i) );
829 } else if( node->getChild(i)->isTied() ) {
830 node->getChild(i)->untie();
835 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
837 void FGFCS::convert(void)
839 for (int i=0; i<FCSComponents.size(); i++) {
840 FCSComponents[i]->convert();
844 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
845 // The bitmasked value choices are as follows:
846 // unset: In this case (the default) JSBSim would only print
847 // out the normally expected messages, essentially echoing
848 // the config files as they are read. If the environment
849 // variable is not set, debug_lvl is set to 1 internally
850 // 0: This requests JSBSim not to output any messages
852 // 1: This value explicity requests the normal JSBSim
854 // 2: This value asks for a message to be printed out when
855 // a class is instantiated
856 // 4: When this value is set, a message is displayed when a
857 // FGModel object executes its Run() method
858 // 8: When this value is set, various runtime state variables
859 // are printed out periodically
860 // 16: When set various parameters are sanity checked and
861 // a message is printed out when they go out of bounds
863 void FGFCS::Debug(int from)
865 if (debug_lvl <= 0) return;
867 if (debug_lvl & 1) { // Standard console startup message output
868 if (from == 0) { // Constructor
872 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
873 if (from == 0) cout << "Instantiated: FGFCS" << endl;
874 if (from == 1) cout << "Destroyed: FGFCS" << endl;
876 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
878 if (debug_lvl & 8 ) { // Runtime state variables
880 if (debug_lvl & 16) { // Sanity checking
882 if (debug_lvl & 64) {
883 if (from == 0) { // Constructor
884 cout << IdSrc << endl;
885 cout << IdHdr << endl;