input_output/FGXMLElement.h
input_output/net_fdm.hxx
input_output/FGGroundCallback.h
+ input_output/FGInputType.h
+ input_output/FGInputSocket.h
+ input_output/FGUDPInputSocket.h
input_output/FGOutputFG.h
input_output/FGOutputFile.h
input_output/FGOutputSocket.h
+ input_output/FGUDPOutputSocket.h
input_output/FGOutputTextFile.h
input_output/FGOutputType.h
input_output/FGModelLoader.h
input_output/FGXMLElement.cpp
input_output/FGXMLParse.cpp
input_output/FGfdmSocket.cpp
+ input_output/FGInputType.cpp
+ input_output/FGInputSocket.cpp
+ input_output/FGUDPInputSocket.cpp
input_output/FGOutputFG.cpp
input_output/FGOutputFile.cpp
input_output/FGOutputSocket.cpp
+ input_output/FGUDPOutputSocket.cpp
input_output/FGOutputTextFile.cpp
input_output/FGOutputType.cpp
input_output/FGModelLoader.cpp
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.170 2015/02/07 17:52:36 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.171 2015/02/15 12:03:21 bcoconni Exp $");
IDENT(IdHdr,ID_FDMEXEC);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DeAllocate();
delete instance;
- SetGroundCallback(0);
if (IdFDM == 0) { // Meaning this is no child FDM
if(Root != 0) {
ChildFDMList.clear();
PropertyCatalog.clear();
+
+ SetGroundCallback(0);
if (FDMctr > 0) (*FDMctr)--;
// Initialize models
for (unsigned int i = 0; i < Models.size(); i++) {
- // The Output model must not be initialized prior to IC loading
- if (i == eOutput) continue;
+ // The Input/Output models must not be initialized prior to IC loading
+ if (i == eInput || i == eOutput) continue;
LoadInputs(i);
Models[i]->InitModel();
{
FGPropulsion* propulsion = (FGPropulsion*)Models[ePropulsion];
+ Models[eInput]->InitModel();
Models[eOutput]->InitModel();
SuspendIntegration(); // saves the integration rate, dt, then sets it to 0.0.
if (mode == 1) Output->SetStartNewOutput();
for (unsigned int i = 0; i < Models.size(); i++) {
- // The Output model will be initialized during the RunIC() execution
- if (i == eOutput) continue;
+ // The Input/Output models will be initialized during the RunIC() execution
+ if (i == eInput || i == eOutput) continue;
LoadInputs(i);
Models[i]->InitModel();
cerr << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
}
- // Process the input element. This element is OPTIONAL.
+ // Process the input element. This element is OPTIONAL, and there may be more than one.
element = document->FindElement("input");
- if (element) {
- result = ((FGInput*)Models[eInput])->Load(element);
- if (!result) {
- cerr << endl << "Aircraft input element has problems in file " << aircraftCfgFileName << endl;
- return result;
- }
+ while (element) {
+ if (!static_cast<FGInput*>(Models[eInput])->Load(element))
+ return false;
+
+ element = document->FindNextElement("input");
}
// Process the output element[s]. This element is OPTIONAL, and there may be
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.98 2014/11/30 12:35:32 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGInitialCondition.cpp,v 1.99 2015/02/19 05:18:45 dpculp Exp $");
IDENT(IdHdr,ID_INITIALCONDITION);
//******************************************************************************
lastSpeedSet = setvt;
lastAltitudeSet = setasl;
enginesRunning = 0;
+ needTrim = 0;
}
//******************************************************************************
{
SetTargetNlfIC(document->FindElementValueAsNumber("targetNlf"));
}
+ if (document->FindElement("trim"))
+ needTrim = document->FindElementValueAsNumber("trim");
// Refer to Stevens and Lewis, 1.5-14a, pg. 49.
// This is the rotation rate of the "Local" frame, expressed in the local frame.
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.41 2014/05/01 18:32:54 bcoconni Exp $"
+#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.43 2015/03/28 14:49:01 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
- mach (mach)
- vground (ground speed, ft/sec)
- running (-1 for all engines, 0 for no engines, 1 ... n for specific engines)
+ - trim (0 for no trim, 1 for ground trim)
<h3>Properties</h3>
@property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots
@property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
@author Tony Peden
- @version "$Id: FGInitialCondition.h,v 1.41 2014/05/01 18:32:54 bcoconni Exp $"
+ @version "$Id: FGInitialCondition.h,v 1.43 2015/03/28 14:49:01 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** Is an engine running ?
@param index of the engine to be checked
@return true if the engine is running. */
- bool IsEngineRunning(unsigned int n) const { return (enginesRunning & (1 << n)); }
+ bool IsEngineRunning(unsigned int n) const { return (enginesRunning & (1 << n)) != 0; }
+
+ /** Does initialization file call for trim ?
+ @return true if initialization file (version 1) called for trim. */
+ bool NeedTrim(void) const { return needTrim == 0 ? false : true; }
void bind(FGPropertyManager* pm);
speedset lastSpeedSet;
altitudeset lastAltitudeSet;
unsigned int enginesRunning;
+ int needTrim;
FGFDMExec *fdmex;
FGAtmosphere* Atmosphere;
double abstol = node->GetDouble("trim/solver/abstol");
double speed = node->GetDouble("trim/solver/speed"); // must be > 1, 2 typical
double random = node->GetDouble("trim/solver/random");
- int iterMax = node->GetDouble("trim/solver/iterMax");
+ int iterMax = node->GetInt("trim/solver/iterMax");
bool showConvergence = node->GetBool("trim/solver/showConvergence");
bool pause = node->GetBool("trim/solver/pause");
bool showSimplex = node->GetBool("trim/solver/showSimplex");
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module: FGInputSocket.cpp
+ Author: Paul Chavent
+ Date started: 01/20/15
+ Purpose: Manage input of sim parameters to a socket
+ Called by: FGInput
+
+ ------------- Copyright (C) 2015 Paul Chavent -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This is the place where you create input routines to dump data for perusal
+later.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/20/15 PC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <cstring>
+#include <cstdlib>
+#include <sstream>
+#include <iomanip>
+
+#include "FGInputSocket.h"
+#include "FGFDMExec.h"
+#include "models/FGAircraft.h"
+#include "input_output/FGXMLElement.h"
+
+using namespace std;
+
+namespace JSBSim {
+
+IDENT(IdSrc,"$Id");
+IDENT(IdHdr,ID_INPUTSOCKET);
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+FGInputSocket::FGInputSocket(FGFDMExec* fdmex) :
+ FGInputType(fdmex),
+ socket(0)
+{
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGInputSocket::~FGInputSocket()
+{
+ delete socket;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInputSocket::Load(Element* el)
+{
+ if (!FGInputType::Load(el))
+ return false;
+
+ SockPort = atoi(el->GetAttributeValue("port").c_str());
+
+ if (SockPort == 0) {
+ cerr << endl << "No port assigned in input element" << endl;
+ return false;
+ }
+
+ return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInputSocket::InitModel(void)
+{
+ if (FGInputType::InitModel()) {
+ delete socket;
+ socket = new FGfdmSocket(SockPort);
+
+ if (socket == 0) return false;
+ if (!socket->GetConnectStatus()) return false;
+
+ return true;
+ }
+
+ return false;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGInputSocket::Read(bool Holding)
+{
+ string line, token;
+ size_t start=0, string_start=0, string_end=0;
+ double value=0;
+ FGPropertyNode* node=0;
+
+ if (socket == 0) return;
+ if (!socket->GetConnectStatus()) return;
+
+ data = socket->Receive(); // get socket transmission if present
+
+ if (data.size() > 0) {
+ // parse lines
+ while (1) {
+ string_start = data.find_first_not_of("\r\n", start);
+ if (string_start == string::npos) break;
+ string_end = data.find_first_of("\r\n", string_start);
+ if (string_end == string::npos) break;
+ line = data.substr(string_start, string_end-string_start);
+ if (line.size() == 0) break;
+
+ // now parse individual line
+ vector <string> tokens = split(line,' ');
+
+ string command="", argument="", str_value="";
+ if (tokens.size() > 0) {
+ command = to_lower(tokens[0]);
+ if (tokens.size() > 1) {
+ argument = trim(tokens[1]);
+ if (tokens.size() > 2) {
+ str_value = trim(tokens[2]);
+ }
+ }
+ }
+
+ if (command == "set") { // SET PROPERTY
+
+ if (argument.size() == 0) {
+ socket->Reply("No property argument supplied.\n");
+ break;
+ }
+ try {
+ node = PropertyManager->GetNode(argument);
+ } catch(...) {
+ socket->Reply("Badly formed property query\n");
+ break;
+ }
+
+ if (node == 0) {
+ socket->Reply("Unknown property\n");
+ break;
+ } else if (!node->hasValue()) {
+ socket->Reply("Not a leaf property\n");
+ break;
+ } else {
+ value = atof(str_value.c_str());
+ node->setDoubleValue(value);
+ }
+ socket->Reply("");
+
+ } else if (command == "get") { // GET PROPERTY
+
+ if (argument.size() == 0) {
+ socket->Reply("No property argument supplied.\n");
+ break;
+ }
+ try {
+ node = PropertyManager->GetNode(argument);
+ } catch(...) {
+ socket->Reply("Badly formed property query\n");
+ break;
+ }
+
+ if (node == 0) {
+ socket->Reply("Unknown property\n");
+ break;
+ } else if (!node->hasValue()) {
+ if (Holding) { // if holding can query property list
+ string query = FDMExec->QueryPropertyCatalog(argument);
+ socket->Reply(query);
+ } else {
+ socket->Reply("Must be in HOLD to search properties\n");
+ }
+ } else if (node > 0) {
+ ostringstream buf;
+ buf << argument << " = " << setw(12) << setprecision(6) << node->getDoubleValue() << endl;
+ socket->Reply(buf.str());
+ }
+
+ } else if (command == "hold") { // PAUSE
+
+ FDMExec->Hold();
+ socket->Reply("");
+
+ } else if (command == "resume") { // RESUME
+
+ FDMExec->Resume();
+ socket->Reply("");
+
+ } else if (command == "iterate") { // ITERATE
+
+ int argumentInt;
+ istringstream (argument) >> argumentInt;
+ if (argument.size() == 0) {
+ socket->Reply("No argument supplied for number of iterations.\n");
+ break;
+ }
+ if ( !(argumentInt > 0) ){
+ socket->Reply("Required argument must be a positive Integer.\n");
+ break;
+ }
+ FDMExec->EnableIncrementThenHold( argumentInt );
+ FDMExec->Resume();
+ socket->Reply("");
+
+ } else if (command == "quit") { // QUIT
+
+ // close the socket connection
+ socket->Reply("");
+ socket->Close();
+
+ } else if (command == "info") { // INFO
+
+ // get info about the sim run and/or aircraft, etc.
+ ostringstream info;
+ info << "JSBSim version: " << JSBSim_version << endl;
+ info << "Config File version: " << needed_cfg_version << endl;
+ info << "Aircraft simulated: " << FDMExec->GetAircraft()->GetAircraftName() << endl;
+ info << "Simulation time: " << setw(8) << setprecision(3) << FDMExec->GetSimTime() << endl;
+ socket->Reply(info.str());
+
+ } else if (command == "help") { // HELP
+
+ socket->Reply(
+ " JSBSim Server commands:\n\n"
+ " get {property name}\n"
+ " set {property name} {value}\n"
+ " hold\n"
+ " resume\n"
+ " iterate {value}\n"
+ " help\n"
+ " quit\n"
+ " info\n\n");
+
+ } else {
+ socket->Reply(string("Unknown command: ") + token + string("\n"));
+ }
+
+ start = string_end;
+ }
+ }
+
+}
+
+}
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header: FGInputSocket.h
+ Author: Paul Chavent
+ Date started: 01/20/15
+
+ ------------- Copyright (C) 2015 Paul Chavent -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+20/01/15 PC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGINPUTSOCKET_H
+#define FGINPUTSOCKET_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGInputType.h"
+#include "input_output/FGfdmSocket.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_INPUTSOCKET "$Id: FGInputSocket.h,v 1.1 2015/02/15 12:04:32 bcoconni Exp $"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Implements the input from a socket. This class inputs data from a telnet
+ session. This is a leaf class.
+ */
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGInputSocket : public FGInputType
+{
+public:
+ /** Constructor. */
+ FGInputSocket(FGFDMExec* fdmex);
+
+ /** Destructor. */
+ ~FGInputSocket();
+
+ /** Init the input directives from an XML file.
+ @param element XML Element that is pointing to the input directives
+ */
+ bool Load(Element* el);
+
+ /** Initializes the instance. This method basically opens the socket to which
+ inputs will be directed.
+ @result true if the execution succeeded.
+ */
+ bool InitModel(void);
+
+ /// Generates the input.
+ void Read(bool Holding);
+
+protected:
+
+ unsigned int SockPort;
+ FGfdmSocket* socket;
+ std::string data;
+};
+}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#endif
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module: FGInputType.cpp
+ Author: Paul Chavent
+ Date started: 01/20/15
+ Purpose: Manage input of sim parameters to file or stdout
+
+ ------------- Copyright (C) 2015 Paul Chavent -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This is the place where you create input routines to dump data for perusal
+later.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/20/15 PC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <ostream>
+
+#include "FGFDMExec.h"
+#include "FGInputType.h"
+#include "input_output/FGXMLElement.h"
+#include "input_output/FGPropertyManager.h"
+
+namespace JSBSim {
+
+IDENT(IdSrc,"$Id: FGInputType.cpp,v 1.2 2015/03/28 14:49:01 bcoconni Exp $");
+IDENT(IdHdr,ID_INPUTTYPE);
+
+using namespace std;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+FGInputType::FGInputType(FGFDMExec* fdmex) :
+ FGModel(fdmex),
+ enabled(true)
+{
+ Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGInputType::~FGInputType()
+{
+ Debug(1);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGInputType::SetIdx(unsigned int idx)
+{
+ InputIdx = idx;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInputType::Load(Element* element)
+{
+ // Perform base class Load.
+ if(!FGModel::Load(element))
+ return false;
+
+ // no common attributes yet (see FGOutputType for example
+
+ // FIXME : PostLoad should be called in the most derived class ?
+ PostLoad(element, PropertyManager);
+
+ return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInputType::InitModel(void)
+{
+ bool ret = FGModel::InitModel();
+
+ Debug(2);
+ return ret;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInputType::Run(bool Holding)
+{
+ if (!enabled) return true;
+ if (FGModel::Run(Holding)) return true;
+ // if (Holding) return false;
+
+ RunPreFunctions();
+ Read(Holding);
+ RunPostFunctions();
+
+ Debug(4);
+
+ return false;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// The bitmasked value choices are as follows:
+// unset: In this case (the default) JSBSim would only print
+// out the normally expected messages, essentially echoing
+// the config files as they are read. If the environment
+// variable is not set, debug_lvl is set to 1 internally
+// 0: This requests JSBSim not to input any messages
+// whatsoever.
+// 1: This value explicity requests the normal JSBSim
+// startup messages
+// 2: This value asks for a message to be printed out when
+// a class is instantiated
+// 4: When this value is set, a message is displayed when a
+// FGModel object executes its Run() method
+// 8: When this value is set, various runtime state variables
+// are printed out periodically
+// 16: When set various parameters are sanity checked and
+// a message is printed out when they go out of bounds
+
+void FGInputType::Debug(int from)
+{
+ string scratch="";
+
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message input
+ if (from == 0) { // Constructor
+
+ }
+ if (from == 2) {
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGInputType" << endl;
+ if (from == 1) cout << "Destroyed: FGInputType" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity checking
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
+}
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header: FGInputType.h
+ Author: Paul Chavent
+ Date started: 01/20/15
+
+ ------------- Copyright (C) 2015 Paul Chavent -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/20/15 PC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGINPUTTYPE_H
+#define FGINPUTTYPE_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "models/FGModel.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_INPUTTYPE "$Id: FGInputType.h,v 1.2 2015/03/28 14:49:01 bcoconni Exp $"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Abstract class to provide functions generic to all the input directives.
+ This class is used by the input manager FGInput to manage a list of
+ different input classes without needing to know the details of each one of
+ them. It also provides the functions that are common to all the input
+ classes.
+
+ The class inherits from FGModelFunctions so it is possible to define
+ functions that execute before or after the input is generated. Such
+ functions need to be tagged with a "pre" or "post" type attribute to denote
+ the sequence in which they should be executed.
+
+ The class mimics some functionalities of FGModel (methods InitModel(),
+ Run() and SetRate()). However it does not inherit from FGModel since it is
+ conceptually different from the model paradigm.
+ */
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGInputType : public FGModel
+{
+public:
+ /** Constructor (implement the FGModel interface).
+ @param fdmex a pointer to the parent executive object
+ */
+ FGInputType(FGFDMExec* fdmex);
+
+ /// Destructor
+ virtual ~FGInputType();
+
+ /** Set the idx for this output instance
+ @param idx ID of the output instance that is constructed
+ */
+ void SetIdx(unsigned int idx);
+
+ /** Init the input directives from an XML file (implement the FGModel interface).
+ @param element XML Element that is pointing to the input directives
+ */
+ virtual bool Load(Element* el);
+
+ /// Init the input model according to its configitation.
+ virtual bool InitModel(void);
+
+ /** Executes the input directives (implement the FGModel interface).
+ This method checks that the current time step matches the input
+ rate and calls the registered "pre" functions, the input
+ generation and finally the "post" functions.
+ @result false if no error.
+ */
+ bool Run(bool Holding);
+
+ /** Generate the input. This is a pure method so it must be implemented by
+ the classes that inherits from FGInputType. The Read name may not be
+ relevant to all inputs but it has been kept for backward compatibility.
+ */
+ virtual void Read(bool Holding) = 0;
+
+ /// Enables the output generation.
+ void Enable(void) { enabled = true; }
+ /// Disables the output generation.
+ void Disable(void) { enabled = false; }
+ /** Toggles the output generation.
+ @result the output generation status i.e. true if the output has been
+ enabled, false if the output has been disabled. */
+ bool Toggle(void) {enabled = !enabled; return enabled;}
+
+ /** Overwrites the name identifier under which the input will be read.
+ This method is taken into account if it is called before
+ FGFDMExec::RunIC() otherwise it is ignored until the next call to
+ SetStartNewInput().
+ @param name new name */
+ virtual void SetInputName(const std::string& name) { Name = name; }
+
+ /** Get the name identifier to which the input will be directed.
+ @result the name identifier.*/
+ virtual const std::string& GetInputName(void) const { return Name; }
+
+protected:
+ unsigned int InputIdx;
+ bool enabled;
+
+ void Debug(int from);
+};
+}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#endif
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGOutputType.cpp,v 1.11 2014/09/12 20:10:04 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGOutputType.cpp,v 1.12 2015/03/28 14:49:01 bcoconni Exp $");
IDENT(IdHdr,ID_OUTPUTTYPE);
using namespace std;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGOutputType::SetIdx(int idx)
+void FGOutputType::SetIdx(unsigned int idx)
{
typedef double (FGOutputType::*iOPMF)(void) const;
string outputProp = CreateIndexedPropertyName("simulation/output", idx) + "/log_rate_hz";
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_OUTPUTTYPE "$Id: FGOutputType.h,v 1.5 2013/01/26 17:06:49 bcoconni Exp $"
+#define ID_OUTPUTTYPE "$Id: FGOutputType.h,v 1.6 2015/03/28 14:49:01 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
/** Set the idx for this output instance
@param idx ID of the output instance that is constructed
*/
- void SetIdx(int idx);
+ void SetIdx(unsigned int idx);
/** Set the output rate for this output instances.
@param rtHz new output rate in Hz */
} subsystems;
protected:
- int OutputIdx;
+ unsigned int OutputIdx;
int SubSystems;
std::vector <FGPropertyNode_ptr> OutputProperties;
std::vector <std::string> OutputCaptions;
}
string fqname="";
- for(unsigned i=stack.size()-1;i>0;i--) {
+ for(size_t i=stack.size()-1;i>0;i--) {
fqname+= stack[i];
fqname+= "/";
}
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module: FGUDPInputSocket.cpp
+ Author: Dave Culp
+ Date started: 02/19/15
+ Purpose: Manage input of data from a UDP socket
+ Called by: FGInput
+
+ ------------- Copyright (C) 2015 Dave Culp --------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class establishes a UDP socket and reads data from it.
+
+HISTORY
+--------------------------------------------------------------------------------
+02/19/15 DC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <cstring>
+#include <cstdlib>
+#include <sstream>
+
+#include "FGUDPInputSocket.h"
+#include "FGFDMExec.h"
+#include "input_output/FGXMLElement.h"
+
+using namespace std;
+
+namespace JSBSim {
+
+IDENT(IdSrc,"$Id");
+IDENT(IdHdr,ID_UDPINPUTSOCKET);
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+FGUDPInputSocket::FGUDPInputSocket(FGFDMExec* fdmex) :
+ FGInputType(fdmex),
+ socket(0)
+{
+ rate = 20;
+ SockPort = 5139;
+ oldTimeStamp = 0.0;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGUDPInputSocket::~FGUDPInputSocket()
+{
+ delete socket;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGUDPInputSocket::Load(Element* el)
+{
+ if (!FGInputType::Load(el))
+ return false;
+
+ rate = atoi(el->GetAttributeValue("rate").c_str());
+ FGModel::SetRate(0.5 + 1.0/(FDMExec->GetDeltaT()*rate));
+
+ SockPort = atoi(el->GetAttributeValue("port").c_str());
+ if (SockPort == 0) {
+ cerr << endl << "No port assigned in input element" << endl;
+ return false;
+ }
+
+ Element *property_element = el->FindElement("property");
+
+ while (property_element) {
+ string property_str = property_element->GetDataLine();
+ FGPropertyNode* node = PropertyManager->GetNode(property_str);
+ if (!node) {
+ cerr << fgred << highint << endl << " No property by the name "
+ << property_str << " can be found." << reset << endl;
+ } else {
+ InputProperties.push_back(node);
+ }
+ property_element = el->FindNextElement("property");
+ }
+
+ return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGUDPInputSocket::InitModel(void)
+{
+ if (FGInputType::InitModel()) {
+ delete socket;
+ socket = new FGfdmSocket(SockPort, FGfdmSocket::ptUDP, FGfdmSocket::dIN);
+
+ if (socket == 0) return false;
+ cout << "UDP input socket established on port " << SockPort << endl;
+ return true;
+ }
+
+ return false;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGUDPInputSocket::Read(bool Holding)
+{
+
+ if (socket == 0) return;
+
+ data = socket->Receive();
+
+ if (data.size() > 0) {
+
+ vector<string> tokens;
+ stringstream ss(data);
+ string temp;
+ while (getline(ss, temp, ',')) {
+ tokens.push_back(temp);
+ }
+
+ vector<double> values;
+
+ for (unsigned int i=0; i<tokens.size(); i++) {
+ values.push_back( atof(tokens[i].c_str()) );
+ }
+
+ if (values[0] < oldTimeStamp) {
+ return;
+ } else {
+ oldTimeStamp = values[0];
+ }
+
+ // the zeroeth value is the time stamp
+ if ((values.size() - 1) != InputProperties.size()) {
+ cerr << endl << "Mismatch between UDP input property and value counts." << endl;
+ return;
+ }
+
+ for (unsigned int i=1; i<values.size(); i++) {
+ InputProperties[i-1]->setDoubleValue(values[i]);
+ }
+
+ }
+
+}
+
+}
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header: FGUDPInputSocket.h
+ Author: Dave Culp
+ Date started: 02/19/15
+
+ ------------- Copyright (C) 2015 David Culp -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+02/19/15 DC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGUDPINPUTSOCKET_H
+#define FGUDPINPUTSOCKET_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGInputType.h"
+#include "input_output/FGfdmSocket.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_UDPINPUTSOCKET ""
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Implements a UDP input socket.
+ */
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGUDPInputSocket : public FGInputType
+{
+public:
+ /** Constructor. */
+ FGUDPInputSocket(FGFDMExec* fdmex);
+
+ /** Destructor. */
+ ~FGUDPInputSocket();
+
+ /** Reads the property names from an XML file.
+ @param element The root XML Element of the input file.
+ */
+ bool Load(Element* el);
+
+ /** Initializes the instance. This method basically opens the socket to which
+ inputs will be directed.
+ @result true if the execution succeeded.
+ */
+ bool InitModel(void);
+
+ /// Reads the socket and updates properties accordingly.
+ void Read(bool Holding);
+
+protected:
+
+ int rate;
+ double oldTimeStamp;
+ std::vector<FGPropertyNode_ptr> InputProperties;
+ unsigned int SockPort;
+ FGfdmSocket* socket;
+ std::string data;
+};
+}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#endif
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module: FGUDPOutputSocket.cpp
+ Author: David Culp
+ Date started: 03/31/15
+ Purpose: Manage output of property values to a UDP socket
+ Called by: FGOutput
+
+ ------------- Copyright (C) 2015 David Culp ----------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class sends comma-separated strings over a UDP socket. The format is that required
+by the QtJSBSim application.
+
+HISTORY
+--------------------------------------------------------------------------------
+03/31/15 DC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <cstring>
+#include <cstdlib>
+
+#include "FGUDPOutputSocket.h"
+#include "FGFDMExec.h"
+#include "input_output/FGPropertyManager.h"
+#include "input_output/FGXMLElement.h"
+
+using namespace std;
+
+namespace JSBSim {
+
+IDENT(IdSrc,"$Id: FGUDPOutputSocket.cpp,v 1.1 2015/04/02 02:23:33 dpculp Exp $");
+IDENT(IdHdr,ID_UDPOUTPUTSOCKET);
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+FGUDPOutputSocket::FGUDPOutputSocket(FGFDMExec* fdmex) :
+ FGOutputType(fdmex),
+ socket(0)
+{
+ FDMExec = fdmex;
+ PropertyManager = fdmex->GetPropertyManager();
+ root = PropertyManager->GetNode();
+ root->SetDouble("simulation/null", 0.0);
+ SockName = "localhost";
+ SockPort = 5138;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGUDPOutputSocket::~FGUDPOutputSocket()
+{
+ delete socket;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGUDPOutputSocket::Load(Element* el)
+{
+
+ Element *property_element = el->FindElement("property");
+
+ while (property_element) {
+ string caption="";
+ string property_str = property_element->GetDataLine();
+ FGPropertyNode* node = PropertyManager->GetNode(property_str);
+ if (!node) {
+ node = PropertyManager->GetNode("simulation/null");
+ }
+ OutputProperties.push_back(node);
+ property_element = el->FindNextElement("property");
+ }
+
+ double outRate = 1.0;
+ if (!el->GetAttributeValue("rate").empty()) {
+ outRate = el->GetAttributeValueAsNumber("rate");
+ }
+ SetRate(outRate);
+
+ SockPort = atoi(el->GetAttributeValue("port").c_str());
+ if (SockPort == 0) {
+ cerr << endl << "No port assigned for output." << endl;
+ return false;
+ }
+
+ return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGUDPOutputSocket::InitModel(void)
+{
+ if (FGOutputType::InitModel()) {
+ delete socket;
+ socket = new FGfdmSocket(SockName, SockPort, FGfdmSocket::ptUDP);
+
+ if (socket == 0) return false;
+ if (!socket->GetConnectStatus()) return false;
+
+ return true;
+ }
+
+ return false;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGUDPOutputSocket::Print(void)
+{
+
+ if (socket == 0) return;
+ if (!socket->GetConnectStatus()) return;
+
+ socket->Clear();
+ socket->Append(FDMExec->GetSimTime());
+
+ for (unsigned int i=0;i<OutputProperties.size();i++) {
+ socket->Append(OutputProperties[i]->getDoubleValue());
+ }
+
+ socket->Send();
+}
+
+}
--- /dev/null
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header: FGOutputSocket.h
+ Author: David Culp
+ Date started: 03/31/15
+
+ ------------- Copyright (C) 2015 David Culp ---------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+03/31/15 DC Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGUDPOUTPUTSOCKET_H
+#define FGUDPOUTPUTSOCKET_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGOutputType.h"
+#include "input_output/FGPropertyManager.h"
+#include "input_output/FGfdmSocket.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_UDPOUTPUTSOCKET "$Id: FGUDPOutputSocket.h,v 1.1 2015/04/02 02:23:33 dpculp Exp $"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Implements the output to a UDP socket. This class outputs data to a socket
+ in a comma-separated strings format. The first string represents a time
+ stamp, and each string thereafter is the value of a property. If a
+ specified property does not exist, then a zero is sent, so that the
+ number of values sent will always equal the number of properties requested.
+ */
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGUDPOutputSocket : public FGOutputType
+{
+public:
+ /** Constructor. */
+ FGUDPOutputSocket(FGFDMExec* fdmex);
+
+ /** Destructor. */
+ ~FGUDPOutputSocket();
+
+ /** Init the output directives from an XML file.
+ @param element XML Element that is pointing to the output directives
+ */
+ virtual bool Load(Element* el);
+
+ /** Initializes the instance. This method opens the ouput socket.
+ @result true if the execution succeeded.
+ */
+ bool InitModel(void);
+
+ /// Generates and sends the output datagram.
+ void Print(void);
+
+protected:
+
+ std::string SockName;
+ unsigned int SockPort;
+ FGfdmSocket* socket;
+ FGPropertyManager* PropertyManager;
+ FGPropertyNode* root;
+ FGFDMExec* FDMExec;
+};
+}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#endif
+
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#include <WS2tcpip.h>
+#else
+#include <fcntl.h>
+#endif
#include <iostream>
#include <iomanip>
#include <cstring>
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGfdmSocket.cpp,v 1.29 2014/01/13 10:46:03 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGfdmSocket.cpp,v 1.31 2015/03/22 12:19:31 bcoconni Exp $");
IDENT(IdHdr,ID_FDMSOCKET);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+#if defined(_MSC_VER) || defined(__MINGW32__)
+static bool LoadWinSockDLL(void)
+{
+ WSADATA wsaData;
+ if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
+ cout << "Winsock DLL not initialized ..." << endl;
+ return false;
+ }
+
+ cout << "Winsock DLL loaded ..." << endl;
+ return true;
+}
+#endif
+
FGfdmSocket::FGfdmSocket(const string& address, int port, int protocol)
{
sckt = sckt_in = 0;
+ Protocol = (ProtocolType)protocol;
connected = false;
#if defined(_MSC_VER) || defined(__MINGW32__)
- WSADATA wsaData;
- int wsaReturnCode;
- wsaReturnCode = WSAStartup(MAKEWORD(1,1), &wsaData);
- if (wsaReturnCode == 0) cout << "Winsock DLL loaded ..." << endl;
- else cout << "Winsock DLL not initialized ..." << endl;
+ if (!LoadWinSockDLL()) return;
#endif
if (!is_number(address)) {
} else { // unsuccessful
cout << "Could not create socket for FDM output, error = " << errno << endl;
}
+
}
Debug(0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// assumes UDP socket on localhost, for inbound datagrams
+FGfdmSocket::FGfdmSocket(int port, int protocol, int direction) // assumes UDP
+{
+ sckt = -1;
+ connected = false;
+ Protocol = (ProtocolType)protocol;
+ Direction = (DirectionType) direction;
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ if (!LoadWinSockDLL()) return;
+#endif
-FGfdmSocket::FGfdmSocket(const string& address, int port)
+ if (Protocol == ptUDP) { //use udp protocol
+ sckt = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ u_long NonBlock = 1; // True
+ ioctlsocket(sckt, FIONBIO, &NonBlock);
+#else
+ fcntl(sckt, F_SETFL, O_NONBLOCK);
+#endif
+ cout << "Creating UDP input socket on port " << port << endl;
+ }
+
+ if (sckt != -1) {
+ memset(&scktName, 0, sizeof(struct sockaddr_in));
+ scktName.sin_family = AF_INET;
+ scktName.sin_port = htons(port);
+ scktName.sin_addr.s_addr = htonl(INADDR_ANY);
+ int len = sizeof(struct sockaddr_in);
+ if (bind(sckt, (struct sockaddr*)&scktName, len) != -1) {
+ cout << "Successfully bound to UDP input socket on port " << port << endl <<endl;
+ connected = true;
+ } else { // unsuccessful
+ cout << "Could not bind to UDP input socket, error = " << errno << endl;
+ }
+ } else { // unsuccessful
+ cout << "Could not create socket for UDP input, error = " << errno << endl;
+ }
+
+
+ Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGfdmSocket::FGfdmSocket(const string& address, int port) // assumes TCP
{
sckt = sckt_in = 0;
connected = false;
+ Protocol = ptTCP;
#if defined(_MSC_VER) || defined(__MINGW32__)
- WSADATA wsaData;
- int wsaReturnCode;
- wsaReturnCode = WSAStartup(MAKEWORD(1,1), &wsaData);
- if (wsaReturnCode == 0) cout << "Winsock DLL loaded ..." << endl;
- else cout << "Winsock DLL not initialized ..." << endl;
+ if (!LoadWinSockDLL()) return;
#endif
cout << "... Socket Configuration Sanity Check ..." << endl;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGfdmSocket::FGfdmSocket(int port)
+FGfdmSocket::FGfdmSocket(int port) // assumes TCP
{
connected = false;
unsigned long NoBlock = true;
+ Protocol = ptTCP;
#if defined(_MSC_VER) || defined(__MINGW32__)
- WSADATA wsaData;
- int wsaReturnCode;
- wsaReturnCode = WSAStartup(MAKEWORD(1,1), &wsaData);
- if (wsaReturnCode == 0) cout << "Winsock DLL loaded ..." << endl;
- else cerr << "Winsock DLL not initialized ..." << endl;
+ if (!LoadWinSockDLL()) return;
#endif
sckt = socket(AF_INET, SOCK_STREAM, 0);
string data; // todo: should allocate this with a standard size as a
// class attribute and pass as a reference?
- if (sckt_in <= 0) {
+ if (sckt_in <= 0 && Protocol == ptTCP) {
#if defined(_MSC_VER) || defined(__MINGW32__)
sckt_in = accept(sckt, (struct sockaddr*)&scktName, &len);
#else
}
#endif
}
-
+
+ // this is for FGUDPInputSocket
+ if (sckt >= 0 && Protocol == ptUDP) {
+ struct sockaddr addr;
+ socklen_t fromlen = sizeof addr;
+ num_chars = recvfrom(sckt, buf, sizeof buf, 0, (struct sockaddr*)&addr, &fromlen);
+ if (num_chars != -1) data.append(buf, num_chars);
+ }
+
return data;
}
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FDMSOCKET "$Id: FGfdmSocket.h,v 1.20 2010/10/15 11:30:28 jberndt Exp $"
+#define ID_FDMSOCKET "$Id: FGfdmSocket.h,v 1.23 2015/03/28 15:03:44 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
public:
FGfdmSocket(const std::string&, int);
FGfdmSocket(const std::string&, int, int);
+ FGfdmSocket(int, int, int);
FGfdmSocket(int);
~FGfdmSocket();
void Send(void);
void Close(void);
bool GetConnectStatus(void) {return connected;}
- enum ProtocolType {ptUDP, ptTCP} ;
-
+ enum ProtocolType {ptUDP, ptTCP};
+ enum DirectionType {dIN, dOUT};
+
private:
int sckt;
int sckt_in;
+ int udpsckt;
+ DirectionType Direction;
+ ProtocolType Protocol;
struct sockaddr_in scktName;
struct hostent *host;
std::ostringstream buffer;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.21 2015/02/14 14:03:00 bcoconni Exp $"
+#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.22 2015/03/28 14:49:01 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
string replace(string str, const string& oldstr, const string& newstr)
{
- int old_idx;
string temp;
- old_idx = str.find(oldstr);
- if (old_idx >= 0) {
+ size_t old_idx = str.find(oldstr);
+ if (old_idx != string::npos) {
temp = str.replace(old_idx, 1, newstr);
}
return temp;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGCondition.cpp,v 1.20 2014/01/13 10:46:03 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGCondition.cpp,v 1.21 2015/02/27 20:36:47 bcoconni Exp $");
IDENT(IdHdr,ID_CONDITION);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// This constructor is called when tests are inside an element
FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) :
- PropertyManager(PropertyManager), isGroup(true)
+ isGroup(true)
{
string property1, property2, logic;
Element* condition_element;
// condition
FGCondition::FGCondition(const string& test, FGPropertyManager* PropertyManager) :
- PropertyManager(PropertyManager), isGroup(false)
+ isGroup(false)
{
string property1, property2, compare_string;
vector <string> test_strings;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_CONDITION "$Id: FGCondition.h,v 1.7 2012/10/27 20:29:01 jberndt Exp $"
+#define ID_CONDITION "$Id: FGCondition.h,v 1.8 2015/02/27 20:36:47 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
std::map <std::string, eComparison> mComparison;
eLogic Logic;
- FGPropertyManager *PropertyManager;
+ //FGPropertyManager *PropertyManager;
FGPropertyValue *TestParam1, *TestParam2;
double TestValue;
eComparison Comparison;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFunction.cpp,v 1.55 2014/01/13 10:46:03 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGFunction.cpp,v 1.57 2015/03/28 14:49:01 bcoconni Exp $");
IDENT(IdHdr,ID_FUNCTION);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
break;
case eSwitch:
{
- unsigned int n = Parameters.size()-1;
+ size_t n = Parameters.size()-1;
i = int(temp+0.5);
- if (i >= 0u && i < n) {
+ if (i < n) {
temp = Parameters[i+1]->GetValue();
} else {
throw(string("The switch function index selected a value above the range of supplied values"
break;
case eInterpolate1D:
{
- unsigned int sz = Parameters.size();
+ size_t sz = Parameters.size();
if (temp <= Parameters[1]->GetValue()) {
temp = Parameters[2]->GetValue();
} else if (temp >= Parameters[sz-2]->GetValue()) {
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGModelFunctions.cpp,v 1.14 2014/05/30 17:26:42 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGModelFunctions.cpp,v 1.15 2015/03/28 14:49:01 bcoconni Exp $");
IDENT(IdHdr,ID_MODELFUNCTIONS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGModelFunctions::RunPreFunctions(void)
{
- unsigned int sz = PreFunctions.size();
+ size_t sz = PreFunctions.size();
for (unsigned int i=0; i<sz; i++) {
PreFunctions[i]->cacheValue(true);
}
void FGModelFunctions::RunPostFunctions(void)
{
- unsigned int sz = PostFunctions.size();
+ size_t sz = PostFunctions.size();
for (unsigned int i=0; i<sz; i++) {
PostFunctions[i]->cacheValue(true);
}
{
m_cost[vertex] = eval(m_simplex[vertex]);
}
- catch (const std::exception & e)
+ catch (...)
{
m_status = -1;
throw;
}
}
- catch (const std::exception & e)
+ catch (...)
{
m_status = -1;
throw;
double m_randomization;
const std::vector<double> & m_lowerBound;
const std::vector<double> & m_upperBound;
- int m_nDim, m_nVert, m_iMax, m_iNextMax, m_iMin;
+ size_t m_nDim, m_nVert;
+ int m_iMax, m_iNextMax, m_iMin;
std::vector< std::vector<double> > m_simplex;
std::vector<double> m_cost;
std::vector<double> m_elemSum;
void FGStateSpace::numericalJacobian(std::vector< std::vector<double> > & J, ComponentVector & y,
ComponentVector & x, const std::vector<double> & y0, const std::vector<double> & x0, double h, bool computeYDerivative)
{
- int nX = x.getSize();
- int nY = y.getSize();
+ size_t nX = x.getSize();
+ size_t nY = y.getSize();
double f1 = 0, f2 = 0, fn1 = 0, fn2 = 0;
J.resize(nY);
for (int iY=0;iY<nY;iY++)
std::ostream &operator<<( std::ostream &out, const std::vector< std::vector<double> > &vec2d )
{
- int width = out.width();
- int nI = vec2d.size();
+ std::streamsize width = out.width();
+ size_t nI = vec2d.size();
out << std::left << std::setw(1) << "[" << std::right;
for (int i=0;i<nI;i++)
{
//std::cout << "i: " << i << std::endl;
- int nJ = vec2d[i].size();
+ size_t nJ = vec2d[i].size();
for (int j=0;j<nJ;j++)
{
//std::cout << "j: " << j << std::endl;
std::ostream &operator<<( std::ostream &out, const std::vector<double> &vec )
{
- int width = out.width();
- int nI = vec.size();
+ std::streamsize width = out.width();
+ size_t nI = vec.size();
out << std::left << std::setw(1) << "[" << std::right;
for (int i=0;i<nI;i++)
{
comp->setFdm(m_fdm);
m_components.push_back(comp);
}
- int getSize() const
+ size_t getSize() const
{
return m_components.size();
}
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGAccelerations.cpp,v 1.19 2014/01/13 10:46:03 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGAccelerations.cpp,v 1.22 2015/03/28 14:49:02 bcoconni Exp $");
IDENT(IdHdr,ID_ACCELERATIONS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const FGMatrix33& Jinv = in.Jinv;
FGColumnVector3 vdot, wdot;
vector<LagrangeMultiplier*>& multipliers = *in.MultipliersList;
- int n = multipliers.size();
+ size_t n = multipliers.size();
vFrictionForces.InitMatrix();
vFrictionMoments.InitMatrix();
vector<double> rhs(n);
// Assemble the linear system of equations
- for (int i=0; i < n; i++) {
+ for (unsigned int i=0; i < n; i++) {
FGColumnVector3 v1 = invMass * multipliers[i]->ForceJacobian;
FGColumnVector3 v2 = Jinv * multipliers[i]->MomentJacobian; // Should be J^-T but J is symmetric and so is J^-1
- for (int j=0; j < i; j++)
+ for (unsigned int j=0; j < i; j++)
a[i*n+j] = a[j*n+i]; // Takes advantage of the symmetry of Jac^T*M^-1*Jac
- for (int j=i; j < n; j++)
+ for (unsigned int j=i; j < n; j++)
a[i*n+j] = DotProduct(v1, multipliers[j]->ForceJacobian)
+ DotProduct(v2, multipliers[j]->MomentJacobian);
}
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGBuoyantForces.cpp,v 1.27 2014/06/09 11:52:07 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGBuoyantForces.cpp,v 1.30 2015/03/28 14:49:02 bcoconni Exp $");
IDENT(IdHdr,ID_BUOYANTFORCES);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const FGMatrix33& FGBuoyantForces::GetGasMassInertia(void)
{
- const unsigned int size = Cells.size();
+ size_t size = Cells.size();
if (size == 0) return gasCellJ;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.16 2014/11/25 01:42:27 dpculp Exp $"
+#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.17 2015/02/27 20:36:47 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
private:
std::vector <FGExternalForce*> Forces;
- unsigned int numForces;
+ //unsigned int numForces;
FGColumnVector3 vTotalForces;
FGColumnVector3 vTotalMoments;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCS "$Id: FGFCS.h,v 1.46 2014/06/09 11:52:07 bcoconni Exp $"
+#define ID_FCS "$Id: FGFCS.h,v 1.47 2015/02/27 20:36:47 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@property gear/tailhook-pos-norm
@author Jon S. Berndt
- @version $Revision: 1.46 $
+ @version $Revision: 1.47 $
@see FGActuator
@see FGDeadBand
@see FGFCSFunction
std::vector <bool> PropFeatherCmd;
std::vector <bool> PropFeather;
std::vector <double> SteerPosDeg;
- double LeftBrake, RightBrake, CenterBrake; // Brake settings
+ //double LeftBrake, RightBrake, CenterBrake; // Brake settings
std::vector <double> BrakePos; // left, center, right - defined by FGLGear:: enum
double GearCmd,GearPos;
double TailhookPos, WingFoldPos;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.4 2013/12/22 15:21:51 bcoconni Exp $"
+#define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.5 2015/03/28 14:49:02 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
/// Adds a component to a channel
void Add(FGFCSComponent* comp) {FCSComponents.push_back(comp);}
/// Returns the number of components in the channel.
- unsigned int GetNumComponents() {return FCSComponents.size();}
+ size_t GetNumComponents() {return FCSComponents.size();}
/// Retrieves a specific component.
FGFCSComponent* GetComponent(unsigned int i) {
if (i >= GetNumComponents()) {
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGGasCell.cpp,v 1.21 2014/06/29 10:18:16 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGGasCell.cpp,v 1.22 2015/03/28 14:49:02 bcoconni Exp $");
IDENT(IdHdr,ID_GASCELL);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const double FGGasCell::M_hydrogen = 0.00013841; // [slug/mol]
const double FGGasCell::M_helium = 0.00027409; // [slug/mol]
-FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, int num, const struct Inputs& input)
+FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
+ const struct Inputs& input)
: FGForce(exec), in(input)
{
string token;
const double OldTemperature = Temperature;
const double OldPressure = Pressure;
unsigned int i;
- const unsigned int no_ballonets = Ballonet.size();
+ const size_t no_ballonets = Ballonet.size();
//-- Read ballonet state --
// NOTE: This model might need a more proper integration technique.
const double FGBallonet::M_air = 0.0019186; // [slug/mol]
const double FGBallonet::Cv_air = 5.0/2.0; // [??]
-FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, int num, FGGasCell* parent, const struct FGGasCell::Inputs& input)
+FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num,
+ FGGasCell* parent, const struct FGGasCell::Inputs& input)
: in(input)
{
string token;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_GASCELL "$Id: FGGasCell.h,v 1.15 2014/06/29 10:18:16 bcoconni Exp $"
+#define ID_GASCELL "$Id: FGGasCell.h,v 1.16 2015/03/28 14:49:02 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@param exec Executive a pointer to the parent executive object
@param el Pointer to configuration file XML node
@param num Gas cell index number. */
- FGGasCell(FGFDMExec* exec, Element* el, int num, const struct Inputs& input);
+ FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
+ const struct Inputs& input);
~FGGasCell();
/** Runs the gas cell model; called by BuoyantForces
GasType Type;
std::string type;
- int CellNum;
+ unsigned int CellNum;
// Structural constants
double MaxVolume; // [ft^3]
double MaxOverpressure; // [lbs/ft^2]
class FGBallonet : public FGJSBBase
{
public:
- FGBallonet(FGFDMExec* exec, Element* el, int num, FGGasCell* parent, const struct FGGasCell::Inputs& input);
+ FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, FGGasCell* parent,
+ const struct FGGasCell::Inputs& input);
~FGBallonet();
/** Runs the ballonet model; called by FGGasCell
const struct FGGasCell::Inputs& in;
private:
- int CellNum;
+ unsigned int CellNum;
// Structural constants
double MaxVolume; // [ft^3]
double MaxOverpressure; // [lbs/ft^2]
Module: FGInput.cpp
Author: Jon Berndt
Date started: 12/02/98
- Purpose: Manage output of sim parameters to file or stdout
+ Purpose: Manage input of sim parameters from socket
Called by: FGSimExec
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGInput.h"
-#include "FGAircraft.h"
#include "FGFDMExec.h"
-
-#include "input_output/FGfdmSocket.h"
+#include "input_output/FGInputSocket.h"
+#include "input_output/FGUDPInputSocket.h"
+#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
-
-#include <sstream>
-#include <iomanip>
-#include <cstdlib>
-
+#include "input_output/FGModelLoader.h"
+
using namespace std;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGInput.cpp,v 1.28 2014/01/13 10:46:07 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGInput.cpp,v 1.32 2015/04/02 02:20:50 dpculp Exp $");
IDENT(IdHdr,ID_INPUT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGInput";
- socket = 0;
- port = 0;
Debug(0);
}
FGInput::~FGInput()
{
- delete socket;
+ vector<FGInputType*>::iterator it;
+ for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
+ delete (*it);
+
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+bool FGInput::Load(Element* el)
+{
+ // Unlike the other FGModel classes, properties listed in the <input> section
+ // are not intended to create new properties. For that reason, FGInput
+ // cannot load its XML directives with FGModel::Load().
+ // Instead FGModelLoader::Open() and FGModel::PreLoad() must be explicitely
+ // called.
+ FGModelLoader ModelLoader(this);
+ Element* element = ModelLoader.Open(el);
+
+ if (!element) return false;
+
+ FGModel::PreLoad(element, PropertyManager);
+
+ size_t idx = InputTypes.size();
+ string type = element->GetAttributeValue("type");
+ FGInputType* Input = 0;
+
+ if (debug_lvl > 0) cout << endl << " Input data set: " << idx << " " << endl;
+
+ type = to_upper(type);
+
+ if (type.empty() || type == "SOCKET") {
+ Input = new FGInputSocket(FDMExec);
+ } else if (type == "QTJSBSIM") {
+ Input = new FGUDPInputSocket(FDMExec);
+ } else if (type != string("NONE")) {
+ cerr << "Unknown type of input specified in config file" << endl;
+ }
+
+ if (!Input) return false;
+
+ Input->SetIdx(idx);
+ Input->Load(element);
+ PostLoad(element, PropertyManager);
+
+ InputTypes.push_back(Input);
+
+ Debug(2);
+ return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
bool FGInput::InitModel(void)
{
- return FGModel::InitModel();
+ bool ret = false;
+
+ if (!FGModel::InitModel()) return false;
+
+ vector<FGInputType*>::iterator it;
+ for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
+ ret &= (*it)->InitModel();
+
+ return ret;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-//
-// This function handles accepting input commands from the socket interface.
-//
bool FGInput::Run(bool Holding)
{
- string line, token;
- size_t start=0, string_start=0, string_end=0;
- double value=0;
- FGPropertyNode* node=0;
-
- if (FGModel::Run(Holding)) return true; // fast exit if nothing to do
- if (port == 0) return false; // Do nothing here if port not defined
- // return false if no error
- // This model DOES execute if "Exec->Holding"
-
- RunPreFunctions();
-
- data = socket->Receive(); // get socket transmission if present
-
- if (data.size() > 0) {
- // parse lines
- while (1) {
- string_start = data.find_first_not_of("\r\n", start);
- if (string_start == string::npos) break;
- string_end = data.find_first_of("\r\n", string_start);
- if (string_end == string::npos) break;
- line = data.substr(string_start, string_end-string_start);
- if (line.size() == 0) break;
-
- // now parse individual line
- vector <string> tokens = split(line,' ');
-
- string command="", argument="", str_value="";
- if (tokens.size() > 0) {
- command = to_lower(tokens[0]);
- if (tokens.size() > 1) {
- argument = trim(tokens[1]);
- if (tokens.size() > 2) {
- str_value = trim(tokens[2]);
- }
- }
- }
-
- if (command == "set") { // SET PROPERTY
-
- if (argument.size() == 0) {
- socket->Reply("No property argument supplied.\n");
- break;
- }
- try {
- node = PropertyManager->GetNode(argument);
- } catch(...) {
- socket->Reply("Badly formed property query\n");
- break;
- }
-
- if (node == 0) {
- socket->Reply("Unknown property\n");
- break;
- } else if (!node->hasValue()) {
- socket->Reply("Not a leaf property\n");
- break;
- } else {
- value = atof(str_value.c_str());
- node->setDoubleValue(value);
- }
- socket->Reply("");
-
- } else if (command == "get") { // GET PROPERTY
-
- if (argument.size() == 0) {
- socket->Reply("No property argument supplied.\n");
- break;
- }
- try {
- node = PropertyManager->GetNode(argument);
- } catch(...) {
- socket->Reply("Badly formed property query\n");
- break;
- }
-
- if (node == 0) {
- socket->Reply("Unknown property\n");
- break;
- } else if (!node->hasValue()) {
- if (Holding) { // if holding can query property list
- string query = FDMExec->QueryPropertyCatalog(argument);
- socket->Reply(query);
- } else {
- socket->Reply("Must be in HOLD to search properties\n");
- }
- } else if (node > 0) {
- ostringstream buf;
- buf << argument << " = " << setw(12) << setprecision(6) << node->getDoubleValue() << endl;
- socket->Reply(buf.str());
- }
-
- } else if (command == "hold") { // PAUSE
-
- FDMExec->Hold();
- socket->Reply("");
-
- } else if (command == "resume") { // RESUME
-
- FDMExec->Resume();
- socket->Reply("");
-
- } else if (command == "iterate") { // ITERATE
-
- int argumentInt;
- istringstream (argument) >> argumentInt;
- if (argument.size() == 0) {
- socket->Reply("No argument supplied for number of iterations.\n");
- break;
- }
- if ( !(argumentInt > 0) ){
- socket->Reply("Required argument must be a positive Integer.\n");
- break;
- }
- FDMExec->EnableIncrementThenHold( argumentInt );
- FDMExec->Resume();
- socket->Reply("");
-
- } else if (command == "quit") { // QUIT
-
- // close the socket connection
- socket->Reply("");
- socket->Close();
-
- } else if (command == "info") { // INFO
-
- // get info about the sim run and/or aircraft, etc.
- ostringstream info;
- info << "JSBSim version: " << JSBSim_version << endl;
- info << "Config File version: " << needed_cfg_version << endl;
- info << "Aircraft simulated: " << FDMExec->GetAircraft()->GetAircraftName() << endl;
- info << "Simulation time: " << setw(8) << setprecision(3) << FDMExec->GetSimTime() << endl;
- socket->Reply(info.str());
-
- } else if (command == "help") { // HELP
-
- socket->Reply(
- " JSBSim Server commands:\n\n"
- " get {property name}\n"
- " set {property name} {value}\n"
- " hold\n"
- " resume\n"
- " iterate {value}\n"
- " help\n"
- " quit\n"
- " info\n\n");
-
- } else {
- socket->Reply(string("Unknown command: ") + token + string("\n"));
- }
-
- start = string_end;
- }
- }
+ if (FGModel::Run(Holding)) return true;
- RunPostFunctions();
+ vector<FGInputType*>::iterator it;
+ for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
+ (*it)->Run(Holding);
return false;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGInput::Load(Element* element)
+bool FGInput::SetDirectivesFile(const std::string& fname)
{
- string type="", parameter="";
- string name="", fname="";
- string property;
-
- // if the input has already been set up, print a warning message and return
- if (port > 0) {
- cerr << "An input port has already been assigned for this run" << endl;
- return false;
- }
+ FGXMLFileRead XMLFile;
+ Element* document = XMLFile.LoadXMLDocument(fname);
+ bool result = Load(document);
- port = int(element->GetAttributeValueAsNumber("port"));
- if (port == 0) {
- cerr << endl << "No port assigned in input element" << endl;
- } else {
- socket = new FGfdmSocket(port);
- }
+ if (!result)
+ cerr << endl << "Aircraft input element has problems in file " << fname << endl;
- Debug(2);
+ return result;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGInput::Enable(void)
+{
+ vector<FGInputType*>::iterator it;
+ for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
+ (*it)->Enable();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGInput::Disable(void)
+{
+ vector<FGInputType*>::iterator it;
+ for (it = InputTypes.begin(); it != InputTypes.end(); ++it)
+ (*it)->Disable();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInput::Toggle(int idx)
+{
+ if (idx >= (int)0 && idx < (int)InputTypes.size())
+ return InputTypes[idx]->Toggle();
+ return false;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInput::SetInputName(unsigned int idx, const std::string& name)
+{
+ if (idx >= InputTypes.size()) return false;
+
+ InputTypes[idx]->SetInputName(name);
return true;
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGInput::GetInputName(unsigned int idx) const
+{
+ string name;
+
+ if (idx < InputTypes.size())
+ name = InputTypes[idx]->GetInputName();
+ return name;
+}
+
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
HISTORY
--------------------------------------------------------------------------------
12/02/98 JSB Created
+19/01/15 PCH Split the code in several classes (see input_output dir)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGModel.h"
-
-#include <string>
+#include "input_output/FGInputType.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_INPUT "$Id: FGInput.h,v 1.10 2012/11/17 19:42:53 bcoconni Exp $"
+#define ID_INPUT "$Id: FGInput.h,v 1.11 2015/02/15 12:03:21 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
namespace JSBSim {
-class FGFDMExec;
-class Element;
-class FGfdmSocket;
-
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-/** Handles simulation socket input.
+/** Handles simulation input.
+ INPUT section definition
+
+ The following specifies the way that JSBSim writes out data.
+<pre>
+ NAME is the filename you want the input to come from
+
+ TYPE can be:
+ SOCKET Will eventually send data to a socket input, where NAME
+ would then be the IP address of the machine the data should
+ be sent to. DON'T USE THIS YET!
+ NONE Specifies to do nothing. This setting makes it easy to turn on and
+ off the data input without having to mess with anything else.
+
+ Examples:
+</pre>
+@code
+<input type="SOCKET" port="4321"/>
+@endcode
+<br>
+
+ The class FGInput is the manager of the inputs requested by the user. It
+ manages a list of instances derived from the abstract class FGInputType.
+ @version $Id: FGInput.h,v 1.11 2015/02/15 12:03:21 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGInput(FGFDMExec*);
~FGInput();
+ /** Load the input directives and adds a new input instance to the Input
+ Manager list.
+ @param el XMLElement that is pointing to the input directives
+ @result true if the execution succeeded. */
+ bool Load(Element* el);
+
+ /** Initializes the instance. This method is called by FGFDMExec::RunIC().
+ This is were the initialization of all classes derived from FGInputType
+ takes place. It is important that this method is not called prior
+ to FGFDMExec::RunIC() so that the initialization process can be executed
+ properly.
+ @result true if the execution succeeded. */
bool InitModel(void);
+
/** Runs the Input model; called by the Executive
Can pass in a value indicating if the executive is directing the simulation to Hold.
- @param Holding if true, the executive has been directed to hold the sim from
+ @param Holding if true, the executive has been directed to hold the sim from
advancing time. Some models may ignore this flag, such as the Input
model, which may need to be active to listen on a socket for the
"Resume" command to be given.
@return false if no error */
bool Run(bool Holding);
- bool Load(Element* el);
+ /** Adds a new input instance to the Input Manager. The definition of the
+ new input instance is read from a file.
+ @param fname the name of the file from which the ouput directives should
+ be read.
+ @return true if the execution succeeded. */
+ bool SetDirectivesFile(const std::string& fname);
+
+ /// Enables the input generation for all input instances.
+ void Enable(void);
+ /// Disables the input generation for all input instances.
+ void Disable(void);
+ /** Toggles the input generation for an ouput instances.
+ @param idx ID of the input instance which input generation will be
+ toggled.
+ @result false if the instance does not exist otherwise returns the status
+ of the input generation (i.e. true if the input has been
+ enabled, false if the input has been disabled) */
+ bool Toggle(int idx);
+
+ /** Overwrites the name identifier under which the input will be logged.
+ This method is taken into account if it is called between Load() and
+ FGFDMExec::RunIC() otherwise it is ignored until the next call to
+ SetStartNewInput().
+ @param idx ID of the instance which name identifier will be changed
+ @param name new name
+ @result false if the instance does not exists. */
+ bool SetInputName(unsigned int idx, const std::string& name);
+ /** Get the name identifier to which the input will be directed.
+ @param idx ID of the input instance from which the name identifier must
+ be obtained
+ @result the name identifier.*/
+ std::string GetInputName(unsigned int idx) const;
private:
- unsigned int port;
- FGfdmSocket* socket;
- std::string data;
+ std::vector<FGInputType*> InputTypes;
+
void Debug(int from);
};
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif
-
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.52 2015/02/15 10:14:46 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.53 2015/03/28 14:49:02 bcoconni Exp $");
IDENT(IdHdr,ID_MASSBALANCE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const FGMatrix33& FGMassBalance::CalculatePMInertias(void)
{
- unsigned int size;
+ size_t size = PointMasses.size();
- size = PointMasses.size();
if (size == 0) return pmJ;
pmJ = FGMatrix33();
//
// This function binds properties for each pointmass object created.
//
-void FGMassBalance::PointMass::bind(FGPropertyManager* PropertyManager, int num) {
+void FGMassBalance::PointMass::bind(FGPropertyManager* PropertyManager,
+ unsigned int num) {
string tmp = CreateIndexedPropertyName("inertia/pointmass-weight-lbs", num);
PropertyManager->Tie( tmp.c_str(), this, &PointMass::GetPointMassWeight,
&PointMass::SetPointMassWeight);
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.32 2014/11/29 13:47:19 bcoconni Exp $"
+#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.35 2015/03/28 14:49:02 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONSS
void SetPointMassMoI(const FGMatrix33& MoI) { mPMInertia = MoI; }
double GetPointMassMoI(int r, int c) {return mPMInertia(r,c);}
- void bind(FGPropertyManager* PropertyManager, int num);
+ void bind(FGPropertyManager* PropertyManager, unsigned int num);
};
std::vector <struct PointMass*> PointMasses;
#include "input_output/FGOutputSocket.h"
#include "input_output/FGOutputTextFile.h"
#include "input_output/FGOutputFG.h"
+#include "input_output/FGUDPOutputSocket.h"
#include "input_output/FGXMLFileRead.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGModelLoader.h"
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGOutput.cpp,v 1.80 2014/09/12 20:10:05 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGOutput.cpp,v 1.82 2015/04/02 02:20:50 dpculp Exp $");
IDENT(IdHdr,ID_OUTPUT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
std::string port, std::string name, double outRate,
std::vector<FGPropertyNode_ptr> & outputProperties)
{
- unsigned int idx = OutputTypes.size();
+ size_t idx = OutputTypes.size();
FGOutputType* Output = 0;
if (debug_lvl > 0) cout << endl << " Output data set: " << idx << endl;
} else if (type == "FLIGHTGEAR") {
Output = new FGOutputFG(FDMExec);
name += ":" + port + "/" + protocol;
+ } else if (type == "QTJSBSIM") {
+ Output = new FGUDPOutputSocket(FDMExec);
+ name += ":" + port + "/" + protocol;
} else if (type == "TERMINAL") {
// Not done yet
} else if (type != string("NONE")) {
FGModel::PreLoad(element, PropertyManager);
- unsigned int idx = OutputTypes.size();
+ size_t idx = OutputTypes.size();
string type = element->GetAttributeValue("type");
FGOutputType* Output = 0;
Output = new FGOutputSocket(FDMExec);
} else if (type == "FLIGHTGEAR") {
Output = new FGOutputFG(FDMExec);
+ } else if (type == "QTJSBSIM") {
+ Output = new FGUDPOutputSocket(FDMExec);
} else if (type == "TERMINAL") {
// Not done yet
} else if (type != string("NONE")) {
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPropulsion.cpp,v 1.83 2015/01/31 14:56:21 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGPropulsion.cpp,v 1.84 2015/03/28 14:49:02 bcoconni Exp $");
IDENT(IdHdr,ID_PROPULSION);
extern short debug_lvl;
const FGMatrix33& FGPropulsion::CalculateTankInertias(void)
{
- unsigned int size;
+ size_t size = Tanks.size();
- size = Tanks.size();
if (size == 0) return tankJ;
tankJ = FGMatrix33();
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGWinds.cpp,v 1.14 2014/09/03 17:40:59 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGWinds.cpp,v 1.15 2015/02/27 20:49:36 bcoconni Exp $");
IDENT(IdHdr,ID_WINDS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// square a value, but preserve the original sign
+/*
static inline double square_signed (double value)
{
if (value < 0)
else
return value * value;
}
+*/
/// simply square a value
static inline double sqr(double x) { return x*x; }
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_WINDS "$Id: FGWinds.h,v 1.10 2014/02/17 05:02:38 jberndt Exp $"
+#define ID_WINDS "$Id: FGWinds.h,v 1.11 2015/02/27 20:36:47 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
private:
double MagnitudedAccelDt, MagnitudeAccel, Magnitude, TurbDirection;
- double h;
+ //double h;
double TurbGain;
double TurbRate;
double Rhythmicity;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ACCELEROMETER "$Id: FGAccelerometer.h,v 1.8 2013/12/07 12:21:14 bcoconni Exp $"
+#define ID_ACCELEROMETER "$Id: FGAccelerometer.h,v 1.9 2015/03/07 18:48:22 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
<drift_rate> number </drift_rate>
<gain> number </gain>
<bias> number </bias>
+ <output> { output_property } </output>
</accelerometer>
@endcode
<max> 400 </max>
</quantization>
<bias> 0.5 </bias>
+ <output> aero/accelerometer/right_tip_wing </output>
</accelerometer>
@endcode
time.
@author Jon S. Berndt
-@version $Revision: 1.8 $
+@version $Revision: 1.9 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ACTUATOR "$Id: FGActuator.h,v 1.19 2014/08/28 13:44:28 bcoconni Exp $"
+#define ID_ACTUATOR "$Id: FGActuator.h,v 1.20 2015/02/27 20:36:47 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@endcode
@author Jon S. Berndt
-@version $Revision: 1.19 $
+@version $Revision: 1.20 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool IsSaturated(void) const {return saturated;}
private:
- double span;
+ //double span;
double bias;
FGParameter* rate_limit_incr;
FGParameter* rate_limit_decr;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGDistributor.cpp,v 1.6 2014/02/17 05:33:25 jberndt Exp $");
+IDENT(IdSrc,"$Id: FGDistributor.cpp,v 1.7 2015/02/27 20:46:01 bcoconni Exp $");
IDENT(IdHdr,ID_DISTRIBUTOR);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case_element = element->FindElement("case");
while (case_element) {
- current_case = new struct Case;
+ current_case = new Case;
test_element = case_element->FindElement("test");
if (test_element) current_case->SetTest(new FGCondition(test_element, PropertyManager));
prop_val_element = case_element->FindElement("property");
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_DISTRIBUTOR "$Id: FGDistributor.h,v 1.6 2014/02/17 05:33:25 jberndt Exp $"
+#define ID_DISTRIBUTOR "$Id: FGDistributor.h,v 1.7 2015/03/28 14:49:02 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
Note: In the "logic" attribute, "AND" is the default logic, if none is supplied.
@author Jon S. Berndt
-@version $Id: FGDistributor.h,v 1.6 2014/02/17 05:33:25 jberndt Exp $
+@version $Id: FGDistributor.h,v 1.7 2015/03/28 14:49:02 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for (unsigned int i=0; i<PropValPairs.size(); i++) PropValPairs[i]->SetPropToValue();
}
PropValPair* GetPropValPair(unsigned int idx) { return PropValPairs[idx]; }
- unsigned int GetNumPropValPairs(void) {return PropValPairs.size();}
+ size_t GetNumPropValPairs(void) {return PropValPairs.size();}
bool HasTest() {return (Test != 0);}
bool GetTestResult() { return Test->Evaluate(); }
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FLAPS "$Id: FGKinemat.h,v 1.10 2009/10/24 22:59:30 jberndt Exp $"
+#define ID_FLAPS "$Id: FGKinemat.h,v 1.11 2015/03/28 14:49:02 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
private:
std::vector<double> Detents;
std::vector<double> TransitionTimes;
- int NumDetents;
+ size_t NumDetents;
double OutputPct;
bool DoScale;
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ELECTRIC "$Id: FGElectric.h,v 1.12 2013/11/24 11:40:57 bcoconni Exp $"
+#define ID_ELECTRIC "$Id: FGElectric.h,v 1.14 2015/02/27 20:36:47 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
there is no battery model available, so this motor does not consume any
energy. There is no internal friction.
@author David Culp
- @version "$Id: FGElectric.h,v 1.12 2013/11/24 11:40:57 bcoconni Exp $"
+ @version "$Id: FGElectric.h,v 1.14 2015/02/27 20:36:47 bcoconni Exp $"
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double CalcFuelNeed(void);
- double BrakeHorsePower;
+ //double BrakeHorsePower;
// constants
double hptowatts;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGEngine.cpp,v 1.61 2015/01/07 23:22:59 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGEngine.cpp,v 1.62 2015/02/27 20:42:55 bcoconni Exp $");
IDENT(IdHdr,ID_ENGINE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
unsigned int FGEngine::GetSourceTank(unsigned int i) const
{
- if (i >= 0 && i < SourceTanks.size()) {
+ if (i < SourceTanks.size()) {
return SourceTanks[i];
} else {
throw("No such source tank is available for this engine");
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ENGINE "$Id: FGEngine.h,v 1.43 2015/01/07 23:22:59 dpculp Exp $"
+#define ID_ENGINE "$Id: FGEngine.h,v 1.44 2015/03/28 14:49:02 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
documentation for engine and thruster classes.
</pre>
@author Jon S. Berndt
- @version $Id: FGEngine.h,v 1.43 2015/01/07 23:22:59 dpculp Exp $
+ @version $Id: FGEngine.h,v 1.44 2015/03/28 14:49:02 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGThruster* GetThruster(void) const {return Thruster;}
unsigned int GetSourceTank(unsigned int i) const;
- unsigned int GetNumSourceTanks() const {return SourceTanks.size();}
+ size_t GetNumSourceTanks() const {return SourceTanks.size();}
virtual std::string GetEngineLabels(const std::string& delimiter) = 0;
virtual std::string GetEngineValues(const std::string& delimiter) = 0;
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPiston.cpp,v 1.78 2015/01/07 23:22:59 dpculp Exp $");
+IDENT(IdSrc,"$Id: FGPiston.cpp,v 1.79 2015/02/27 20:36:47 bcoconni Exp $");
IDENT(IdHdr,ID_PISTON);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Inputs& input)
: FGEngine(exec, engine_number, input),
R_air(287.3), // Gas constant for air J/Kg/K
- rho_fuel(800), // estimate
calorific_value_fuel(47.3e6), // J/Kg
Cp_air(1005), // Specific heat (constant pressure) J/Kg/K
Cp_fuel(1700),
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PISTON "$Id: FGPiston.h,v 1.35 2012/04/07 01:50:54 jentron Exp $"
+#define ID_PISTON "$Id: FGPiston.h,v 1.37 2015/02/27 20:36:47 bcoconni Exp $"
#define FG_MAX_BOOST_SPEEDS 3
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@author David Megginson (initial porting and additional code)
@author Ron Jensen (additional engine code)
@see Taylor, Charles Fayette, "The Internal Combustion Engine in Theory and Practice"
- @version $Id: FGPiston.h,v 1.35 2012/04/07 01:50:54 jentron Exp $
+ @version $Id: FGPiston.h,v 1.37 2015/02/27 20:36:47 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int crank_counter;
double IndicatedHorsePower;
- double IndicatedPower;
+ //double IndicatedPower;
double PMEP;
double FMEP;
double FMEPDynamic;
double FMEPStatic;
- double T_Intake;
+ //double T_Intake;
void doEngineStartup(void);
void doBoostControl(void);
//
const double R_air;
- const double rho_fuel; // kg/m^3
+ //const double rho_fuel; // kg/m^3
const double calorific_value_fuel; // J/Kg (approximate)
const double Cp_air; // J/KgK
const double Cp_fuel; // J/KgK
//
double MinManifoldPressure_inHg; // Inches Hg
double MaxManifoldPressure_inHg; // Inches Hg
- double MaxManifoldPressure_Percent; // MaxManifoldPressure / 29.92
+ //double MaxManifoldPressure_Percent; // MaxManifoldPressure / 29.92
double ManifoldPressureLag; // Manifold Pressure delay in seconds.
double Displacement; // cubic inches
double displacement_SI; // cubic meters
double rho_air;
double volumetric_efficiency;
double volumetric_efficiency_reduced;
- double map_coefficient;
+ //double map_coefficient;
double m_dot_air;
double v_dot_air;
double equivalence_ratio;
#include "FGEngine.h"
#include "math/FGTable.h"
-#define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.18 2013/11/24 14:22:22 bcoconni Exp $"
+#define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.19 2015/02/27 20:36:48 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
double StarterN1; // rotates of generator maked by starter [%]
double MaxStartingTime; // maximal time for start [s] (-1 means not used)
double RPM; // shaft RPM
- double Velocity;
- double rho;
+ //double Velocity;
+ //double rho;
double PSFC; // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
double CombustionEfficiency;