]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGFCS.cpp
Converted FCS to use property tree internally, documentation updates.
[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) const
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) const
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   string nodeName;
310   for(i=0;i<Components.size();i++) {
311     
312     if( (Components[i]->GetType() == "AEROSURFACE_SCALE" 
313           || Components[i]->GetType() == "KINEMAT")  
314                     && Components[i]->GetOutputNode() ) { 
315       nodeName= Components[i]->GetOutputNode()->GetName();  
316       if( nodeName == "elevator-pos-rad" ) {
317         ToNormalize[iDe]=i;
318       } else if ( nodeName  == "left-aileron-pos-rad" 
319                    || nodeName == "aileron-pos-rad" ) {
320         ToNormalize[iDaL]=i;
321       } else if ( nodeName == "right-aileron-pos-rad" ) {
322         ToNormalize[iDaR]=i;
323       } else if ( nodeName == "rudder-pos-rad" ) {
324         ToNormalize[iDr]=i;
325       } else if ( nodeName == "speedbrake-pos-rad" ) {
326         ToNormalize[iDsb]=i;
327       } else if ( nodeName == "spoiler-pos-rad" ) {
328         ToNormalize[iDsp]=i;
329       } else if ( nodeName == "flaps-pos-deg" ) {
330         ToNormalize[iDf]=i;
331       }
332     }
333   }     
334   
335   bindModel();
336   
337   return true;
338 }
339
340 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341
342 double FGFCS::GetComponentOutput(int idx) {
343   return Components[idx]->GetOutput();
344 }
345
346 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
347
348 string FGFCS::GetComponentName(int idx) {
349   return Components[idx]->GetName();
350 }
351
352 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
353
354 double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
355 {
356   switch (bg) {
357   case FGLGear::bgLeft:
358     return LeftBrake;
359   case FGLGear::bgRight:
360     return RightBrake;
361   case FGLGear::bgCenter:
362     return CenterBrake;
363   default:
364     cerr << "GetBrake asked to return a bogus brake value" << endl;
365   }
366   return 0.0;
367 }
368
369 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370
371 string FGFCS::GetComponentStrings(void)
372 {
373   unsigned int comp;
374   string CompStrings = "";
375   bool firstime = true;
376
377   for (comp = 0; comp < Components.size(); comp++) {
378     if (firstime) firstime = false;
379     else          CompStrings += ", ";
380
381     CompStrings += Components[comp]->GetName();
382   }
383
384   return CompStrings;
385 }
386
387 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388
389 string FGFCS::GetComponentValues(void)
390 {
391   unsigned int comp;
392   string CompValues = "";
393   char buffer[10];
394   bool firstime = true;
395
396   for (comp = 0; comp < Components.size(); comp++) {
397     if (firstime) firstime = false;
398     else          CompValues += ", ";
399
400     sprintf(buffer, "%9.6f", Components[comp]->GetOutput());
401     CompValues += string(buffer);
402   }
403
404   return CompValues;
405 }
406
407 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
408
409 void FGFCS::AddThrottle(void)
410 {
411   ThrottleCmd.push_back(0.0);
412   ThrottlePos.push_back(0.0);
413   MixtureCmd.push_back(0.0);     // assume throttle and mixture are coupled
414   MixturePos.push_back(0.0);
415   PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
416   PropAdvance.push_back(0.0);
417 }
418
419 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
420
421 void FGFCS::Normalize(void) {
422   
423   //not all of these are guaranteed to be defined for every model
424   //those that are have an index >=0 in the ToNormalize array
425   //ToNormalize is filled in Load()
426   
427   if( ToNormalize[iDe] > -1 ) {
428     DePos[ofNorm] = Components[ToNormalize[iDe]]->GetOutputPct();
429   }
430   
431   if( ToNormalize[iDaL] > -1 ) {
432     DaLPos[ofNorm] = Components[ToNormalize[iDaL]]->GetOutputPct();
433   }
434   
435   if( ToNormalize[iDaR] > -1 ) {
436     DaRPos[ofNorm] = Components[ToNormalize[iDaR]]->GetOutputPct();
437   }
438
439   if( ToNormalize[iDr] > -1 ) {
440     DrPos[ofNorm] = Components[ToNormalize[iDr]]->GetOutputPct();
441   }
442        
443   if( ToNormalize[iDsb] > -1 ) { 
444     DsbPos[ofNorm] = Components[ToNormalize[iDsb]]->GetOutputPct();
445   }
446   
447   if( ToNormalize[iDsp] > -1 ) {
448     DspPos[ofNorm] = Components[ToNormalize[iDsp]]->GetOutputPct();
449   }
450   
451   if( ToNormalize[iDf] > -1 ) {
452     DfPos[ofNorm] = Components[ToNormalize[iDf]]->GetOutputPct();
453   }
454   
455   DePos[ofMag]  = fabs(DePos[ofRad]);
456   DaLPos[ofMag] = fabs(DaLPos[ofRad]);
457   DaRPos[ofMag] = fabs(DaRPos[ofRad]);
458   DrPos[ofMag]  = fabs(DrPos[ofRad]);
459   DsbPos[ofMag] = fabs(DsbPos[ofRad]);
460   DspPos[ofMag] = fabs(DspPos[ofRad]);
461   DfPos[ofMag]  = fabs(DfPos[ofRad]);
462    
463 }  
464     
465 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
466
467 void FGFCS::bind(void){
468   PropertyManager->Tie("fcs/aileron-cmd-norm", this,
469                        &FGFCS::GetDaCmd,
470                        &FGFCS::SetDaCmd,
471                        true);
472   PropertyManager->Tie("fcs/elevator-cmd-norm", this,
473                        &FGFCS::GetDeCmd,
474                        &FGFCS::SetDeCmd,
475                        true);
476   PropertyManager->Tie("fcs/rudder-cmd-norm", this,
477                        &FGFCS::GetDrCmd,
478                        &FGFCS::SetDrCmd,
479                        true);
480   PropertyManager->Tie("fcs/flap-cmd-norm", this,
481                        &FGFCS::GetDfCmd,
482                        &FGFCS::SetDfCmd,
483                        true);
484   PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
485                        &FGFCS::GetDsbCmd,
486                        &FGFCS::SetDsbCmd,
487                        true);
488   PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
489                        &FGFCS::GetDspCmd,
490                        &FGFCS::SetDspCmd,
491                        true);
492   PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
493                        &FGFCS::GetPitchTrimCmd,
494                        &FGFCS::SetPitchTrimCmd,
495                        true);
496   PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
497                        &FGFCS::GetYawTrimCmd,
498                        &FGFCS::SetYawTrimCmd,
499                        true);
500   PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
501                        &FGFCS::GetRollTrimCmd,
502                        &FGFCS::SetRollTrimCmd,
503                        true);
504   PropertyManager->Tie("gear/gear-cmd-norm", this,
505                        &FGFCS::GetGearCmd,
506                        &FGFCS::SetGearCmd,
507                        true);
508   
509   PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
510                        &FGFCS::GetDaLPos,
511                        &FGFCS::SetDaLPos,
512                        true);
513   PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
514                        &FGFCS::GetDaLPos,
515                        &FGFCS::SetDaLPos,
516                        true);
517   PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
518                        &FGFCS::GetDaLPos,
519                        &FGFCS::SetDaLPos,
520                        true);
521  
522   PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
523                        &FGFCS::GetDaRPos,
524                        &FGFCS::SetDaRPos,
525                        true);
526   PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
527                        &FGFCS::GetDaRPos,
528                        &FGFCS::SetDaRPos,
529                        true);
530   PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
531                        &FGFCS::GetDaRPos,
532                        &FGFCS::SetDaRPos,
533                        true);
534   
535   PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
536                        &FGFCS::GetDePos,
537                        &FGFCS::SetDePos,
538                        true );
539   PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
540                        &FGFCS::GetDePos,                       
541                        &FGFCS::SetDePos,
542                        true );
543   PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
544                        &FGFCS::GetDePos,
545                        &FGFCS::SetDePos,
546                        true );
547   
548   PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
549                        &FGFCS::GetDrPos,
550                        &FGFCS::SetDrPos,
551                        true);
552   PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
553                        &FGFCS::GetDrPos,
554                        &FGFCS::SetDrPos,
555                        true);
556   PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
557                        &FGFCS::GetDrPos,
558                        &FGFCS::SetDrPos,
559                        true);
560                        
561   PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
562                        &FGFCS::GetDfPos,
563                        &FGFCS::SetDfPos,
564                        true);
565   PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
566                        &FGFCS::GetDfPos,
567                        &FGFCS::SetDfPos,
568                        true);
569   
570   PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
571                        &FGFCS::GetDsbPos,
572                        &FGFCS::SetDsbPos,
573                        true);
574   PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
575                        &FGFCS::GetDsbPos,
576                        &FGFCS::SetDsbPos,
577                        true);
578   PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
579                        &FGFCS::GetDsbPos,
580                        &FGFCS::SetDsbPos,
581                        true);
582                        
583   PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
584                        &FGFCS::GetDspPos,
585                        &FGFCS::SetDspPos,
586                        true);
587   PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
588                        &FGFCS::GetDspPos,
589                        &FGFCS::SetDspPos,
590                        true);
591   PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
592                        &FGFCS::GetDspPos,
593                        &FGFCS::SetDspPos,
594                        true);
595                        
596   PropertyManager->Tie("gear/gear-pos-norm", this,
597                        &FGFCS::GetGearPos,
598                        &FGFCS::SetGearPos,
599                        true);
600 }
601 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
602
603 void FGFCS::bindModel(void){
604   unsigned i;
605   for(i=0;i<ThrottleCmd.size();i++) {
606     PropertyManager->Tie("fcs/throttle-cmd-norm",this,i,
607                           &FGFCS::GetThrottleCmd,
608                           &FGFCS::SetThrottleCmd,
609                           true );
610     PropertyManager->Tie("fcs/throttle-pos-norm",this,i,
611                           &FGFCS::GetThrottlePos,
612                           &FGFCS::SetThrottlePos,
613                           true );
614     if( MixtureCmd.size() > i ) {
615       PropertyManager->Tie("fcs/mixture-cmd-norm",this,i,
616                             &FGFCS::GetMixtureCmd,
617                             &FGFCS::SetMixtureCmd,
618                             true );
619       PropertyManager->Tie("fcs/mixture-pos-norm",this,i,
620                             &FGFCS::GetMixturePos,
621                             &FGFCS::SetMixturePos,
622                             true );
623     }
624     if( PropAdvanceCmd.size() > i ) {
625       PropertyManager->Tie("fcs/advance-cmd-norm",this,i,
626                             &FGFCS::GetPropAdvanceCmd,
627                             &FGFCS::SetPropAdvanceCmd,
628                             true );
629       PropertyManager->Tie("fcs/advance-pos-norm",this,i,
630                             &FGFCS::GetPropAdvance,
631                             &FGFCS::SetPropAdvance,
632                             true );
633     }
634   }
635 }                            
636                           
637 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638
639 void FGFCS::unbind(void){
640   PropertyManager->Untie("fcs/aileron-cmd-norm");
641   PropertyManager->Untie("fcs/elevator-cmd-norm");
642   PropertyManager->Untie("fcs/rudder-cmd-norm");
643   PropertyManager->Untie("fcs/flap-cmd-norm");
644   PropertyManager->Untie("fcs/speedbrake-cmd-norm");
645   PropertyManager->Untie("fcs/spoiler-cmd-norm");
646   PropertyManager->Untie("fcs/pitch-trim-cmd-norm");
647   PropertyManager->Untie("fcs/roll-trim-cmd-norm");
648   PropertyManager->Untie("fcs/yaw-trim-cmd-norm");
649   PropertyManager->Untie("gear/gear-cmd-norm");
650   PropertyManager->Untie("fcs/left-aileron-pos-rad");
651   PropertyManager->Untie("fcs/mag-left-aileron-pos-rad");
652   PropertyManager->Untie("fcs/left-aileron-pos-norm");
653   PropertyManager->Untie("fcs/right-aileron-pos-rad");
654   PropertyManager->Untie("fcs/mag-right-aileron-pos-rad");
655   PropertyManager->Untie("fcs/right-aileron-pos-norm");
656   PropertyManager->Untie("fcs/elevator-pos-rad");
657   PropertyManager->Untie("fcs/mag-elevator-pos-rad");
658   PropertyManager->Untie("fcs/elevator-pos-norm");
659   PropertyManager->Untie("fcs/rudder-pos-rad");
660   PropertyManager->Untie("fcs/mag-rudder-pos-rad");
661   PropertyManager->Untie("fcs/rudder-pos-norm");
662   PropertyManager->Untie("fcs/flap-pos-deg");
663   PropertyManager->Untie("fcs/flap-pos-norm");
664   PropertyManager->Untie("fcs/speedbrake-pos-rad");
665   PropertyManager->Untie("fcs/mag-speedbrake-pos-rad");
666   PropertyManager->Untie("fcs/speedbrake-pos-norm");
667   PropertyManager->Untie("fcs/spoiler-pos-rad");
668   PropertyManager->Untie("fcs/mag-spoiler-pos-rad");
669   PropertyManager->Untie("fcs/spoiler-pos-norm");
670   PropertyManager->Untie("gear/gear-pos-norm");
671 }
672
673
674
675 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
676 //    The bitmasked value choices are as follows:
677 //    unset: In this case (the default) JSBSim would only print
678 //       out the normally expected messages, essentially echoing
679 //       the config files as they are read. If the environment
680 //       variable is not set, debug_lvl is set to 1 internally
681 //    0: This requests JSBSim not to output any messages
682 //       whatsoever.
683 //    1: This value explicity requests the normal JSBSim
684 //       startup messages
685 //    2: This value asks for a message to be printed out when
686 //       a class is instantiated
687 //    4: When this value is set, a message is displayed when a
688 //       FGModel object executes its Run() method
689 //    8: When this value is set, various runtime state variables
690 //       are printed out periodically
691 //    16: When set various parameters are sanity checked and
692 //       a message is printed out when they go out of bounds
693
694 void FGFCS::Debug(int from)
695 {
696   if (debug_lvl <= 0) return;
697
698   if (debug_lvl & 1) { // Standard console startup message output
699     if (from == 0) { // Constructor
700
701     }
702   }
703   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
704     if (from == 0) cout << "Instantiated: FGFCS" << endl;
705     if (from == 1) cout << "Destroyed:    FGFCS" << endl;
706   }
707   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
708   }
709   if (debug_lvl & 8 ) { // Runtime state variables
710   }
711   if (debug_lvl & 16) { // Sanity checking
712   }
713   if (debug_lvl & 64) {
714     if (from == 0) { // Constructor
715       cout << IdSrc << endl;
716       cout << IdHdr << endl;
717     }
718   }
719 }
720