first commit

This commit is contained in:
Your Name
2022-10-20 20:29:11 +08:00
commit 4d531f8044
3238 changed files with 1387862 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
include(FlightGearComponent)
set(SOURCES
dds_ctrls.c
dds_gui.c
dds_fdm.c
dds_props.c
)
set(HEADERS
dds_ctrls.h
dds_fdm.h
dds_gui.h
dds_props.h
)
add_executable(fg_dds_log
WIN32
MACOSX_BUNDLE
fg_dds_log.cpp
${SOURCES}
)
setup_fgfs_libraries(fg_dds_log)
add_executable(fg_dds_prop
WIN32
MACOSX_BUNDLE
fg_dds_prop.cpp
${SOURCES}
)
setup_fgfs_libraries(fg_dds_prop)
flightgear_component(Network "${SOURCES}" "${HEADERS}")

12
src/Network/DDS/README Normal file
View File

@@ -0,0 +1,12 @@
Converting the OMG-IDL compatible interface definition files to C compatible
header and code files can be done using the package provided by CycloneDDS,
or any other OMG-IDL compatible IDL to C converter.
java -classpath "/usr/lib/cmake/CycloneDDS/idlc/idlc-jar-with-dependencies.jar"\
org.eclipse.cyclonedds.compilers.Idlc dds_<type>.idl
The .idl files as well as the genereated dds_ctrls, dds_fdm and dds_gui header
and souce files in this dirctory are in the Public Domain, and come with no
warranty.

View File

@@ -0,0 +1,88 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_ctrls.c
Source: dds_ctrls.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds_ctrls.h"
static const dds_key_descriptor_t FG_DDS_Ctrls_keys[1] =
{
{ "id", 0 }
};
static const uint32_t FG_DDS_Ctrls_ops [] =
{
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN | DDS_OP_FLAG_KEY, offsetof (FG_DDS_Ctrls, id),
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN, offsetof (FG_DDS_Ctrls, version),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, aileron),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, elevator),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, rudder),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, aileron_trim),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, elevator_trim),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, rudder_trim),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, flaps),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, spoilers),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, speedbrake),
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_Ctrls, flaps_power),
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_Ctrls, flap_motor_ok),
DDS_OP_ADR | DDS_OP_TYPE_2BY, offsetof (FG_DDS_Ctrls, num_engines),
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, master_bat), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, master_alt), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY, offsetof (FG_DDS_Ctrls, magnetos), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY, offsetof (FG_DDS_Ctrls, starter_power), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, throttle), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, mixture), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, condition), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY, offsetof (FG_DDS_Ctrls, fuel_pump_power), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, prop_advance), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_2BY, offsetof (FG_DDS_Ctrls, feed_tank_to), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, reverse), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, engine_ok), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, mag_left_ok), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, mag_right_ok), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, spark_plugs_ok), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_2BY, offsetof (FG_DDS_Ctrls, oil_press_status), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_Ctrls, fuel_pump_ok), 4,
DDS_OP_ADR | DDS_OP_TYPE_2BY, offsetof (FG_DDS_Ctrls, num_tanks),
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_2BY, offsetof (FG_DDS_Ctrls, fuel_selector), 8,
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_Ctrls, cross_feed),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, brake_left),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, brake_right),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, copilot_brake_left),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, copilot_brake_right),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, brake_parking),
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_Ctrls, gear_handle),
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_Ctrls, master_avionics),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, comm_1),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, comm_2),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, nav_1),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, nav_2),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, wind_speed_kt),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, wind_dir_deg),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, turbulence_norm),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, temp_c),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, press_inhg),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, hground),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_Ctrls, magvar),
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_Ctrls, icing),
DDS_OP_ADR | DDS_OP_TYPE_4BY, offsetof (FG_DDS_Ctrls, speedup),
DDS_OP_ADR | DDS_OP_TYPE_2BY, offsetof (FG_DDS_Ctrls, freeze),
DDS_OP_RTS
};
const dds_topic_descriptor_t FG_DDS_Ctrls_desc =
{
sizeof (FG_DDS_Ctrls),
4u,
DDS_TOPIC_FIXED_KEY,
1u,
"FG::DDS_Ctrls",
FG_DDS_Ctrls_keys,
56,
FG_DDS_Ctrls_ops,
"<MetaData version=\"1.0.0\"><Module name=\"FG\"><Struct name=\"DDS_Ctrls\"><Member name=\"id\"><Short/></Member><Member name=\"version\"><Short/></Member><Member name=\"aileron\"><Float/></Member><Member name=\"elevator\"><Float/></Member><Member name=\"rudder\"><Float/></Member><Member name=\"aileron_trim\"><Float/></Member><Member name=\"elevator_trim\"><Float/></Member><Member name=\"rudder_trim\"><Float/></Member><Member name=\"flaps\"><Float/></Member><Member name=\"spoilers\"><Float/></Member><Member name=\"speedbrake\"><Float/></Member><Member name=\"flaps_power\"><Boolean/></Member><Member name=\"flap_motor_ok\"><Boolean/></Member><Member name=\"num_engines\"><UShort/></Member><Member name=\"master_bat\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"master_alt\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"magnetos\"><Array size=\"4\"><ULong/></Array></Member><Member name=\"starter_power\"><Array size=\"4\"><ULong/></Array></Member><Member name=\"throttle\"><Array size=\"4\"><Float/></Array></Member><Member name=\"mixture\"><Array size=\"4\"><Float/></Array></Member><Member name=\"condition\"><Array size=\"4\"><Float/></Array></Member><Member name=\"fuel_pump_power\"><Array size=\"4\"><ULong/></Array></Member><Member name=\"prop_advance\"><Array size=\"4\"><Float/></Array></Member><Member name=\"feed_tank_to\"><Array size=\"4\"><UShort/></Array></Member><Member name=\"reverse\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"engine_ok\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"mag_left_ok\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"mag_right_ok\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"spark_plugs_ok\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"oil_press_status\"><Array size=\"4\"><UShort/></Array></Member><Member name=\"fuel_pump_ok\"><Array size=\"4\"><Boolean/></Array></Member><Member name=\"num_tanks\"><UShort/></Member><Member name=\"fuel_selector\"><Array size=\"8\"><UShort/></Array></Member><Member name=\"cross_feed\"><Boolean/></Member><Member name=\"brake_left\"><Float/></Member><Member name=\"brake_right\"><Float/></Member><Member name=\"copilot_brake_left\"><Float/></Member><Member name=\"copilot_brake_right\"><Float/></Member><Member name=\"brake_parking\"><Float/></Member><Member name=\"gear_handle\"><Boolean/></Member><Member name=\"master_avionics\"><Boolean/></Member><Member name=\"comm_1\"><Float/></Member><Member name=\"comm_2\"><Float/></Member><Member name=\"nav_1\"><Float/></Member><Member name=\"nav_2\"><Float/></Member><Member name=\"wind_speed_kt\"><Float/></Member><Member name=\"wind_dir_deg\"><Float/></Member><Member name=\"turbulence_norm\"><Float/></Member><Member name=\"temp_c\"><Float/></Member><Member name=\"press_inhg\"><Float/></Member><Member name=\"hground\"><Float/></Member><Member name=\"magvar\"><Float/></Member><Member name=\"icing\"><Boolean/></Member><Member name=\"speedup\"><ULong/></Member><Member name=\"freeze\"><UShort/></Member></Struct></Module></MetaData>"
};

View File

@@ -0,0 +1,96 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_ctrls.h
Source: dds_ctrls.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds/ddsc/dds_public_impl.h"
#ifndef _DDSL_DDS_CTRLS_H_
#define _DDSL_DDS_CTRLS_H_
#ifdef __cplusplus
extern "C" {
#endif
#define FG_DDS_CTRLS_VERSION 1
#define FG_DDS_ENGINES 4
#define FG_DDS_WHEELS 16
#define FG_DDS_TANKS 8
typedef struct FG_DDS_Ctrls
{
int16_t id;
int16_t version;
float aileron;
float elevator;
float rudder;
float aileron_trim;
float elevator_trim;
float rudder_trim;
float flaps;
float spoilers;
float speedbrake;
bool flaps_power;
bool flap_motor_ok;
uint16_t num_engines;
bool master_bat[4];
bool master_alt[4];
uint32_t magnetos[4];
uint32_t starter_power[4];
float throttle[4];
float mixture[4];
float condition[4];
uint32_t fuel_pump_power[4];
float prop_advance[4];
uint16_t feed_tank_to[4];
bool reverse[4];
bool engine_ok[4];
bool mag_left_ok[4];
bool mag_right_ok[4];
bool spark_plugs_ok[4];
uint16_t oil_press_status[4];
bool fuel_pump_ok[4];
uint16_t num_tanks;
uint16_t fuel_selector[8];
bool cross_feed;
float brake_left;
float brake_right;
float copilot_brake_left;
float copilot_brake_right;
float brake_parking;
bool gear_handle;
bool master_avionics;
float comm_1;
float comm_2;
float nav_1;
float nav_2;
float wind_speed_kt;
float wind_dir_deg;
float turbulence_norm;
float temp_c;
float press_inhg;
float hground;
float magvar;
bool icing;
uint32_t speedup;
uint16_t freeze;
} FG_DDS_Ctrls;
extern const dds_topic_descriptor_t FG_DDS_Ctrls_desc;
#define FG_DDS_Ctrls__alloc() \
((FG_DDS_Ctrls*) dds_alloc (sizeof (FG_DDS_Ctrls)));
#define FG_DDS_Ctrls_free(d,o) \
dds_sample_free ((d), &FG_DDS_Ctrls_desc, (o))
#ifdef __cplusplus
}
#endif
#endif /* _DDSL_DDS_CTRLS_H_ */

View File

@@ -0,0 +1,113 @@
// format dfescription: https://www.omg.org/spec/IDL/4.2/PDF
// Adapted from net_ctrls.hxx
module FG
{
// defining it this way also generates accompanying #defines in the header file.
const short DDS_CTRLS_VERSION = 1;
const short DDS_ENGINES = 4;
const short DDS_WHEELS = 16;
const short DDS_TANKS = 8;
struct DDS_Ctrls
{
short id; // DDS id
short version; // packet version
// Aero controls
// net_ctrl.hxx defines doubles but flouts do have enough precission
float aileron; // -1 ... 1
float elevator; // -1 ... 1
float rudder; // -1 ... 1
float aileron_trim; // -1 ... 1
float elevator_trim; // -1 ... 1
float rudder_trim; // -1 ... 1
float flaps; // 0 ... 1
float spoilers;
float speedbrake;
// Aero control faults
boolean flaps_power; // true = power available
boolean flap_motor_ok;
// Engine controls
unsigned short num_engines; // number of valid engines
boolean master_bat[DDS_ENGINES];
boolean master_alt[DDS_ENGINES];
unsigned long magnetos[DDS_ENGINES];
unsigned long starter_power[DDS_ENGINES]; // true = starter power
float throttle[DDS_ENGINES]; // 0 ... 1
float mixture[DDS_ENGINES]; // 0 ... 1
float condition[DDS_ENGINES]; // 0 ... 1
unsigned long fuel_pump_power[DDS_ENGINES]; // true = on
float prop_advance[DDS_ENGINES]; // 0 ... 1
unsigned short feed_tank_to[4];
boolean reverse[4];
// Engine faults
boolean engine_ok[DDS_ENGINES];
boolean mag_left_ok[DDS_ENGINES];
boolean mag_right_ok[DDS_ENGINES];
boolean spark_plugs_ok[DDS_ENGINES]; // false = fouled plugs
unsigned short oil_press_status[DDS_ENGINES];// 0 = normal, 1 = low, 2 = full fail
boolean fuel_pump_ok[DDS_ENGINES];
// Fuel management
unsigned short num_tanks; // number of valid tanks
unsigned short fuel_selector[DDS_TANKS]; // false = off, true = on
// unsigned short xfer_pump[5]; // specifies transfer from array
// value tank to tank specified
// by int value
boolean cross_feed; // false = off, true = on
// Brake controls
float brake_left;
float brake_right;
float copilot_brake_left;
float copilot_brake_right;
float brake_parking;
// Landing Gear
boolean gear_handle; // true=gear handle down; false= gear handle up
// Switches
boolean master_avionics;
// nav and Comm
float comm_1;
float comm_2;
float nav_1;
float nav_2;
// wind and turbulance
float wind_speed_kt;
float wind_dir_deg;
float turbulence_norm;
// temp and pressure
float temp_c;
float press_inhg;
// other information about environment
float hground; // ground elevation (meters)
float magvar; // local magnetic variation in degs.
// hazards
boolean icing; // icing status could me much
// more complex but I'm
// starting simple here.
// simulation control
unsigned long speedup; // integer speedup multiplier
unsigned short freeze; // 0=normal
// 0x01=master
// 0x02=position
// 0x04=fuel
};
#pragma keylist DDS_Ctrls id
}; // module FG

96
src/Network/DDS/dds_fdm.c Normal file
View File

@@ -0,0 +1,96 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_fdm.c
Source: dds_fdm.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds_fdm.h"
static const dds_key_descriptor_t FG_DDS_FDM_keys[1] =
{
{ "id", 0 }
};
static const uint32_t FG_DDS_FDM_ops [] =
{
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN | DDS_OP_FLAG_KEY, offsetof (FG_DDS_FDM, id),
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN, offsetof (FG_DDS_FDM, version),
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, longitude),
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, latitude),
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, altitude),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, agl),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, phi),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, theta),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, psi),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, alpha),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, beta),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, phidot),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, thetadot),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, psidot),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, vcas),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, climb_rate),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, v_north),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, v_east),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, v_down),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, v_body_u),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, v_body_v),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, v_body_w),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, A_X_pilot),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, A_Y_pilot),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, A_Z_pilot),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, stall_warning),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, slip_deg),
DDS_OP_ADR | DDS_OP_TYPE_2BY, offsetof (FG_DDS_FDM, num_engines),
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_2BY, offsetof (FG_DDS_FDM, eng_state), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, rpm), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, fuel_flow), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, fuel_px), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, egt), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, cht), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, mp_osi), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, tit), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, oil_temp), 4,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, oil_px), 4,
DDS_OP_ADR | DDS_OP_TYPE_2BY, offsetof (FG_DDS_FDM, num_tanks),
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, fuel_quantity), 8,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_BOO, offsetof (FG_DDS_FDM, tank_selected), 8,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, capacity_m3), 8,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, unusable_m3), 8,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, density_kgpm3), 8,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, level_m3), 8,
DDS_OP_ADR | DDS_OP_TYPE_2BY, offsetof (FG_DDS_FDM, num_wheels),
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_2BY, offsetof (FG_DDS_FDM, wow), 16,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, gear_pos), 16,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, gear_steer), 16,
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, gear_compression), 16,
DDS_OP_ADR | DDS_OP_TYPE_8BY, offsetof (FG_DDS_FDM, cur_time),
DDS_OP_ADR | DDS_OP_TYPE_8BY, offsetof (FG_DDS_FDM, warp),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, visibility),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, elevator),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, elevator_trim_tab),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, left_flap),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, right_flap),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, left_aileron),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, right_aileron),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, rudder),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, nose_wheel),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, speedbrake),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_FDM, spoilers),
DDS_OP_RTS
};
const dds_topic_descriptor_t FG_DDS_FDM_desc =
{
sizeof (FG_DDS_FDM),
8u,
DDS_TOPIC_FIXED_KEY,
1u,
"FG::DDS_FDM",
FG_DDS_FDM_keys,
64,
FG_DDS_FDM_ops,
"<MetaData version=\"1.0.0\"><Module name=\"FG\"><Struct name=\"DDS_FDM\"><Member name=\"id\"><Short/></Member><Member name=\"version\"><Short/></Member><Member name=\"longitude\"><Double/></Member><Member name=\"latitude\"><Double/></Member><Member name=\"altitude\"><Double/></Member><Member name=\"agl\"><Float/></Member><Member name=\"phi\"><Float/></Member><Member name=\"theta\"><Float/></Member><Member name=\"psi\"><Float/></Member><Member name=\"alpha\"><Float/></Member><Member name=\"beta\"><Float/></Member><Member name=\"phidot\"><Float/></Member><Member name=\"thetadot\"><Float/></Member><Member name=\"psidot\"><Float/></Member><Member name=\"vcas\"><Float/></Member><Member name=\"climb_rate\"><Float/></Member><Member name=\"v_north\"><Float/></Member><Member name=\"v_east\"><Float/></Member><Member name=\"v_down\"><Float/></Member><Member name=\"v_body_u\"><Float/></Member><Member name=\"v_body_v\"><Float/></Member><Member name=\"v_body_w\"><Float/></Member><Member name=\"A_X_pilot\"><Float/></Member><Member name=\"A_Y_pilot\"><Float/></Member><Member name=\"A_Z_pilot\"><Float/></Member><Member name=\"stall_warning\"><Float/></Member><Member name=\"slip_deg\"><Float/></Member><Member name=\"num_engines\"><UShort/></Member><Member name=\"eng_state\"><Array size=\"4\"><UShort/></Array></Member><Member name=\"rpm\"><Array size=\"4\"><Float/></Array></Member><Member name=\"fuel_flow\"><Array size=\"4\"><Float/></Array></Member><Member name=\"fuel_px\"><Array size=\"4\"><Float/></Array></Member><Member name=\"egt\"><Array size=\"4\"><Float/></Array></Member><Member name=\"cht\"><Array size=\"4\"><Float/></Array></Member><Member name=\"mp_osi\"><Array size=\"4\"><Float/></Array></Member><Member name=\"tit\"><Array size=\"4\"><Float/></Array></Member><Member name=\"oil_temp\"><Array size=\"4\"><Float/></Array></Member><Member name=\"oil_px\"><Array size=\"4\"><Float/></Array></Member><Member name=\"num_tanks\"><UShort/></Member><Member name=\"fuel_quantity\"><Array size=\"8\"><Float/></Array></Member><Member name=\"tank_selected\"><Array size=\"8\"><Boolean/></Array></Member><Member name=\"capacity_m3\"><Array size=\"8\"><Float/></Array></Member><Member name=\"unusable_m3\"><Array size=\"8\"><Float/></Array></Member><Member name=\"density_kgpm3\"><Array size=\"8\"><Float/></Array></Member><Member name=\"level_m3\"><Array size=\"8\"><Float/></Array></Member><Member name=\"num_wheels\"><UShort/></Member><Member name=\"wow\"><Array size=\"16\"><UShort/></Array></Member><Member name=\"gear_pos\"><Array size=\"16\"><Float/></Array></Member><Member name=\"gear_steer\"><Array size=\"16\"><Float/></Array></Member><Member name=\"gear_compression\"><Array size=\"16\"><Float/></Array></Member><Member name=\"cur_time\"><ULongLong/></Member><Member name=\"warp\"><ULongLong/></Member><Member name=\"visibility\"><Float/></Member><Member name=\"elevator\"><Float/></Member><Member name=\"elevator_trim_tab\"><Float/></Member><Member name=\"left_flap\"><Float/></Member><Member name=\"right_flap\"><Float/></Member><Member name=\"left_aileron\"><Float/></Member><Member name=\"right_aileron\"><Float/></Member><Member name=\"rudder\"><Float/></Member><Member name=\"nose_wheel\"><Float/></Member><Member name=\"speedbrake\"><Float/></Member><Member name=\"spoilers\"><Float/></Member></Struct></Module></MetaData>"
};

104
src/Network/DDS/dds_fdm.h Normal file
View File

@@ -0,0 +1,104 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_fdm.h
Source: dds_fdm.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds/ddsc/dds_public_impl.h"
#ifndef _DDSL_DDS_FDM_H_
#define _DDSL_DDS_FDM_H_
#ifdef __cplusplus
extern "C" {
#endif
#define FG_DDS_FDM_VERSION 1
#define FG_DDS_ENGINES 4
#define FG_DDS_WHEELS 16
#define FG_DDS_TANKS 8
typedef struct FG_DDS_FDM
{
int16_t id;
int16_t version;
double longitude;
double latitude;
double altitude;
float agl;
float phi;
float theta;
float psi;
float alpha;
float beta;
float phidot;
float thetadot;
float psidot;
float vcas;
float climb_rate;
float v_north;
float v_east;
float v_down;
float v_body_u;
float v_body_v;
float v_body_w;
float A_X_pilot;
float A_Y_pilot;
float A_Z_pilot;
float stall_warning;
float slip_deg;
uint16_t num_engines;
uint16_t eng_state[4];
float rpm[4];
float fuel_flow[4];
float fuel_px[4];
float egt[4];
float cht[4];
float mp_osi[4];
float tit[4];
float oil_temp[4];
float oil_px[4];
uint16_t num_tanks;
float fuel_quantity[8];
bool tank_selected[8];
float capacity_m3[8];
float unusable_m3[8];
float density_kgpm3[8];
float level_m3[8];
uint16_t num_wheels;
uint16_t wow[16];
float gear_pos[16];
float gear_steer[16];
float gear_compression[16];
uint64_t cur_time;
uint64_t warp;
float visibility;
float elevator;
float elevator_trim_tab;
float left_flap;
float right_flap;
float left_aileron;
float right_aileron;
float rudder;
float nose_wheel;
float speedbrake;
float spoilers;
} FG_DDS_FDM;
extern const dds_topic_descriptor_t FG_DDS_FDM_desc;
#define FG_DDS_FDM__alloc() \
((FG_DDS_FDM*) dds_alloc (sizeof (FG_DDS_FDM)));
#define FG_DDS_FDM_free(d,o) \
dds_sample_free ((d), &FG_DDS_FDM_desc, (o))
#ifdef __cplusplus
}
#endif
#endif /* _DDSL_DDS_FDM_H_ */

106
src/Network/DDS/dds_fdm.idl Normal file
View File

@@ -0,0 +1,106 @@
// format dfescription: https://www.omg.org/spec/IDL/4.2/PDF
// Adapted from net_fdm.hxx
module FG
{
// defining it this way also generates accompanying #defines in the header file.
const short DDS_FDM_VERSION = 1;
// same as defined in net_ctrls.hxx
// this is different from net_fdm.hxx
const short DDS_ENGINES = 4;
const short DDS_WHEELS = 16;
const short DDS_TANKS = 8;
struct DDS_FDM
{
short id; // DDS id
short version; // packet version
// Positions
double longitude; // geodetic (radians)
double latitude; // geodetic (radians)
double altitude; // above sea level (meters)
float agl; // above ground level (meters)
float phi; // roll (radians)
float theta; // pitch (radians)
float psi; // yaw or true heading (radians)
float alpha; // angle of attack (radians)
float beta; // side slip angle (radians)
// Velocities
float phidot; // roll rate (radians/sec)
float thetadot; // pitch rate (radians/sec)
float psidot; // yaw rate (radians/sec)
float vcas; // calibrated airspeed
float climb_rate; // feet per second
float v_north; // north velocity in local/body frame, fps
float v_east; // east velocity in local/body frame, fps
float v_down; // down/vertical velocity in local/body frame, fps
float v_body_u; // ECEF velocity in body frame
float v_body_v; // ECEF velocity in body frame
float v_body_w; // ECEF velocity in body frame
// Accelerations
float A_X_pilot; // X accel in body frame ft/sec^2
float A_Y_pilot; // Y accel in body frame ft/sec^2
float A_Z_pilot; // Z accel in body frame ft/sec^2
// Stall
float stall_warning;// 0.0 - 1.0 indicating the amount of stall
float slip_deg; // slip ball deflection
// Pressure
// Engine status
unsigned short num_engines; // Number of valid engines
unsigned short eng_state[DDS_ENGINES];// Engine state (off, cranking, running)
float rpm[DDS_ENGINES]; // Engine RPM rev/min
float fuel_flow[DDS_ENGINES]; // Fuel flow gallons/hr
float fuel_px[DDS_ENGINES]; // Fuel pressure psi
float egt[DDS_ENGINES]; // Exhuast gas temp deg F
float cht[DDS_ENGINES]; // Cylinder head temp deg F
float mp_osi[DDS_ENGINES]; // Manifold pressure
float tit[DDS_ENGINES]; // Turbine Inlet Temperature
float oil_temp[DDS_ENGINES]; // Oil temp deg F
float oil_px[DDS_ENGINES]; // Oil pressure psi
// Consumables
unsigned short num_tanks; // Max number of fuel tanks
float fuel_quantity[DDS_TANKS]; // used by GPSsmooth and possibly others
boolean tank_selected[DDS_TANKS]; // selected, capacity, usable, density and level required for multiple-pc setups to work
float capacity_m3[DDS_TANKS];
float unusable_m3[DDS_TANKS];
float density_kgpm3[DDS_TANKS];
float level_m3[DDS_TANKS];
// Gear status
unsigned short num_wheels;
unsigned short wow[DDS_WHEELS];
float gear_pos[DDS_WHEELS];
float gear_steer[DDS_WHEELS];
float gear_compression[DDS_WHEELS];
// Environment
unsigned long long cur_time;// current unix time, 64-bit
unsigned long long warp; // offset in seconds to unix time
float visibility; // visibility in meters (for env. effects)
// Control surface positions (normalized values)
float elevator;
float elevator_trim_tab;
float left_flap;
float right_flap;
float left_aileron;
float right_aileron;
float rudder;
float nose_wheel;
float speedbrake;
float spoilers;
};
#pragma keylist DDS_FDM id
}; // module FG

View File

@@ -0,0 +1,10 @@
// dds_fwd.hxx
//
// This file is in the Public Domain, and comes with no warranty.
#pragma once
#include "dds_gui.h"
#include "dds_fdm.h"
#include "dds_ctrls.h"
#include "dds_props.h"

55
src/Network/DDS/dds_gui.c Normal file
View File

@@ -0,0 +1,55 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_gui.c
Source: dds_gui.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds_gui.h"
static const dds_key_descriptor_t FG_DDS_GUI_keys[1] =
{
{ "id", 0 }
};
static const uint32_t FG_DDS_GUI_ops [] =
{
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN | DDS_OP_FLAG_KEY, offsetof (FG_DDS_GUI, id),
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN, offsetof (FG_DDS_GUI, version),
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, longitude),
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, latitude),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, altitude),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, agl),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, phi),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, theta),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, psi),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, vcas),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, climb_rate),
DDS_OP_ADR | DDS_OP_TYPE_2BY, offsetof (FG_DDS_GUI, num_tanks),
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, fuel_quantity), 8,
DDS_OP_ADR | DDS_OP_TYPE_8BY, offsetof (FG_DDS_GUI, cur_time),
DDS_OP_ADR | DDS_OP_TYPE_8BY, offsetof (FG_DDS_GUI, warp),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, ground_elev),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, tuned_freq),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, nav_radial),
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_GUI, in_range),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, dist_nm),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, course_deviation_deg),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, gs_deviation_deg),
DDS_OP_RTS
};
const dds_topic_descriptor_t FG_DDS_GUI_desc =
{
sizeof (FG_DDS_GUI),
8u,
DDS_TOPIC_FIXED_KEY,
1u,
"FG::DDS_GUI",
FG_DDS_GUI_keys,
23,
FG_DDS_GUI_ops,
"<MetaData version=\"1.0.0\"><Module name=\"FG\"><Struct name=\"DDS_GUI\"><Member name=\"id\"><Short/></Member><Member name=\"version\"><Short/></Member><Member name=\"longitude\"><Double/></Member><Member name=\"latitude\"><Double/></Member><Member name=\"altitude\"><Float/></Member><Member name=\"agl\"><Float/></Member><Member name=\"phi\"><Float/></Member><Member name=\"theta\"><Float/></Member><Member name=\"psi\"><Float/></Member><Member name=\"vcas\"><Float/></Member><Member name=\"climb_rate\"><Float/></Member><Member name=\"num_tanks\"><UShort/></Member><Member name=\"fuel_quantity\"><Array size=\"8\"><Float/></Array></Member><Member name=\"cur_time\"><ULongLong/></Member><Member name=\"warp\"><ULongLong/></Member><Member name=\"ground_elev\"><Float/></Member><Member name=\"tuned_freq\"><Float/></Member><Member name=\"nav_radial\"><Float/></Member><Member name=\"in_range\"><Boolean/></Member><Member name=\"dist_nm\"><Float/></Member><Member name=\"course_deviation_deg\"><Float/></Member><Member name=\"gs_deviation_deg\"><Float/></Member></Struct></Module></MetaData>"
};

61
src/Network/DDS/dds_gui.h Normal file
View File

@@ -0,0 +1,61 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_gui.h
Source: dds_gui.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds/ddsc/dds_public_impl.h"
#ifndef _DDSL_DDS_GUI_H_
#define _DDSL_DDS_GUI_H_
#ifdef __cplusplus
extern "C" {
#endif
#define FG_DDS_GUI_VERSION 1
#define FG_DDS_TANKS 8
typedef struct FG_DDS_GUI
{
int16_t id;
int16_t version;
double longitude;
double latitude;
float altitude;
float agl;
float phi;
float theta;
float psi;
float vcas;
float climb_rate;
uint16_t num_tanks;
float fuel_quantity[8];
uint64_t cur_time;
uint64_t warp;
float ground_elev;
float tuned_freq;
float nav_radial;
bool in_range;
float dist_nm;
float course_deviation_deg;
float gs_deviation_deg;
} FG_DDS_GUI;
extern const dds_topic_descriptor_t FG_DDS_GUI_desc;
#define FG_DDS_GUI__alloc() \
((FG_DDS_GUI*) dds_alloc (sizeof (FG_DDS_GUI)));
#define FG_DDS_GUI_free(d,o) \
dds_sample_free ((d), &FG_DDS_GUI_desc, (o))
#ifdef __cplusplus
}
#endif
#endif /* _DDSL_DDS_GUI_H_ */

View File

@@ -0,0 +1,55 @@
// format dfescription: https://www.omg.org/spec/IDL/4.2/PDF
// Taken from net_gui.hxx
module FG
{
// defining it this way also generates accompanying #defines in the header file.
const short DDS_GUI_VERSION = 1;
// same as defined in net_ctrls.hxx
// this is different from net_gui.hxx
const short DDS_TANKS = 8;
struct DDS_GUI
{
short id;
short version;
// Positions
double longitude; // geodetic (radians)
double latitude; // geodetic (radians)
float altitude; // above sea level (meters)
float agl; // above ground level (meters)
float phi; // roll (radians)
float theta; // pitch (radians)
float psi; // yaw or true heading (radians)
// Velocities
float vcas;
float climb_rate; // feet per second
// Consumables
unsigned short num_tanks; // Max number of fuel tanks
float fuel_quantity[DDS_TANKS];
// Environment
unsigned long long cur_time;// current unix time
unsigned long long warp; // offset in seconds to unix time
float ground_elev; // ground elev (meters)
// Approach
float tuned_freq; // currently tuned frequency
float nav_radial; // target nav radial
boolean in_range; // tuned navaid is in range?
float dist_nm; // distance to tuned navaid in nautical miles
float course_deviation_deg; // degrees off target course
float gs_deviation_deg; // degrees off target glide slope
};
#pragma keylist DDS_GUI id
}; // module FG

View File

@@ -0,0 +1,47 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_props.c
Source: dds_props.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds_props.h"
static const dds_key_descriptor_t FG_DDS_prop_keys[1] =
{
{ "id", 0 }
};
static const uint32_t FG_DDS_prop_ops [] =
{
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_SGN | DDS_OP_FLAG_KEY, offsetof (FG_DDS_prop, id),
DDS_OP_ADR | DDS_OP_TYPE_1BY, offsetof (FG_DDS_prop, version),
DDS_OP_ADR | DDS_OP_TYPE_BOO, offsetof (FG_DDS_prop, mode),
DDS_OP_ADR | DDS_OP_TYPE_UNI | DDS_OP_SUBTYPE_4BY | DDS_OP_FLAG_SGN, offsetof (FG_DDS_prop, val._d), 9u, (31u << 16) + 4u,
DDS_OP_JEQ | DDS_OP_TYPE_BOO | 0, FG_DDS_BOOL, offsetof (FG_DDS_prop, val._u.Bool),
DDS_OP_JEQ | DDS_OP_TYPE_4BY | DDS_OP_FLAG_SGN | 0, FG_DDS_NONE, offsetof (FG_DDS_prop, val._u.Int32),
DDS_OP_JEQ | DDS_OP_TYPE_4BY | DDS_OP_FLAG_SGN | 0, FG_DDS_INT, offsetof (FG_DDS_prop, val._u.Int32),
DDS_OP_JEQ | DDS_OP_TYPE_8BY | DDS_OP_FLAG_SGN | 0, FG_DDS_LONG, offsetof (FG_DDS_prop, val._u.Int64),
DDS_OP_JEQ | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP | 0, FG_DDS_FLOAT, offsetof (FG_DDS_prop, val._u.Float32),
DDS_OP_JEQ | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP | 0, FG_DDS_DOUBLE, offsetof (FG_DDS_prop, val._u.Float64),
DDS_OP_JEQ | DDS_OP_TYPE_STR | 0, FG_DDS_ALIAS, offsetof (FG_DDS_prop, val._u.String),
DDS_OP_JEQ | DDS_OP_TYPE_STR | 0, FG_DDS_STRING, offsetof (FG_DDS_prop, val._u.String),
DDS_OP_JEQ | DDS_OP_TYPE_STR | 0, FG_DDS_UNSPECIFIED, offsetof (FG_DDS_prop, val._u.String),
DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_1BY, offsetof (FG_DDS_prop, guid), 16,
DDS_OP_RTS
};
const dds_topic_descriptor_t FG_DDS_prop_desc =
{
sizeof (FG_DDS_prop),
8u,
DDS_TOPIC_FIXED_KEY | DDS_TOPIC_NO_OPTIMIZE | DDS_TOPIC_CONTAINS_UNION,
1u,
"FG::DDS_prop",
FG_DDS_prop_keys,
15,
FG_DDS_prop_ops,
"<MetaData version=\"1.0.0\"><Module name=\"FG\"><Enum name=\"propType\"><Element name=\"DDS_NONE\" value=\"0\"/><Element name=\"DDS_ALIAS\" value=\"1\"/><Element name=\"DDS_BOOL\" value=\"2\"/><Element name=\"DDS_INT\" value=\"3\"/><Element name=\"DDS_LONG\" value=\"4\"/><Element name=\"DDS_FLOAT\" value=\"5\"/><Element name=\"DDS_DOUBLE\" value=\"6\"/><Element name=\"DDS_STRING\" value=\"7\"/><Element name=\"DDS_UNSPECIFIED\" value=\"8\"/></Enum><Union name=\"propValue\"><SwitchType><Type name=\"propType\"/></SwitchType><Case name=\"Bool\"><Boolean/><Label value=\"DDS_BOOL\"/></Case><Case name=\"Int32\"><Long/><Label value=\"DDS_NONE\"/><Label value=\"DDS_INT\"/></Case><Case name=\"Int64\"><LongLong/><Label value=\"DDS_LONG\"/></Case><Case name=\"Float32\"><Float/><Label value=\"DDS_FLOAT\"/></Case><Case name=\"Float64\"><Double/><Label value=\"DDS_DOUBLE\"/></Case><Case name=\"String\"><String/><Label value=\"DDS_ALIAS\"/><Label value=\"DDS_STRING\"/><Label value=\"DDS_UNSPECIFIED\"/></Case></Union><Struct name=\"DDS_prop\"><Member name=\"id\"><Long/></Member><Member name=\"version\"><Octet/></Member><Member name=\"mode\"><Boolean/></Member><Member name=\"val\"><Type name=\"propValue\"/></Member><Member name=\"guid\"><Array size=\"16\"><Octet/></Array></Member></Struct></Module></MetaData>"
};

View File

@@ -0,0 +1,79 @@
/****************************************************************
Generated by Eclipse Cyclone DDS IDL to C Translator
File name: dds_props.h
Source: dds_props.idl
Cyclone DDS: V0.7.0
*****************************************************************/
#include "dds/ddsc/dds_public_impl.h"
#ifndef _DDSL_DDS_PROPS_H_
#define _DDSL_DDS_PROPS_H_
#ifdef __cplusplus
extern "C" {
#endif
#define FG_DDS_PROP_VERSION 0
#define FG_DDS_PROP_REQUEST -1
#define FG_DDS_MODE_READ (0)
#define FG_DDS_MODE_WRITE (1)
typedef enum FG_propType
{
FG_DDS_NONE,
FG_DDS_ALIAS,
FG_DDS_BOOL,
FG_DDS_INT,
FG_DDS_LONG,
FG_DDS_FLOAT,
FG_DDS_DOUBLE,
FG_DDS_STRING,
FG_DDS_UNSPECIFIED
} FG_propType;
#define FG_propType__alloc() \
((FG_propType*) dds_alloc (sizeof (FG_propType)));
typedef struct FG_propValue
{
FG_propType _d;
union
{
bool Bool;
int32_t Int32;
int64_t Int64;
float Float32;
double Float64;
char * String;
} _u;
} FG_propValue;
#define FG_propValue__alloc() \
((FG_propValue*) dds_alloc (sizeof (FG_propValue)));
typedef struct FG_DDS_prop
{
int32_t id;
uint8_t version;
bool mode;
FG_propValue val;
uint8_t guid[16];
} FG_DDS_prop;
extern const dds_topic_descriptor_t FG_DDS_prop_desc;
#define FG_DDS_prop__alloc() \
((FG_DDS_prop*) dds_alloc (sizeof (FG_DDS_prop)));
#define FG_DDS_prop_free(d,o) \
dds_sample_free ((d), &FG_DDS_prop_desc, (o))
#ifdef __cplusplus
}
#endif
#endif /* _DDSL_DDS_PROPS_H_ */

View File

@@ -0,0 +1,90 @@
// format dfescription: https://www.omg.org/spec/IDL/4.2/PDF
// Adapted from net_fdm.hxx
module FG
{
// defining it this way also generates accompanying #defines in the header file.
const octet DDS_PROP_VERSION = 0;
const short DDS_PROP_REQUEST = -1;
const boolean DDS_MODE_READ = 0;
const boolean DDS_MODE_WRITE = 1;
enum propType
{
DDS_NONE, // The node hasn't been assigned a value yet
DDS_ALIAS, // The node "points" to another node
DDS_BOOL,
DDS_INT, // 32-bit integer
DDS_LONG, // 64-bit integer
DDS_FLOAT, // 32-bit floating point number
DDS_DOUBLE, // 64-bit floating point number
DDS_STRING, // UTF-8 string
DDS_UNSPECIFIED // Resolves to STRING
};
union propValue switch ( propType )
{
case DDS_BOOL:
boolean Bool;
case DDS_NONE:
case DDS_INT:
long Int32;
case DDS_LONG:
long long Int64;
case DDS_FLOAT:
float Float32;
case DDS_DOUBLE:
double Float64;
case DDS_ALIAS:
case DDS_STRING:
case DDS_UNSPECIFIED:
string String;
};
// Initial property request sequence
// for properties where the id is not yet known:
// 1. Set id to FG_DDS_PROP_REQUEST
// 2. Set version to FG_DDS_PROP_VERSION
// 3. Set mode to FG_DDS_MODE_READ
// 4. set guid to the 16-byte participants GUID
// 5. Set val type to FG_DDS_STRING
// 6. Set val String to the propery path
// 7. Send the package.
//
// 8. Wait for an answer
// * Check whether guid matches the participants GUID.
// * The index of the requested propery path is stored in the id variable
// which should be used by successive request as the id for that property.
// * The val union holds the value of the propery.
//
// Successive property request sequence:
// 1. Make sure id is to the id of the requested property
// 2. Make sure version is to FG_DDS_PROP_VERSION
// 3. Set mode to FG_DDS_MODE_READ or FG_DDS_MODE_WRITE
// 3a. Optionally set the val union to match the property to overwrite.
// 4. Send the package.
//
// 5. Wait for an answer
// * Check whether id matches the requested property id.
// * The val union holds the value of the propery.
struct DDS_prop
{
long id; // 32-bit property index and DDS id.
octet version; // 8-bit sample-type version number.
boolean mode; // FG_DDS_MODE_READ or FG_DDS_MODE_WRITE
propValue val; // property value or path.
// A sequence could be used here but unfortunatelly it's initializer
// already is 10-bytes in size.
octet guid[16];
};
#pragma keylist DDS_prop id
}; // module FG

View File

@@ -0,0 +1,170 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <simgear/io/SGDataDistributionService.hxx>
#include "dds_fwd.hxx"
/* An array of one message(aka sample in dds terms) will be used. */
#define MAX_SAMPLES 1
#ifndef _WIN32
# include <termios.h>
void set_mode(int want_key)
{
static struct termios tios_old, tios_new;
if (!want_key) {
tcsetattr(STDIN_FILENO, TCSANOW, &tios_old);
return;
}
tcgetattr(STDIN_FILENO, &tios_old);
tios_new = tios_old;
tios_new.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &tios_new);
}
int get_key()
{
int c = 0;
struct timeval tv;
fd_set fs;
tv.tv_usec = tv.tv_sec = 0;
FD_ZERO(&fs);
FD_SET(STDIN_FILENO, &fs);
select(STDIN_FILENO + 1, &fs, 0, 0, &tv);
if (FD_ISSET(STDIN_FILENO, &fs)) {
c = getchar();
}
return c;
}
#else
# include <conio.h>
int get_key()
{
if (kbhit()) {
return getch();
}
return 0;
}
void set_mode(int want_key)
{
}
#endif
int main()
{
std::map<std::string, SG_DDS_Topic*> topics;
SG_DDS participant;
FG_DDS_GUI gui;
topics["gui"] = new SG_DDS_Topic(gui, &FG_DDS_GUI_desc);
participant.add(topics["gui"], SG_IO_IN);
FG_DDS_FDM fdm;
topics["fdm"] = new SG_DDS_Topic(fdm, &FG_DDS_FDM_desc);
participant.add(topics["fdm"], SG_IO_IN);
FG_DDS_Ctrls ctrls;
topics["ctrls"] = new SG_DDS_Topic(ctrls, &FG_DDS_Ctrls_desc);
participant.add(topics["ctrls"], SG_IO_IN);
FG_DDS_prop prop;
topics["prop"] = new SG_DDS_Topic(prop, &FG_DDS_prop_desc);
participant.add(topics["prop"], SG_IO_IN);
set_mode(1);
while(participant.wait(0.1f))
{
if (topics["gui"]->read()) {
printf("=== [fg_dds_log] Received : ");
printf("GUI Message:\n");
printf(" version: %i\n", gui.version);
printf(" tuned_freq: %lf\n", gui.longitude);
printf(" nav_radial: %lf\n", gui.latitude);
printf(" dist_nm: %lf\n", gui.altitude);
}
if (topics["fdm"]->read()) {
printf("=== [fg_dds_log] Received : ");
printf("FDM Message:\n");
printf(" version: %i\n", fdm.version);
printf(" longitude: %lf\n", fdm.longitude);
printf(" latitude: %lf\n", fdm.latitude);
printf(" altitude: %lf\n", fdm.altitude);
}
if (topics["ctrls"]->read()) {
printf("=== [fg_dds_log] Received : ");
printf("Ctrls Message:\n");
printf(" version: %i\n", ctrls.version);
printf(" aileron: %lf\n", ctrls.aileron);
printf(" elevator: %lf\n", ctrls.elevator);
printf(" rudder: %lf\n", ctrls.rudder);
}
if (topics["prop"]->read() &&
prop.version == FG_DDS_PROP_VERSION )
{
printf("=== [fg_dds_log] Received : ");
printf("Prop Message:\n");
printf(" version: %i\n", prop.version);
printf(" mode: %s\n", prop.mode ? "write" : "read");
printf(" id: %i\n", prop.id);
if (prop.id == FG_DDS_PROP_REQUEST) {
printf(" path: %s\n", prop.val._u.String);
printf("GUID: ");
for(int i=0; i<16; ++i)
printf("%X ", prop.guid[i]);
printf("\n");
}
else
{
switch(prop.val._d)
{
case FG_DDS_BOOL:
printf(" type: bool");
printf(" value: %i\n", prop.val._u.Bool);
break;
case FG_DDS_INT:
printf(" type: int");
printf(" value: %i\n", prop.val._u.Int32);
break;
case FG_DDS_LONG:
printf(" type: long");
printf(" value: %li\n", prop.val._u.Int64);
break;
case FG_DDS_FLOAT:
printf(" type: float");
printf(" value: %f\n", prop.val._u.Float32);
break;
case FG_DDS_DOUBLE:
printf(" type: double");
printf(" value: %lf\n", prop.val._u.Float64);
break;
case FG_DDS_STRING:
printf(" type: string");
printf(" value: %s\n", prop.val._u.String);
break;
default:
break;
}
}
}
fflush(stdout);
if (get_key()) break;
}
set_mode(0);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,99 @@
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <simgear/io/SGDataDistributionService.hxx>
#include "dds_props.h"
/* An array of one message(aka sample in dds terms) will be used. */
#define MAX_SAMPLES 1
int main()
{
SG_DDS participant;
FG_DDS_prop prop;
SG_DDS_Topic *topic = new SG_DDS_Topic(prop, &FG_DDS_prop_desc);
participant.add(topic, SG_IO_BI);
dds_guid_t guid = topic->get_guid();
memcpy(prop.guid, guid.v, 16);
printf("GUID: ");
for(int i=0; i<16; ++i)
printf("%X ", prop.guid[i]);
printf("\n");
char path[256];
printf("\nType 'q' to quit\n");
do
{
printf("Property path or id: ");
int len = scanf("%255s", path);
if (len == EOF) continue;
if (*path == 'q') break;
char *end;
int id = strtol(path, &end, 10);
prop.id = (end == path) ? FG_DDS_PROP_REQUEST : id;
prop.version = FG_DDS_PROP_VERSION;
prop.mode = FG_DDS_MODE_READ;
prop.val._d = FG_DDS_STRING;
prop.val._u.String = path;
topic->write();
participant.wait();
if (topic->read() &&
prop.version == FG_DDS_PROP_VERSION &&
prop.id != FG_DDS_PROP_REQUEST)
{
printf("\nReceived:\n");
switch(prop.val._d)
{
case FG_DDS_NONE:
printf(" type: none");
break;
case FG_DDS_ALIAS:
printf(" type: alias");
printf(" value: %s\n", prop.val._u.String);
break;
case FG_DDS_BOOL:
printf(" type: bool");
printf(" value: %i\n", prop.val._u.Bool);
break;
case FG_DDS_INT:
printf(" type: int");
printf(" value: %i\n", prop.val._u.Int32);
break;
case FG_DDS_LONG:
printf(" type: long");
printf(" value: %li\n", prop.val._u.Int64);
break;
case FG_DDS_FLOAT:
printf(" type: float");
printf(" value: %f\n", prop.val._u.Float32);
break;
case FG_DDS_DOUBLE:
printf(" type: double");
printf(" value: %lf\n", prop.val._u.Float64);
break;
case FG_DDS_STRING:
printf(" type: string");
printf(" value: %s\n", prop.val._u.String);
break;
case FG_DDS_UNSPECIFIED:
printf(" type: unspecified");
printf(" value: %s\n", prop.val._u.String);
break;
default:
break;
}
}
} while(true);
return EXIT_SUCCESS;
}