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"
62 static const char *IdSrc = "$Id$";
63 static const char *IdHdr = ID_FCS;
65 #if defined(WIN32) && !defined(__CYGWIN__)
66 #define snprintf _snprintf
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73 FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
78 DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0.0;
79 AP_DaCmd = AP_DeCmd = AP_DrCmd = AP_ThrottleCmd = 0.0;
80 PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
81 GearCmd = GearPos = 1; // default to gear down
82 LeftBrake = RightBrake = CenterBrake = 0.0;
88 for (i=0;i<=NForms;i++) {
89 DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
90 DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
93 for (i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
97 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 unbind( PropertyManager->GetNode("fcs") );
102 unbind( PropertyManager->GetNode("ap") );
103 PropertyManager->Untie( "gear/gear-cmd-norm" );
104 PropertyManager->Untie( "gear/gear-pos-norm" );
110 PropAdvanceCmd.clear();
116 for (i=0;i<APComponents.size();i++) delete APComponents[i];
117 for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
122 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 bool FGFCS::Run(void)
128 if (!FGModel::Run()) {
129 for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
130 for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
131 for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
132 for (i=0; i<APComponents.size(); i++) {
134 APComponents[i]->Run();
137 for (i=0; i<FCSComponents.size(); i++) {
139 FCSComponents[i]->Run();
142 if (DoNormalize) Normalize();
150 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
152 void FGFCS::SetThrottleCmd(int engineNum, double setting)
156 if (engineNum < (int)ThrottlePos.size()) {
158 for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
160 ThrottleCmd[engineNum] = setting;
163 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
164 << " engines exist, but attempted throttle command is for engine "
165 << engineNum << endl;
169 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171 void FGFCS::SetThrottlePos(int engineNum, double setting)
175 if (engineNum < (int)ThrottlePos.size()) {
177 for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
179 ThrottlePos[engineNum] = setting;
182 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
183 << " engines exist, but attempted throttle position setting is for engine "
184 << engineNum << endl;
188 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 double FGFCS::GetThrottleCmd(int engineNum) const
192 if (engineNum < (int)ThrottlePos.size()) {
194 cerr << "Cannot get throttle value for ALL engines" << endl;
196 return ThrottleCmd[engineNum];
199 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
200 << " engines exist, but throttle setting for engine " << engineNum
201 << " is selected" << endl;
206 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 double FGFCS::GetThrottlePos(int engineNum) const
210 if (engineNum < (int)ThrottlePos.size()) {
212 cerr << "Cannot get throttle value for ALL engines" << endl;
214 return ThrottlePos[engineNum];
217 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
218 << " engines exist, but attempted throttle position setting is for engine "
219 << engineNum << endl;
224 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 void FGFCS::SetMixtureCmd(int engineNum, double setting)
230 if (engineNum < (int)ThrottlePos.size()) {
232 for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
234 MixtureCmd[engineNum] = setting;
239 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 void FGFCS::SetMixturePos(int engineNum, double setting)
245 if (engineNum < (int)ThrottlePos.size()) {
247 for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
249 MixturePos[engineNum] = setting;
254 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
260 if (engineNum < (int)ThrottlePos.size()) {
262 for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
264 PropAdvanceCmd[engineNum] = setting;
269 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271 void FGFCS::SetPropAdvance(int engineNum, double setting)
275 if (engineNum < (int)ThrottlePos.size()) {
277 for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
279 PropAdvance[engineNum] = setting;
284 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286 bool FGFCS::Load(FGConfigFile* AC_cfg)
288 string token, delimiter;
289 string name, file, fname;
291 vector <FGFCSComponent*> *Components;
292 FGConfigFile *FCS_cfg;
295 // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
296 // file or in a separate file. Set up the config file class as appropriate.
298 delimiter = AC_cfg->GetValue();
299 name = AC_cfg->GetValue("NAME");
300 fname = AC_cfg->GetValue("FILE");
302 if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
304 cout << " Automatic Control Surface Normalization Disabled" << endl;
308 file = "control/" + fname + ".xml";
310 file = "control;" + fname + ".xml";
316 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
318 FCS_cfg = new FGConfigFile(file);
319 if (!FCS_cfg->IsOpen()) {
320 cerr << "Could not open " << delimiter << " file: " << file << endl;
323 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
324 // file object pointer
328 AC_cfg->GetNextConfigLine();
331 if (delimiter == "AUTOPILOT") {
332 Components = &APComponents;
334 Name = "Autopilot: " + name;
335 } else if (delimiter == "FLIGHT_CONTROL") {
336 Components = &FCSComponents;
338 Name = "FCS: " + name;
340 cerr << endl << "Unknown FCS delimiter" << endl << endl;
343 if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
345 while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
346 if (token == "COMPONENT") {
347 token = AC_cfg->GetValue("TYPE");
348 if (debug_lvl > 0) cout << endl << " Loading Component \""
349 << AC_cfg->GetValue("NAME")
350 << "\" of type: " << token << endl;
351 if ((token == "LAG_FILTER") ||
352 (token == "LEAD_LAG_FILTER") ||
353 (token == "SECOND_ORDER_FILTER") ||
354 (token == "WASHOUT_FILTER") ||
355 (token == "INTEGRATOR") ) {
356 Components->push_back(new FGFilter(this, AC_cfg));
357 } else if ((token == "PURE_GAIN") ||
358 (token == "SCHEDULED_GAIN") ||
359 (token == "AEROSURFACE_SCALE") ) {
361 Components->push_back(new FGGain(this, AC_cfg));
363 } else if (token == "SUMMER") {
364 Components->push_back(new FGSummer(this, AC_cfg));
365 } else if (token == "DEADBAND") {
366 Components->push_back(new FGDeadBand(this, AC_cfg));
367 } else if (token == "GRADIENT") {
368 Components->push_back(new FGGradient(this, AC_cfg));
369 } else if (token == "SWITCH") {
370 Components->push_back(new FGSwitch(this, AC_cfg));
371 } else if (token == "KINEMAT") {
372 Components->push_back(new FGKinemat(this, AC_cfg));
374 cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
377 if (AC_cfg->GetNextConfigLine() == "EOF") break;
381 //collect information for normalizing control surfaces
384 for (i=0; i<Components->size(); i++) {
386 if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE"
387 || ((*Components)[i])->GetType() == "KINEMAT")
388 && ((*Components)[i])->GetOutputNode() ) {
389 nodeName = ((*Components)[i])->GetOutputNode()->GetName();
390 if ( nodeName == "elevator-pos-rad" ) {
392 } else if ( nodeName == "left-aileron-pos-rad"
393 || nodeName == "aileron-pos-rad" ) {
395 } else if ( nodeName == "right-aileron-pos-rad" ) {
397 } else if ( nodeName == "rudder-pos-rad" ) {
399 } else if ( nodeName == "speedbrake-pos-rad" ) {
401 } else if ( nodeName == "spoiler-pos-rad" ) {
403 } else if ( nodeName == "flap-pos-deg" ) {
409 if (delimiter == "FLIGHT_CONTROL") bindModel();
416 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
418 double FGFCS::GetComponentOutput(int idx)
422 return FCSComponents[idx]->GetOutput();
424 return APComponents[idx]->GetOutput();
426 cerr << "Unknown FCS mode" << endl;
432 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
434 string FGFCS::GetComponentName(int idx)
438 return FCSComponents[idx]->GetName();
440 return APComponents[idx]->GetName();
442 cerr << "Unknown FCS mode" << endl;
448 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
453 case FGLGear::bgLeft:
455 case FGLGear::bgRight:
457 case FGLGear::bgCenter:
460 cerr << "GetBrake asked to return a bogus brake value" << endl;
465 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
467 string FGFCS::GetComponentStrings(void)
470 string CompStrings = "";
471 bool firstime = true;
473 for (comp = 0; comp < FCSComponents.size(); comp++) {
474 if (firstime) firstime = false;
475 else CompStrings += ", ";
477 CompStrings += FCSComponents[comp]->GetName();
480 for (comp = 0; comp < APComponents.size(); comp++)
483 CompStrings += APComponents[comp]->GetName();
489 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
491 string FGFCS::GetComponentValues(void)
494 string CompValues = "";
496 bool firstime = true;
498 for (comp = 0; comp < FCSComponents.size(); comp++) {
499 if (firstime) firstime = false;
500 else CompValues += ", ";
502 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
503 CompValues += string(buffer);
506 for (comp = 0; comp < APComponents.size(); comp++) {
507 sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
508 CompValues += string(buffer);
514 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
516 void FGFCS::AddThrottle(void)
518 ThrottleCmd.push_back(0.0);
519 ThrottlePos.push_back(0.0);
520 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
521 MixturePos.push_back(0.0);
522 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
523 PropAdvance.push_back(0.0);
526 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
528 void FGFCS::Normalize(void) {
530 //not all of these are guaranteed to be defined for every model
531 //those that are have an index >=0 in the ToNormalize array
532 //ToNormalize is filled in Load()
534 if ( ToNormalize[iDe] > -1 ) {
535 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
538 if ( ToNormalize[iDaL] > -1 ) {
539 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
542 if ( ToNormalize[iDaR] > -1 ) {
543 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
546 if ( ToNormalize[iDr] > -1 ) {
547 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
550 if ( ToNormalize[iDsb] > -1 ) {
551 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
554 if ( ToNormalize[iDsp] > -1 ) {
555 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
558 if ( ToNormalize[iDf] > -1 ) {
559 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
562 DePos[ofMag] = fabs(DePos[ofRad]);
563 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
564 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
565 DrPos[ofMag] = fabs(DrPos[ofRad]);
566 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
567 DspPos[ofMag] = fabs(DspPos[ofRad]);
568 DfPos[ofMag] = fabs(DfPos[ofRad]);
572 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
574 void FGFCS::bind(void)
576 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
580 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
584 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
588 PropertyManager->Tie("fcs/flap-cmd-norm", this,
592 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
596 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
600 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
601 &FGFCS::GetPitchTrimCmd,
602 &FGFCS::SetPitchTrimCmd,
604 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
605 &FGFCS::GetYawTrimCmd,
606 &FGFCS::SetYawTrimCmd,
608 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
609 &FGFCS::GetRollTrimCmd,
610 &FGFCS::SetRollTrimCmd,
612 PropertyManager->Tie("gear/gear-cmd-norm", this,
617 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
621 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
625 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
630 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
634 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
638 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
643 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
647 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
651 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
656 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
660 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
664 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
669 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
673 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
678 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
682 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
686 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
691 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
695 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
699 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
704 PropertyManager->Tie("gear/gear-pos-norm", this,
709 PropertyManager->Tie("ap/elevator_cmd", this,
714 PropertyManager->Tie("ap/aileron_cmd", this,
719 PropertyManager->Tie("ap/rudder_cmd", this,
724 PropertyManager->Tie("ap/throttle_cmd", this,
725 &FGFCS::GetAPThrottleCmd,
726 &FGFCS::SetAPThrottleCmd,
729 PropertyManager->Tie("ap/attitude_setpoint", this,
730 &FGFCS::GetAPAttitudeSetPt,
731 &FGFCS::SetAPAttitudeSetPt,
734 PropertyManager->Tie("ap/altitude_setpoint", this,
735 &FGFCS::GetAPAltitudeSetPt,
736 &FGFCS::SetAPAltitudeSetPt,
739 PropertyManager->Tie("ap/heading_setpoint", this,
740 &FGFCS::GetAPHeadingSetPt,
741 &FGFCS::SetAPHeadingSetPt,
744 PropertyManager->Tie("ap/airspeed_setpoint", this,
745 &FGFCS::GetAPAirspeedSetPt,
746 &FGFCS::SetAPAirspeedSetPt,
749 PropertyManager->Tie("ap/acquire_attitude", this,
750 &FGFCS::GetAPAcquireAttitude,
751 &FGFCS::SetAPAcquireAttitude,
754 PropertyManager->Tie("ap/acquire_altitude", this,
755 &FGFCS::GetAPAcquireAltitude,
756 &FGFCS::SetAPAcquireAltitude,
759 PropertyManager->Tie("ap/acquire_heading", this,
760 &FGFCS::GetAPAcquireHeading,
761 &FGFCS::SetAPAcquireHeading,
764 PropertyManager->Tie("ap/acquire_airspeed", this,
765 &FGFCS::GetAPAcquireAirspeed,
766 &FGFCS::SetAPAcquireAirspeed,
769 PropertyManager->Tie("ap/attitude_hold", this,
770 &FGFCS::GetAPAttitudeHold,
771 &FGFCS::SetAPAttitudeHold,
774 PropertyManager->Tie("ap/altitude_hold", this,
775 &FGFCS::GetAPAltitudeHold,
776 &FGFCS::SetAPAltitudeHold,
779 PropertyManager->Tie("ap/heading_hold", this,
780 &FGFCS::GetAPHeadingHold,
781 &FGFCS::SetAPHeadingHold,
784 PropertyManager->Tie("ap/airspeed_hold", this,
785 &FGFCS::GetAPAirspeedHold,
786 &FGFCS::SetAPAirspeedHold,
789 PropertyManager->Tie("ap/wingslevel_hold", this,
790 &FGFCS::GetAPWingsLevelHold,
791 &FGFCS::SetAPWingsLevelHold,
795 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 void FGFCS::bindModel(void)
803 for (i=0; i<ThrottleCmd.size(); i++) {
804 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
805 PropertyManager->Tie( tmp,this,i,
806 &FGFCS::GetThrottleCmd,
807 &FGFCS::SetThrottleCmd,
809 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
810 PropertyManager->Tie( tmp,this,i,
811 &FGFCS::GetThrottlePos,
812 &FGFCS::SetThrottlePos,
814 if ( MixtureCmd.size() > i ) {
815 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
816 PropertyManager->Tie( tmp,this,i,
817 &FGFCS::GetMixtureCmd,
818 &FGFCS::SetMixtureCmd,
820 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
821 PropertyManager->Tie( tmp,this,i,
822 &FGFCS::GetMixturePos,
823 &FGFCS::SetMixturePos,
826 if ( PropAdvanceCmd.size() > i ) {
827 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
828 PropertyManager->Tie( tmp,this,i,
829 &FGFCS::GetPropAdvanceCmd,
830 &FGFCS::SetPropAdvanceCmd,
832 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
833 PropertyManager->Tie( tmp,this,i,
834 &FGFCS::GetPropAdvance,
835 &FGFCS::SetPropAdvance,
841 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
843 void FGFCS::unbind(FGPropertyManager *node)
845 int N = node->nChildren();
846 for(int i=0;i<N;i++) {
847 if(node->getChild(i)->nChildren() ) {
848 unbind( (FGPropertyManager*)node->getChild(i) );
849 } else if( node->getChild(i)->isTied() ) {
850 node->getChild(i)->untie();
855 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
856 // The bitmasked value choices are as follows:
857 // unset: In this case (the default) JSBSim would only print
858 // out the normally expected messages, essentially echoing
859 // the config files as they are read. If the environment
860 // variable is not set, debug_lvl is set to 1 internally
861 // 0: This requests JSBSim not to output any messages
863 // 1: This value explicity requests the normal JSBSim
865 // 2: This value asks for a message to be printed out when
866 // a class is instantiated
867 // 4: When this value is set, a message is displayed when a
868 // FGModel object executes its Run() method
869 // 8: When this value is set, various runtime state variables
870 // are printed out periodically
871 // 16: When set various parameters are sanity checked and
872 // a message is printed out when they go out of bounds
874 void FGFCS::Debug(int from)
876 if (debug_lvl <= 0) return;
878 if (debug_lvl & 1) { // Standard console startup message output
879 if (from == 0) { // Constructor
883 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
884 if (from == 0) cout << "Instantiated: FGFCS" << endl;
885 if (from == 1) cout << "Destroyed: FGFCS" << endl;
887 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
889 if (debug_lvl & 8 ) { // Runtime state variables
891 if (debug_lvl & 16) { // Sanity checking
893 if (debug_lvl & 64) {
894 if (from == 0) { // Constructor
895 cout << IdSrc << endl;
896 cout << IdHdr << endl;