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 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 PropAdvanceCmd.clear();
110 for (i=0;i<APComponents.size();i++) delete APComponents[i];
111 for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
116 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 bool FGFCS::Run(void)
122 if (!FGModel::Run()) {
123 for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
124 for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
125 for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
126 for (i=0; i<APComponents.size(); i++) {
128 APComponents[i]->Run();
131 for (i=0; i<FCSComponents.size(); i++) {
133 FCSComponents[i]->Run();
136 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";
304 file = "control;" + fname + ".xml";
310 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
312 FCS_cfg = new FGConfigFile(file);
313 if (!FCS_cfg->IsOpen()) {
314 cerr << "Could not open " << delimiter << " file: " << file << endl;
317 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
318 // file object pointer
322 AC_cfg->GetNextConfigLine();
325 if (delimiter == "AUTOPILOT") {
326 Components = &APComponents;
328 Name = "Autopilot: " + name;
329 } else if (delimiter == "FLIGHT_CONTROL") {
330 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();
410 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
412 double FGFCS::GetComponentOutput(int idx)
416 return FCSComponents[idx]->GetOutput();
418 return APComponents[idx]->GetOutput();
420 cerr << "Unknown FCS mode" << endl;
426 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
428 string FGFCS::GetComponentName(int idx)
432 return FCSComponents[idx]->GetName();
434 return APComponents[idx]->GetName();
436 cerr << "Unknown FCS mode" << endl;
442 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
444 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
447 case FGLGear::bgLeft:
449 case FGLGear::bgRight:
451 case FGLGear::bgCenter:
454 cerr << "GetBrake asked to return a bogus brake value" << endl;
459 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
461 string FGFCS::GetComponentStrings(void)
464 string CompStrings = "";
465 bool firstime = true;
467 for (comp = 0; comp < FCSComponents.size(); comp++) {
468 if (firstime) firstime = false;
469 else CompStrings += ", ";
471 CompStrings += FCSComponents[comp]->GetName();
474 for (comp = 0; comp < APComponents.size(); comp++)
477 CompStrings += APComponents[comp]->GetName();
483 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
485 string FGFCS::GetComponentValues(void)
488 string CompValues = "";
490 bool firstime = true;
492 for (comp = 0; comp < FCSComponents.size(); comp++) {
493 if (firstime) firstime = false;
494 else CompValues += ", ";
496 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
497 CompValues += string(buffer);
500 for (comp = 0; comp < APComponents.size(); comp++) {
501 sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
502 CompValues += string(buffer);
508 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510 void FGFCS::AddThrottle(void)
512 ThrottleCmd.push_back(0.0);
513 ThrottlePos.push_back(0.0);
514 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
515 MixturePos.push_back(0.0);
516 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
517 PropAdvance.push_back(0.0);
520 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522 void FGFCS::Normalize(void) {
524 //not all of these are guaranteed to be defined for every model
525 //those that are have an index >=0 in the ToNormalize array
526 //ToNormalize is filled in Load()
528 if ( ToNormalize[iDe] > -1 ) {
529 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
532 if ( ToNormalize[iDaL] > -1 ) {
533 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
536 if ( ToNormalize[iDaR] > -1 ) {
537 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
540 if ( ToNormalize[iDr] > -1 ) {
541 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
544 if ( ToNormalize[iDsb] > -1 ) {
545 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
548 if ( ToNormalize[iDsp] > -1 ) {
549 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
552 if ( ToNormalize[iDf] > -1 ) {
553 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
556 DePos[ofMag] = fabs(DePos[ofRad]);
557 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
558 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
559 DrPos[ofMag] = fabs(DrPos[ofRad]);
560 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
561 DspPos[ofMag] = fabs(DspPos[ofRad]);
562 DfPos[ofMag] = fabs(DfPos[ofRad]);
566 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 void FGFCS::bind(void)
570 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
574 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
578 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
582 PropertyManager->Tie("fcs/flap-cmd-norm", this,
586 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
590 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
594 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
595 &FGFCS::GetPitchTrimCmd,
596 &FGFCS::SetPitchTrimCmd,
598 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
599 &FGFCS::GetYawTrimCmd,
600 &FGFCS::SetYawTrimCmd,
602 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
603 &FGFCS::GetRollTrimCmd,
604 &FGFCS::SetRollTrimCmd,
606 PropertyManager->Tie("gear/gear-cmd-norm", this,
611 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
615 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
619 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
624 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
628 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
632 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
637 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
641 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
645 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
650 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
654 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
658 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
663 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
667 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
672 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
676 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
680 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
685 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
689 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
693 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
698 PropertyManager->Tie("gear/gear-pos-norm", this,
703 PropertyManager->Tie("ap/elevator_cmd", this,
708 PropertyManager->Tie("ap/aileron_cmd", this,
713 PropertyManager->Tie("ap/rudder_cmd", this,
718 PropertyManager->Tie("ap/throttle_cmd", this,
719 &FGFCS::GetAPThrottleCmd,
720 &FGFCS::SetAPThrottleCmd,
723 PropertyManager->Tie("ap/attitude_setpoint", this,
724 &FGFCS::GetAPAttitudeSetPt,
725 &FGFCS::SetAPAttitudeSetPt,
728 PropertyManager->Tie("ap/altitude_setpoint", this,
729 &FGFCS::GetAPAltitudeSetPt,
730 &FGFCS::SetAPAltitudeSetPt,
733 PropertyManager->Tie("ap/heading_setpoint", this,
734 &FGFCS::GetAPHeadingSetPt,
735 &FGFCS::SetAPHeadingSetPt,
738 PropertyManager->Tie("ap/airspeed_setpoint", this,
739 &FGFCS::GetAPAirspeedSetPt,
740 &FGFCS::SetAPAirspeedSetPt,
743 PropertyManager->Tie("ap/acquire_attitude", this,
744 &FGFCS::GetAPAcquireAttitude,
745 &FGFCS::SetAPAcquireAttitude,
748 PropertyManager->Tie("ap/acquire_altitude", this,
749 &FGFCS::GetAPAcquireAltitude,
750 &FGFCS::SetAPAcquireAltitude,
753 PropertyManager->Tie("ap/acquire_heading", this,
754 &FGFCS::GetAPAcquireHeading,
755 &FGFCS::SetAPAcquireHeading,
758 PropertyManager->Tie("ap/acquire_airspeed", this,
759 &FGFCS::GetAPAcquireAirspeed,
760 &FGFCS::SetAPAcquireAirspeed,
763 PropertyManager->Tie("ap/attitude_hold", this,
764 &FGFCS::GetAPAttitudeHold,
765 &FGFCS::SetAPAttitudeHold,
768 PropertyManager->Tie("ap/altitude_hold", this,
769 &FGFCS::GetAPAltitudeHold,
770 &FGFCS::SetAPAltitudeHold,
773 PropertyManager->Tie("ap/heading_hold", this,
774 &FGFCS::GetAPHeadingHold,
775 &FGFCS::SetAPHeadingHold,
778 PropertyManager->Tie("ap/airspeed_hold", this,
779 &FGFCS::GetAPAirspeedHold,
780 &FGFCS::SetAPAirspeedHold,
783 PropertyManager->Tie("ap/wingslevel_hold", this,
784 &FGFCS::GetAPWingsLevelHold,
785 &FGFCS::SetAPWingsLevelHold,
789 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
791 void FGFCS::bindModel(void)
797 for (i=0; i<ThrottleCmd.size(); i++) {
798 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
799 PropertyManager->Tie( tmp,this,i,
800 &FGFCS::GetThrottleCmd,
801 &FGFCS::SetThrottleCmd,
803 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
804 PropertyManager->Tie( tmp,this,i,
805 &FGFCS::GetThrottlePos,
806 &FGFCS::SetThrottlePos,
808 if ( MixtureCmd.size() > i ) {
809 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
810 PropertyManager->Tie( tmp,this,i,
811 &FGFCS::GetMixtureCmd,
812 &FGFCS::SetMixtureCmd,
814 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
815 PropertyManager->Tie( tmp,this,i,
816 &FGFCS::GetMixturePos,
817 &FGFCS::SetMixturePos,
820 if ( PropAdvanceCmd.size() > i ) {
821 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
822 PropertyManager->Tie( tmp,this,i,
823 &FGFCS::GetPropAdvanceCmd,
824 &FGFCS::SetPropAdvanceCmd,
826 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
827 PropertyManager->Tie( tmp,this,i,
828 &FGFCS::GetPropAdvance,
829 &FGFCS::SetPropAdvance,
835 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
837 void FGFCS::unbind(void)
839 PropertyManager->Untie("fcs/aileron-cmd-norm");
840 PropertyManager->Untie("fcs/elevator-cmd-norm");
841 PropertyManager->Untie("fcs/rudder-cmd-norm");
842 PropertyManager->Untie("fcs/flap-cmd-norm");
843 PropertyManager->Untie("fcs/speedbrake-cmd-norm");
844 PropertyManager->Untie("fcs/spoiler-cmd-norm");
845 PropertyManager->Untie("fcs/pitch-trim-cmd-norm");
846 PropertyManager->Untie("fcs/roll-trim-cmd-norm");
847 PropertyManager->Untie("fcs/yaw-trim-cmd-norm");
848 PropertyManager->Untie("gear/gear-cmd-norm");
849 PropertyManager->Untie("fcs/left-aileron-pos-rad");
850 PropertyManager->Untie("fcs/mag-left-aileron-pos-rad");
851 PropertyManager->Untie("fcs/left-aileron-pos-norm");
852 PropertyManager->Untie("fcs/right-aileron-pos-rad");
853 PropertyManager->Untie("fcs/mag-right-aileron-pos-rad");
854 PropertyManager->Untie("fcs/right-aileron-pos-norm");
855 PropertyManager->Untie("fcs/elevator-pos-rad");
856 PropertyManager->Untie("fcs/mag-elevator-pos-rad");
857 PropertyManager->Untie("fcs/elevator-pos-norm");
858 PropertyManager->Untie("fcs/rudder-pos-rad");
859 PropertyManager->Untie("fcs/mag-rudder-pos-rad");
860 PropertyManager->Untie("fcs/rudder-pos-norm");
861 PropertyManager->Untie("fcs/flap-pos-deg");
862 PropertyManager->Untie("fcs/flap-pos-norm");
863 PropertyManager->Untie("fcs/speedbrake-pos-rad");
864 PropertyManager->Untie("fcs/mag-speedbrake-pos-rad");
865 PropertyManager->Untie("fcs/speedbrake-pos-norm");
866 PropertyManager->Untie("fcs/spoiler-pos-rad");
867 PropertyManager->Untie("fcs/mag-spoiler-pos-rad");
868 PropertyManager->Untie("fcs/spoiler-pos-norm");
869 PropertyManager->Untie("gear/gear-pos-norm");
870 PropertyManager->Untie("ap/elevator_cmd");
871 PropertyManager->Untie("ap/aileron_cmd");
872 PropertyManager->Untie("ap/rudder_cmd");
873 PropertyManager->Untie("ap/throttle_cmd");
874 PropertyManager->Untie("ap/attitude_setpoint");
875 PropertyManager->Untie("ap/altitude_setpoint");
876 PropertyManager->Untie("ap/heading_setpoint");
877 PropertyManager->Untie("ap/airspeed_setpoint");
878 PropertyManager->Untie("ap/acquire_attitude");
879 PropertyManager->Untie("ap/acquire_altitude");
880 PropertyManager->Untie("ap/acquire_heading");
881 PropertyManager->Untie("ap/acquire_airspeed");
882 PropertyManager->Untie("ap/attitude_hold");
883 PropertyManager->Untie("ap/altitude_hold");
884 PropertyManager->Untie("ap/heading_hold");
885 PropertyManager->Untie("ap/airspeed_hold");
886 PropertyManager->Untie("ap/wingslevel_hold");
889 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
890 // The bitmasked value choices are as follows:
891 // unset: In this case (the default) JSBSim would only print
892 // out the normally expected messages, essentially echoing
893 // the config files as they are read. If the environment
894 // variable is not set, debug_lvl is set to 1 internally
895 // 0: This requests JSBSim not to output any messages
897 // 1: This value explicity requests the normal JSBSim
899 // 2: This value asks for a message to be printed out when
900 // a class is instantiated
901 // 4: When this value is set, a message is displayed when a
902 // FGModel object executes its Run() method
903 // 8: When this value is set, various runtime state variables
904 // are printed out periodically
905 // 16: When set various parameters are sanity checked and
906 // a message is printed out when they go out of bounds
908 void FGFCS::Debug(int from)
910 if (debug_lvl <= 0) return;
912 if (debug_lvl & 1) { // Standard console startup message output
913 if (from == 0) { // Constructor
917 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
918 if (from == 0) cout << "Instantiated: FGFCS" << endl;
919 if (from == 1) cout << "Destroyed: FGFCS" << endl;
921 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
923 if (debug_lvl & 8 ) { // Runtime state variables
925 if (debug_lvl & 16) { // Sanity checking
927 if (debug_lvl & 64) {
928 if (from == 0) { // Constructor
929 cout << IdSrc << endl;
930 cout << IdHdr << endl;