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;
83 APAttitudeSetPt = APAltitudeSetPt = APHeadingSetPt = APAirspeedSetPt = 0.0;
89 for (i=0;i<=NForms;i++) {
90 DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
91 DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
94 for (i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
98 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 unbind( PropertyManager->GetNode("fcs") );
103 unbind( PropertyManager->GetNode("ap") );
104 PropertyManager->Untie( "gear/gear-cmd-norm" );
105 PropertyManager->Untie( "gear/gear-pos-norm" );
111 PropAdvanceCmd.clear();
117 for (i=0;i<APComponents.size();i++) delete APComponents[i];
118 for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
123 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 bool FGFCS::Run(void)
129 if (!FGModel::Run()) {
130 for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
131 for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
132 for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
133 for (i=0; i<APComponents.size(); i++) {
135 APComponents[i]->Run();
138 for (i=0; i<FCSComponents.size(); i++) {
140 FCSComponents[i]->Run();
143 if (DoNormalize) Normalize();
151 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153 void FGFCS::SetThrottleCmd(int engineNum, double setting)
157 if (engineNum < (int)ThrottlePos.size()) {
159 for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
161 ThrottleCmd[engineNum] = setting;
164 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
165 << " engines exist, but attempted throttle command is for engine "
166 << engineNum << endl;
170 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172 void FGFCS::SetThrottlePos(int engineNum, double setting)
176 if (engineNum < (int)ThrottlePos.size()) {
178 for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
180 ThrottlePos[engineNum] = setting;
183 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
184 << " engines exist, but attempted throttle position setting is for engine "
185 << engineNum << endl;
189 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 double FGFCS::GetThrottleCmd(int engineNum) const
193 if (engineNum < (int)ThrottlePos.size()) {
195 cerr << "Cannot get throttle value for ALL engines" << endl;
197 return ThrottleCmd[engineNum];
200 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
201 << " engines exist, but throttle setting for engine " << engineNum
202 << " is selected" << endl;
207 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 double FGFCS::GetThrottlePos(int engineNum) const
211 if (engineNum < (int)ThrottlePos.size()) {
213 cerr << "Cannot get throttle value for ALL engines" << endl;
215 return ThrottlePos[engineNum];
218 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
219 << " engines exist, but attempted throttle position setting is for engine "
220 << engineNum << endl;
225 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
227 void FGFCS::SetMixtureCmd(int engineNum, double setting)
231 if (engineNum < (int)ThrottlePos.size()) {
233 for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
235 MixtureCmd[engineNum] = setting;
240 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 void FGFCS::SetMixturePos(int engineNum, double setting)
246 if (engineNum < (int)ThrottlePos.size()) {
248 for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
250 MixturePos[engineNum] = setting;
255 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
261 if (engineNum < (int)ThrottlePos.size()) {
263 for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
265 PropAdvanceCmd[engineNum] = setting;
270 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272 void FGFCS::SetPropAdvance(int engineNum, double setting)
276 if (engineNum < (int)ThrottlePos.size()) {
278 for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
280 PropAdvance[engineNum] = setting;
285 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 bool FGFCS::Load(FGConfigFile* AC_cfg)
289 string token, delimiter;
290 string name, file, fname;
292 vector <FGFCSComponent*> *Components;
293 FGConfigFile *FCS_cfg;
296 // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
297 // file or in a separate file. Set up the config file class as appropriate.
299 delimiter = AC_cfg->GetValue();
300 name = AC_cfg->GetValue("NAME");
301 fname = AC_cfg->GetValue("FILE");
303 if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
305 cout << " Automatic Control Surface Normalization Disabled" << endl;
309 file = "control/" + fname + ".xml";
311 file = "control;" + fname + ".xml";
317 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
319 FCS_cfg = new FGConfigFile(file);
320 if (!FCS_cfg->IsOpen()) {
321 cerr << "Could not open " << delimiter << " file: " << file << endl;
324 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
325 // file object pointer
329 AC_cfg->GetNextConfigLine();
332 if (delimiter == "AUTOPILOT") {
333 Components = &APComponents;
335 Name = "Autopilot: " + name;
336 } else if (delimiter == "FLIGHT_CONTROL") {
337 Components = &FCSComponents;
339 Name = "FCS: " + name;
341 cerr << endl << "Unknown FCS delimiter" << endl << endl;
344 if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
346 while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
347 if (token == "COMPONENT") {
348 token = AC_cfg->GetValue("TYPE");
349 if (debug_lvl > 0) cout << endl << " Loading Component \""
350 << AC_cfg->GetValue("NAME")
351 << "\" of type: " << token << endl;
352 if ((token == "LAG_FILTER") ||
353 (token == "LEAD_LAG_FILTER") ||
354 (token == "SECOND_ORDER_FILTER") ||
355 (token == "WASHOUT_FILTER") ||
356 (token == "INTEGRATOR") ) {
357 Components->push_back(new FGFilter(this, AC_cfg));
358 } else if ((token == "PURE_GAIN") ||
359 (token == "SCHEDULED_GAIN") ||
360 (token == "AEROSURFACE_SCALE") ) {
362 Components->push_back(new FGGain(this, AC_cfg));
364 } else if (token == "SUMMER") {
365 Components->push_back(new FGSummer(this, AC_cfg));
366 } else if (token == "DEADBAND") {
367 Components->push_back(new FGDeadBand(this, AC_cfg));
368 } else if (token == "GRADIENT") {
369 Components->push_back(new FGGradient(this, AC_cfg));
370 } else if (token == "SWITCH") {
371 Components->push_back(new FGSwitch(this, AC_cfg));
372 } else if (token == "KINEMAT") {
373 Components->push_back(new FGKinemat(this, AC_cfg));
375 cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
378 if (AC_cfg->GetNextConfigLine() == "EOF") break;
382 //collect information for normalizing control surfaces
385 for (i=0; i<Components->size(); i++) {
387 if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE"
388 || ((*Components)[i])->GetType() == "KINEMAT")
389 && ((*Components)[i])->GetOutputNode() ) {
390 nodeName = ((*Components)[i])->GetOutputNode()->GetName();
391 if ( nodeName == "elevator-pos-rad" ) {
393 } else if ( nodeName == "left-aileron-pos-rad"
394 || nodeName == "aileron-pos-rad" ) {
396 } else if ( nodeName == "right-aileron-pos-rad" ) {
398 } else if ( nodeName == "rudder-pos-rad" ) {
400 } else if ( nodeName == "speedbrake-pos-rad" ) {
402 } else if ( nodeName == "spoiler-pos-rad" ) {
404 } else if ( nodeName == "flap-pos-deg" ) {
410 if (delimiter == "FLIGHT_CONTROL") bindModel();
417 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419 double FGFCS::GetComponentOutput(int idx)
423 return FCSComponents[idx]->GetOutput();
425 return APComponents[idx]->GetOutput();
427 cerr << "Unknown FCS mode" << endl;
433 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
435 string FGFCS::GetComponentName(int idx)
439 return FCSComponents[idx]->GetName();
441 return APComponents[idx]->GetName();
443 cerr << "Unknown FCS mode" << endl;
449 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
454 case FGLGear::bgLeft:
456 case FGLGear::bgRight:
458 case FGLGear::bgCenter:
461 cerr << "GetBrake asked to return a bogus brake value" << endl;
466 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
468 string FGFCS::GetComponentStrings(void)
471 string CompStrings = "";
472 bool firstime = true;
474 for (comp = 0; comp < FCSComponents.size(); comp++) {
475 if (firstime) firstime = false;
476 else CompStrings += ", ";
478 CompStrings += FCSComponents[comp]->GetName();
481 for (comp = 0; comp < APComponents.size(); comp++)
484 CompStrings += APComponents[comp]->GetName();
490 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
492 string FGFCS::GetComponentValues(void)
495 string CompValues = "";
497 bool firstime = true;
499 for (comp = 0; comp < FCSComponents.size(); comp++) {
500 if (firstime) firstime = false;
501 else CompValues += ", ";
503 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
504 CompValues += string(buffer);
507 for (comp = 0; comp < APComponents.size(); comp++) {
508 sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
509 CompValues += string(buffer);
515 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
517 void FGFCS::AddThrottle(void)
519 ThrottleCmd.push_back(0.0);
520 ThrottlePos.push_back(0.0);
521 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
522 MixturePos.push_back(0.0);
523 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
524 PropAdvance.push_back(0.0);
527 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529 void FGFCS::Normalize(void) {
531 //not all of these are guaranteed to be defined for every model
532 //those that are have an index >=0 in the ToNormalize array
533 //ToNormalize is filled in Load()
535 if ( ToNormalize[iDe] > -1 ) {
536 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
539 if ( ToNormalize[iDaL] > -1 ) {
540 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
543 if ( ToNormalize[iDaR] > -1 ) {
544 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
547 if ( ToNormalize[iDr] > -1 ) {
548 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
551 if ( ToNormalize[iDsb] > -1 ) {
552 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
555 if ( ToNormalize[iDsp] > -1 ) {
556 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
559 if ( ToNormalize[iDf] > -1 ) {
560 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
563 DePos[ofMag] = fabs(DePos[ofRad]);
564 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
565 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
566 DrPos[ofMag] = fabs(DrPos[ofRad]);
567 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
568 DspPos[ofMag] = fabs(DspPos[ofRad]);
569 DfPos[ofMag] = fabs(DfPos[ofRad]);
573 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
575 void FGFCS::bind(void)
577 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
581 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
585 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
589 PropertyManager->Tie("fcs/flap-cmd-norm", this,
593 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
597 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
601 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
602 &FGFCS::GetPitchTrimCmd,
603 &FGFCS::SetPitchTrimCmd,
605 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
606 &FGFCS::GetRollTrimCmd,
607 &FGFCS::SetRollTrimCmd,
609 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
610 &FGFCS::GetYawTrimCmd,
611 &FGFCS::SetYawTrimCmd,
613 PropertyManager->Tie("gear/gear-cmd-norm", this,
618 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
622 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
626 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
631 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
635 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
639 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
644 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
648 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
652 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
657 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
661 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
665 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
670 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
674 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
679 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
683 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
687 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
692 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
696 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
700 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
705 PropertyManager->Tie("gear/gear-pos-norm", this,
710 PropertyManager->Tie("ap/elevator_cmd", this,
715 PropertyManager->Tie("ap/aileron_cmd", this,
720 PropertyManager->Tie("ap/rudder_cmd", this,
725 PropertyManager->Tie("ap/throttle_cmd", this,
726 &FGFCS::GetAPThrottleCmd,
727 &FGFCS::SetAPThrottleCmd,
730 PropertyManager->Tie("ap/attitude_setpoint", this,
731 &FGFCS::GetAPAttitudeSetPt,
732 &FGFCS::SetAPAttitudeSetPt,
735 PropertyManager->Tie("ap/altitude_setpoint", this,
736 &FGFCS::GetAPAltitudeSetPt,
737 &FGFCS::SetAPAltitudeSetPt,
740 PropertyManager->Tie("ap/heading_setpoint", this,
741 &FGFCS::GetAPHeadingSetPt,
742 &FGFCS::SetAPHeadingSetPt,
745 PropertyManager->Tie("ap/airspeed_setpoint", this,
746 &FGFCS::GetAPAirspeedSetPt,
747 &FGFCS::SetAPAirspeedSetPt,
750 PropertyManager->Tie("ap/acquire_attitude", this,
751 &FGFCS::GetAPAcquireAttitude,
752 &FGFCS::SetAPAcquireAttitude,
755 PropertyManager->Tie("ap/acquire_altitude", this,
756 &FGFCS::GetAPAcquireAltitude,
757 &FGFCS::SetAPAcquireAltitude,
760 PropertyManager->Tie("ap/acquire_heading", this,
761 &FGFCS::GetAPAcquireHeading,
762 &FGFCS::SetAPAcquireHeading,
765 PropertyManager->Tie("ap/acquire_airspeed", this,
766 &FGFCS::GetAPAcquireAirspeed,
767 &FGFCS::SetAPAcquireAirspeed,
770 PropertyManager->Tie("ap/attitude_hold", this,
771 &FGFCS::GetAPAttitudeHold,
772 &FGFCS::SetAPAttitudeHold,
775 PropertyManager->Tie("ap/altitude_hold", this,
776 &FGFCS::GetAPAltitudeHold,
777 &FGFCS::SetAPAltitudeHold,
780 PropertyManager->Tie("ap/heading_hold", this,
781 &FGFCS::GetAPHeadingHold,
782 &FGFCS::SetAPHeadingHold,
785 PropertyManager->Tie("ap/airspeed_hold", this,
786 &FGFCS::GetAPAirspeedHold,
787 &FGFCS::SetAPAirspeedHold,
790 PropertyManager->Tie("ap/wingslevel_hold", this,
791 &FGFCS::GetAPWingsLevelHold,
792 &FGFCS::SetAPWingsLevelHold,
796 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798 void FGFCS::bindModel(void)
804 for (i=0; i<ThrottleCmd.size(); i++) {
805 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
806 PropertyManager->Tie( tmp,this,i,
807 &FGFCS::GetThrottleCmd,
808 &FGFCS::SetThrottleCmd,
810 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
811 PropertyManager->Tie( tmp,this,i,
812 &FGFCS::GetThrottlePos,
813 &FGFCS::SetThrottlePos,
815 if ( MixtureCmd.size() > i ) {
816 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
817 PropertyManager->Tie( tmp,this,i,
818 &FGFCS::GetMixtureCmd,
819 &FGFCS::SetMixtureCmd,
821 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
822 PropertyManager->Tie( tmp,this,i,
823 &FGFCS::GetMixturePos,
824 &FGFCS::SetMixturePos,
827 if ( PropAdvanceCmd.size() > i ) {
828 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
829 PropertyManager->Tie( tmp,this,i,
830 &FGFCS::GetPropAdvanceCmd,
831 &FGFCS::SetPropAdvanceCmd,
833 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
834 PropertyManager->Tie( tmp,this,i,
835 &FGFCS::GetPropAdvance,
836 &FGFCS::SetPropAdvance,
842 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
844 void FGFCS::unbind(FGPropertyManager *node)
846 int N = node->nChildren();
847 for(int i=0;i<N;i++) {
848 if(node->getChild(i)->nChildren() ) {
849 unbind( (FGPropertyManager*)node->getChild(i) );
850 } else if( node->getChild(i)->isTied() ) {
851 node->getChild(i)->untie();
856 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
857 // The bitmasked value choices are as follows:
858 // unset: In this case (the default) JSBSim would only print
859 // out the normally expected messages, essentially echoing
860 // the config files as they are read. If the environment
861 // variable is not set, debug_lvl is set to 1 internally
862 // 0: This requests JSBSim not to output any messages
864 // 1: This value explicity requests the normal JSBSim
866 // 2: This value asks for a message to be printed out when
867 // a class is instantiated
868 // 4: When this value is set, a message is displayed when a
869 // FGModel object executes its Run() method
870 // 8: When this value is set, various runtime state variables
871 // are printed out periodically
872 // 16: When set various parameters are sanity checked and
873 // a message is printed out when they go out of bounds
875 void FGFCS::Debug(int from)
877 if (debug_lvl <= 0) return;
879 if (debug_lvl & 1) { // Standard console startup message output
880 if (from == 0) { // Constructor
884 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
885 if (from == 0) cout << "Instantiated: FGFCS" << endl;
886 if (from == 1) cout << "Destroyed: FGFCS" << endl;
888 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
890 if (debug_lvl & 8 ) { // Runtime state variables
892 if (debug_lvl & 16) { // Sanity checking
894 if (debug_lvl & 64) {
895 if (from == 0) { // Constructor
896 cout << IdSrc << endl;
897 cout << IdHdr << endl;