]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGFCS.cpp
JSBSim fix:
[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 == "flap-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 {
469   PropertyManager->Tie("fcs/aileron-cmd-norm", this,
470                        &FGFCS::GetDaCmd,
471                        &FGFCS::SetDaCmd,
472                        true);
473   PropertyManager->Tie("fcs/elevator-cmd-norm", this,
474                        &FGFCS::GetDeCmd,
475                        &FGFCS::SetDeCmd,
476                        true);
477   PropertyManager->Tie("fcs/rudder-cmd-norm", this,
478                        &FGFCS::GetDrCmd,
479                        &FGFCS::SetDrCmd,
480                        true);
481   PropertyManager->Tie("fcs/flap-cmd-norm", this,
482                        &FGFCS::GetDfCmd,
483                        &FGFCS::SetDfCmd,
484                        true);
485   PropertyManager->Tie("fcs/speedbrake-cmd-norm", this,
486                        &FGFCS::GetDsbCmd,
487                        &FGFCS::SetDsbCmd,
488                        true);
489   PropertyManager->Tie("fcs/spoiler-cmd-norm", this,
490                        &FGFCS::GetDspCmd,
491                        &FGFCS::SetDspCmd,
492                        true);
493   PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this,
494                        &FGFCS::GetPitchTrimCmd,
495                        &FGFCS::SetPitchTrimCmd,
496                        true);
497   PropertyManager->Tie("fcs/roll-trim-cmd-norm", this,
498                        &FGFCS::GetYawTrimCmd,
499                        &FGFCS::SetYawTrimCmd,
500                        true);
501   PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this,
502                        &FGFCS::GetRollTrimCmd,
503                        &FGFCS::SetRollTrimCmd,
504                        true);
505   PropertyManager->Tie("gear/gear-cmd-norm", this,
506                        &FGFCS::GetGearCmd,
507                        &FGFCS::SetGearCmd,
508                        true);
509   
510   PropertyManager->Tie("fcs/left-aileron-pos-rad", this,ofRad,
511                        &FGFCS::GetDaLPos,
512                        &FGFCS::SetDaLPos,
513                        true);
514   PropertyManager->Tie("fcs/left-aileron-pos-norm", this,ofNorm,
515                        &FGFCS::GetDaLPos,
516                        &FGFCS::SetDaLPos,
517                        true);
518   PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this,ofMag,
519                        &FGFCS::GetDaLPos,
520                        &FGFCS::SetDaLPos,
521                        true);
522  
523   PropertyManager->Tie("fcs/right-aileron-pos-rad", this,ofRad,
524                        &FGFCS::GetDaRPos,
525                        &FGFCS::SetDaRPos,
526                        true);
527   PropertyManager->Tie("fcs/right-aileron-pos-norm", this,ofNorm,
528                        &FGFCS::GetDaRPos,
529                        &FGFCS::SetDaRPos,
530                        true);
531   PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this,ofMag,
532                        &FGFCS::GetDaRPos,
533                        &FGFCS::SetDaRPos,
534                        true);
535   
536   PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad,
537                        &FGFCS::GetDePos,
538                        &FGFCS::SetDePos,
539                        true );
540   PropertyManager->Tie("fcs/elevator-pos-norm", this,ofNorm,
541                        &FGFCS::GetDePos,                       
542                        &FGFCS::SetDePos,
543                        true );
544   PropertyManager->Tie("fcs/mag-elevator-pos-rad", this,ofMag,
545                        &FGFCS::GetDePos,
546                        &FGFCS::SetDePos,
547                        true );
548   
549   PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad,
550                        &FGFCS::GetDrPos,
551                        &FGFCS::SetDrPos,
552                        true);
553   PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm,
554                        &FGFCS::GetDrPos,
555                        &FGFCS::SetDrPos,
556                        true);
557   PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag,
558                        &FGFCS::GetDrPos,
559                        &FGFCS::SetDrPos,
560                        true);
561                        
562   PropertyManager->Tie("fcs/flap-pos-deg", this,ofRad,
563                        &FGFCS::GetDfPos,
564                        &FGFCS::SetDfPos,
565                        true);
566   PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm,
567                        &FGFCS::GetDfPos,
568                        &FGFCS::SetDfPos,
569                        true);
570   
571   PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad,
572                        &FGFCS::GetDsbPos,
573                        &FGFCS::SetDsbPos,
574                        true);
575   PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm,
576                        &FGFCS::GetDsbPos,
577                        &FGFCS::SetDsbPos,
578                        true);
579   PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag,
580                        &FGFCS::GetDsbPos,
581                        &FGFCS::SetDsbPos,
582                        true);
583                        
584   PropertyManager->Tie("fcs/spoiler-pos-rad", this,ofRad,
585                        &FGFCS::GetDspPos,
586                        &FGFCS::SetDspPos,
587                        true);
588   PropertyManager->Tie("fcs/spoiler-pos-norm", this,ofNorm,
589                        &FGFCS::GetDspPos,
590                        &FGFCS::SetDspPos,
591                        true);
592   PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this,ofMag,
593                        &FGFCS::GetDspPos,
594                        &FGFCS::SetDspPos,
595                        true);
596                        
597   PropertyManager->Tie("gear/gear-pos-norm", this,
598                        &FGFCS::GetGearPos,
599                        &FGFCS::SetGearPos,
600                        true);
601 }
602
603 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
604
605 void FGFCS::bindModel(void)
606 {
607   unsigned i;
608
609   for (i=0; i<ThrottleCmd.size(); i++) {
610     PropertyManager->Tie("fcs/throttle-cmd-norm",this,i,
611                           &FGFCS::GetThrottleCmd,
612                           &FGFCS::SetThrottleCmd,
613                           true );
614     PropertyManager->Tie("fcs/throttle-pos-norm",this,i,
615                           &FGFCS::GetThrottlePos,
616                           &FGFCS::SetThrottlePos,
617                           true );
618     if ( MixtureCmd.size() > i ) {
619       PropertyManager->Tie("fcs/mixture-cmd-norm",this,i,
620                             &FGFCS::GetMixtureCmd,
621                             &FGFCS::SetMixtureCmd,
622                             true );
623       PropertyManager->Tie("fcs/mixture-pos-norm",this,i,
624                             &FGFCS::GetMixturePos,
625                             &FGFCS::SetMixturePos,
626                             true );
627     }
628     if ( PropAdvanceCmd.size() > i ) {
629       PropertyManager->Tie("fcs/advance-cmd-norm",this,i,
630                             &FGFCS::GetPropAdvanceCmd,
631                             &FGFCS::SetPropAdvanceCmd,
632                             true );
633       PropertyManager->Tie("fcs/advance-pos-norm",this,i,
634                             &FGFCS::GetPropAdvance,
635                             &FGFCS::SetPropAdvance,
636                             true );
637     }
638   }
639 }                            
640                           
641 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
642
643 void FGFCS::unbind(void)
644 {
645   PropertyManager->Untie("fcs/aileron-cmd-norm");
646   PropertyManager->Untie("fcs/elevator-cmd-norm");
647   PropertyManager->Untie("fcs/rudder-cmd-norm");
648   PropertyManager->Untie("fcs/flap-cmd-norm");
649   PropertyManager->Untie("fcs/speedbrake-cmd-norm");
650   PropertyManager->Untie("fcs/spoiler-cmd-norm");
651   PropertyManager->Untie("fcs/pitch-trim-cmd-norm");
652   PropertyManager->Untie("fcs/roll-trim-cmd-norm");
653   PropertyManager->Untie("fcs/yaw-trim-cmd-norm");
654   PropertyManager->Untie("gear/gear-cmd-norm");
655   PropertyManager->Untie("fcs/left-aileron-pos-rad");
656   PropertyManager->Untie("fcs/mag-left-aileron-pos-rad");
657   PropertyManager->Untie("fcs/left-aileron-pos-norm");
658   PropertyManager->Untie("fcs/right-aileron-pos-rad");
659   PropertyManager->Untie("fcs/mag-right-aileron-pos-rad");
660   PropertyManager->Untie("fcs/right-aileron-pos-norm");
661   PropertyManager->Untie("fcs/elevator-pos-rad");
662   PropertyManager->Untie("fcs/mag-elevator-pos-rad");
663   PropertyManager->Untie("fcs/elevator-pos-norm");
664   PropertyManager->Untie("fcs/rudder-pos-rad");
665   PropertyManager->Untie("fcs/mag-rudder-pos-rad");
666   PropertyManager->Untie("fcs/rudder-pos-norm");
667   PropertyManager->Untie("fcs/flap-pos-deg");
668   PropertyManager->Untie("fcs/flap-pos-norm");
669   PropertyManager->Untie("fcs/speedbrake-pos-rad");
670   PropertyManager->Untie("fcs/mag-speedbrake-pos-rad");
671   PropertyManager->Untie("fcs/speedbrake-pos-norm");
672   PropertyManager->Untie("fcs/spoiler-pos-rad");
673   PropertyManager->Untie("fcs/mag-spoiler-pos-rad");
674   PropertyManager->Untie("fcs/spoiler-pos-norm");
675   PropertyManager->Untie("gear/gear-pos-norm");
676 }
677
678 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
679 //    The bitmasked value choices are as follows:
680 //    unset: In this case (the default) JSBSim would only print
681 //       out the normally expected messages, essentially echoing
682 //       the config files as they are read. If the environment
683 //       variable is not set, debug_lvl is set to 1 internally
684 //    0: This requests JSBSim not to output any messages
685 //       whatsoever.
686 //    1: This value explicity requests the normal JSBSim
687 //       startup messages
688 //    2: This value asks for a message to be printed out when
689 //       a class is instantiated
690 //    4: When this value is set, a message is displayed when a
691 //       FGModel object executes its Run() method
692 //    8: When this value is set, various runtime state variables
693 //       are printed out periodically
694 //    16: When set various parameters are sanity checked and
695 //       a message is printed out when they go out of bounds
696
697 void FGFCS::Debug(int from)
698 {
699   if (debug_lvl <= 0) return;
700
701   if (debug_lvl & 1) { // Standard console startup message output
702     if (from == 0) { // Constructor
703
704     }
705   }
706   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
707     if (from == 0) cout << "Instantiated: FGFCS" << endl;
708     if (from == 1) cout << "Destroyed:    FGFCS" << endl;
709   }
710   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
711   }
712   if (debug_lvl & 8 ) { // Runtime state variables
713   }
714   if (debug_lvl & 16) { // Sanity checking
715   }
716   if (debug_lvl & 64) {
717     if (from == 0) { // Constructor
718       cout << IdSrc << endl;
719       cout << IdHdr << endl;
720     }
721   }
722 }
723