The xplane_io (X-Plane I/O) program is used to establish network communications, via UDP, with the X-Plane flight simulator running on a computer. The code consists of class libraries that abstract the lower-level UDP packet encoding and decoding details, according to the UDP protocol specifications in X-Plane version 9. Any X-Plane DATA packets can be sent and received, and any X-Plane DataRefs can be set by sending DREF packets to X-Plane.
Dependencies: EthernetNetIf mbed ConfigFile
XPlaneUdp/XPlaneUdpDATA.h
- Committer:
- bapowell
- Date:
- 2011-12-21
- Revision:
- 0:a5d13af495af
File content as of revision 0:a5d13af495af:
#ifndef XPLANEUDPDATA_H_INCLUDED #define XPLANEUDPDATA_H_INCLUDED #include <map> #include "mbed.h" #include "XPlaneUdp.h" #define XPLANE_DATA_MSG_LENGTH 36 // 1 int + 8 floats class XPlaneUdpDATA { public: XPlaneUdpDATA(int messageIndex, bool reverseByteOrder); /** * Accessor for the message index of this DATA message. */ int messageIndex() const; /** * Accessor for the float data at the given float index (0-7). */ float getData(int i) const; /** * Mutator for the float data at the given float index (0-7). * The dataChanged flag will also be set. */ void setData(int i, float f); /** * Overload the [] operator to return a reference to the float data at the given float index (0-7). * NOTE: The dataChanged flag will not be set if this is used to modify the float data. */ float& operator [] (int i); /** * Fill data[8] with 32 bytes starting at (DATAMessage + 4). * Byte order will be reversed, according to the reverseByteOrder property. */ void setAllData(char * DATAMessage); /** * Starting at the given pointer location, populate 36 bytes from values in index and data[8]. * Byte order will be reversed, according to the reverseByteOrder property. */ void populateDATAMessage(char * bytes); // Methods to read/write flag to track if data has been modified. bool isDataChanged() const; void setDataChanged(); void resetDataChanged(); /** * Print a representation of this instance to outputStream. */ void toString(FILE * outputStream); private: int _messageIndex; float _data[8]; bool _reverseByteOrder; bool _dataChanged; }; #endif // XPLANEUDPDATA_H_INCLUDED