5
5
Date started: 09/12/2000
6
6
Purpose: This module models weight and balance
8
------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) --------------
8
------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) --------------
10
10
This program is free software; you can redistribute it and/or modify it under
11
11
the terms of the GNU Lesser General Public License as published by the Free Software
41
41
#include "FGMassBalance.h"
42
42
#include "FGPropulsion.h"
43
43
#include "FGBuoyantForces.h"
44
#include <input_output/FGPropertyManager.h>
44
#include "input_output/FGPropertyManager.h"
96
106
string element_name = "";
97
107
double bixx, biyy, bizz, bixy, bixz, biyz;
109
FGModel::Load(el); // Perform base class Load.
99
111
bixx = biyy = bizz = bixy = bixz = biyz = 0.0;
100
112
if (el->FindElement("ixx"))
101
113
bixx = el->FindElementValueAsNumberConvertTo("ixx", "SLUG*FT2");
130
142
element = el->FindNextElement("pointmass");
145
double ChildFDMWeight = 0.0;
146
for (int fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) {
147
if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
133
150
Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
134
+ BuoyantForces->GetGasMass()*slugtolb;
151
+ BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
136
153
Mass = lbtoslug*Weight;
155
FGModel::PostLoad(el);
149
168
if (FGModel::Run()) return true;
150
169
if (FDMExec->Holding()) return false;
173
double ChildFDMWeight = 0.0;
174
for (int fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) {
175
if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
152
178
Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
153
+ BuoyantForces->GetGasMass()*slugtolb;
179
+ BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
155
181
Mass = lbtoslug*Weight;
160
186
+ GetPointMassMoment()
161
187
+ BuoyantForces->GetGasMassMoment()) / Weight;
189
// Track frame-by-frame delta CG, and move the EOM-tracked location
191
if (vLastXYZcg.Magnitude() == 0.0) vLastXYZcg = vXYZcg;
192
vDeltaXYZcg = vXYZcg - vLastXYZcg;
193
vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg);
195
Propagate->NudgeBodyLocation(vDeltaXYZcgBody);
163
197
// Calculate new total moments of inertia
165
199
// At first it is the base configuration inertia matrix ...
315
351
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
353
void FGMassBalance::PointMass::bind(FGPropertyManager* PropertyManager, int num) {
354
string tmp = CreateIndexedPropertyName("inertia/pointmass-weight-lbs", num);
355
PropertyManager->Tie( tmp.c_str(), this, &PointMass::GetPointMassWeight,
356
&PointMass::SetPointMassWeight);
358
tmp = CreateIndexedPropertyName("inertia/pointmass-location-X-inches", num);
359
PropertyManager->Tie( tmp.c_str(), this, eX, &PointMass::GetPointMassLocation,
360
&PointMass::SetPointMassLocation);
361
tmp = CreateIndexedPropertyName("inertia/pointmass-location-Y-inches", num);
362
PropertyManager->Tie( tmp.c_str(), this, eY, &PointMass::GetPointMassLocation,
363
&PointMass::SetPointMassLocation);
364
tmp = CreateIndexedPropertyName("inertia/pointmass-location-Z-inches", num);
365
PropertyManager->Tie( tmp.c_str(), this, eZ, &PointMass::GetPointMassLocation,
366
&PointMass::SetPointMassLocation);
369
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316
370
// The bitmasked value choices are as follows:
317
371
// unset: In this case (the default) JSBSim would only print
318
372
// out the normally expected messages, essentially echoing