44 #include "FGOutputSocket.h" 45 #include "FGFDMExec.h" 46 #include "models/FGAerodynamics.h" 47 #include "models/FGAccelerations.h" 48 #include "models/FGAircraft.h" 49 #include "models/FGAtmosphere.h" 50 #include "models/FGAuxiliary.h" 51 #include "models/FGPropulsion.h" 52 #include "models/FGMassBalance.h" 53 #include "models/FGPropagate.h" 54 #include "models/FGGroundReactions.h" 55 #include "models/FGFCS.h" 56 #include "models/atmosphere/FGWinds.h" 57 #include "input_output/FGXMLElement.h" 63 IDENT(IdSrc,
"$Id: FGOutputSocket.cpp,v 1.9 2014/02/17 05:01:22 jberndt Exp $");
64 IDENT(IdHdr,ID_OUTPUTSOCKET);
88 size_t dot_pos = fname.find(
':', 0);
89 size_t slash_pos = fname.find(
'/', 0);
91 string name = fname.substr(0, dot_pos);
94 if(dot_pos + 1 < slash_pos)
95 proto = fname.substr(dot_pos + 1, slash_pos - dot_pos - 1);
98 if(slash_pos < string::npos)
99 port = fname.substr(slash_pos + 1, string::npos);
102 Name = name +
":" + port +
"/" + proto;
107 SockPort = atoi(port.c_str());
110 SockProtocol = FGfdmSocket::ptUDP;
112 SockProtocol = FGfdmSocket::ptTCP;
135 socket =
new FGfdmSocket(SockName, SockPort, SockProtocol);
137 if (socket == 0)
return false;
138 if (!socket->GetConnectStatus())
return false;
150 void FGOutputSocket::PrintHeaders(
void)
155 socket->Clear(
"<LABELS>");
156 socket->Append(
"Time");
159 socket->Append(
"Aileron Command");
160 socket->Append(
"Elevator Command");
161 socket->Append(
"Rudder Command");
162 socket->Append(
"Flap Command");
163 socket->Append(
"Left Aileron Position");
164 socket->Append(
"Right Aileron Position");
165 socket->Append(
"Elevator Position");
166 socket->Append(
"Rudder Position");
167 socket->Append(
"Flap Position");
174 socket->Append(
"PDot");
175 socket->Append(
"QDot");
176 socket->Append(
"RDot");
180 socket->Append(
"QBar");
181 socket->Append(
"Vtotal");
182 socket->Append(
"UBody");
183 socket->Append(
"VBody");
184 socket->Append(
"WBody");
185 socket->Append(
"UAero");
186 socket->Append(
"VAero");
187 socket->Append(
"WAero");
188 socket->Append(
"Vn");
189 socket->Append(
"Ve");
190 socket->Append(
"Vd");
194 socket->Append(
"F_Drag");
195 socket->Append(
"F_Side");
196 socket->Append(
"F_Lift");
197 socket->Append(
"LoD");
198 socket->Append(
"Fx");
199 socket->Append(
"Fy");
200 socket->Append(
"Fz");
210 socket->Append(
"Rho");
211 socket->Append(
"SL pressure");
212 socket->Append(
"Ambient pressure");
213 socket->Append(
"Turbulence Magnitude");
214 socket->Append(
"Turbulence Direction");
215 socket->Append(
"NWind");
216 socket->Append(
"EWind");
217 socket->Append(
"DWind");
221 socket->Append(
"Ixx");
222 socket->Append(
"Ixy");
223 socket->Append(
"Ixz");
224 socket->Append(
"Iyx");
225 socket->Append(
"Iyy");
226 socket->Append(
"Iyz");
227 socket->Append(
"Izx");
228 socket->Append(
"Izy");
229 socket->Append(
"Izz");
230 socket->Append(
"Mass");
231 socket->Append(
"Xcg");
232 socket->Append(
"Ycg");
233 socket->Append(
"Zcg");
237 socket->Append(
"Altitude");
238 socket->Append(
"Phi (deg)");
239 socket->Append(
"Tht (deg)");
240 socket->Append(
"Psi (deg)");
241 socket->Append(
"Alpha (deg)");
242 socket->Append(
"Beta (deg)");
243 socket->Append(
"Latitude (deg)");
244 socket->Append(
"Longitude (deg)");
249 if (scratch.length() != 0) socket->Append(scratch);
252 if (SubSystems &
ssFCS) {
254 if (scratch.length() != 0) socket->Append(scratch);
258 socket->Append(GroundReactions->GetGroundReactionStrings(
","));
261 socket->Append(Propulsion->GetPropulsionStrings(
","));
263 if (OutputProperties.size() > 0) {
264 for (
unsigned int i=0;i<OutputProperties.size();i++)
265 if (OutputCaptions[i].size() > 0) {
266 socket->Append(OutputCaptions[i]);
268 socket->Append(OutputProperties[i]->GetPrintableName());
279 string asciiData, scratch;
281 if (socket == 0)
return;
282 if (!socket->GetConnectStatus())
return;
299 socket->Append(radtodeg*Propagate->
GetPQR(eP));
300 socket->Append(radtodeg*Propagate->
GetPQR(eQ));
301 socket->Append(radtodeg*Propagate->
GetPQR(eR));
302 socket->Append(radtodeg*Accelerations->
GetPQRdot(eP));
303 socket->Append(radtodeg*Accelerations->
GetPQRdot(eQ));
304 socket->Append(radtodeg*Accelerations->
GetPQRdot(eR));
307 socket->Append(Auxiliary->Getqbar());
308 socket->Append(Auxiliary->
GetVt());
309 socket->Append(Propagate->
GetUVW(eU));
310 socket->Append(Propagate->
GetUVW(eV));
311 socket->Append(Propagate->
GetUVW(eW));
312 socket->Append(Auxiliary->GetAeroUVW(eU));
313 socket->Append(Auxiliary->GetAeroUVW(eV));
314 socket->Append(Auxiliary->GetAeroUVW(eW));
315 socket->Append(Propagate->
GetVel(eNorth));
316 socket->Append(Propagate->
GetVel(eEast));
317 socket->Append(Propagate->
GetVel(eDown));
320 socket->Append(Aerodynamics->
GetvFw()(eDrag));
321 socket->Append(Aerodynamics->
GetvFw()(eSide));
322 socket->Append(Aerodynamics->
GetvFw()(eLift));
323 socket->Append(Aerodynamics->
GetLoD());
324 socket->Append(Aircraft->GetForces(eX));
325 socket->Append(Aircraft->GetForces(eY));
326 socket->Append(Aircraft->GetForces(eZ));
329 socket->Append(Aircraft->GetMoments(eL));
330 socket->Append(Aircraft->GetMoments(eM));
331 socket->Append(Aircraft->GetMoments(eN));
335 socket->Append(Atmosphere->GetPressureSL());
337 socket->Append(Winds->GetTurbMagnitude());
338 socket->Append(Winds->GetTurbDirection());
342 socket->Append(MassBalance->GetJ()(1,1));
343 socket->Append(MassBalance->GetJ()(1,2));
344 socket->Append(MassBalance->GetJ()(1,3));
345 socket->Append(MassBalance->GetJ()(2,1));
346 socket->Append(MassBalance->GetJ()(2,2));
347 socket->Append(MassBalance->GetJ()(2,3));
348 socket->Append(MassBalance->GetJ()(3,1));
349 socket->Append(MassBalance->GetJ()(3,2));
350 socket->Append(MassBalance->GetJ()(3,3));
351 socket->Append(MassBalance->GetMass());
352 socket->Append(MassBalance->GetXYZcg()(eX));
353 socket->Append(MassBalance->GetXYZcg()(eY));
354 socket->Append(MassBalance->GetXYZcg()(eZ));
358 socket->Append(radtodeg*Propagate->
GetEuler(ePhi));
359 socket->Append(radtodeg*Propagate->
GetEuler(eTht));
360 socket->Append(radtodeg*Propagate->
GetEuler(ePsi));
361 socket->Append(Auxiliary->Getalpha(inDegrees));
362 socket->Append(Auxiliary->Getbeta(inDegrees));
368 if (scratch.length() != 0) socket->Append(scratch);
370 if (SubSystems &
ssFCS) {
372 if (scratch.length() != 0) socket->Append(scratch);
375 socket->Append(GroundReactions->GetGroundReactionValues(
","));
378 socket->Append(Propulsion->GetPropulsionValues(
","));
381 for (
unsigned int i=0;i<OutputProperties.size();i++) {
382 socket->Append(OutputProperties[i]->getDoubleValue());
394 if (socket == 0)
return;
397 asciiData = string(
"<STATUS>") + out_str;
398 socket->Append(asciiData.c_str());
Subsystem: Propagate (= 512)
double GetLoD(void) const
Retrieves the lift over drag ratio.
double GetDfPos(int form=ofRad) const
Gets the flaps position.
double GetDeCmd(void) const
Gets the elevator command.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
double GetDePos(int form=ofRad) const
Gets the elevator position.
double GetDfCmd(void) const
Gets the flaps command.
virtual bool InitModel(void)
Init the output model according to its configitation.
virtual const FGColumnVector3 & GetTotalWindNED(void) const
Retrieves the total wind components in NED frame.
double GetDaLPos(int form=ofRad) const
Gets the left aileron position.
std::string GetAeroFunctionValues(const std::string &delimeter) const
Gets the aero function values.
Subsystem: Aerosurfaces (= 2)
virtual double GetPressure(void) const
Returns the pressure in psf.
double GetAltitudeASL(void) const
Returns the current altitude above sea level.
Subsystem: Velocities (= 8)
const FGColumnVector3 & GetvFw(void) const
Retrieves the aerodynamic forces in the wind axes.
const FGColumnVector3 & GetUVW(void) const
Retrieves the body frame vehicle velocity vector.
const FGColumnVector3 & GetPQR(void) const
Retrieves the body angular rates vector, relative to the ECEF frame.
bool InitModel(void)
Initializes the instance.
std::string Dump(const std::string &delimeter) const
Prints the contents of the vector.
Subsystem: Atmosphere (= 64)
std::string GetAeroFunctionStrings(const std::string &delimeter) const
Gets the strings for the current set of aero functions.
std::string GetComponentValues(const std::string &delimiter) const
Retrieves all component outputs for inclusion in output stream.
virtual bool Load(Element *el)
Init the output directives from an XML file (implement the FGModel interface).
const FGColumnVector3 & GetVel(void) const
Retrieves the velocity vector.
Subsystem: Moments (= 32)
const FGColumnVector3 & GetEuler(void) const
Retrieves the Euler angles that define the vehicle orientation.
std::string GetComponentStrings(const std::string &delimiter) const
Retrieves all component names for inclusion in output stream.
virtual double GetDensity(void) const
Returns the density in slugs/ft^3.
Abstract class to provide functions generic to all the output directives.
double GetDaCmd(void) const
Gets the aileron command.
void Print(void)
Generates the output.
double GetLongitudeDeg() const
Get the longitude.
double GetSimTime(void) const
Returns the cumulative simulation time in seconds.
virtual void SetOutputName(const std::string &name)
Overwrites the name identifier under which the output will be logged.
virtual bool Load(Element *el)
Init the output directives from an XML file.
Subsystem: Ground Reactions (= 1024)
double GetLatitudeDeg() const
Get the latitude.
const FGColumnVector3 & GetPQRdot(void) const
Retrieves the body axis angular acceleration vector.
Subsystem: Mass Properties (= 128)
~FGOutputSocket()
Destructor.
void SocketStatusOutput(const std::string &out_str)
Outputs a status thru the socket.
Encapsulates the JSBSim simulation executive.
Subsystem: Body rates (= 4)
double GetDrCmd(void) const
Gets the rudder command.
Subsystem: Coefficients (= 256)
Subsystem: Propulsion (= 4096)
double GetDaRPos(int form=ofRad) const
Gets the right aileron position.
double GetVt(void) const
Gets the magnitude of total vehicle velocity including wind effects in feet per second.
Encapsulates an object that enables JSBSim to communicate via socket (input and/or output)...
double GetDrPos(int form=ofRad) const
Gets the rudder position.
unsigned int GetNumEngines(void) const
Retrieves the number of engines defined for the aircraft.