44 #include "FGUDPOutputSocket.h" 45 #include "FGFDMExec.h" 46 #include "input_output/FGPropertyManager.h" 47 #include "input_output/FGXMLElement.h" 53 IDENT(IdSrc,
"$Id: FGUDPOutputSocket.cpp,v 1.2 2015/08/16 13:19:52 bcoconni Exp $");
54 IDENT(IdHdr,ID_UDPOUTPUTSOCKET);
60 FGUDPOutputSocket::FGUDPOutputSocket(
FGFDMExec* fdmex) :
66 root = PropertyManager->GetNode();
68 SockName =
"localhost";
86 while (property_element) {
87 string property_str = property_element->
GetDataLine();
90 node = PropertyManager->GetNode(
"simulation/null");
92 OutputProperties.push_back(node);
104 cerr << endl <<
"No port assigned for output." << endl;
117 socket =
new FGfdmSocket(SockName, SockPort, FGfdmSocket::ptUDP);
119 if (socket == 0)
return false;
120 if (!socket->GetConnectStatus())
return false;
133 if (socket == 0)
return;
134 if (!socket->GetConnectStatus())
return;
139 for (
unsigned int i=0;i<OutputProperties.size();i++) {
140 socket->Append(OutputProperties[i]->getDoubleValue());
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
bool InitModel(void)
Initializes the instance.
virtual bool InitModel(void)
Init the output model according to its configitation.
Class wrapper for property handling.
void Print(void)
Generates and sends the output datagram.
Element * FindElement(const std::string &el="")
Searches for a specified element.
bool SetDouble(const std::string &name, double val)
Set a double value for a property.
virtual bool Load(Element *el)
Init the output directives from an XML file.
FGPropertyManager * GetPropertyManager(void)
Returns a pointer to the property manager object.
void SetRateHz(double rtHz)
Set the output rate for this output instances.
~FGUDPOutputSocket()
Destructor.
double GetAttributeValueAsNumber(const std::string &key)
Retrieves an attribute value as a double precision real number.
std::string GetDataLine(unsigned int i=0)
Gets a line of data belonging to an element.
Abstract class to provide functions generic to all the output directives.
double GetSimTime(void) const
Returns the cumulative simulation time in seconds.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
Encapsulates the JSBSim simulation executive.
Encapsulates an object that enables JSBSim to communicate via socket (input and/or output)...