]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGFCS.cpp
Square the /environment/turbulence-norm property before scaling it for
[flightgear.git] / src / FDM / JSBSim / FGFCS.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  
3  Module:       FGFCS.cpp
4  Author:       Jon Berndt
5  Date started: 12/12/98
6  Purpose:      Model the flight controls
7  Called by:    FDMExec
8  
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10  
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
14  version.
15  
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
19  details.
20  
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.
24  
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27  
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This class models the flight controls for a specific airplane
31  
32 HISTORY
33 --------------------------------------------------------------------------------
34 12/12/98   JSB   Created
35  
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40 #include "FGFCS.h"
41 #include "FGState.h"
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"
49 #include "FGOutput.h"
50 #include "FGPropertyManager.h"
51
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"
59
60 namespace JSBSim {
61
62 static const char *IdSrc = "$Id$";
63 static const char *IdHdr = ID_FCS;
64
65 #if defined(WIN32) && !defined(__CYGWIN__)
66 #define snprintf _snprintf
67 #endif
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 CLASS IMPLEMENTATION
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
74 {
75   int i;
76   Name = "FGFCS";
77
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   DoNormalize=true;
84   
85   eMode = mNone;
86
87   bind();
88   for (i=0;i<=NForms;i++) {
89     DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
90     DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
91   }
92     
93   for (i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
94   Debug(0);
95 }
96
97 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98
99 FGFCS::~FGFCS()
100 {
101   unbind( PropertyManager->GetNode("fcs") );
102   unbind( PropertyManager->GetNode("ap") );
103   PropertyManager->Untie( "gear/gear-cmd-norm" );
104   PropertyManager->Untie( "gear/gear-pos-norm" );
105
106   ThrottleCmd.clear();
107   ThrottlePos.clear();
108   MixtureCmd.clear();
109   MixturePos.clear();
110   PropAdvanceCmd.clear();
111   PropAdvance.clear();
112
113
114   unsigned int i;
115
116   for (i=0;i<APComponents.size();i++) delete APComponents[i];
117   for (i=0;i<FCSComponents.size();i++) delete FCSComponents[i];
118   
119   Debug(1);
120 }
121
122 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123
124 bool FGFCS::Run(void)
125 {
126   unsigned int i;
127
128   if (!FGModel::Run()) {
129     for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
130     for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
131     for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
132     for (i=0; i<APComponents.size(); i++)  {
133       eMode = mAP;
134       APComponents[i]->Run();
135       eMode = mNone;
136     }
137     for (i=0; i<FCSComponents.size(); i++)  {
138       eMode = mFCS;
139       FCSComponents[i]->Run();
140       eMode = mNone;
141     }
142     if (DoNormalize) Normalize();
143
144     return false;
145   } else {
146     return true;
147   }
148 }
149
150 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151
152 void FGFCS::SetThrottleCmd(int engineNum, double setting)
153 {
154   unsigned int ctr;
155
156   if (engineNum < (int)ThrottlePos.size()) {
157     if (engineNum < 0) {
158       for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
159     } else {
160       ThrottleCmd[engineNum] = setting;
161     }
162   } else {
163     cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
164          << " engines exist, but attempted throttle command is for engine "
165          << engineNum << endl;
166   }
167 }
168
169 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170
171 void FGFCS::SetThrottlePos(int engineNum, double setting)
172 {
173   unsigned int ctr;
174
175   if (engineNum < (int)ThrottlePos.size()) {
176     if (engineNum < 0) {
177       for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
178     } else {
179       ThrottlePos[engineNum] = setting;
180     }
181   } else {
182     cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
183          << " engines exist, but attempted throttle position setting is for engine "
184          << engineNum << endl;
185   }
186 }
187
188 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189
190 double FGFCS::GetThrottleCmd(int engineNum) const
191 {
192   if (engineNum < (int)ThrottlePos.size()) {
193     if (engineNum < 0) {
194        cerr << "Cannot get throttle value for ALL engines" << endl;
195     } else {
196       return ThrottleCmd[engineNum];
197     }
198   } else {
199     cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
200          << " engines exist, but throttle setting for engine " << engineNum
201          << " is selected" << endl;
202   }
203   return 0.0;
204 }
205
206 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207
208 double FGFCS::GetThrottlePos(int engineNum) const
209 {
210   if (engineNum < (int)ThrottlePos.size()) {
211     if (engineNum < 0) {
212        cerr << "Cannot get throttle value for ALL engines" << endl;
213     } else {
214       return ThrottlePos[engineNum];
215     }
216   } else {
217     cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
218          << " engines exist, but attempted throttle position setting is for engine "
219          << engineNum << endl;
220   }
221   return 0.0; 
222 }
223
224 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225
226 void FGFCS::SetMixtureCmd(int engineNum, double setting)
227 {
228   unsigned int ctr;
229
230   if (engineNum < (int)ThrottlePos.size()) {
231     if (engineNum < 0) {
232       for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
233     } else {
234       MixtureCmd[engineNum] = setting;
235     }
236   }
237 }
238
239 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240
241 void FGFCS::SetMixturePos(int engineNum, double setting)
242 {
243   unsigned int ctr;
244
245   if (engineNum < (int)ThrottlePos.size()) {
246     if (engineNum < 0) {
247       for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
248     } else {
249       MixturePos[engineNum] = setting;
250     }
251   }
252 }
253
254 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255
256 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
257 {
258   unsigned int ctr;
259
260   if (engineNum < (int)ThrottlePos.size()) {
261     if (engineNum < 0) {
262       for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
263     } else {
264       PropAdvanceCmd[engineNum] = setting;
265     }
266   }
267 }
268
269 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270
271 void FGFCS::SetPropAdvance(int engineNum, double setting)
272 {
273   unsigned int ctr;
274
275   if (engineNum < (int)ThrottlePos.size()) {
276     if (engineNum < 0) {
277       for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
278     } else {
279       PropAdvance[engineNum] = setting;
280     }
281   }
282 }
283
284 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285
286 bool FGFCS::Load(FGConfigFile* AC_cfg)
287 {
288   string token, delimiter;
289   string name, file, fname;
290   unsigned i;
291   vector <FGFCSComponent*> *Components;
292   FGConfigFile *FCS_cfg;
293
294   Components=0;
295   // Determine if the FCS/Autopilot is defined inline in the aircraft configuration
296   // file or in a separate file. Set up the config file class as appropriate.
297
298   delimiter = AC_cfg->GetValue();
299   name  = AC_cfg->GetValue("NAME");
300   fname = AC_cfg->GetValue("FILE");
301
302   if ( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
303     DoNormalize = false;
304     cout << "    Automatic Control Surface Normalization Disabled" << endl;
305   }
306
307 # ifndef macintosh
308   file = "control/" + fname + ".xml";
309 # else
310   file = "control;" + fname + ".xml";
311 # endif
312
313   if (name.empty()) {
314     name = fname;
315     if (file.empty()) {
316       cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
317     } else {
318       FCS_cfg = new FGConfigFile(file);
319       if (!FCS_cfg->IsOpen()) {
320         cerr << "Could not open " << delimiter << " file: " << file << endl;
321         return false;
322       } else {
323         AC_cfg = FCS_cfg; // set local config file object pointer to FCS config
324                                 // file object pointer
325       }
326     }
327   } else {
328     AC_cfg->GetNextConfigLine();
329   }
330
331   if (delimiter == "AUTOPILOT") {
332     Components = &APComponents;
333     eMode = mAP;
334     Name = "Autopilot: " + name;
335   } else if (delimiter == "FLIGHT_CONTROL") {
336     Components = &FCSComponents;
337     eMode = mFCS;
338     Name = "FCS: " + name;
339   } else {
340     cerr << endl << "Unknown FCS delimiter" << endl << endl;
341   }
342   
343   if (debug_lvl > 0) cout << "    Control System Name: " << Name << endl;
344
345   while ((token = AC_cfg->GetValue()) != string("/" + delimiter)) {
346     if (token == "COMPONENT") {
347       token = AC_cfg->GetValue("TYPE");
348       if (debug_lvl > 0) cout << endl << "    Loading Component \""
349                               << AC_cfg->GetValue("NAME")
350                               << "\" of type: " << token << endl;
351       if ((token == "LAG_FILTER") ||
352           (token == "LEAD_LAG_FILTER") ||
353           (token == "SECOND_ORDER_FILTER") ||
354           (token == "WASHOUT_FILTER") ||
355           (token == "INTEGRATOR") ) {
356         Components->push_back(new FGFilter(this, AC_cfg));
357       } else if ((token == "PURE_GAIN") ||
358                  (token == "SCHEDULED_GAIN") ||
359                  (token == "AEROSURFACE_SCALE") ) {
360
361         Components->push_back(new FGGain(this, AC_cfg));
362
363       } else if (token == "SUMMER") {
364         Components->push_back(new FGSummer(this, AC_cfg));
365       } else if (token == "DEADBAND") {
366         Components->push_back(new FGDeadBand(this, AC_cfg));
367       } else if (token == "GRADIENT") {
368         Components->push_back(new FGGradient(this, AC_cfg));
369       } else if (token == "SWITCH") {
370         Components->push_back(new FGSwitch(this, AC_cfg));
371       } else if (token == "KINEMAT") {
372         Components->push_back(new FGKinemat(this, AC_cfg));
373       } else {
374         cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
375         return false;
376       }
377       if (AC_cfg->GetNextConfigLine() == "EOF") break;
378     }
379   }
380
381   //collect information for normalizing control surfaces
382
383   string nodeName;
384   for (i=0; i<Components->size(); i++) {
385     
386     if ( (((*Components)[i])->GetType() == "AEROSURFACE_SCALE" 
387           || ((*Components)[i])->GetType() == "KINEMAT")  
388                     && ((*Components)[i])->GetOutputNode() ) { 
389       nodeName = ((*Components)[i])->GetOutputNode()->GetName();
390       if ( nodeName == "elevator-pos-rad" ) {
391         ToNormalize[iDe]=i;
392       } else if ( nodeName  == "left-aileron-pos-rad" 
393                    || nodeName == "aileron-pos-rad" ) {
394         ToNormalize[iDaL]=i;
395       } else if ( nodeName == "right-aileron-pos-rad" ) {
396         ToNormalize[iDaR]=i;
397       } else if ( nodeName == "rudder-pos-rad" ) {
398         ToNormalize[iDr]=i;
399       } else if ( nodeName == "speedbrake-pos-rad" ) {
400         ToNormalize[iDsb]=i;
401       } else if ( nodeName == "spoiler-pos-rad" ) {
402         ToNormalize[iDsp]=i;
403       } else if ( nodeName == "flap-pos-deg" ) {
404         ToNormalize[iDf]=i;
405       }
406     }
407   }     
408   
409   if (delimiter == "FLIGHT_CONTROL") bindModel();
410
411   eMode = mNone;
412
413   return true;
414 }
415
416 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
417
418 double FGFCS::GetComponentOutput(int idx)
419 {
420   switch (eMode) {
421   case mFCS:
422     return FCSComponents[idx]->GetOutput();
423   case mAP:
424     return APComponents[idx]->GetOutput();
425   case mNone:
426     cerr << "Unknown FCS mode" << endl;
427     break;
428   }
429   return 0.0;
430 }
431
432 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
433
434 string FGFCS::GetComponentName(int idx)
435 {
436   switch (eMode) {
437   case mFCS:
438     return FCSComponents[idx]->GetName();
439   case mAP:
440     return APComponents[idx]->GetName();
441   case mNone:
442     cerr << "Unknown FCS mode" << endl;
443     break;
444   }
445   return string("");
446
447
448 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
449
450 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
451 {
452   switch (bg) {
453   case FGLGear::bgLeft:
454     return LeftBrake;
455   case FGLGear::bgRight:
456     return RightBrake;
457   case FGLGear::bgCenter:
458     return CenterBrake;
459   default:
460     cerr << "GetBrake asked to return a bogus brake value" << endl;
461   }
462   return 0.0;
463 }
464
465 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
466
467 string FGFCS::GetComponentStrings(void)
468 {
469   unsigned int comp;
470   string CompStrings = "";
471   bool firstime = true;
472
473   for (comp = 0; comp < FCSComponents.size(); comp++) {
474     if (firstime) firstime = false;
475     else          CompStrings += ", ";
476
477     CompStrings += FCSComponents[comp]->GetName();
478   }
479
480   for (comp = 0; comp < APComponents.size(); comp++)
481   {
482     CompStrings += ", ";
483     CompStrings += APComponents[comp]->GetName();
484   }
485
486   return CompStrings;
487 }
488
489 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490
491 string FGFCS::GetComponentValues(void)
492 {
493   unsigned int comp;
494   string CompValues = "";
495   char buffer[10];
496   bool firstime = true;
497
498   for (comp = 0; comp < FCSComponents.size(); comp++) {
499     if (firstime) firstime = false;
500     else          CompValues += ", ";
501
502     sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
503     CompValues += string(buffer);
504   }
505
506   for (comp = 0; comp < APComponents.size(); comp++) {
507     sprintf(buffer, ", %9.6f", APComponents[comp]->GetOutput());
508     CompValues += string(buffer);
509   }
510
511   return CompValues;
512 }
513
514 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
515
516 void FGFCS::AddThrottle(void)
517 {
518   ThrottleCmd.push_back(0.0);
519   ThrottlePos.push_back(0.0);
520   MixtureCmd.push_back(0.0);     // assume throttle and mixture are coupled
521   MixturePos.push_back(0.0);
522   PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
523   PropAdvance.push_back(0.0);
524 }
525
526 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527
528 void FGFCS::Normalize(void) {
529   
530   //not all of these are guaranteed to be defined for every model
531   //those that are have an index >=0 in the ToNormalize array
532   //ToNormalize is filled in Load()
533   
534   if ( ToNormalize[iDe] > -1 ) {
535     DePos[ofNorm] = FCSComponents[ToNormalize[iDe]]->GetOutputPct();
536   }
537   
538   if ( ToNormalize[iDaL] > -1 ) {
539     DaLPos[ofNorm] = FCSComponents[ToNormalize[iDaL]]->GetOutputPct();
540   }
541   
542   if ( ToNormalize[iDaR] > -1 ) {
543     DaRPos[ofNorm] = FCSComponents[ToNormalize[iDaR]]->GetOutputPct();
544   }
545
546   if ( ToNormalize[iDr] > -1 ) {
547     DrPos[ofNorm] = FCSComponents[ToNormalize[iDr]]->GetOutputPct();
548   }
549        
550   if ( ToNormalize[iDsb] > -1 ) { 
551     DsbPos[ofNorm] = FCSComponents[ToNormalize[iDsb]]->GetOutputPct();
552   }
553   
554   if ( ToNormalize[iDsp] > -1 ) {
555     DspPos[ofNorm] = FCSComponents[ToNormalize[iDsp]]->GetOutputPct();
556   }
557   
558   if ( ToNormalize[iDf] > -1 ) {
559     DfPos[ofNorm] = FCSComponents[ToNormalize[iDf]]->GetOutputPct();
560   }
561   
562   DePos[ofMag]  = fabs(DePos[ofRad]);
563   DaLPos[ofMag] = fabs(DaLPos[ofRad]);
564   DaRPos[ofMag] = fabs(DaRPos[ofRad]);
565   DrPos[ofMag]  = fabs(DrPos[ofRad]);
566   DsbPos[ofMag] = fabs(DsbPos[ofRad]);
567   DspPos[ofMag] = fabs(DspPos[ofRad]);
568   DfPos[ofMag]  = fabs(DfPos[ofRad]);
569    
570 }  
571     
572 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573
574 void FGFCS::bind(void)
575 {
576   PropertyManager->Tie("fcs/aileron-cmd-norm", this,
577                        &FGFCS::GetDaCmd,
578                        &FGFCS::SetDaCmd,
579                        true);
580   PropertyManager->Tie("fcs/elevator-cmd-norm", this,
581                        &FGFCS::GetDeCmd,
582                        &FGFCS::SetDeCmd,
583                        true);
584   PropertyManager->Tie("fcs/rudder-cmd-norm", this,
585                        &FGFCS::GetDrCmd,
586                        &FGFCS::SetDrCmd,
587                        true);
588   PropertyManager->Tie("fcs/flap-cmd-norm", this,
589                        &FGFCS::GetDfCmd,
590                        &FGFCS::SetDfCmd,
591                        true);
592   PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
593                        &FGFCS::GetDsbCmd,
594                        &FGFCS::SetDsbCmd,
595                        true);
596   PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
597                        &FGFCS::GetDspCmd,
598                        &FGFCS::SetDspCmd,
599                        true);
600   PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
601                        &FGFCS::GetPitchTrimCmd,
602                        &FGFCS::SetPitchTrimCmd,
603                        true);
604   PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
605                        &FGFCS::GetYawTrimCmd,
606                        &FGFCS::SetYawTrimCmd,
607                        true);
608   PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
609                        &FGFCS::GetRollTrimCmd,
610                        &FGFCS::SetRollTrimCmd,
611                        true);
612   PropertyManager->Tie("gear/gear-cmd-norm", this,
613                        &FGFCS::GetGearCmd,
614                        &FGFCS::SetGearCmd,
615                        true);
616   
617   PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
618                        &FGFCS::GetDaLPos,
619                        &FGFCS::SetDaLPos,
620                        true);
621   PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
622                        &FGFCS::GetDaLPos,
623                        &FGFCS::SetDaLPos,
624                        true);
625   PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
626                        &FGFCS::GetDaLPos,
627                        &FGFCS::SetDaLPos,
628                        true);
629  
630   PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
631                        &FGFCS::GetDaRPos,
632                        &FGFCS::SetDaRPos,
633                        true);
634   PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
635                        &FGFCS::GetDaRPos,
636                        &FGFCS::SetDaRPos,
637                        true);
638   PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
639                        &FGFCS::GetDaRPos,
640                        &FGFCS::SetDaRPos,
641                        true);
642   
643   PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
644                        &FGFCS::GetDePos,
645                        &FGFCS::SetDePos,
646                        true );
647   PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
648                        &FGFCS::GetDePos,                       
649                        &FGFCS::SetDePos,
650                        true );
651   PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
652                        &FGFCS::GetDePos,
653                        &FGFCS::SetDePos,
654                        true );
655   
656   PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
657                        &FGFCS::GetDrPos,
658                        &FGFCS::SetDrPos,
659                        true);
660   PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
661                        &FGFCS::GetDrPos,
662                        &FGFCS::SetDrPos,
663                        true);
664   PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
665                        &FGFCS::GetDrPos,
666                        &FGFCS::SetDrPos,
667                        true);
668                        
669   PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
670                        &FGFCS::GetDfPos,
671                        &FGFCS::SetDfPos,
672                        true);
673   PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
674                        &FGFCS::GetDfPos,
675                        &FGFCS::SetDfPos,
676                        true);
677   
678   PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
679                        &FGFCS::GetDsbPos,
680                        &FGFCS::SetDsbPos,
681                        true);
682   PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
683                        &FGFCS::GetDsbPos,
684                        &FGFCS::SetDsbPos,
685                        true);
686   PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
687                        &FGFCS::GetDsbPos,
688                        &FGFCS::SetDsbPos,
689                        true);
690                        
691   PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
692                        &FGFCS::GetDspPos,
693                        &FGFCS::SetDspPos,
694                        true);
695   PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
696                        &FGFCS::GetDspPos,
697                        &FGFCS::SetDspPos,
698                        true);
699   PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
700                        &FGFCS::GetDspPos,
701                        &FGFCS::SetDspPos,
702                        true);
703                        
704   PropertyManager->Tie("gear/gear-pos-norm", this,
705                        &FGFCS::GetGearPos,
706                        &FGFCS::SetGearPos,
707                        true);
708
709   PropertyManager->Tie("ap/elevator_cmd", this,
710                        &FGFCS::GetAPDeCmd,
711                        &FGFCS::SetAPDeCmd,
712                        true);
713
714   PropertyManager->Tie("ap/aileron_cmd", this,
715                        &FGFCS::GetAPDaCmd,
716                        &FGFCS::SetAPDaCmd,
717                        true);
718
719   PropertyManager->Tie("ap/rudder_cmd", this,
720                        &FGFCS::GetAPDrCmd,
721                        &FGFCS::SetAPDrCmd,
722                        true);
723
724   PropertyManager->Tie("ap/throttle_cmd", this,
725                        &FGFCS::GetAPThrottleCmd,
726                        &FGFCS::SetAPThrottleCmd,
727                        true);
728
729   PropertyManager->Tie("ap/attitude_setpoint", this,
730                        &FGFCS::GetAPAttitudeSetPt,
731                        &FGFCS::SetAPAttitudeSetPt,
732                        true);
733
734   PropertyManager->Tie("ap/altitude_setpoint", this,
735                        &FGFCS::GetAPAltitudeSetPt,
736                        &FGFCS::SetAPAltitudeSetPt,
737                        true);
738
739   PropertyManager->Tie("ap/heading_setpoint", this,
740                        &FGFCS::GetAPHeadingSetPt,
741                        &FGFCS::SetAPHeadingSetPt,
742                        true);
743
744   PropertyManager->Tie("ap/airspeed_setpoint", this,
745                        &FGFCS::GetAPAirspeedSetPt,
746                        &FGFCS::SetAPAirspeedSetPt,
747                        true);
748
749   PropertyManager->Tie("ap/acquire_attitude", this,
750                        &FGFCS::GetAPAcquireAttitude,
751                        &FGFCS::SetAPAcquireAttitude,
752                        true);
753
754   PropertyManager->Tie("ap/acquire_altitude", this,
755                        &FGFCS::GetAPAcquireAltitude,
756                        &FGFCS::SetAPAcquireAltitude,
757                        true);
758
759   PropertyManager->Tie("ap/acquire_heading", this,
760                        &FGFCS::GetAPAcquireHeading,
761                        &FGFCS::SetAPAcquireHeading,
762                        true);
763
764   PropertyManager->Tie("ap/acquire_airspeed", this,
765                        &FGFCS::GetAPAcquireAirspeed,
766                        &FGFCS::SetAPAcquireAirspeed,
767                        true);
768
769   PropertyManager->Tie("ap/attitude_hold", this,
770                        &FGFCS::GetAPAttitudeHold,
771                        &FGFCS::SetAPAttitudeHold,
772                        true);
773
774   PropertyManager->Tie("ap/altitude_hold", this,
775                        &FGFCS::GetAPAltitudeHold,
776                        &FGFCS::SetAPAltitudeHold,
777                        true);
778
779   PropertyManager->Tie("ap/heading_hold", this,
780                        &FGFCS::GetAPHeadingHold,
781                        &FGFCS::SetAPHeadingHold,
782                        true);
783
784   PropertyManager->Tie("ap/airspeed_hold", this,
785                        &FGFCS::GetAPAirspeedHold,
786                        &FGFCS::SetAPAirspeedHold,
787                        true);
788
789   PropertyManager->Tie("ap/wingslevel_hold", this,
790                        &FGFCS::GetAPWingsLevelHold,
791                        &FGFCS::SetAPWingsLevelHold,
792                        true);
793 }
794
795 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
796
797 void FGFCS::bindModel(void)
798 {
799   unsigned i;
800   char tmp[80];
801   
802   
803   for (i=0; i<ThrottleCmd.size(); i++) {
804     snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
805     PropertyManager->Tie( tmp,this,i,
806                           &FGFCS::GetThrottleCmd,
807                           &FGFCS::SetThrottleCmd,
808                           true );
809     snprintf(tmp,80,"fcs/throttle-pos-norm[%u]",i);                      
810     PropertyManager->Tie( tmp,this,i,
811                           &FGFCS::GetThrottlePos,
812                           &FGFCS::SetThrottlePos,
813                           true );
814     if ( MixtureCmd.size() > i ) {
815       snprintf(tmp,80,"fcs/mixture-cmd-norm[%u]",i); 
816       PropertyManager->Tie( tmp,this,i,
817                             &FGFCS::GetMixtureCmd,
818                             &FGFCS::SetMixtureCmd,
819                             true );
820       snprintf(tmp,80,"fcs/mixture-pos-norm[%u]",i);                    
821       PropertyManager->Tie( tmp,this,i,
822                             &FGFCS::GetMixturePos,
823                             &FGFCS::SetMixturePos,
824                             true );
825     }
826     if ( PropAdvanceCmd.size() > i ) {
827       snprintf(tmp,80,"fcs/advance-cmd-norm[%u]",i); 
828       PropertyManager->Tie( tmp,this,i,
829                             &FGFCS::GetPropAdvanceCmd,
830                             &FGFCS::SetPropAdvanceCmd,
831                             true );
832       snprintf(tmp,80,"fcs/advance-pos-norm[%u]",i);                       
833       PropertyManager->Tie( tmp,this,i,
834                             &FGFCS::GetPropAdvance,
835                             &FGFCS::SetPropAdvance,
836                             true );
837     }
838   }
839 }                            
840                           
841 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
842
843 void FGFCS::unbind(FGPropertyManager *node)
844 {
845   int N = node->nChildren();
846   for(int i=0;i<N;i++) {
847     if(node->getChild(i)->nChildren() ) {
848       unbind( (FGPropertyManager*)node->getChild(i) );
849     } else if( node->getChild(i)->isTied() ) {
850       node->getChild(i)->untie();
851     } 
852   }        
853 }
854
855 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
856 //    The bitmasked value choices are as follows:
857 //    unset: In this case (the default) JSBSim would only print
858 //       out the normally expected messages, essentially echoing
859 //       the config files as they are read. If the environment
860 //       variable is not set, debug_lvl is set to 1 internally
861 //    0: This requests JSBSim not to output any messages
862 //       whatsoever.
863 //    1: This value explicity requests the normal JSBSim
864 //       startup messages
865 //    2: This value asks for a message to be printed out when
866 //       a class is instantiated
867 //    4: When this value is set, a message is displayed when a
868 //       FGModel object executes its Run() method
869 //    8: When this value is set, various runtime state variables
870 //       are printed out periodically
871 //    16: When set various parameters are sanity checked and
872 //       a message is printed out when they go out of bounds
873
874 void FGFCS::Debug(int from)
875 {
876   if (debug_lvl <= 0) return;
877
878   if (debug_lvl & 1) { // Standard console startup message output
879     if (from == 0) { // Constructor
880
881     }
882   }
883   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
884     if (from == 0) cout << "Instantiated: FGFCS" << endl;
885     if (from == 1) cout << "Destroyed:    FGFCS" << endl;
886   }
887   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
888   }
889   if (debug_lvl & 8 ) { // Runtime state variables
890   }
891   if (debug_lvl & 16) { // Sanity checking
892   }
893   if (debug_lvl & 64) {
894     if (from == 0) { // Constructor
895       cout << IdSrc << endl;
896       cout << IdHdr << endl;
897     }
898   }
899 }
900
901 }