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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41 #include "FGFDMExec.h"
42 #include "FGPropertyManager.h"
44 #include "filtersjb/FGFilter.h"
45 #include "filtersjb/FGDeadBand.h"
46 #include "filtersjb/FGGain.h"
47 #include "filtersjb/FGGradient.h"
48 #include "filtersjb/FGSwitch.h"
49 #include "filtersjb/FGSummer.h"
50 #include "filtersjb/FGKinemat.h"
54 static const char *IdSrc = "$Id$";
55 static const char *IdHdr = ID_FCS;
57 #if defined(WIN32) && !defined(__CYGWIN__)
58 #define snprintf _snprintf
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
70 DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0.0;
71 AP_DaCmd = AP_DeCmd = AP_DrCmd = AP_ThrottleCmd = 0.0;
72 PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
73 GearCmd = GearPos = 1; // default to gear down
74 LeftBrake = RightBrake = CenterBrake = 0.0;
75 APAttitudeSetPt = APAltitudeSetPt = APHeadingSetPt = APAirspeedSetPt = 0.0;
79 for (i=0;i<=NForms;i++) {
80 DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
81 DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
84 for (i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
88 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 unbind( PropertyManager->GetNode("fcs") );
93 unbind( PropertyManager->GetNode("ap") );
94 PropertyManager->Untie( "gear/gear-cmd-norm" );
95 PropertyManager->Untie( "gear/gear-pos-norm" );
101 PropAdvanceCmd.clear();
107 for (i=0;i<APComponents.size();i++) delete APComponents[i];
108 for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
113 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115 bool FGFCS::Run(void)
119 if (FGModel::Run()) return true; // fast exit if nothing to do
121 // Set the default engine commands
122 for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
123 for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
124 for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
126 // Set the default steering angle
127 for (i=0; i<SteerPosDeg.size(); i++) {
128 FGLGear* gear = GroundReactions->GetGearUnit(i);
129 SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() );
132 for (i=0; i<APComponents.size(); i++) APComponents[i]->Run(); // cycle AP components
133 for (i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); // cycle FCS components
135 if (DoNormalize) Normalize();
140 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 void FGFCS::SetThrottleCmd(int engineNum, double setting)
146 if (engineNum < (int)ThrottlePos.size()) {
148 for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
150 ThrottleCmd[engineNum] = setting;
153 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
154 << " engines exist, but attempted throttle command is for engine "
155 << engineNum << endl;
159 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 void FGFCS::SetThrottlePos(int engineNum, double setting)
165 if (engineNum < (int)ThrottlePos.size()) {
167 for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
169 ThrottlePos[engineNum] = setting;
172 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
173 << " engines exist, but attempted throttle position setting is for engine "
174 << engineNum << endl;
178 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 double FGFCS::GetThrottleCmd(int engineNum) const
182 if (engineNum < (int)ThrottlePos.size()) {
184 cerr << "Cannot get throttle value for ALL engines" << endl;
186 return ThrottleCmd[engineNum];
189 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
190 << " engines exist, but throttle setting for engine " << engineNum
191 << " is selected" << endl;
196 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 double FGFCS::GetThrottlePos(int engineNum) const
200 if (engineNum < (int)ThrottlePos.size()) {
202 cerr << "Cannot get throttle value for ALL engines" << endl;
204 return ThrottlePos[engineNum];
207 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
208 << " engines exist, but attempted throttle position setting is for engine "
209 << engineNum << endl;
214 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216 void FGFCS::SetMixtureCmd(int engineNum, double setting)
220 if (engineNum < (int)ThrottlePos.size()) {
222 for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
224 MixtureCmd[engineNum] = setting;
229 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 void FGFCS::SetMixturePos(int engineNum, double setting)
235 if (engineNum < (int)ThrottlePos.size()) {
237 for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
239 MixturePos[engineNum] = setting;
244 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
250 if (engineNum < (int)ThrottlePos.size()) {
252 for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
254 PropAdvanceCmd[engineNum] = setting;
259 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
261 void FGFCS::SetPropAdvance(int engineNum, double setting)
265 if (engineNum < (int)ThrottlePos.size()) {
267 for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
269 PropAdvance[engineNum] = setting;
274 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276 bool FGFCS::Load(FGConfigFile* AC_cfg)
278 string token, delimiter;
279 string name, file, fname;
281 vector <FGFCSComponent*> *Components;
282 FGConfigFile *FCS_cfg;
285 // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
286 // file or in a separate file. Set up the config file class as appropriate.
288 delimiter = AC_cfg->GetValue();
289 name = AC_cfg->GetValue("NAME");
290 fname = AC_cfg->GetValue("FILE");
292 if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
294 cout << " Automatic Control Surface Normalization Disabled" << endl;
298 // file = "control/" + fname + ".xml";
299 file = FDMExec->GetAircraftPath() + "/" + FDMExec->GetModelName() + "/" + fname + ".xml";
301 // file = "control;" + fname + ".xml";
302 file = FDMExec->GetAircraftPath() + ";" + FDMExec->GetModelName() + ";" + fname + ".xml";
308 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
310 FCS_cfg = new FGConfigFile(file);
311 if (!FCS_cfg->IsOpen()) {
312 cerr << "Could not open " << delimiter << " file: " << file << endl;
315 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
316 // file object pointer
320 AC_cfg->GetNextConfigLine();
323 if (delimiter == "AUTOPILOT") {
324 Components = &APComponents;
325 Name = "Autopilot: " + name;
326 } else if (delimiter == "FLIGHT_CONTROL") {
327 Components = &FCSComponents;
328 Name = "FCS: " + name;
330 cerr << endl << "Unknown FCS delimiter" << endl << endl;
333 if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
335 while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
336 if (token == "COMPONENT") {
337 token = AC_cfg->GetValue("TYPE");
338 if (debug_lvl > 0) cout << endl << " Loading Component \""
339 << AC_cfg->GetValue("NAME")
340 << "\" of type: " << token << endl;
341 if ((token == "LAG_FILTER") ||
342 (token == "LEAD_LAG_FILTER") ||
343 (token == "SECOND_ORDER_FILTER") ||
344 (token == "WASHOUT_FILTER") ||
345 (token == "INTEGRATOR") ) {
346 Components->push_back(new FGFilter(this, AC_cfg));
347 } else if ((token == "PURE_GAIN") ||
348 (token == "SCHEDULED_GAIN") ||
349 (token == "AEROSURFACE_SCALE") ) {
351 Components->push_back(new FGGain(this, AC_cfg));
353 } else if (token == "SUMMER") {
354 Components->push_back(new FGSummer(this, AC_cfg));
355 } else if (token == "DEADBAND") {
356 Components->push_back(new FGDeadBand(this, AC_cfg));
357 } else if (token == "GRADIENT") {
358 Components->push_back(new FGGradient(this, AC_cfg));
359 } else if (token == "SWITCH") {
360 Components->push_back(new FGSwitch(this, AC_cfg));
361 } else if (token == "KINEMAT") {
362 Components->push_back(new FGKinemat(this, AC_cfg));
364 cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
367 if (AC_cfg->GetNextConfigLine() == "EOF") break;
371 //collect information for normalizing control surfaces
374 for (i=0; i<Components->size(); i++) {
376 if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE"
377 || ((*Components)[i])->GetType() == "KINEMAT")
378 && ((*Components)[i])->GetOutputNode() ) {
379 nodeName = ((*Components)[i])->GetOutputNode()->GetName();
380 if ( nodeName == "elevator-pos-rad" ) {
382 } else if ( nodeName == "left-aileron-pos-rad"
383 || nodeName == "aileron-pos-rad" ) {
385 } else if ( nodeName == "right-aileron-pos-rad" ) {
387 } else if ( nodeName == "rudder-pos-rad" ) {
389 } else if ( nodeName == "speedbrake-pos-rad" ) {
391 } else if ( nodeName == "spoiler-pos-rad" ) {
393 } else if ( nodeName == "flap-pos-deg" ) {
399 if (delimiter == "FLIGHT_CONTROL") bindModel();
404 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
409 case FGLGear::bgLeft:
411 case FGLGear::bgRight:
413 case FGLGear::bgCenter:
416 cerr << "GetBrake asked to return a bogus brake value" << endl;
421 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
423 string FGFCS::GetComponentStrings(void)
426 string CompStrings = "";
427 bool firstime = true;
429 for (comp = 0; comp < FCSComponents.size(); comp++) {
430 if (firstime) firstime = false;
431 else CompStrings += ", ";
433 CompStrings += FCSComponents[comp]->GetName();
436 for (comp = 0; comp < APComponents.size(); comp++)
439 CompStrings += APComponents[comp]->GetName();
445 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447 string FGFCS::GetComponentValues(void)
450 string CompValues = "";
452 bool firstime = true;
454 for (comp = 0; comp < FCSComponents.size(); comp++) {
455 if (firstime) firstime = false;
456 else CompValues += ", ";
458 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
459 CompValues += string(buffer);
462 for (comp = 0; comp < APComponents.size(); comp++) {
463 sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
464 CompValues += string(buffer);
470 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
472 void FGFCS::AddThrottle(void)
474 ThrottleCmd.push_back(0.0);
475 ThrottlePos.push_back(0.0);
476 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
477 MixturePos.push_back(0.0);
478 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
479 PropAdvance.push_back(0.0);
482 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484 void FGFCS::AddGear(void)
486 SteerPosDeg.push_back(0.0);
489 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
491 void FGFCS::Normalize(void) {
493 //not all of these are guaranteed to be defined for every model
494 //those that are have an index >=0 in the ToNormalize array
495 //ToNormalize is filled in Load()
497 if ( ToNormalize[iDe] > -1 ) {
498 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
501 if ( ToNormalize[iDaL] > -1 ) {
502 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
505 if ( ToNormalize[iDaR] > -1 ) {
506 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
509 if ( ToNormalize[iDr] > -1 ) {
510 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
513 if ( ToNormalize[iDsb] > -1 ) {
514 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
517 if ( ToNormalize[iDsp] > -1 ) {
518 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
521 if ( ToNormalize[iDf] > -1 ) {
522 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
525 DePos[ofMag] = fabs(DePos[ofRad]);
526 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
527 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
528 DrPos[ofMag] = fabs(DrPos[ofRad]);
529 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
530 DspPos[ofMag] = fabs(DspPos[ofRad]);
531 DfPos[ofMag] = fabs(DfPos[ofRad]);
535 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
537 void FGFCS::bind(void)
539 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
543 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
547 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
551 PropertyManager->Tie("fcs/steer-cmd-norm", this,
555 PropertyManager->Tie("fcs/flap-cmd-norm", this,
559 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
563 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
567 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
568 &FGFCS::GetPitchTrimCmd,
569 &FGFCS::SetPitchTrimCmd,
571 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
572 &FGFCS::GetRollTrimCmd,
573 &FGFCS::SetRollTrimCmd,
575 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
576 &FGFCS::GetYawTrimCmd,
577 &FGFCS::SetYawTrimCmd,
579 PropertyManager->Tie("gear/gear-cmd-norm", this,
584 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
588 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
592 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
597 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
601 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
605 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
610 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
614 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
618 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
623 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
627 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
631 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
636 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
640 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
645 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
649 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
653 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
658 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
662 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
666 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
671 PropertyManager->Tie("gear/gear-pos-norm", this,
676 PropertyManager->Tie("ap/elevator_cmd", this,
681 PropertyManager->Tie("ap/aileron_cmd", this,
686 PropertyManager->Tie("ap/rudder_cmd", this,
691 PropertyManager->Tie("ap/throttle_cmd", this,
692 &FGFCS::GetAPThrottleCmd,
693 &FGFCS::SetAPThrottleCmd,
696 PropertyManager->Tie("ap/attitude_setpoint", this,
697 &FGFCS::GetAPAttitudeSetPt,
698 &FGFCS::SetAPAttitudeSetPt,
701 PropertyManager->Tie("ap/altitude_setpoint", this,
702 &FGFCS::GetAPAltitudeSetPt,
703 &FGFCS::SetAPAltitudeSetPt,
706 PropertyManager->Tie("ap/heading_setpoint", this,
707 &FGFCS::GetAPHeadingSetPt,
708 &FGFCS::SetAPHeadingSetPt,
711 PropertyManager->Tie("ap/airspeed_setpoint", this,
712 &FGFCS::GetAPAirspeedSetPt,
713 &FGFCS::SetAPAirspeedSetPt,
716 PropertyManager->Tie("ap/acquire_attitude", this,
717 &FGFCS::GetAPAcquireAttitude,
718 &FGFCS::SetAPAcquireAttitude,
721 PropertyManager->Tie("ap/acquire_altitude", this,
722 &FGFCS::GetAPAcquireAltitude,
723 &FGFCS::SetAPAcquireAltitude,
726 PropertyManager->Tie("ap/acquire_heading", this,
727 &FGFCS::GetAPAcquireHeading,
728 &FGFCS::SetAPAcquireHeading,
731 PropertyManager->Tie("ap/acquire_airspeed", this,
732 &FGFCS::GetAPAcquireAirspeed,
733 &FGFCS::SetAPAcquireAirspeed,
736 PropertyManager->Tie("ap/attitude_hold", this,
737 &FGFCS::GetAPAttitudeHold,
738 &FGFCS::SetAPAttitudeHold,
741 PropertyManager->Tie("ap/altitude_hold", this,
742 &FGFCS::GetAPAltitudeHold,
743 &FGFCS::SetAPAltitudeHold,
746 PropertyManager->Tie("ap/heading_hold", this,
747 &FGFCS::GetAPHeadingHold,
748 &FGFCS::SetAPHeadingHold,
751 PropertyManager->Tie("ap/airspeed_hold", this,
752 &FGFCS::GetAPAirspeedHold,
753 &FGFCS::SetAPAirspeedHold,
756 PropertyManager->Tie("ap/wingslevel_hold", this,
757 &FGFCS::GetAPWingsLevelHold,
758 &FGFCS::SetAPWingsLevelHold,
762 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
764 void FGFCS::bindModel(void)
769 for (i=0; i<ThrottleCmd.size(); i++) {
770 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
771 PropertyManager->Tie( tmp,this,i,
772 &FGFCS::GetThrottleCmd,
773 &FGFCS::SetThrottleCmd,
775 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
776 PropertyManager->Tie( tmp,this,i,
777 &FGFCS::GetThrottlePos,
778 &FGFCS::SetThrottlePos,
780 if ( MixtureCmd.size() > i ) {
781 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
782 PropertyManager->Tie( tmp,this,i,
783 &FGFCS::GetMixtureCmd,
784 &FGFCS::SetMixtureCmd,
786 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
787 PropertyManager->Tie( tmp,this,i,
788 &FGFCS::GetMixturePos,
789 &FGFCS::SetMixturePos,
792 if ( PropAdvanceCmd.size() > i ) {
793 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
794 PropertyManager->Tie( tmp,this,i,
795 &FGFCS::GetPropAdvanceCmd,
796 &FGFCS::SetPropAdvanceCmd,
798 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
799 PropertyManager->Tie( tmp,this,i,
800 &FGFCS::GetPropAdvance,
801 &FGFCS::SetPropAdvance,
806 for (i=0; i<SteerPosDeg.size(); i++) {
807 if (GroundReactions->GetGearUnit(i)->GetSteerable()) {
808 snprintf(tmp,80,"fcs/steer-pos-deg[%u]",i);
809 PropertyManager->Tie( tmp, this, i,
810 &FGFCS::GetSteerPosDeg,
811 &FGFCS::SetSteerPosDeg,
817 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
819 void FGFCS::unbind(FGPropertyManager *node)
821 int N = node->nChildren();
822 for(int i=0;i<N;i++) {
823 if(node->getChild(i)->nChildren() ) {
824 unbind( (FGPropertyManager*)node->getChild(i) );
825 } else if( node->getChild(i)->isTied() ) {
826 node->getChild(i)->untie();
831 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 // The bitmasked value choices are as follows:
833 // unset: In this case (the default) JSBSim would only print
834 // out the normally expected messages, essentially echoing
835 // the config files as they are read. If the environment
836 // variable is not set, debug_lvl is set to 1 internally
837 // 0: This requests JSBSim not to output any messages
839 // 1: This value explicity requests the normal JSBSim
841 // 2: This value asks for a message to be printed out when
842 // a class is instantiated
843 // 4: When this value is set, a message is displayed when a
844 // FGModel object executes its Run() method
845 // 8: When this value is set, various runtime state variables
846 // are printed out periodically
847 // 16: When set various parameters are sanity checked and
848 // a message is printed out when they go out of bounds
850 void FGFCS::Debug(int from)
852 if (debug_lvl <= 0) return;
854 if (debug_lvl & 1) { // Standard console startup message output
855 if (from == 0) { // Constructor
859 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
860 if (from == 0) cout << "Instantiated: FGFCS" << endl;
861 if (from == 1) cout << "Destroyed: FGFCS" << endl;
863 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
865 if (debug_lvl & 8 ) { // Runtime state variables
867 if (debug_lvl & 16) { // Sanity checking
869 if (debug_lvl & 64) {
870 if (from == 0) { // Constructor
871 cout << IdSrc << endl;
872 cout << IdHdr << endl;