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;
288 // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
289 // file or in a separate file. Set up the config file class as appropriate.
291 delimiter = AC_cfg->GetValue();
292 name = AC_cfg->GetValue("NAME");
293 fname = AC_cfg->GetValue("FILE");
295 if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
297 cout << " Automatic Control Surface Normalization Disabled" << endl;
301 file = "control/" + fname + ".xml";
303 file = "control;" + fname + ".xml";
309 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
311 FCS_cfg = new FGConfigFile(file);
312 if (!FCS_cfg->IsOpen()) {
313 cerr << "Could not open " << delimiter << " file: " << file << endl;
316 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
317 // file object pointer
321 AC_cfg->GetNextConfigLine();
324 if (delimiter == "AUTOPILOT") {
325 Components = &APComponents;
327 Name = "Autopilot:" + name;
328 } else if (delimiter == "FLIGHT_CONTROL") {
329 Components = &FCSComponents;
331 Name = "FCS:" + name;
333 cerr << endl << "Unknown FCS delimiter" << endl << endl;
336 if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
338 while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
339 if (token == "COMPONENT") {
340 token = AC_cfg->GetValue("TYPE");
341 if (debug_lvl > 0) cout << endl << " Loading Component \""
342 << AC_cfg->GetValue("NAME")
343 << "\" of type: " << token << endl;
344 if ((token == "LAG_FILTER") ||
345 (token == "LEAD_LAG_FILTER") ||
346 (token == "SECOND_ORDER_FILTER") ||
347 (token == "WASHOUT_FILTER") ||
348 (token == "INTEGRATOR") ) {
349 Components->push_back(new FGFilter(this, AC_cfg));
350 } else if ((token == "PURE_GAIN") ||
351 (token == "SCHEDULED_GAIN") ||
352 (token == "AEROSURFACE_SCALE") ) {
354 Components->push_back(new FGGain(this, AC_cfg));
356 } else if (token == "SUMMER") {
357 Components->push_back(new FGSummer(this, AC_cfg));
358 } else if (token == "DEADBAND") {
359 Components->push_back(new FGDeadBand(this, AC_cfg));
360 } else if (token == "GRADIENT") {
361 Components->push_back(new FGGradient(this, AC_cfg));
362 } else if (token == "SWITCH") {
363 Components->push_back(new FGSwitch(this, AC_cfg));
364 } else if (token == "KINEMAT") {
365 Components->push_back(new FGKinemat(this, AC_cfg));
367 cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
370 if (AC_cfg->GetNextConfigLine() == "EOF") break;
374 //collect information for normalizing control surfaces
377 for (i=0; i<Components->size(); i++) {
379 if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE"
380 || ((*Components)[i])->GetType() == "KINEMAT")
381 && ((*Components)[i])->GetOutputNode() ) {
382 nodeName = ((*Components)[i])->GetOutputNode()->GetName();
383 if ( nodeName == "elevator-pos-rad" ) {
385 } else if ( nodeName == "left-aileron-pos-rad"
386 || nodeName == "aileron-pos-rad" ) {
388 } else if ( nodeName == "right-aileron-pos-rad" ) {
390 } else if ( nodeName == "rudder-pos-rad" ) {
392 } else if ( nodeName == "speedbrake-pos-rad" ) {
394 } else if ( nodeName == "spoiler-pos-rad" ) {
396 } else if ( nodeName == "flap-pos-deg" ) {
402 if (delimiter == "FLIGHT_CONTROL") bindModel();
409 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411 double FGFCS::GetComponentOutput(int idx)
415 return FCSComponents[idx]->GetOutput();
417 return APComponents[idx]->GetOutput();
419 cerr << "Unknown FCS mode" << endl;
424 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426 string FGFCS::GetComponentName(int idx)
430 return FCSComponents[idx]->GetName();
432 return APComponents[idx]->GetName();
434 cerr << "Unknown FCS mode" << endl;
439 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
444 case FGLGear::bgLeft:
446 case FGLGear::bgRight:
448 case FGLGear::bgCenter:
451 cerr << "GetBrake asked to return a bogus brake value" << endl;
456 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
458 string FGFCS::GetComponentStrings(void)
461 string CompStrings = "";
462 bool firstime = true;
464 for (comp = 0; comp < FCSComponents.size(); comp++) {
465 if (firstime) firstime = false;
466 else CompStrings += ", ";
468 CompStrings += FCSComponents[comp]->GetName();
471 for (comp = 0; comp < APComponents.size(); comp++)
474 CompStrings += APComponents[comp]->GetName();
480 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
482 string FGFCS::GetComponentValues(void)
485 string CompValues = "";
487 bool firstime = true;
489 for (comp = 0; comp < FCSComponents.size(); comp++) {
490 if (firstime) firstime = false;
491 else CompValues += ", ";
493 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
494 CompValues += string(buffer);
497 for (comp = 0; comp < APComponents.size(); comp++) {
498 sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
499 CompValues += string(buffer);
505 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 void FGFCS::AddThrottle(void)
509 ThrottleCmd.push_back(0.0);
510 ThrottlePos.push_back(0.0);
511 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
512 MixturePos.push_back(0.0);
513 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
514 PropAdvance.push_back(0.0);
517 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
519 void FGFCS::Normalize(void) {
521 //not all of these are guaranteed to be defined for every model
522 //those that are have an index >=0 in the ToNormalize array
523 //ToNormalize is filled in Load()
525 if ( ToNormalize[iDe] > -1 ) {
526 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
529 if ( ToNormalize[iDaL] > -1 ) {
530 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
533 if ( ToNormalize[iDaR] > -1 ) {
534 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
537 if ( ToNormalize[iDr] > -1 ) {
538 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
541 if ( ToNormalize[iDsb] > -1 ) {
542 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
545 if ( ToNormalize[iDsp] > -1 ) {
546 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
549 if ( ToNormalize[iDf] > -1 ) {
550 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
553 DePos[ofMag] = fabs(DePos[ofRad]);
554 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
555 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
556 DrPos[ofMag] = fabs(DrPos[ofRad]);
557 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
558 DspPos[ofMag] = fabs(DspPos[ofRad]);
559 DfPos[ofMag] = fabs(DfPos[ofRad]);
563 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 void FGFCS::bind(void)
567 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
571 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
575 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
579 PropertyManager->Tie("fcs/flap-cmd-norm", this,
583 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
587 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
591 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
592 &FGFCS::GetPitchTrimCmd,
593 &FGFCS::SetPitchTrimCmd,
595 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
596 &FGFCS::GetYawTrimCmd,
597 &FGFCS::SetYawTrimCmd,
599 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
600 &FGFCS::GetRollTrimCmd,
601 &FGFCS::SetRollTrimCmd,
603 PropertyManager->Tie("gear/gear-cmd-norm", this,
608 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
612 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
616 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
621 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
625 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
629 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
634 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
638 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
642 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
647 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
651 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
655 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
660 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
664 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
669 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
673 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
677 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
682 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
686 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
690 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
695 PropertyManager->Tie("gear/gear-pos-norm", this,
700 PropertyManager->Tie("jsbsim/ap/elevator_cmd", this,
705 PropertyManager->Tie("jsbsim/ap/aileron_cmd", this,
710 PropertyManager->Tie("jsbsim/ap/rudder_cmd", this,
715 PropertyManager->Tie("jsbsim/ap/throttle_cmd", this,
716 &FGFCS::GetAPThrottleCmd,
717 &FGFCS::SetAPThrottleCmd,
720 PropertyManager->Tie("jsbsim/ap/attitude_setpoint", this,
721 &FGFCS::GetAPAttitudeSetPt,
722 &FGFCS::SetAPAttitudeSetPt,
725 PropertyManager->Tie("jsbsim/ap/altitude_setpoint", this,
726 &FGFCS::GetAPAltitudeSetPt,
727 &FGFCS::SetAPAltitudeSetPt,
730 PropertyManager->Tie("jsbsim/ap/heading_setpoint", this,
731 &FGFCS::GetAPHeadingSetPt,
732 &FGFCS::SetAPHeadingSetPt,
735 PropertyManager->Tie("jsbsim/ap/airspeed_setpoint", this,
736 &FGFCS::GetAPAirspeedSetPt,
737 &FGFCS::SetAPAirspeedSetPt,
740 PropertyManager->Tie("jsbsim/ap/acquire_attitude", this,
741 &FGFCS::GetAPAcquireAttitude,
742 &FGFCS::SetAPAcquireAttitude,
745 PropertyManager->Tie("jsbsim/ap/acquire_altitude", this,
746 &FGFCS::GetAPAcquireAltitude,
747 &FGFCS::SetAPAcquireAltitude,
750 PropertyManager->Tie("jsbsim/ap/acquire_heading", this,
751 &FGFCS::GetAPAcquireHeading,
752 &FGFCS::SetAPAcquireHeading,
755 PropertyManager->Tie("jsbsim/ap/acquire_airspeed", this,
756 &FGFCS::GetAPAcquireAirspeed,
757 &FGFCS::SetAPAcquireAirspeed,
760 PropertyManager->Tie("jsbsim/ap/attitude_hold", this,
761 &FGFCS::GetAPAttitudeHold,
762 &FGFCS::SetAPAttitudeHold,
765 PropertyManager->Tie("jsbsim/ap/altitude_hold", this,
766 &FGFCS::GetAPAltitudeHold,
767 &FGFCS::SetAPAltitudeHold,
770 PropertyManager->Tie("jsbsim/ap/heading_hold", this,
771 &FGFCS::GetAPHeadingHold,
772 &FGFCS::SetAPHeadingHold,
775 PropertyManager->Tie("jsbsim/ap/airspeed_hold", this,
776 &FGFCS::GetAPAirspeedHold,
777 &FGFCS::SetAPAirspeedHold,
780 PropertyManager->Tie("jsbsim/ap/wingslevel_hold", this,
781 &FGFCS::GetAPWingsLevelHold,
782 &FGFCS::SetAPWingsLevelHold,
786 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
788 void FGFCS::bindModel(void)
793 for (i=0; i<ThrottleCmd.size(); i++) {
794 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
795 PropertyManager->Tie( tmp,this,i,
796 &FGFCS::GetThrottleCmd,
797 &FGFCS::SetThrottleCmd,
799 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
800 PropertyManager->Tie( tmp,this,i,
801 &FGFCS::GetThrottlePos,
802 &FGFCS::SetThrottlePos,
804 if ( MixtureCmd.size() > i ) {
805 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
806 PropertyManager->Tie( tmp,this,i,
807 &FGFCS::GetMixtureCmd,
808 &FGFCS::SetMixtureCmd,
810 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
811 PropertyManager->Tie( tmp,this,i,
812 &FGFCS::GetMixturePos,
813 &FGFCS::SetMixturePos,
816 if ( PropAdvanceCmd.size() > i ) {
817 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
818 PropertyManager->Tie( tmp,this,i,
819 &FGFCS::GetPropAdvanceCmd,
820 &FGFCS::SetPropAdvanceCmd,
822 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
823 PropertyManager->Tie( tmp,this,i,
824 &FGFCS::GetPropAdvance,
825 &FGFCS::SetPropAdvance,
831 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833 void FGFCS::unbind(void)
835 PropertyManager->Untie("fcs/aileron-cmd-norm");
836 PropertyManager->Untie("fcs/elevator-cmd-norm");
837 PropertyManager->Untie("fcs/rudder-cmd-norm");
838 PropertyManager->Untie("fcs/flap-cmd-norm");
839 PropertyManager->Untie("fcs/speedbrake-cmd-norm");
840 PropertyManager->Untie("fcs/spoiler-cmd-norm");
841 PropertyManager->Untie("fcs/pitch-trim-cmd-norm");
842 PropertyManager->Untie("fcs/roll-trim-cmd-norm");
843 PropertyManager->Untie("fcs/yaw-trim-cmd-norm");
844 PropertyManager->Untie("gear/gear-cmd-norm");
845 PropertyManager->Untie("fcs/left-aileron-pos-rad");
846 PropertyManager->Untie("fcs/mag-left-aileron-pos-rad");
847 PropertyManager->Untie("fcs/left-aileron-pos-norm");
848 PropertyManager->Untie("fcs/right-aileron-pos-rad");
849 PropertyManager->Untie("fcs/mag-right-aileron-pos-rad");
850 PropertyManager->Untie("fcs/right-aileron-pos-norm");
851 PropertyManager->Untie("fcs/elevator-pos-rad");
852 PropertyManager->Untie("fcs/mag-elevator-pos-rad");
853 PropertyManager->Untie("fcs/elevator-pos-norm");
854 PropertyManager->Untie("fcs/rudder-pos-rad");
855 PropertyManager->Untie("fcs/mag-rudder-pos-rad");
856 PropertyManager->Untie("fcs/rudder-pos-norm");
857 PropertyManager->Untie("fcs/flap-pos-deg");
858 PropertyManager->Untie("fcs/flap-pos-norm");
859 PropertyManager->Untie("fcs/speedbrake-pos-rad");
860 PropertyManager->Untie("fcs/mag-speedbrake-pos-rad");
861 PropertyManager->Untie("fcs/speedbrake-pos-norm");
862 PropertyManager->Untie("fcs/spoiler-pos-rad");
863 PropertyManager->Untie("fcs/mag-spoiler-pos-rad");
864 PropertyManager->Untie("fcs/spoiler-pos-norm");
865 PropertyManager->Untie("gear/gear-pos-norm");
866 PropertyManager->Untie("jsbsim/ap/elevator_cmd");
867 PropertyManager->Untie("jsbsim/ap/aileron_cmd");
868 PropertyManager->Untie("jsbsim/ap/rudder_cmd");
869 PropertyManager->Untie("jsbsim/ap/throttle_cmd");
870 PropertyManager->Untie("jsbsim/ap/attitude_setpoint");
871 PropertyManager->Untie("jsbsim/ap/altitude_setpoint");
872 PropertyManager->Untie("jsbsim/ap/heading_setpoint");
873 PropertyManager->Untie("jsbsim/ap/airspeed_setpoint");
874 PropertyManager->Untie("jsbsim/ap/acquire_attitude");
875 PropertyManager->Untie("jsbsim/ap/acquire_altitude");
876 PropertyManager->Untie("jsbsim/ap/acquire_heading");
877 PropertyManager->Untie("jsbsim/ap/acquire_airspeed");
878 PropertyManager->Untie("jsbsim/ap/attitude_hold");
879 PropertyManager->Untie("jsbsim/ap/altitude_hold");
880 PropertyManager->Untie("jsbsim/ap/heading_hold");
881 PropertyManager->Untie("jsbsim/ap/airspeed_hold");
882 PropertyManager->Untie("jsbsim/ap/wingslevel_hold");
885 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
886 // The bitmasked value choices are as follows:
887 // unset: In this case (the default) JSBSim would only print
888 // out the normally expected messages, essentially echoing
889 // the config files as they are read. If the environment
890 // variable is not set, debug_lvl is set to 1 internally
891 // 0: This requests JSBSim not to output any messages
893 // 1: This value explicity requests the normal JSBSim
895 // 2: This value asks for a message to be printed out when
896 // a class is instantiated
897 // 4: When this value is set, a message is displayed when a
898 // FGModel object executes its Run() method
899 // 8: When this value is set, various runtime state variables
900 // are printed out periodically
901 // 16: When set various parameters are sanity checked and
902 // a message is printed out when they go out of bounds
904 void FGFCS::Debug(int from)
906 if (debug_lvl <= 0) return;
908 if (debug_lvl & 1) { // Standard console startup message output
909 if (from == 0) { // Constructor
913 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
914 if (from == 0) cout << "Instantiated: FGFCS" << endl;
915 if (from == 1) cout << "Destroyed: FGFCS" << endl;
917 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
919 if (debug_lvl & 8 ) { // Runtime state variables
921 if (debug_lvl & 16) { // Sanity checking
923 if (debug_lvl & 64) {
924 if (from == 0) { // Constructor
925 cout << IdSrc << endl;
926 cout << IdHdr << endl;