]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGFCS.cpp
First commit of properties code. JSBSim now has a basic property tree all
[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 static const char *IdSrc = "$Id$";
61 static const char *IdHdr = ID_FCS;
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 CLASS IMPLEMENTATION
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
68 {
69   int i;
70   Name = "FGFCS";
71
72   DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0.0;
73   PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
74   GearCmd = GearPos = 1; // default to gear down
75   LeftBrake = RightBrake = CenterBrake = 0.0;
76   DoNormalize=true;
77   
78   bind();
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;
82   }
83     
84   for(i=0;i<NNorm;i++) { ToNormalize[i]=-1;}
85   Debug(0);
86 }
87
88 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89
90 FGFCS::~FGFCS()
91 {
92   ThrottleCmd.clear();
93   ThrottlePos.clear();
94   MixtureCmd.clear();
95   MixturePos.clear();
96   PropAdvanceCmd.clear();
97   PropAdvance.clear();
98
99   unsigned int i;
100   
101   unbind();
102
103   for (i=0;i<Components.size();i++) delete Components[i];
104   Debug(1);
105 }
106
107 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108
109 bool FGFCS::Run(void)
110 {
111   unsigned int i;
112
113   if (!FGModel::Run()) {
114     for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
115     for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
116     for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
117     for (i=0; i<Components.size(); i++)  Components[i]->Run();
118     if(DoNormalize) Normalize();
119   } else {
120   }
121
122   return false;
123 }
124
125 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126
127 void FGFCS::SetThrottleCmd(int engineNum, double setting)
128 {
129   unsigned int ctr;
130
131   if (engineNum < (int)ThrottlePos.size()) {
132     if (engineNum < 0) {
133       for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
134     } else {
135       ThrottleCmd[engineNum] = setting;
136     }
137   } else {
138     cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
139          << " engines exist, but attempted throttle command is for engine "
140          << engineNum << endl;
141   }
142 }
143
144 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145
146 void FGFCS::SetThrottlePos(int engineNum, double setting)
147 {
148   unsigned int ctr;
149
150   if (engineNum < (int)ThrottlePos.size()) {
151     if (engineNum < 0) {
152       for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
153     } else {
154       ThrottlePos[engineNum] = setting;
155     }
156   } else {
157     cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
158          << " engines exist, but attempted throttle position setting is for engine "
159          << engineNum << endl;
160   }
161 }
162
163 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164
165 double FGFCS::GetThrottleCmd(int engineNum)
166 {
167   if (engineNum < (int)ThrottlePos.size()) {
168     if (engineNum < 0) {
169        cerr << "Cannot get throttle value for ALL engines" << endl;
170     } else {
171       return ThrottleCmd[engineNum];
172     }
173   } else {
174     cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
175          << " engines exist, but throttle setting for engine " << engineNum
176          << " is selected" << endl;
177   }
178   return 0.0;
179 }
180
181 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182
183 double FGFCS::GetThrottlePos(int engineNum)
184 {
185   if (engineNum < (int)ThrottlePos.size()) {
186     if (engineNum < 0) {
187        cerr << "Cannot get throttle value for ALL engines" << endl;
188     } else {
189       return ThrottlePos[engineNum];
190     }
191   } else {
192     cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
193          << " engines exist, but attempted throttle position setting is for engine "
194          << engineNum << endl;
195   }
196   return 0.0; 
197 }
198
199 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200
201 void FGFCS::SetMixtureCmd(int engineNum, double setting)
202 {
203   unsigned int ctr;
204
205   if (engineNum < (int)ThrottlePos.size()) {
206     if (engineNum < 0) {
207       for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
208     } else {
209       MixtureCmd[engineNum] = setting;
210     }
211   }
212 }
213
214 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215
216 void FGFCS::SetMixturePos(int engineNum, double setting)
217 {
218   unsigned int ctr;
219
220   if (engineNum < (int)ThrottlePos.size()) {
221     if (engineNum < 0) {
222       for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
223     } else {
224       MixturePos[engineNum] = setting;
225     }
226   }
227 }
228
229 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
230
231 void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
232 {
233   unsigned int ctr;
234
235   if (engineNum < (int)ThrottlePos.size()) {
236     if (engineNum < 0) {
237       for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
238     } else {
239       PropAdvanceCmd[engineNum] = setting;
240     }
241   }
242 }
243
244 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245
246 void FGFCS::SetPropAdvance(int engineNum, double setting)
247 {
248   unsigned int ctr;
249
250   if (engineNum < (int)ThrottlePos.size()) {
251     if (engineNum < 0) {
252       for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
253     } else {
254       PropAdvance[engineNum] = setting;
255     }
256   }
257 }
258
259 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260
261 bool FGFCS::Load(FGConfigFile* AC_cfg)
262 {
263   string token;
264   unsigned i;
265   
266   Name = Name + ":" + AC_cfg->GetValue("NAME");
267   if (debug_lvl > 0) cout << "    Control System Name: " << Name << endl;
268   if( AC_cfg->GetValue("NORMALIZE") == "FALSE") {
269       DoNormalize=false;
270       cout << "    Automatic Control Surface Normalization Disabled" << endl;
271   }    
272   AC_cfg->GetNextConfigLine();
273   while ((token = AC_cfg->GetValue()) != string("/FLIGHT_CONTROL")) {
274     if (token == "COMPONENT") {
275       token = AC_cfg->GetValue("TYPE");
276       if (debug_lvl > 0) cout << endl << "    Loading Component \""
277                               << AC_cfg->GetValue("NAME")
278                               << "\" of type: " << token << endl;
279       if ((token == "LAG_FILTER") ||
280           (token == "LEAD_LAG_FILTER") ||
281           (token == "SECOND_ORDER_FILTER") ||
282           (token == "WASHOUT_FILTER") ||
283           (token == "INTEGRATOR") ) {
284         Components.push_back(new FGFilter(this, AC_cfg));
285       } else if ((token == "PURE_GAIN") ||
286                  (token == "SCHEDULED_GAIN") ||
287                  (token == "AEROSURFACE_SCALE") ) {
288
289         Components.push_back(new FGGain(this, AC_cfg));
290
291       } else if (token == "SUMMER") {
292         Components.push_back(new FGSummer(this, AC_cfg));
293       } else if (token == "DEADBAND") {
294         Components.push_back(new FGDeadBand(this, AC_cfg));
295       } else if (token == "GRADIENT") {
296         Components.push_back(new FGGradient(this, AC_cfg));
297       } else if (token == "SWITCH") {
298         Components.push_back(new FGSwitch(this, AC_cfg));
299       } else if (token == "KINEMAT") {
300         Components.push_back(new FGKinemat(this, AC_cfg));
301       } else {
302         cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
303         return false;
304       }
305       AC_cfg->GetNextConfigLine();
306     }
307   }
308   //collect information for normalizing control surfaces
309   
310   for(i=0;i<Components.size();i++) {
311     
312     if(Components[i]->GetType() == "AEROSURFACE_SCALE" 
313         || Components[i]->GetType() == "KINEMAT"  ) {
314       if( Components[i]->GetOutputIdx() == FG_ELEVATOR_POS ) {
315         ToNormalize[iDe]=i;
316       } else if ( Components[i]->GetOutputIdx() == FG_LEFT_AILERON_POS 
317                       || Components[i]->GetOutputIdx() == FG_AILERON_POS ) {
318         ToNormalize[iDaL]=i;
319       } else if ( Components[i]->GetOutputIdx() == FG_RIGHT_AILERON_POS ) {
320         ToNormalize[iDaR]=i;
321       } else if ( Components[i]->GetOutputIdx() == FG_RUDDER_POS ) {
322         ToNormalize[iDr]=i;
323       } else if ( Components[i]->GetOutputIdx() == FG_SPDBRAKE_POS ) {
324         ToNormalize[iDsb]=i;
325       } else if ( Components[i]->GetOutputIdx() == FG_SPOILERS_POS ) {
326         ToNormalize[iDsp]=i;
327       } else if ( Components[i]->GetOutputIdx() == FG_FLAPS_POS ) {
328         ToNormalize[iDf]=i;
329       }
330     }
331   }     
332   
333   return true;
334 }
335
336 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
337
338 double FGFCS::GetComponentOutput(eParam idx) {
339   return Components[idx]->GetOutput();
340 }
341
342 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343
344 string FGFCS::GetComponentName(int idx) {
345   return Components[idx]->GetName();
346 }
347
348 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
349
350 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
351 {
352   switch (bg) {
353   case FGLGear::bgLeft:
354     return LeftBrake;
355   case FGLGear::bgRight:
356     return RightBrake;
357   case FGLGear::bgCenter:
358     return CenterBrake;
359   default:
360     cerr << "GetBrake asked to return a bogus brake value" << endl;
361   }
362   return 0.0;
363 }
364
365 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366
367 string FGFCS::GetComponentStrings(void)
368 {
369   unsigned int comp;
370   string CompStrings = "";
371   bool firstime = true;
372
373   for (comp = 0; comp < Components.size(); comp++) {
374     if (firstime) firstime = false;
375     else          CompStrings += ", ";
376
377     CompStrings += Components[comp]->GetName();
378   }
379
380   return CompStrings;
381 }
382
383 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
384
385 string FGFCS::GetComponentValues(void)
386 {
387   unsigned int comp;
388   string CompValues = "";
389   char buffer[10];
390   bool firstime = true;
391
392   for (comp = 0; comp < Components.size(); comp++) {
393     if (firstime) firstime = false;
394     else          CompValues += ", ";
395
396     sprintf(buffer, "%9.6f", Components[comp]->GetOutput());
397     CompValues += string(buffer);
398   }
399
400   return CompValues;
401 }
402
403 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404
405 void FGFCS::AddThrottle(void)
406 {
407   ThrottleCmd.push_back(0.0);
408   ThrottlePos.push_back(0.0);
409   MixtureCmd.push_back(0.0);     // assume throttle and mixture are coupled
410   MixturePos.push_back(0.0);
411   PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
412   PropAdvance.push_back(0.0);
413 }
414
415 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416
417 void FGFCS::Normalize(void) {
418   
419   //not all of these are guaranteed to be defined for every model
420   //those that are have an index >=0 in the ToNormalize array
421   //ToNormalize is filled in Load()
422   
423   if( ToNormalize[iDe] > -1 ) {
424     DePos[ofNorm] = Components[ToNormalize[iDe]]->GetOutputPct();
425   }
426   
427   if( ToNormalize[iDaL] > -1 ) {
428     DaLPos[ofNorm] = Components[ToNormalize[iDaL]]->GetOutputPct();
429   }
430   
431   if( ToNormalize[iDaR] > -1 ) {
432     DaRPos[ofNorm] = Components[ToNormalize[iDaR]]->GetOutputPct();
433   }
434
435   if( ToNormalize[iDr] > -1 ) {
436     DrPos[ofNorm] = Components[ToNormalize[iDr]]->GetOutputPct();
437   }
438        
439   if( ToNormalize[iDsb] > -1 ) { 
440     DsbPos[ofNorm] = Components[ToNormalize[iDsb]]->GetOutputPct();
441   }
442   
443   if( ToNormalize[iDsp] > -1 ) {
444     DspPos[ofNorm] = Components[ToNormalize[iDsp]]->GetOutputPct();
445   }
446   
447   if( ToNormalize[iDf] > -1 ) {
448     DfPos[ofNorm] = Components[ToNormalize[iDf]]->GetOutputPct();
449   }
450   
451   DePos[ofMag]  = fabs(DePos[ofRad]);
452   DaLPos[ofMag] = fabs(DaLPos[ofRad]);
453   DaRPos[ofMag] = fabs(DaRPos[ofRad]);
454   DrPos[ofMag]  = fabs(DrPos[ofRad]);
455   DsbPos[ofMag] = fabs(DsbPos[ofRad]);
456   DspPos[ofMag] = fabs(DspPos[ofRad]);
457   DfPos[ofMag]  = fabs(DfPos[ofRad]);
458    
459 }  
460     
461 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462
463 void FGFCS::bind(void){
464   PropertyManager->Tie("fcs/aileron-cmd-norm", this,
465                        &FGFCS::GetDaCmd,
466                        &FGFCS::SetDaCmd,
467                        true);
468   PropertyManager->Tie("fcs/elevator-cmd-norm", this,
469                        &FGFCS::GetDeCmd,
470                        &FGFCS::SetDeCmd,
471                        true);
472   PropertyManager->Tie("fcs/rudder-cmd-norm", this,
473                        &FGFCS::GetDrCmd,
474                        &FGFCS::SetDrCmd,
475                        true);
476   PropertyManager->Tie("fcs/flap-cmd-norm", this,
477                        &FGFCS::GetDfCmd,
478                        &FGFCS::SetDfCmd,
479                        true);
480   PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
481                        &FGFCS::GetDsbCmd,
482                        &FGFCS::SetDsbCmd,
483                        true);
484   PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
485                        &FGFCS::GetDspCmd,
486                        &FGFCS::SetDspCmd,
487                        true);
488   PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
489                        &FGFCS::GetPitchTrimCmd,
490                        &FGFCS::SetPitchTrimCmd,
491                        true);
492   PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
493                        &FGFCS::GetYawTrimCmd,
494                        &FGFCS::SetYawTrimCmd,
495                        true);
496   PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
497                        &FGFCS::GetRollTrimCmd,
498                        &FGFCS::SetRollTrimCmd,
499                        true);
500   PropertyManager->Tie("gear/gear-cmd-norm", this,
501                        &FGFCS::GetGearCmd,
502                        &FGFCS::SetGearCmd,
503                        true);
504   
505   PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
506                        &FGFCS::GetDaLPos,
507                        &FGFCS::SetDaLPos,
508                        true);
509   PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
510                        &FGFCS::GetDaLPos,
511                        &FGFCS::SetDaLPos,
512                        true);
513   PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
514                        &FGFCS::GetDaLPos,
515                        &FGFCS::SetDaLPos,
516                        true);
517  
518   PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
519                        &FGFCS::GetDaRPos,
520                        &FGFCS::SetDaRPos,
521                        true);
522   PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
523                        &FGFCS::GetDaRPos,
524                        &FGFCS::SetDaRPos,
525                        true);
526   PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
527                        &FGFCS::GetDaRPos,
528                        &FGFCS::SetDaRPos,
529                        true);
530   
531   PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
532                        &FGFCS::GetDePos,
533                        &FGFCS::SetDePos,
534                        true );
535   PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
536                        &FGFCS::GetDePos,                       
537                        &FGFCS::SetDePos,
538                        true );
539   PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
540                        &FGFCS::GetDePos,
541                        &FGFCS::SetDePos,
542                        true );
543   
544   PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
545                        &FGFCS::GetDrPos,
546                        &FGFCS::SetDrPos,
547                        true);
548   PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
549                        &FGFCS::GetDrPos,
550                        &FGFCS::SetDrPos,
551                        true);
552   PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
553                        &FGFCS::GetDrPos,
554                        &FGFCS::SetDrPos,
555                        true);
556                        
557   PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
558                        &FGFCS::GetDfPos,
559                        &FGFCS::SetDfPos,
560                        true);
561   PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
562                        &FGFCS::GetDfPos,
563                        &FGFCS::SetDfPos,
564                        true);
565   
566   PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
567                        &FGFCS::GetDsbPos,
568                        &FGFCS::SetDsbPos,
569                        true);
570   PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
571                        &FGFCS::GetDsbPos,
572                        &FGFCS::SetDsbPos,
573                        true);
574   PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
575                        &FGFCS::GetDsbPos,
576                        &FGFCS::SetDsbPos,
577                        true);
578                        
579   PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
580                        &FGFCS::GetDspPos,
581                        &FGFCS::SetDspPos,
582                        true);
583   PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
584                        &FGFCS::GetDspPos,
585                        &FGFCS::SetDspPos,
586                        true);
587   PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
588                        &FGFCS::GetDspPos,
589                        &FGFCS::SetDspPos,
590                        true);
591                        
592   PropertyManager->Tie("gear/gear-pos-norm", this,
593                        &FGFCS::GetGearPos,
594                        &FGFCS::SetGearPos,
595                        true);
596 }
597
598 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599
600 void FGFCS::unbind(void){
601   PropertyManager->Untie("fcs/aileron-cmd-norm");
602   PropertyManager->Untie("fcs/elevator-cmd-norm");
603   PropertyManager->Untie("fcs/rudder-cmd-norm");
604   PropertyManager->Untie("fcs/flap-cmd-norm");
605   PropertyManager->Untie("fcs/speedbrake-cmd-norm");
606   PropertyManager->Untie("fcs/spoiler-cmd-norm");
607   PropertyManager->Untie("fcs/pitch-trim-cmd-norm");
608   PropertyManager->Untie("fcs/roll-trim-cmd-norm");
609   PropertyManager->Untie("fcs/yaw-trim-cmd-norm");
610   PropertyManager->Untie("gear/gear-cmd-norm");
611   PropertyManager->Untie("fcs/left-aileron-pos-rad");
612   PropertyManager->Untie("fcs/mag-left-aileron-pos-rad");
613   PropertyManager->Untie("fcs/left-aileron-pos-norm");
614   PropertyManager->Untie("fcs/right-aileron-pos-rad");
615   PropertyManager->Untie("fcs/mag-right-aileron-pos-rad");
616   PropertyManager->Untie("fcs/right-aileron-pos-norm");
617   PropertyManager->Untie("fcs/elevator-pos-rad");
618   PropertyManager->Untie("fcs/mag-elevator-pos-rad");
619   PropertyManager->Untie("fcs/elevator-pos-norm");
620   PropertyManager->Untie("fcs/rudder-pos-rad");
621   PropertyManager->Untie("fcs/mag-rudder-pos-rad");
622   PropertyManager->Untie("fcs/rudder-pos-norm");
623   PropertyManager->Untie("fcs/flap-pos-deg");
624   PropertyManager->Untie("fcs/flap-pos-norm");
625   PropertyManager->Untie("fcs/speedbrake-pos-rad");
626   PropertyManager->Untie("fcs/mag-speedbrake-pos-rad");
627   PropertyManager->Untie("fcs/speedbrake-pos-norm");
628   PropertyManager->Untie("fcs/spoiler-pos-rad");
629   PropertyManager->Untie("fcs/mag-spoiler-pos-rad");
630   PropertyManager->Untie("fcs/spoiler-pos-norm");
631   PropertyManager->Untie("gear/gear-pos-norm");
632 }
633
634
635
636 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
637 //    The bitmasked value choices are as follows:
638 //    unset: In this case (the default) JSBSim would only print
639 //       out the normally expected messages, essentially echoing
640 //       the config files as they are read. If the environment
641 //       variable is not set, debug_lvl is set to 1 internally
642 //    0: This requests JSBSim not to output any messages
643 //       whatsoever.
644 //    1: This value explicity requests the normal JSBSim
645 //       startup messages
646 //    2: This value asks for a message to be printed out when
647 //       a class is instantiated
648 //    4: When this value is set, a message is displayed when a
649 //       FGModel object executes its Run() method
650 //    8: When this value is set, various runtime state variables
651 //       are printed out periodically
652 //    16: When set various parameters are sanity checked and
653 //       a message is printed out when they go out of bounds
654
655 void FGFCS::Debug(int from)
656 {
657   if (debug_lvl <= 0) return;
658
659   if (debug_lvl & 1) { // Standard console startup message output
660     if (from == 0) { // Constructor
661
662     }
663   }
664   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
665     if (from == 0) cout << "Instantiated: FGFCS" << endl;
666     if (from == 1) cout << "Destroyed:    FGFCS" << endl;
667   }
668   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
669   }
670   if (debug_lvl & 8 ) { // Runtime state variables
671   }
672   if (debug_lvl & 16) { // Sanity checking
673   }
674   if (debug_lvl & 64) {
675     if (from == 0) { // Constructor
676       cout << IdSrc << endl;
677       cout << IdHdr << endl;
678     }
679   }
680 }
681