29 #ifndef _XPMPRemote_h_
30 #define _XPMPRemote_h_
60 const std::string& _shortId);
66 constexpr
const T&
clamp(
const T& v,
const T& lo,
const T& hi )
69 return (v < lo) ? lo : (hi < v) ? hi : v;
96 std::uint8_t
pack (
float f)
const {
return std::uint8_t(clamp<float>(f-
minV,0.0f,
range) * UINT8_MAX /
range); }
102 extern const std::array<RemoteDataRefPackTy,V_COUNT>
REMOTE_DR_DEF;
113 #elif defined(__clang__) || defined(__GNUC__)
114 #define PACKED __attribute__ ((__packed__))
116 #error Unhandled Compiler!
230 void CopyFrom (
const Aircraft& _ac,
double _lat,
double _lon,
float _alt_ft, std::uint16_t _dTime);
243 void SetRoll (
float _r) {
roll = std::int16_t(std::lround(_r*100.0f)); }
293 std::int16_t _dLat, std::int16_t _dLon,
294 std::int16_t _dAlt_ft, std::uint16_t _dTime,
295 float _pitch,
float _heading,
float _roll);
305 void SetRoll (
float _r) {
roll = std::int16_t(std::lround(_r*100.0f)); }
348 static constexpr
size_t msgSize (std::uint8_t num)
399 static_assert(
sizeof(RemoteMsgBaseTy) == 8,
"RemoteMsgBaseTy doesn't have expected size");
400 static_assert(
sizeof(RemoteMsgSettingsTy) == 40,
"RemoteMsgSettingsTy doesn't have expected size");
401 static_assert(
sizeof(RemoteAcDetailTy) == 246+42,
"RemoteAcDetailTy doesn't have expected size");
402 static_assert(
sizeof(RemoteMsgAcDetailTy) == 254+42,
"RemoteMsgAcDetailTy doesn't have expected size");
403 static_assert(
sizeof(RemoteAcPosUpdateTy) == 20,
"RemoteAcPosUpdateTy doesn't have expected size");
404 static_assert(
sizeof(RemoteMsgAcPosUpdateTy)== 28,
"RemoteMsgAcPosUpdateTy doesn't have expected size");
405 static_assert(
sizeof(RemoteAcAnimTy) == 8,
"RemoteAcAnimTy doesn't have expected size");
407 static_assert(
sizeof(RemoteMsgAcAnimTy) == 16,
"RemoteMsgAcAnimTy doesn't have expected size");
408 static_assert(
sizeof(RemoteMsgAcRemoveTy) == 12,
"RemoteMsgAcRemoveTy doesn't have expected size");
422 const std::string& sFrom,
unsigned XPMPPlaneID
Unique ID for an aircraft created by a plugin.
Definition: XPMPMultiplayer.h:252
Actual representation of all aircraft in XPMP2.
Definition: XPMPAircraft.h:178
Represents a CSL model as it is saved on disk.
Definition: CSLModels.h:113
Definition: XPMPAircraft.h:70
constexpr std::uint8_t RMT_VER_BEACON
Interest Beacon message version number.
Definition: XPMPRemote.h:136
constexpr std::uint8_t RMT_VER_AC_DETAIL_0
Definition: XPMPRemote.h:182
constexpr std::uint8_t RMT_VER_SETTINGS
Setttings message version number.
Definition: XPMPRemote.h:152
constexpr std::uint8_t RMT_VER_AC_ANIM
A/C Position update message version number.
Definition: XPMPRemote.h:326
constexpr std::uint8_t RMT_VER_AC_REMOVE
A/C removal message version number.
Definition: XPMPRemote.h:372
RemoteStatusTy RemoteGetStatus()
Returns the current Remote status.
Definition: Remote.cpp:1145
void RemoteRecvStop()
Stops the receiver.
Definition: Remote.cpp:1410
RemoteMsgTy
Message type.
Definition: XPMPRemote.h:77
@ RMT_MSG_AC_REMOVE
aircraft is removed
Definition: XPMPRemote.h:84
@ RMT_MSG_AC_ANIM
aircraft animation values (dataRef values) only
Definition: XPMPRemote.h:83
@ RMT_MSG_INTEREST_BEACON
beacon sent by a remote client to signal interest in data
Definition: XPMPRemote.h:78
@ RMT_MSG_SEND
internal indicator telling to send out all pending messages
Definition: XPMPRemote.h:79
@ RMT_MSG_AC_DETAILED
aircraft full details, needed to create new a/c objects and to re-synch all remote data
Definition: XPMPRemote.h:81
@ RMT_MSG_SETTINGS
a sender's id and its settings
Definition: XPMPRemote.h:80
@ RMT_MSG_AC_POS_UPDATE
aircraft differences only
Definition: XPMPRemote.h:82
constexpr float REMOTE_MAX_DIFF_TIME
maximum time difference thatn can be represented in a pos update msg
Definition: XPMPRemote.h:272
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
Clamps v between lo and hi: lo if v < lo, hi if hi < v, otherwise v
Definition: XPMPRemote.h:66
constexpr std::uint8_t RMT_VER_AC_DETAIL_1
Definition: XPMPRemote.h:181
CSLModel * CSLModelByPkgShortId(std::uint16_t _pkgHash, const std::string &_shortId)
Find a model by package name hash and short id.
Definition: CSLModels.cpp:1154
RemoteStatusTy
State of remote communcations.
Definition: XPMPRemote.h:439
@ REMOTE_RECV_WAITING
waiting to receive data, periodically sending a token of interest
Definition: XPMPRemote.h:443
@ REMOTE_OFF
no remote connectivtiy, not listening, not sending
Definition: XPMPRemote.h:440
@ REMOTE_SEND_WAITING
listening for a request to send data, but not actively sending data
Definition: XPMPRemote.h:441
@ REMOTE_SENDING
actively sending aircraft data out to the network
Definition: XPMPRemote.h:442
@ REMOTE_RECEIVING
actively receiving data
Definition: XPMPRemote.h:444
constexpr double REMOTE_DEGREE_RES
What is the maximum difference a RemoteAcPosUpdateTy can hold?
Definition: XPMPRemote.h:267
constexpr std::uint8_t RMT_VER_AC_DETAIL
A/C detail message version number.
Definition: XPMPRemote.h:179
constexpr float REMOTE_TIME_RES
resolution of time difference
Definition: XPMPRemote.h:271
constexpr double REMOTE_MAX_DIFF_ALT_FT
maximum altitude[ft] difference that can be represented in a pos update msg
Definition: XPMPRemote.h:270
constexpr int REMOTE_SEND_SETTINGS_INTVL
How often to send settings? [s].
Definition: XPMPRemote.h:149
std::uint16_t PJWHash16(const char *s)
Produces a reproducible(!) hash value for strings.
Definition: Utilities.cpp:634
constexpr std::uint8_t RMT_VER_AC_DETAIL_2
Definition: XPMPRemote.h:180
struct XPMP2::RemoteMsgBaseTy PACKED
DR_VALS
The dataRefs provided by XPMP2 to the CSL models.
Definition: XPMPAircraft.h:87
@ V_COUNT
always last, number of dataRefs XPMP2 pre-defines
Definition: XPMPAircraft.h:137
constexpr double REMOTE_ALT_FT_RES
resolution of altitude[ft] updates
Definition: XPMPRemote.h:269
const std::array< RemoteDataRefPackTy, V_COUNT > REMOTE_DR_DEF
An array holding all dataRef packing definitions.
Definition: Remote.cpp:36
constexpr const char * REMOTE_SIGNATURE
The signature of the XPMP2 Remote Client.
Definition: XPMPRemote.h:42
constexpr double REMOTE_MAX_DIFF_DEGREE
maximum degree difference that can be represented in a pos update msg
Definition: XPMPRemote.h:268
constexpr std::uint8_t RMT_VER_AC_POS_UPDATE
A/C Position update message version number.
Definition: XPMPRemote.h:264
void RemoteRecvStart(const RemoteCBFctTy &_rmtCBFcts)
Starts the listener, will call provided callback functions with received messages.
Definition: Remote.cpp:1403
A/C animation dataRef changes.
Definition: XPMPRemote.h:333
DR_VALS idx
index into XPMP2::Aircraft::v
Definition: XPMPRemote.h:340
std::uint8_t v
dataRef animation value
Definition: XPMPRemote.h:341
std::uint8_t filler
not yet used
Definition: XPMPRemote.h:336
static constexpr size_t msgSize(std::uint8_t num)
message size assuming num array elements
Definition: XPMPRemote.h:348
size_t msgSize() const
current message size
Definition: XPMPRemote.h:351
RemoteAcAnimTy(XPMPPlaneID _id)
Constructor.
Definition: XPMPRemote.h:345
struct XPMP2::RemoteAcAnimTy::DataRefValTy v[1]
array of dataRef animation types and value
std::uint8_t numVals
number of dataRef values in the following array
Definition: XPMPRemote.h:335
std::uint32_t modeS_id
plane's unique id at the sender side (might differ remotely in case of duplicates)
Definition: XPMPRemote.h:334
dataRef animation types and value
Definition: XPMPRemote.h:339
A/C details, packed into an array message.
Definition: XPMPRemote.h:184
double lat
latitude
Definition: XPMPRemote.h:194
double lon
longitude
Definition: XPMPRemote.h:195
void CopyFrom(const Aircraft &_ac, double _lat, double _lon, float _alt_ft, std::uint16_t _dTime)
Copies values from passed-in XPMP2::Aircraft object.
Definition: Remote.cpp:192
bool bVisible
Shall this plane be drawn at the moment?
Definition: XPMPRemote.h:203
char flightNum[10]
flight number
Definition: XPMPRemote.h:214
std::int16_t roll
[0.01°] roll/100
Definition: XPMPRemote.h:198
char icaoOp[4]
icao airline code
Definition: XPMPRemote.h:187
char icaoType[4]
icao a/c type
Definition: XPMPRemote.h:186
std::uint16_t heading
[0.01°] heading/100
Definition: XPMPRemote.h:197
std::uint8_t filler[3]
yet unused
Definition: XPMPRemote.h:220
char manufacturer[40]
a/c manufacturer, human readable
Definition: XPMPRemote.h:211
std::uint32_t modeS_id
plane's unique id at the sender side (might differ remotely in case of duplicates)
Definition: XPMPRemote.h:185
void SetPitch(float _p)
sets pitch from float
Definition: XPMPRemote.h:235
float alt_ft
[ft] current altitude
Definition: XPMPRemote.h:192
bool bOnGrnd
Is the aircraft on the ground?
Definition: XPMPRemote.h:206
float GetRoll() const
returns float pitch
Definition: XPMPRemote.h:244
void SetRoll(float _r)
sets pitch from float
Definition: XPMPRemote.h:243
std::uint16_t pkgHash
hash value of package name
Definition: XPMPRemote.h:189
char label[23]
label
Definition: XPMPRemote.h:190
std::uint8_t labelCol[3]
label color (RGB)
Definition: XPMPRemote.h:191
char airline[40]
airline, human readable
Definition: XPMPRemote.h:213
float GetHeading() const
returns float heading
Definition: XPMPRemote.h:241
char model[40]
a/c model, human readable
Definition: XPMPRemote.h:212
char tailNum[10]
registration, tail number
Definition: XPMPRemote.h:210
char aptFrom[5]
Origin airport (ICAO)
Definition: XPMPRemote.h:215
bool bRender
Shall the CSL model be drawn in 3D world?
Definition: XPMPRemote.h:204
static constexpr size_t msgSize()
message size
Definition: XPMPRemote.h:246
std::uint8_t v[XPMP2::V_COUNT]
Definition: XPMPRemote.h:223
char sShortId[20]
CSL model's short id.
Definition: XPMPRemote.h:188
void SetLabelCol(const float _col[4])
set the label color from a float array (4th number, alpha, is always considered 1....
Definition: Remote.cpp:243
void GetLabelCol(float _col[4]) const
writes color out into a float array
Definition: Remote.cpp:251
bool bValid
is this object valid? (Will be reset in case of exceptions)
Definition: XPMPRemote.h:202
void SetHeading(float _h)
Sets heading from float.
Definition: Remote.cpp:260
bool bDrawLabel
Draw the label of the aircraft? (new with v2)
Definition: XPMPRemote.h:205
std::uint8_t contrailDist_m
distance between several contrails and to the aircraft's centerline, in meter
Definition: XPMPRemote.h:218
RemoteAcDetailTy()
Default Constructor sets all to zero.
Definition: Remote.cpp:170
std::int16_t aiPrio
priority for display in limited TCAS target slots, -1 indicates "no TCAS display"
Definition: XPMPRemote.h:200
std::uint8_t contrailLifeTime
this aircraft's contrail's life time
Definition: XPMPRemote.h:219
char aptTo[5]
Destination airport (ICAO)
Definition: XPMPRemote.h:216
std::int16_t pitch
[0.01°] pitch/100
Definition: XPMPRemote.h:196
std::uint16_t dTime
[0.0001s] time difference to previous position in 1/10000s
Definition: XPMPRemote.h:201
float GetPitch() const
returns float pitch
Definition: XPMPRemote.h:236
std::uint8_t contrailNum
number of contrails requested
Definition: XPMPRemote.h:207
A/C Position updates based on global coordinates.
Definition: XPMPRemote.h:278
std::uint16_t dTime
[0.0001s] time difference to previous position in 1/10000s
Definition: XPMPRemote.h:283
float GetPitch() const
returns float pitch
Definition: XPMPRemote.h:298
std::int16_t roll
[0.01 degree] roll/100
Definition: XPMPRemote.h:286
float GetHeading() const
returns float heading
Definition: XPMPRemote.h:303
std::int16_t dAlt_ft
[0.01 ft] altitude difference
Definition: XPMPRemote.h:282
std::uint16_t filler1
not yet used (for 4-byte alignment)
Definition: XPMPRemote.h:287
std::uint16_t heading
[0.01 degree] heading/100
Definition: XPMPRemote.h:285
std::uint32_t modeS_id
plane's unique id at the sender side (might differ remotely in case of duplicates)
Definition: XPMPRemote.h:279
void SetPitch(float _p)
sets pitch from float
Definition: XPMPRemote.h:297
std::int16_t pitch
[0.01 degree] pitch/100
Definition: XPMPRemote.h:284
std::int16_t dLon
[0.0000001 degrees] longitude position difference
Definition: XPMPRemote.h:281
RemoteAcPosUpdateTy()
Default Constructor sets all 0.
Definition: XPMPRemote.h:290
void SetRoll(float _r)
sets pitch from float
Definition: XPMPRemote.h:305
static constexpr size_t msgSize()
message size
Definition: XPMPRemote.h:308
std::int16_t dLat
[0.0000001 degrees] latitude position difference
Definition: XPMPRemote.h:280
void SetHeading(float _h)
Sets heading from float.
Definition: Remote.cpp:386
float GetRoll() const
returns float pitch
Definition: XPMPRemote.h:306
A/C Removal only includes the plane id, structure required for msgSize() function.
Definition: XPMPRemote.h:375
std::uint32_t modeS_id
plane's unique id at the sender side (might differ remotely in case of duplicates)
Definition: XPMPRemote.h:376
static constexpr size_t msgSize()
message size
Definition: XPMPRemote.h:381
RemoteAcRemoveTy(XPMPPlaneID _id=0)
Constructor sets plane id.
Definition: XPMPRemote.h:379
Function prototypes for callback functions to handle the received messages.
Definition: XPMPRemote.h:415
void(* pfMsgSettings)(const std::uint32_t from[4], const std::string &sFrom, const RemoteMsgSettingsTy &)
Callback for processing Settings messages.
Definition: XPMPRemote.h:421
void(* pfAfterLastAc)()
Called in flight loop after processing last aircraft.
Definition: XPMPRemote.h:419
void(* pfMsgACRemove)(const std::uint32_t from[4], size_t msgLen, const RemoteMsgAcRemoveTy &)
Callback for processing A/C Removal messages.
Definition: XPMPRemote.h:434
void(* pfMsgACAnim)(const std::uint32_t from[4], size_t msgLen, const RemoteMsgAcAnimTy &)
Callback for processing A/C Animation dataRef messages.
Definition: XPMPRemote.h:431
void(* pfBeforeFirstAc)()
Called in flight loop before processing first aircraft.
Definition: XPMPRemote.h:417
void(* pfMsgACDetails)(const std::uint32_t from[4], size_t msgLen, const RemoteMsgAcDetailTy &)
Callback for processing A/C Details messages.
Definition: XPMPRemote.h:425
void(* pfMsgACPosUpdate)(const std::uint32_t from[4], size_t msgLen, const RemoteMsgAcPosUpdateTy &)
Callback for processing A/C Details messages.
Definition: XPMPRemote.h:428
Definition for how to map dataRef values to (u)int8, ie. to an integer range of 8 bits.
Definition: XPMPRemote.h:88
float unpack(std::uint8_t i) const
unpack an integer value to float
Definition: XPMPRemote.h:98
RemoteDataRefPackTy(float _min, float _max)
Constructor sets minimum value and range.
Definition: XPMPRemote.h:93
float minV
minimum transferred value
Definition: XPMPRemote.h:89
std::uint8_t pack(float f) const
pack afloat value to integer
Definition: XPMPRemote.h:96
float range
range of transferred value = maxV - minV
Definition: XPMPRemote.h:90
A/C animation dataRef message, has an inherited header plus an array of variable sized XPMP2::RemoteA...
Definition: XPMPRemote.h:355
RemoteAcAnimTy animData
message data starts here but extend beyond this point!
Definition: XPMPRemote.h:356
const RemoteAcAnimTy * next(size_t _msgLen, const RemoteAcAnimTy *pCurr=nullptr) const
Returns a pointer to the first/next animation data element in the message.
Definition: Remote.cpp:505
RemoteMsgAcAnimTy()
Constructor sets expected message type and version.
Definition: XPMPRemote.h:359
A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements.
Definition: XPMPRemote.h:250
static constexpr size_t NumElem(size_t _msgLen)
Convert msg len to number of arr elements.
Definition: XPMPRemote.h:256
RemoteMsgAcDetailTy()
Constructor sets expected message type and version.
Definition: XPMPRemote.h:254
RemoteAcDetailTy arr[1]
basis for the array of actual details
Definition: XPMPRemote.h:251
A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements.
Definition: XPMPRemote.h:312
static constexpr size_t NumElem(size_t _msgLen)
Convert msg len to number of arr elements.
Definition: XPMPRemote.h:318
RemoteMsgAcPosUpdateTy()
Constructor sets expected message type and version.
Definition: XPMPRemote.h:316
RemoteAcPosUpdateTy arr[1]
basis for the array of actual position updates
Definition: XPMPRemote.h:313
A/C removal message, an array of plane ids.
Definition: XPMPRemote.h:385
RemoteAcRemoveTy arr[1]
plane's unique id at the sender side (might differ remotely in case of duplicates)
Definition: XPMPRemote.h:386
RemoteMsgAcRemoveTy()
Constructor sets expected message type and version.
Definition: XPMPRemote.h:389
static constexpr size_t NumElem(size_t _msgLen)
Convert msg len to number of arr elements.
Definition: XPMPRemote.h:391
Message header, identical for all message types.
Definition: XPMPRemote.h:120
std::uint8_t filler1
yet unsed
Definition: XPMPRemote.h:124
std::uint32_t filler2
Definition: XPMPRemote.h:126
RemoteMsgTy msgTy
message type
Definition: XPMPRemote.h:121
std::uint16_t pluginId
lower 16 bit of the sending plugin's id
Definition: XPMPRemote.h:125
std::uint8_t msgVer
message version
Definition: XPMPRemote.h:122
bool bLocalSender
is the sender "local", ie. on same machine?
Definition: XPMPRemote.h:123
RemoteMsgBaseTy(RemoteMsgTy _ty, std::uint8_t _ver)
Constructor just sets the values.
Definition: Remote.cpp:145
"Beacon of Interest", ie. some message on the multicast just to wake up sender
Definition: XPMPRemote.h:138
RemoteMsgBeaconTy()
Constructor sets appropriate message type.
Definition: Remote.cpp:153
Settings message, identifying a sending plugin, regularly providing its settings.
Definition: XPMPRemote.h:154
char name[16]
plugin's name, not necessarily zero-terminated if using full 12 chars
Definition: XPMPRemote.h:155
char defaultIcao[4]
Default ICAO aircraft type designator if no match can be found.
Definition: XPMPRemote.h:157
bool bMapEnabled
Do we feed X-Plane's maps with our aircraft positions?
Definition: XPMPRemote.h:164
std::uint8_t logLvl
logging level
Definition: XPMPRemote.h:159
RemoteMsgSettingsTy()
Constructor sets most values to zero.
Definition: Remote.cpp:159
bool bHaveTCASControl
Do we have AI/TCAS control?
Definition: XPMPRemote.h:166
bool bLabelCutOffAtVisibility
Cut off labels at XP's reported visibility mit?
Definition: XPMPRemote.h:163
bool bObjReplTextures
Replace textures in .obj files on load if needed?
Definition: XPMPRemote.h:162
char carIcaoType[4]
Ground vehicle type identifier.
Definition: XPMPRemote.h:158
bool bLogMdlMatch
Debug model matching?
Definition: XPMPRemote.h:160
bool bObjReplDataRefs
Replace dataRefs in .obj files on load?
Definition: XPMPRemote.h:161
std::uint16_t filler
yet unused, fills size up for a multiple of 8
Definition: XPMPRemote.h:167
float maxLabelDist
Maximum distance for drawing labels? [m].
Definition: XPMPRemote.h:156
bool bMapLabels
Do we show labels with the aircraft icons?
Definition: XPMPRemote.h:165