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();
106 for (i=0;i<APComponents.size();i++) delete APComponents[i];
107 for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
112 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 bool FGFCS::Run(void)
118 if (FGModel::Run()) return true; // fast exit if nothing to do
120 for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
121 for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
122 for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
124 for (i=0; i<APComponents.size(); i++) APComponents[i]->Run(); // cycle AP components
125 for (i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); // cycle FCS components
127 if (DoNormalize) Normalize();
132 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 void FGFCS::SetThrottleCmd(int engineNum, double setting)
138 if (engineNum < (int)ThrottlePos.size()) {
140 for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
142 ThrottleCmd[engineNum] = setting;
145 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
146 << " engines exist, but attempted throttle command is for engine "
147 << engineNum << endl;
151 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153 void FGFCS::SetThrottlePos(int engineNum, double setting)
157 if (engineNum < (int)ThrottlePos.size()) {
159 for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
161 ThrottlePos[engineNum] = setting;
164 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
165 << " engines exist, but attempted throttle position setting is for engine "
166 << engineNum << endl;
170 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172 double FGFCS::GetThrottleCmd(int engineNum) const
174 if (engineNum < (int)ThrottlePos.size()) {
176 cerr << "Cannot get throttle value for ALL engines" << endl;
178 return ThrottleCmd[engineNum];
181 cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
182 << " engines exist, but throttle setting for engine " << engineNum
183 << " is selected" << endl;
188 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 double FGFCS::GetThrottlePos(int engineNum) const
192 if (engineNum < (int)ThrottlePos.size()) {
194 cerr << "Cannot get throttle value for ALL engines" << endl;
196 return ThrottlePos[engineNum];
199 cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
200 << " engines exist, but attempted throttle position setting is for engine "
201 << engineNum << endl;
206 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 void FGFCS::SetMixtureCmd(int engineNum, double setting)
212 if (engineNum < (int)ThrottlePos.size()) {
214 for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
216 MixtureCmd[engineNum] = setting;
221 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 void FGFCS::SetMixturePos(int engineNum, double setting)
227 if (engineNum < (int)ThrottlePos.size()) {
229 for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
231 MixturePos[engineNum] = setting;
236 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
242 if (engineNum < (int)ThrottlePos.size()) {
244 for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
246 PropAdvanceCmd[engineNum] = setting;
251 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 void FGFCS::SetPropAdvance(int engineNum, double setting)
257 if (engineNum < (int)ThrottlePos.size()) {
259 for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
261 PropAdvance[engineNum] = setting;
266 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
268 bool FGFCS::Load(FGConfigFile* AC_cfg)
270 string token, delimiter;
271 string name, file, fname;
273 vector <FGFCSComponent*> *Components;
274 FGConfigFile *FCS_cfg;
277 // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
278 // file or in a separate file. Set up the config file class as appropriate.
280 delimiter = AC_cfg->GetValue();
281 name = AC_cfg->GetValue("NAME");
282 fname = AC_cfg->GetValue("FILE");
284 if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
286 cout << " Automatic Control Surface Normalization Disabled" << endl;
290 // file = "control/" + fname + ".xml";
291 file = FDMExec->GetAircraftPath() + "/" + FDMExec->GetModelName() + "/" + fname + ".xml";
293 // file = "control;" + fname + ".xml";
294 file = FDMExec->GetAircraftPath() + ";" + FDMExec->GetModelName() + ";" + fname + ".xml";
300 cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
302 FCS_cfg = new FGConfigFile(file);
303 if (!FCS_cfg->IsOpen()) {
304 cerr << "Could not open " << delimiter << " file: " << file << endl;
307 AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
308 // file object pointer
312 AC_cfg->GetNextConfigLine();
315 if (delimiter == "AUTOPILOT") {
316 Components = &APComponents;
317 Name = "Autopilot: " + name;
318 } else if (delimiter == "FLIGHT_CONTROL") {
319 Components = &FCSComponents;
320 Name = "FCS: " + name;
322 cerr << endl << "Unknown FCS delimiter" << endl << endl;
325 if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
327 while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
328 if (token == "COMPONENT") {
329 token = AC_cfg->GetValue("TYPE");
330 if (debug_lvl > 0) cout << endl << " Loading Component \""
331 << AC_cfg->GetValue("NAME")
332 << "\" of type: " << token << endl;
333 if ((token == "LAG_FILTER") ||
334 (token == "LEAD_LAG_FILTER") ||
335 (token == "SECOND_ORDER_FILTER") ||
336 (token == "WASHOUT_FILTER") ||
337 (token == "INTEGRATOR") ) {
338 Components->push_back(new FGFilter(this, AC_cfg));
339 } else if ((token == "PURE_GAIN") ||
340 (token == "SCHEDULED_GAIN") ||
341 (token == "AEROSURFACE_SCALE") ) {
343 Components->push_back(new FGGain(this, AC_cfg));
345 } else if (token == "SUMMER") {
346 Components->push_back(new FGSummer(this, AC_cfg));
347 } else if (token == "DEADBAND") {
348 Components->push_back(new FGDeadBand(this, AC_cfg));
349 } else if (token == "GRADIENT") {
350 Components->push_back(new FGGradient(this, AC_cfg));
351 } else if (token == "SWITCH") {
352 Components->push_back(new FGSwitch(this, AC_cfg));
353 } else if (token == "KINEMAT") {
354 Components->push_back(new FGKinemat(this, AC_cfg));
356 cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
359 if (AC_cfg->GetNextConfigLine() == "EOF") break;
363 //collect information for normalizing control surfaces
366 for (i=0; i<Components->size(); i++) {
368 if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE"
369 || ((*Components)[i])->GetType() == "KINEMAT")
370 && ((*Components)[i])->GetOutputNode() ) {
371 nodeName = ((*Components)[i])->GetOutputNode()->GetName();
372 if ( nodeName == "elevator-pos-rad" ) {
374 } else if ( nodeName == "left-aileron-pos-rad"
375 || nodeName == "aileron-pos-rad" ) {
377 } else if ( nodeName == "right-aileron-pos-rad" ) {
379 } else if ( nodeName == "rudder-pos-rad" ) {
381 } else if ( nodeName == "speedbrake-pos-rad" ) {
383 } else if ( nodeName == "spoiler-pos-rad" ) {
385 } else if ( nodeName == "flap-pos-deg" ) {
391 if (delimiter == "FLIGHT_CONTROL") bindModel();
396 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
401 case FGLGear::bgLeft:
403 case FGLGear::bgRight:
405 case FGLGear::bgCenter:
408 cerr << "GetBrake asked to return a bogus brake value" << endl;
413 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
415 string FGFCS::GetComponentStrings(void)
418 string CompStrings = "";
419 bool firstime = true;
421 for (comp = 0; comp < FCSComponents.size(); comp++) {
422 if (firstime) firstime = false;
423 else CompStrings += ", ";
425 CompStrings += FCSComponents[comp]->GetName();
428 for (comp = 0; comp < APComponents.size(); comp++)
431 CompStrings += APComponents[comp]->GetName();
437 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439 string FGFCS::GetComponentValues(void)
442 string CompValues = "";
444 bool firstime = true;
446 for (comp = 0; comp < FCSComponents.size(); comp++) {
447 if (firstime) firstime = false;
448 else CompValues += ", ";
450 sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
451 CompValues += string(buffer);
454 for (comp = 0; comp < APComponents.size(); comp++) {
455 sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
456 CompValues += string(buffer);
462 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
464 void FGFCS::AddThrottle(void)
466 ThrottleCmd.push_back(0.0);
467 ThrottlePos.push_back(0.0);
468 MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
469 MixturePos.push_back(0.0);
470 PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
471 PropAdvance.push_back(0.0);
474 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
476 void FGFCS::Normalize(void) {
478 //not all of these are guaranteed to be defined for every model
479 //those that are have an index >=0 in the ToNormalize array
480 //ToNormalize is filled in Load()
482 if ( ToNormalize[iDe] > -1 ) {
483 DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
486 if ( ToNormalize[iDaL] > -1 ) {
487 DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
490 if ( ToNormalize[iDaR] > -1 ) {
491 DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
494 if ( ToNormalize[iDr] > -1 ) {
495 DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
498 if ( ToNormalize[iDsb] > -1 ) {
499 DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
502 if ( ToNormalize[iDsp] > -1 ) {
503 DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
506 if ( ToNormalize[iDf] > -1 ) {
507 DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
510 DePos[ofMag] = fabs(DePos[ofRad]);
511 DaLPos[ofMag] = fabs(DaLPos[ofRad]);
512 DaRPos[ofMag] = fabs(DaRPos[ofRad]);
513 DrPos[ofMag] = fabs(DrPos[ofRad]);
514 DsbPos[ofMag] = fabs(DsbPos[ofRad]);
515 DspPos[ofMag] = fabs(DspPos[ofRad]);
516 DfPos[ofMag] = fabs(DfPos[ofRad]);
520 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522 void FGFCS::bind(void)
524 PropertyManager->Tie("fcs/aileron-cmd-norm", this,
528 PropertyManager->Tie("fcs/elevator-cmd-norm", this,
532 PropertyManager->Tie("fcs/rudder-cmd-norm", this,
536 PropertyManager->Tie("fcs/flap-cmd-norm", this,
540 PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
544 PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
548 PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
549 &FGFCS::GetPitchTrimCmd,
550 &FGFCS::SetPitchTrimCmd,
552 PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
553 &FGFCS::GetRollTrimCmd,
554 &FGFCS::SetRollTrimCmd,
556 PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
557 &FGFCS::GetYawTrimCmd,
558 &FGFCS::SetYawTrimCmd,
560 PropertyManager->Tie("gear/gear-cmd-norm", this,
565 PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
569 PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
573 PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
578 PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
582 PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
586 PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
591 PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
595 PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
599 PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
604 PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
608 PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
612 PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
617 PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
621 PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
626 PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
630 PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
634 PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
639 PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
643 PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
647 PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
652 PropertyManager->Tie("gear/gear-pos-norm", this,
657 PropertyManager->Tie("ap/elevator_cmd", this,
662 PropertyManager->Tie("ap/aileron_cmd", this,
667 PropertyManager->Tie("ap/rudder_cmd", this,
672 PropertyManager->Tie("ap/throttle_cmd", this,
673 &FGFCS::GetAPThrottleCmd,
674 &FGFCS::SetAPThrottleCmd,
677 PropertyManager->Tie("ap/attitude_setpoint", this,
678 &FGFCS::GetAPAttitudeSetPt,
679 &FGFCS::SetAPAttitudeSetPt,
682 PropertyManager->Tie("ap/altitude_setpoint", this,
683 &FGFCS::GetAPAltitudeSetPt,
684 &FGFCS::SetAPAltitudeSetPt,
687 PropertyManager->Tie("ap/heading_setpoint", this,
688 &FGFCS::GetAPHeadingSetPt,
689 &FGFCS::SetAPHeadingSetPt,
692 PropertyManager->Tie("ap/airspeed_setpoint", this,
693 &FGFCS::GetAPAirspeedSetPt,
694 &FGFCS::SetAPAirspeedSetPt,
697 PropertyManager->Tie("ap/acquire_attitude", this,
698 &FGFCS::GetAPAcquireAttitude,
699 &FGFCS::SetAPAcquireAttitude,
702 PropertyManager->Tie("ap/acquire_altitude", this,
703 &FGFCS::GetAPAcquireAltitude,
704 &FGFCS::SetAPAcquireAltitude,
707 PropertyManager->Tie("ap/acquire_heading", this,
708 &FGFCS::GetAPAcquireHeading,
709 &FGFCS::SetAPAcquireHeading,
712 PropertyManager->Tie("ap/acquire_airspeed", this,
713 &FGFCS::GetAPAcquireAirspeed,
714 &FGFCS::SetAPAcquireAirspeed,
717 PropertyManager->Tie("ap/attitude_hold", this,
718 &FGFCS::GetAPAttitudeHold,
719 &FGFCS::SetAPAttitudeHold,
722 PropertyManager->Tie("ap/altitude_hold", this,
723 &FGFCS::GetAPAltitudeHold,
724 &FGFCS::SetAPAltitudeHold,
727 PropertyManager->Tie("ap/heading_hold", this,
728 &FGFCS::GetAPHeadingHold,
729 &FGFCS::SetAPHeadingHold,
732 PropertyManager->Tie("ap/airspeed_hold", this,
733 &FGFCS::GetAPAirspeedHold,
734 &FGFCS::SetAPAirspeedHold,
737 PropertyManager->Tie("ap/wingslevel_hold", this,
738 &FGFCS::GetAPWingsLevelHold,
739 &FGFCS::SetAPWingsLevelHold,
743 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
745 void FGFCS::bindModel(void)
751 for (i=0; i<ThrottleCmd.size(); i++) {
752 snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
753 PropertyManager->Tie( tmp,this,i,
754 &FGFCS::GetThrottleCmd,
755 &FGFCS::SetThrottleCmd,
757 snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);
758 PropertyManager->Tie( tmp,this,i,
759 &FGFCS::GetThrottlePos,
760 &FGFCS::SetThrottlePos,
762 if ( MixtureCmd.size() > i ) {
763 snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i);
764 PropertyManager->Tie( tmp,this,i,
765 &FGFCS::GetMixtureCmd,
766 &FGFCS::SetMixtureCmd,
768 snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);
769 PropertyManager->Tie( tmp,this,i,
770 &FGFCS::GetMixturePos,
771 &FGFCS::SetMixturePos,
774 if ( PropAdvanceCmd.size() > i ) {
775 snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i);
776 PropertyManager->Tie( tmp,this,i,
777 &FGFCS::GetPropAdvanceCmd,
778 &FGFCS::SetPropAdvanceCmd,
780 snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);
781 PropertyManager->Tie( tmp,this,i,
782 &FGFCS::GetPropAdvance,
783 &FGFCS::SetPropAdvance,
789 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
791 void FGFCS::unbind(FGPropertyManager *node)
793 int N = node->nChildren();
794 for(int i=0;i<N;i++) {
795 if(node->getChild(i)->nChildren() ) {
796 unbind( (FGPropertyManager*)node->getChild(i) );
797 } else if( node->getChild(i)->isTied() ) {
798 node->getChild(i)->untie();
803 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
804 // The bitmasked value choices are as follows:
805 // unset: In this case (the default) JSBSim would only print
806 // out the normally expected messages, essentially echoing
807 // the config files as they are read. If the environment
808 // variable is not set, debug_lvl is set to 1 internally
809 // 0: This requests JSBSim not to output any messages
811 // 1: This value explicity requests the normal JSBSim
813 // 2: This value asks for a message to be printed out when
814 // a class is instantiated
815 // 4: When this value is set, a message is displayed when a
816 // FGModel object executes its Run() method
817 // 8: When this value is set, various runtime state variables
818 // are printed out periodically
819 // 16: When set various parameters are sanity checked and
820 // a message is printed out when they go out of bounds
822 void FGFCS::Debug(int from)
824 if (debug_lvl <= 0) return;
826 if (debug_lvl & 1) { // Standard console startup message output
827 if (from == 0) { // Constructor
831 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
832 if (from == 0) cout << "Instantiated: FGFCS" << endl;
833 if (from == 1) cout << "Destroyed: FGFCS" << endl;
835 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
837 if (debug_lvl & 8 ) { // Runtime state variables
839 if (debug_lvl & 16) { // Sanity checking
841 if (debug_lvl & 64) {
842 if (from == 0) { // Constructor
843 cout << IdSrc << endl;
844 cout << IdHdr << endl;