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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 #include "FGFDMExec.h"
43 #include "FGAtmosphere.h"
44 #include "FGAircraft.h"
45 #include "FGTranslation.h"
46 #include "FGRotation.h"
47 #include "FGPosition.h"
48 #include "FGAuxiliary.h"
50 #include "FGPropertyManager.h"
52 #include "filtersjb/FGFilter.h"
53 #include "filtersjb/FGDeadBand.h"
54 #include "filtersjb/FGGain.h"
55 #include "filtersjb/FGGradient.h"
56 #include "filtersjb/FGSwitch.h"
57 #include "filtersjb/FGSummer.h"
58 #include "filtersjb/FGKinemat.h"
60 static const char *IdSrc = "$Id$";
61 static const char *IdHdr = ID_FCS;
63 #if defined(WIN32) && !defined(__CYGWIN__)
64 #define snprintf _snprintf
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71 FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
76 DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0.0;
77 AP_DaCmd = AP_DeCmd = AP_DrCmd = AP_ThrottleCmd = 0.0;
78 PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
79 GearCmd = GearPos = 1; // default to gear down
80 LeftBrake = RightBrake = CenterBrake = 0.0;
86 for (i=0;i<=NForms;i++) {
87 DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
88 DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
91 for (i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
95 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 unbind( PropertyManager->GetNode("fcs") );
100 unbind( PropertyManager->GetNode("ap") );
101 PropertyManager->Untie( "gear/gear-cmd-norm" );
102 PropertyManager->Untie( "gear/gear-pos-norm" );
108 PropAdvanceCmd.clear();
114 for (i=0;i<APComponents.size();i++) delete APComponents[i];
115 for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
120 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 bool FGFCS::Run(void)
126 if (!FGModel::Run()) {
127 for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
128 for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
129 for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
130 for (i=0; i<APComponents.size(); i++) {
132 APComponents[i]->Run();
135 for (i=0; i<FCSComponents.size(); i++) {
137 FCSComponents[i]->Run();
140 if (DoNormalize) Normalize();
148 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 void FGFCS::SetThrottleCmd(int engineNum, double setting)
154 if (engineNum < (int)ThrottlePos.size()) {
156 for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
158 ThrottleCmd[engineNum] = setting;
161 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
162 << " engines exist, but attempted throttle command is for engine "
163 << engineNum << endl;
167 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169 void FGFCS::SetThrottlePos(int engineNum, double setting)
173 if (engineNum < (int)ThrottlePos.size()) {
175 for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
177 ThrottlePos[engineNum] = setting;
180 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
181 << " engines exist, but attempted throttle position setting is for engine "
182 << engineNum << endl;
186 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188 double FGFCS::GetThrottleCmd(int engineNum) const
190 if (engineNum < (int)ThrottlePos.size()) {
192 cerr << "Cannot get throttle value for ALL engines" << endl;
194 return ThrottleCmd[engineNum];
197 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
198 << " engines exist, but throttle setting for engine " << engineNum
199 << " is selected" << endl;
204 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 double FGFCS::GetThrottlePos(int engineNum) const
208 if (engineNum < (int)ThrottlePos.size()) {
210 cerr << "Cannot get throttle value for ALL engines" << endl;
212 return ThrottlePos[engineNum];
215 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
216 << " engines exist, but attempted throttle position setting is for engine "
217 << engineNum << endl;
222 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224 void FGFCS::SetMixtureCmd(int engineNum, double setting)
228 if (engineNum < (int)ThrottlePos.size()) {
230 for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
232 MixtureCmd[engineNum] = setting;
237 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 void FGFCS::SetMixturePos(int engineNum, double setting)
243 if (engineNum < (int)ThrottlePos.size()) {
245 for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
247 MixturePos[engineNum] = setting;
252 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
258 if (engineNum < (int)ThrottlePos.size()) {
260 for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
262 PropAdvanceCmd[engineNum] = setting;
267 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
269 void FGFCS::SetPropAdvance(int engineNum, double setting)
273 if (engineNum < (int)ThrottlePos.size()) {
275 for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
277 PropAdvance[engineNum] = setting;
282 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284 bool FGFCS::Load(FGConfigFile* AC_cfg)
286 string token, delimiter;
287 string name, file, fname;
289 vector <FGFCSComponent*> *Components;
290 FGConfigFile *FCS_cfg;
293 // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
294 // file or in a separate file. Set up the config file class as appropriate.
296 delimiter = AC_cfg->GetValue();
297 name = AC_cfg->GetValue("NAME");
298 fname = AC_cfg->GetValue("FILE");
300 if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
302 cout << " Automatic Control Surface Normalization Disabled" << endl;
306 file = "control/" + fname + ".xml";
308 file = "control;" + fname + ".xml";
314 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
316 FCS_cfg = new FGConfigFile(file);
317 if (!FCS_cfg->IsOpen()) {
318 cerr << "Could not open " << delimiter << " file: " << file << endl;
321 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
322 // file object pointer
326 AC_cfg->GetNextConfigLine();
329 if (delimiter == "AUTOPILOT") {
330 Components = &APComponents;
332 Name = "Autopilot: " + name;
333 } else if (delimiter == "FLIGHT_CONTROL") {
334 Components = &FCSComponents;
336 Name = "FCS: " + name;
338 cerr << endl << "Unknown FCS delimiter" << endl << endl;
341 if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
343 while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
344 if (token == "COMPONENT") {
345 token = AC_cfg->GetValue("TYPE");
346 if (debug_lvl > 0) cout << endl << " Loading Component \""
347 << AC_cfg->GetValue("NAME")
348 << "\" of type: " << token << endl;
349 if ((token == "LAG_FILTER") ||
350 (token == "LEAD_LAG_FILTER") ||
351 (token == "SECOND_ORDER_FILTER") ||
352 (token == "WASHOUT_FILTER") ||
353 (token == "INTEGRATOR") ) {
354 Components->push_back(new FGFilter(this, AC_cfg));
355 } else if ((token == "PURE_GAIN") ||
356 (token == "SCHEDULED_GAIN") ||
357 (token == "AEROSURFACE_SCALE") ) {
359 Components->push_back(new FGGain(this, AC_cfg));
361 } else if (token == "SUMMER") {
362 Components->push_back(new FGSummer(this, AC_cfg));
363 } else if (token == "DEADBAND") {
364 Components->push_back(new FGDeadBand(this, AC_cfg));
365 } else if (token == "GRADIENT") {
366 Components->push_back(new FGGradient(this, AC_cfg));
367 } else if (token == "SWITCH") {
368 Components->push_back(new FGSwitch(this, AC_cfg));
369 } else if (token == "KINEMAT") {
370 Components->push_back(new FGKinemat(this, AC_cfg));
372 cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
375 if (AC_cfg->GetNextConfigLine() == "EOF") break;
379 //collect information for normalizing control surfaces
382 for (i=0; i<Components->size(); i++) {
384 if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE"
385 || ((*Components)[i])->GetType() == "KINEMAT")
386 && ((*Components)[i])->GetOutputNode() ) {
387 nodeName = ((*Components)[i])->GetOutputNode()->GetName();
388 if ( nodeName == "elevator-pos-rad" ) {
390 } else if ( nodeName == "left-aileron-pos-rad"
391 || nodeName == "aileron-pos-rad" ) {
393 } else if ( nodeName == "right-aileron-pos-rad" ) {
395 } else if ( nodeName == "rudder-pos-rad" ) {
397 } else if ( nodeName == "speedbrake-pos-rad" ) {
399 } else if ( nodeName == "spoiler-pos-rad" ) {
401 } else if ( nodeName == "flap-pos-deg" ) {
407 if (delimiter == "FLIGHT_CONTROL") bindModel();
414 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416 double FGFCS::GetComponentOutput(int idx)
420 return FCSComponents[idx]->GetOutput();
422 return APComponents[idx]->GetOutput();
424 cerr << "Unknown FCS mode" << endl;
430 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
432 string FGFCS::GetComponentName(int idx)
436 return FCSComponents[idx]->GetName();
438 return APComponents[idx]->GetName();
440 cerr << "Unknown FCS mode" << endl;
446 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
451 case FGLGear::bgLeft:
453 case FGLGear::bgRight:
455 case FGLGear::bgCenter:
458 cerr << "GetBrake asked to return a bogus brake value" << endl;
463 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465 string FGFCS::GetComponentStrings(void)
468 string CompStrings = "";
469 bool firstime = true;
471 for (comp = 0; comp < FCSComponents.size(); comp++) {
472 if (firstime) firstime = false;
473 else CompStrings += ", ";
475 CompStrings += FCSComponents[comp]->GetName();
478 for (comp = 0; comp < APComponents.size(); comp++)
481 CompStrings += APComponents[comp]->GetName();
487 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
489 string FGFCS::GetComponentValues(void)
492 string CompValues = "";
494 bool firstime = true;
496 for (comp = 0; comp < FCSComponents.size(); comp++) {
497 if (firstime) firstime = false;
498 else CompValues += ", ";
500 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
501 CompValues += string(buffer);
504 for (comp = 0; comp < APComponents.size(); comp++) {
505 sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
506 CompValues += string(buffer);
512 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
514 void FGFCS::AddThrottle(void)
516 ThrottleCmd.push_back(0.0);
517 ThrottlePos.push_back(0.0);
518 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
519 MixturePos.push_back(0.0);
520 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
521 PropAdvance.push_back(0.0);
524 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
526 void FGFCS::Normalize(void) {
528 //not all of these are guaranteed to be defined for every model
529 //those that are have an index >=0 in the ToNormalize array
530 //ToNormalize is filled in Load()
532 if ( ToNormalize[iDe] > -1 ) {
533 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
536 if ( ToNormalize[iDaL] > -1 ) {
537 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
540 if ( ToNormalize[iDaR] > -1 ) {
541 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
544 if ( ToNormalize[iDr] > -1 ) {
545 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
548 if ( ToNormalize[iDsb] > -1 ) {
549 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
552 if ( ToNormalize[iDsp] > -1 ) {
553 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
556 if ( ToNormalize[iDf] > -1 ) {
557 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
560 DePos[ofMag] = fabs(DePos[ofRad]);
561 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
562 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
563 DrPos[ofMag] = fabs(DrPos[ofRad]);
564 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
565 DspPos[ofMag] = fabs(DspPos[ofRad]);
566 DfPos[ofMag] = fabs(DfPos[ofRad]);
570 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 void FGFCS::bind(void)
574 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
578 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
582 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
586 PropertyManager->Tie("fcs/flap-cmd-norm", this,
590 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
594 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
598 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
599 &FGFCS::GetPitchTrimCmd,
600 &FGFCS::SetPitchTrimCmd,
602 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
603 &FGFCS::GetYawTrimCmd,
604 &FGFCS::SetYawTrimCmd,
606 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
607 &FGFCS::GetRollTrimCmd,
608 &FGFCS::SetRollTrimCmd,
610 PropertyManager->Tie("gear/gear-cmd-norm", this,
615 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
619 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
623 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
628 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
632 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
636 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
641 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
645 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
649 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
654 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
658 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
662 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
667 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
671 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
676 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
680 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
684 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
689 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
693 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
697 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
702 PropertyManager->Tie("gear/gear-pos-norm", this,
707 PropertyManager->Tie("ap/elevator_cmd", this,
712 PropertyManager->Tie("ap/aileron_cmd", this,
717 PropertyManager->Tie("ap/rudder_cmd", this,
722 PropertyManager->Tie("ap/throttle_cmd", this,
723 &FGFCS::GetAPThrottleCmd,
724 &FGFCS::SetAPThrottleCmd,
727 PropertyManager->Tie("ap/attitude_setpoint", this,
728 &FGFCS::GetAPAttitudeSetPt,
729 &FGFCS::SetAPAttitudeSetPt,
732 PropertyManager->Tie("ap/altitude_setpoint", this,
733 &FGFCS::GetAPAltitudeSetPt,
734 &FGFCS::SetAPAltitudeSetPt,
737 PropertyManager->Tie("ap/heading_setpoint", this,
738 &FGFCS::GetAPHeadingSetPt,
739 &FGFCS::SetAPHeadingSetPt,
742 PropertyManager->Tie("ap/airspeed_setpoint", this,
743 &FGFCS::GetAPAirspeedSetPt,
744 &FGFCS::SetAPAirspeedSetPt,
747 PropertyManager->Tie("ap/acquire_attitude", this,
748 &FGFCS::GetAPAcquireAttitude,
749 &FGFCS::SetAPAcquireAttitude,
752 PropertyManager->Tie("ap/acquire_altitude", this,
753 &FGFCS::GetAPAcquireAltitude,
754 &FGFCS::SetAPAcquireAltitude,
757 PropertyManager->Tie("ap/acquire_heading", this,
758 &FGFCS::GetAPAcquireHeading,
759 &FGFCS::SetAPAcquireHeading,
762 PropertyManager->Tie("ap/acquire_airspeed", this,
763 &FGFCS::GetAPAcquireAirspeed,
764 &FGFCS::SetAPAcquireAirspeed,
767 PropertyManager->Tie("ap/attitude_hold", this,
768 &FGFCS::GetAPAttitudeHold,
769 &FGFCS::SetAPAttitudeHold,
772 PropertyManager->Tie("ap/altitude_hold", this,
773 &FGFCS::GetAPAltitudeHold,
774 &FGFCS::SetAPAltitudeHold,
777 PropertyManager->Tie("ap/heading_hold", this,
778 &FGFCS::GetAPHeadingHold,
779 &FGFCS::SetAPHeadingHold,
782 PropertyManager->Tie("ap/airspeed_hold", this,
783 &FGFCS::GetAPAirspeedHold,
784 &FGFCS::SetAPAirspeedHold,
787 PropertyManager->Tie("ap/wingslevel_hold", this,
788 &FGFCS::GetAPWingsLevelHold,
789 &FGFCS::SetAPWingsLevelHold,
793 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
795 void FGFCS::bindModel(void)
801 for (i=0; i<ThrottleCmd.size(); i++) {
802 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
803 PropertyManager->Tie( tmp,this,i,
804 &FGFCS::GetThrottleCmd,
805 &FGFCS::SetThrottleCmd,
807 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
808 PropertyManager->Tie( tmp,this,i,
809 &FGFCS::GetThrottlePos,
810 &FGFCS::SetThrottlePos,
812 if ( MixtureCmd.size() > i ) {
813 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
814 PropertyManager->Tie( tmp,this,i,
815 &FGFCS::GetMixtureCmd,
816 &FGFCS::SetMixtureCmd,
818 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
819 PropertyManager->Tie( tmp,this,i,
820 &FGFCS::GetMixturePos,
821 &FGFCS::SetMixturePos,
824 if ( PropAdvanceCmd.size() > i ) {
825 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
826 PropertyManager->Tie( tmp,this,i,
827 &FGFCS::GetPropAdvanceCmd,
828 &FGFCS::SetPropAdvanceCmd,
830 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
831 PropertyManager->Tie( tmp,this,i,
832 &FGFCS::GetPropAdvance,
833 &FGFCS::SetPropAdvance,
839 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
841 void FGFCS::unbind(FGPropertyManager *node)
843 int N = node->nChildren();
844 for(int i=0;i<N;i++) {
845 if(node->getChild(i)->nChildren() ) {
846 unbind( (FGPropertyManager*)node->getChild(i) );
847 } else if( node->getChild(i)->isTied() ) {
848 node->getChild(i)->untie();
853 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
854 // The bitmasked value choices are as follows:
855 // unset: In this case (the default) JSBSim would only print
856 // out the normally expected messages, essentially echoing
857 // the config files as they are read. If the environment
858 // variable is not set, debug_lvl is set to 1 internally
859 // 0: This requests JSBSim not to output any messages
861 // 1: This value explicity requests the normal JSBSim
863 // 2: This value asks for a message to be printed out when
864 // a class is instantiated
865 // 4: When this value is set, a message is displayed when a
866 // FGModel object executes its Run() method
867 // 8: When this value is set, various runtime state variables
868 // are printed out periodically
869 // 16: When set various parameters are sanity checked and
870 // a message is printed out when they go out of bounds
872 void FGFCS::Debug(int from)
874 if (debug_lvl <= 0) return;
876 if (debug_lvl & 1) { // Standard console startup message output
877 if (from == 0) { // Constructor
881 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
882 if (from == 0) cout << "Instantiated: FGFCS" << endl;
883 if (from == 1) cout << "Destroyed: FGFCS" << endl;
885 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
887 if (debug_lvl & 8 ) { // Runtime state variables
889 if (debug_lvl & 16) { // Sanity checking
891 if (debug_lvl & 64) {
892 if (from == 0) { // Constructor
893 cout << IdSrc << endl;
894 cout << IdHdr << endl;