1
0
Fork 0

Use standard length types (stdint.h where available) to make the FGNetCTRLS,

FGNetFDM, and FGNetGUI structures more cross platform/architecture portable.
This commit is contained in:
curt 2005-03-24 19:56:57 +00:00
parent 4b116a1196
commit f55f96c44a
7 changed files with 115 additions and 130 deletions

View file

@ -155,7 +155,7 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
if ( fuelpump != NULL ) { if ( fuelpump != NULL ) {
net->fuel_pump_power[i] = ( fuelpump->getDoubleValue() >= 1.0 ); net->fuel_pump_power[i] = ( fuelpump->getDoubleValue() >= 1.0 );
} else { } else {
net->fuel_pump_power[i] = 0.0; net->fuel_pump_power[i] = 0;
} }
// Faults // Faults
@ -214,7 +214,7 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
net->hground = cur_fdm_state->get_ground_elev_ft() * SG_FEET_TO_METER; net->hground = cur_fdm_state->get_ground_elev_ft() * SG_FEET_TO_METER;
net->magvar = fgGetDouble("/environment/magnetic-variation-deg"); net->magvar = fgGetDouble("/environment/magnetic-variation-deg");
net->icing = fgGetDouble("/hazards/icing/wing"); net->icing = fgGetBool("/hazards/icing/wing");
net->speedup = fgGetInt("/sim/speed-up"); net->speedup = fgGetInt("/sim/speed-up");
net->freeze = 0; net->freeze = 0;
@ -232,7 +232,7 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
if ( net_byte_order ) { if ( net_byte_order ) {
// convert to network byte order // convert to network byte order
net->version = htonl(net->version); net->version = htons(net->version);
htond(net->aileron); htond(net->aileron);
htond(net->elevator); htond(net->elevator);
htond(net->rudder); htond(net->rudder);
@ -240,37 +240,17 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
htond(net->elevator_trim); htond(net->elevator_trim);
htond(net->rudder_trim); htond(net->rudder_trim);
htond(net->flaps); htond(net->flaps);
net->flaps_power = htonl(net->flaps_power);
net->flap_motor_ok = htonl(net->flap_motor_ok);
for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) {
net->master_bat[i] = htonl(net->master_bat[i]);
net->master_alt[i] = htonl(net->master_alt[i]);
net->magnetos[i] = htonl(net->magnetos[i]);
net->starter_power[i] = htonl(net->starter_power[i]);
htond(net->throttle[i]); htond(net->throttle[i]);
htond(net->mixture[i]); htond(net->mixture[i]);
net->fuel_pump_power[i] = htonl(net->fuel_pump_power[i]);
htond(net->prop_advance[i]); htond(net->prop_advance[i]);
htond(net->condition[i]); htond(net->condition[i]);
net->engine_ok[i] = htonl(net->engine_ok[i]);
net->mag_left_ok[i] = htonl(net->mag_left_ok[i]);
net->mag_right_ok[i] = htonl(net->mag_right_ok[i]);
net->spark_plugs_ok[i] = htonl(net->spark_plugs_ok[i]);
net->oil_press_status[i] = htonl(net->oil_press_status[i]);
net->fuel_pump_ok[i] = htonl(net->fuel_pump_ok[i]);
} }
net->num_engines = htonl(net->num_engines);
for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) {
net->fuel_selector[i] = htonl(net->fuel_selector[i]);
}
net->num_tanks = htonl(net->num_tanks);
htond(net->brake_left); htond(net->brake_left);
htond(net->brake_right); htond(net->brake_right);
htond(net->copilot_brake_left); htond(net->copilot_brake_left);
htond(net->copilot_brake_right); htond(net->copilot_brake_right);
htond(net->brake_parking); htond(net->brake_parking);
net->gear_handle = htonl(net->gear_handle);
net->master_avionics = htonl(net->master_avionics);
htond(net->wind_speed_kt); htond(net->wind_speed_kt);
htond(net->wind_dir_deg); htond(net->wind_dir_deg);
htond(net->turbulence_norm); htond(net->turbulence_norm);
@ -278,9 +258,6 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes,
htond(net->press_inhg); htond(net->press_inhg);
htond(net->hground); htond(net->hground);
htond(net->magvar); htond(net->magvar);
net->icing = htonl(net->icing);
net->speedup = htonl(net->speedup);
net->freeze = htonl(net->freeze);
} }
} }
@ -295,7 +272,7 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
if ( net_byte_order ) { if ( net_byte_order ) {
// convert from network byte order // convert from network byte order
net->version = htonl(net->version); net->version = htons(net->version);
htond(net->aileron); htond(net->aileron);
htond(net->elevator); htond(net->elevator);
htond(net->rudder); htond(net->rudder);
@ -303,37 +280,17 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
htond(net->elevator_trim); htond(net->elevator_trim);
htond(net->rudder_trim); htond(net->rudder_trim);
htond(net->flaps); htond(net->flaps);
net->flaps_power = htonl(net->flaps_power);
net->flap_motor_ok = htonl(net->flap_motor_ok);
net->num_engines = htonl(net->num_engines);
for ( i = 0; i < net->num_engines; ++i ) { for ( i = 0; i < net->num_engines; ++i ) {
net->master_bat[i] = htonl(net->master_bat[i]);
net->master_alt[i] = htonl(net->master_alt[i]);
net->magnetos[i] = htonl(net->magnetos[i]);
net->starter_power[i] = htonl(net->starter_power[i]);
htond(net->throttle[i]); htond(net->throttle[i]);
htond(net->mixture[i]); htond(net->mixture[i]);
net->fuel_pump_power[i] = htonl(net->fuel_pump_power[i]);
htond(net->prop_advance[i]); htond(net->prop_advance[i]);
htond(net->condition[i]); htond(net->condition[i]);
net->engine_ok[i] = htonl(net->engine_ok[i]);
net->mag_left_ok[i] = htonl(net->mag_left_ok[i]);
net->mag_right_ok[i] = htonl(net->mag_right_ok[i]);
net->spark_plugs_ok[i] = htonl(net->spark_plugs_ok[i]);
net->oil_press_status[i] = htonl(net->oil_press_status[i]);
net->fuel_pump_ok[i] = htonl(net->fuel_pump_ok[i]);
}
net->num_tanks = htonl(net->num_tanks);
for ( i = 0; i < net->num_tanks; ++i ) {
net->fuel_selector[i] = htonl(net->fuel_selector[i]);
} }
htond(net->brake_left); htond(net->brake_left);
htond(net->brake_right); htond(net->brake_right);
htond(net->copilot_brake_left); htond(net->copilot_brake_left);
htond(net->copilot_brake_right); htond(net->copilot_brake_right);
htond(net->brake_parking); htond(net->brake_parking);
net->gear_handle = htonl(net->gear_handle);
net->master_avionics = htonl(net->master_avionics);
htond(net->wind_speed_kt); htond(net->wind_speed_kt);
htond(net->wind_dir_deg); htond(net->wind_dir_deg);
htond(net->turbulence_norm); htond(net->turbulence_norm);
@ -341,9 +298,6 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes,
htond(net->press_inhg); htond(net->press_inhg);
htond(net->hground); htond(net->hground);
htond(net->magvar); htond(net->magvar);
net->icing = htonl(net->icing);
net->speedup = htonl(net->speedup);
net->freeze = htonl(net->freeze);
} }
if ( net->version != FG_NET_CTRLS_VERSION ) { if ( net->version != FG_NET_CTRLS_VERSION ) {

View file

@ -191,7 +191,7 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
net->num_wheels = FGNetFDM::FG_MAX_WHEELS; net->num_wheels = FGNetFDM::FG_MAX_WHEELS;
for (i = 0; i < net->num_wheels; ++i ) { for (i = 0; i < net->num_wheels; ++i ) {
SGPropertyNode *node = fgGetNode("/gear/gear", i, true); SGPropertyNode *node = fgGetNode("/gear/gear", i, true);
net->wow[i] = node->getDoubleValue("wow"); net->wow[i] = node->getIntValue("wow");
net->gear_pos[i] = node->getDoubleValue("position-norm"); net->gear_pos[i] = node->getDoubleValue("position-norm");
net->gear_steer[i] = node->getDoubleValue("steering-norm"); net->gear_steer[i] = node->getDoubleValue("steering-norm");
net->gear_compression[i] = node->getDoubleValue("compression-norm"); net->gear_compression[i] = node->getDoubleValue("compression-norm");
@ -219,7 +219,7 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
if ( net_byte_order ) { if ( net_byte_order ) {
// Convert the net buffer to network format // Convert the net buffer to network format
net->version = htonl(net->version); net->version = htons(net->version);
htond(net->longitude); htond(net->longitude);
htond(net->latitude); htond(net->latitude);
@ -251,7 +251,6 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
htonf(net->slip_deg); htonf(net->slip_deg);
for ( i = 0; i < net->num_engines; ++i ) { for ( i = 0; i < net->num_engines; ++i ) {
net->eng_state[i] = htonl(net->eng_state[i]);
htonf(net->rpm[i]); htonf(net->rpm[i]);
htonf(net->fuel_flow[i]); htonf(net->fuel_flow[i]);
htonf(net->egt[i]); htonf(net->egt[i]);
@ -261,20 +260,16 @@ void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
htonf(net->oil_temp[i]); htonf(net->oil_temp[i]);
htonf(net->oil_px[i]); htonf(net->oil_px[i]);
} }
net->num_engines = htonl(net->num_engines);
for ( i = 0; i < net->num_tanks; ++i ) { for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]); htonf(net->fuel_quantity[i]);
} }
net->num_tanks = htonl(net->num_tanks);
for ( i = 0; i < net->num_wheels; ++i ) { for ( i = 0; i < net->num_wheels; ++i ) {
net->wow[i] = htonl(net->wow[i]);
htonf(net->gear_pos[i]); htonf(net->gear_pos[i]);
htonf(net->gear_steer[i]); htonf(net->gear_steer[i]);
htonf(net->gear_compression[i]); htonf(net->gear_compression[i]);
} }
net->num_wheels = htonl(net->num_wheels);
net->cur_time = htonl( net->cur_time ); net->cur_time = htonl( net->cur_time );
net->warp = htonl( net->warp ); net->warp = htonl( net->warp );
@ -299,7 +294,7 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
if ( net_byte_order ) { if ( net_byte_order ) {
// Convert to the net buffer from network format // Convert to the net buffer from network format
net->version = ntohl(net->version); net->version = ntohs(net->version);
htond(net->longitude); htond(net->longitude);
htond(net->latitude); htond(net->latitude);
@ -330,9 +325,7 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
htonf(net->stall_warning); htonf(net->stall_warning);
htonf(net->slip_deg); htonf(net->slip_deg);
net->num_engines = htonl(net->num_engines);
for ( i = 0; i < net->num_engines; ++i ) { for ( i = 0; i < net->num_engines; ++i ) {
net->eng_state[i] = htonl(net->eng_state[i]);
htonf(net->rpm[i]); htonf(net->rpm[i]);
htonf(net->fuel_flow[i]); htonf(net->fuel_flow[i]);
htonf(net->egt[i]); htonf(net->egt[i]);
@ -343,20 +336,17 @@ void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
htonf(net->oil_px[i]); htonf(net->oil_px[i]);
} }
net->num_tanks = htonl(net->num_tanks);
for ( i = 0; i < net->num_tanks; ++i ) { for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]); htonf(net->fuel_quantity[i]);
} }
net->num_wheels = htonl(net->num_wheels);
for ( i = 0; i < net->num_wheels; ++i ) { for ( i = 0; i < net->num_wheels; ++i ) {
net->wow[i] = htonl(net->wow[i]);
htonf(net->gear_pos[i]); htonf(net->gear_pos[i]);
htonf(net->gear_steer[i]); htonf(net->gear_steer[i]);
htonf(net->gear_compression[i]); htonf(net->gear_compression[i]);
} }
net->cur_time = ntohl(net->cur_time); net->cur_time = htonl(net->cur_time);
net->warp = ntohl(net->warp); net->warp = ntohl(net->warp);
htonf(net->visibility); htonf(net->visibility);

View file

@ -215,7 +215,7 @@ void FGProps2NetGUI( FGNetGUI *net ) {
#if defined( FG_USE_NETWORK_BYTE_ORDER ) #if defined( FG_USE_NETWORK_BYTE_ORDER )
// Convert the net buffer to network format // Convert the net buffer to network format
net->version = htonl(net->version); net->version = htons(net->version);
htond(net->longitude); htond(net->longitude);
htond(net->latitude); htond(net->latitude);
@ -229,7 +229,6 @@ void FGProps2NetGUI( FGNetGUI *net ) {
for ( i = 0; i < net->num_tanks; ++i ) { for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]); htonf(net->fuel_quantity[i]);
} }
net->num_tanks = htonl(net->num_tanks);
net->cur_time = htonl( net->cur_time ); net->cur_time = htonl( net->cur_time );
net->warp = htonl( net->warp ); net->warp = htonl( net->warp );
@ -237,7 +236,6 @@ void FGProps2NetGUI( FGNetGUI *net ) {
htonf(net->tuned_freq); htonf(net->tuned_freq);
htonf(net->nav_radial); htonf(net->nav_radial);
net->in_range = htonl(net->in_range);
htonf(net->dist_nm); htonf(net->dist_nm);
htonf(net->course_deviation_deg); htonf(net->course_deviation_deg);
htonf(net->gs_deviation_deg); htonf(net->gs_deviation_deg);
@ -250,7 +248,7 @@ void FGNetGUI2Props( FGNetGUI *net ) {
#if defined( FG_USE_NETWORK_BYTE_ORDER ) #if defined( FG_USE_NETWORK_BYTE_ORDER )
// Convert to the net buffer from network format // Convert to the net buffer from network format
net->version = ntohl(net->version); net->version = ntohs(net->version);
htond(net->longitude); htond(net->longitude);
htond(net->latitude); htond(net->latitude);
@ -261,7 +259,6 @@ void FGNetGUI2Props( FGNetGUI *net ) {
htonf(net->vcas); htonf(net->vcas);
htonf(net->climb_rate); htonf(net->climb_rate);
net->num_tanks = htonl(net->num_tanks);
for ( i = 0; i < net->num_tanks; ++i ) { for ( i = 0; i < net->num_tanks; ++i ) {
htonf(net->fuel_quantity[i]); htonf(net->fuel_quantity[i]);
} }
@ -271,7 +268,6 @@ void FGNetGUI2Props( FGNetGUI *net ) {
net->ground_elev = htonl( net->ground_elev ); net->ground_elev = htonl( net->ground_elev );
htonf(net->tuned_freq); htonf(net->tuned_freq);
net->in_range = htonl(net->in_range);
htonf(net->dist_nm); htonf(net->dist_nm);
htonf(net->course_deviation_deg); htonf(net->course_deviation_deg);
htonf(net->gs_deviation_deg); htonf(net->gs_deviation_deg);

View file

@ -13,11 +13,28 @@
#define _NET_CTRLS_HXX #define _NET_CTRLS_HXX
#ifndef __cplusplus // NOTE: this file defines an external interface structure. Due to
# error This library requires C++ // variability between platforms and architectures, we only used fixed
#endif // length types here. Specifically, integer types can vary in length.
// I am not aware of any platforms that don't use 4 bytes for float
// and 8 bytes for double.
const int FG_NET_CTRLS_VERSION = 24; #ifdef HAVE_STDINT_H
# include <stdint.h>
#elif defined( _MSC_VER ) || defined(__MINGW32__)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed __int64 int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
#else
# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
#endif
const uint16_t FG_NET_CTRLS_VERSION = 25;
// Define a structure containing the control parameters // Define a structure containing the control parameters
@ -26,14 +43,14 @@ class FGNetCtrls {
public: public:
int version; // increment when data values change
enum { enum {
FG_MAX_ENGINES = 4, FG_MAX_ENGINES = 4,
FG_MAX_WHEELS = 16, FG_MAX_WHEELS = 16,
FG_MAX_TANKS = 6 FG_MAX_TANKS = 6
}; };
uint16_t version; // increment when data values change
// Aero controls // Aero controls
double aileron; // -1 ... 1 double aileron; // -1 ... 1
double elevator; // -1 ... 1 double elevator; // -1 ... 1
@ -44,32 +61,33 @@ public:
double flaps; // 0 ... 1 double flaps; // 0 ... 1
// Aero control faults // Aero control faults
bool flaps_power; // true = power available uint8_t flaps_power; // true = power available
bool flap_motor_ok; uint8_t flap_motor_ok;
// Engine controls // Engine controls
int num_engines; // number of valid engines uint8_t num_engines; // number of valid engines
bool master_bat[FG_MAX_ENGINES]; uint8_t master_bat[FG_MAX_ENGINES];
bool master_alt[FG_MAX_ENGINES]; uint8_t master_alt[FG_MAX_ENGINES];
int magnetos[FG_MAX_ENGINES]; uint8_t magnetos[FG_MAX_ENGINES];
bool starter_power[FG_MAX_ENGINES]; // true = starter power uint8_t starter_power[FG_MAX_ENGINES];// true = starter power
double throttle[FG_MAX_ENGINES]; // 0 ... 1 double throttle[FG_MAX_ENGINES]; // 0 ... 1
double mixture[FG_MAX_ENGINES]; // 0 ... 1 double mixture[FG_MAX_ENGINES]; // 0 ... 1
double condition[FG_MAX_ENGINES]; // 0 ... 1 double condition[FG_MAX_ENGINES]; // 0 ... 1
bool fuel_pump_power[FG_MAX_ENGINES];// true = on uint8_t fuel_pump_power[FG_MAX_ENGINES];// true = on
double prop_advance[FG_MAX_ENGINES]; // 0 ... 1 double prop_advance[FG_MAX_ENGINES]; // 0 ... 1
// Engine faults // Engine faults
bool engine_ok[FG_MAX_ENGINES]; uint8_t engine_ok[FG_MAX_ENGINES];
bool mag_left_ok[FG_MAX_ENGINES]; uint8_t mag_left_ok[FG_MAX_ENGINES];
bool mag_right_ok[FG_MAX_ENGINES]; uint8_t mag_right_ok[FG_MAX_ENGINES];
bool spark_plugs_ok[FG_MAX_ENGINES]; // false = fouled plugs uint8_t spark_plugs_ok[FG_MAX_ENGINES]; // false = fouled plugs
int oil_press_status[FG_MAX_ENGINES]; // 0 = normal, 1 = low, 2 = full fail uint8_t oil_press_status[FG_MAX_ENGINES];// 0 = normal, 1 = low, 2 = full fail
bool fuel_pump_ok[FG_MAX_ENGINES]; uint8_t fuel_pump_ok[FG_MAX_ENGINES];
// Fuel management // Fuel management
int num_tanks; // number of valid tanks uint8_t num_tanks; // number of valid tanks
bool fuel_selector[FG_MAX_TANKS]; // false = off, true = on uint8_t fuel_selector[FG_MAX_TANKS]; // false = off, true = on
uint8_t cross_feed; // false = off, true = on
// Brake controls // Brake controls
double brake_left; double brake_left;
@ -79,10 +97,10 @@ public:
double brake_parking; double brake_parking;
// Landing Gear // Landing Gear
bool gear_handle; // true=gear handle down; false= gear handle up uint8_t gear_handle; // true=gear handle down; false= gear handle up
// Switches // Switches
bool master_avionics; uint8_t master_avionics;
// wind and turbulance // wind and turbulance
double wind_speed_kt; double wind_speed_kt;
@ -98,13 +116,13 @@ public:
double magvar; // local magnetic variation in degs. double magvar; // local magnetic variation in degs.
// hazards // hazards
bool icing; // icing status could me much uint8_t icing; // icing status could me much
// more complex but I'm // more complex but I'm
// starting simple here. // starting simple here.
// simulation control // simulation control
int speedup; // integer speedup multiplier uint8_t speedup; // integer speedup multiplier
int freeze; // 0=normal uint8_t freeze; // 0=normal
// 0x01=master // 0x01=master
// 0x02=position // 0x02=position
// 0x04=fuel // 0x04=fuel

View file

@ -13,13 +13,30 @@
#define _NET_FDM_HXX #define _NET_FDM_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <time.h> // time_t #include <time.h> // time_t
const int FG_NET_FDM_VERSION = 20; // NOTE: this file defines an external interface structure. Due to
// variability between platforms and architectures, we only used fixed
// length types here. Specifically, integer types can vary in length.
// I am not aware of any platforms that don't use 4 bytes for float
// and 8 bytes for double.
#ifdef HAVE_STDINT_H
# include <stdint.h>
#elif defined( _MSC_VER ) || defined(__MINGW32__)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed __int64 int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
#else
# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
#endif
const uint16_t FG_NET_FDM_VERSION = 21;
// Define a structure containing the top level flight dynamics model // Define a structure containing the top level flight dynamics model
@ -29,18 +46,14 @@ class FGNetFDM {
public: public:
int version; // increment when data values change
int pad; // keep doubles 64-bit aligned for some
// hardware platforms, such as the Sun
// SPARC, which don't like misaligned
// data
enum { enum {
FG_MAX_ENGINES = 4, FG_MAX_ENGINES = 4,
FG_MAX_WHEELS = 3, FG_MAX_WHEELS = 3,
FG_MAX_TANKS = 4 FG_MAX_TANKS = 4
}; };
uint16_t version; // increment when data values change
// Positions // Positions
double longitude; // geodetic (radians) double longitude; // geodetic (radians)
double latitude; // geodetic (radians) double latitude; // geodetic (radians)
@ -80,8 +93,8 @@ public:
// Pressure // Pressure
// Engine status // Engine status
int num_engines; // Number of valid engines uint8_t num_engines; // Number of valid engines
int eng_state[FG_MAX_ENGINES]; // Engine state (off, cranking, running) uint8_t eng_state[FG_MAX_ENGINES];// Engine state (off, cranking, running)
float rpm[FG_MAX_ENGINES]; // Engine RPM rev/min float rpm[FG_MAX_ENGINES]; // Engine RPM rev/min
float fuel_flow[FG_MAX_ENGINES]; // Fuel flow gallons/hr float fuel_flow[FG_MAX_ENGINES]; // Fuel flow gallons/hr
float egt[FG_MAX_ENGINES]; // Exhuast gas temp deg F float egt[FG_MAX_ENGINES]; // Exhuast gas temp deg F
@ -92,20 +105,21 @@ public:
float oil_px[FG_MAX_ENGINES]; // Oil pressure psi float oil_px[FG_MAX_ENGINES]; // Oil pressure psi
// Consumables // Consumables
int num_tanks; // Max number of fuel tanks uint8_t num_tanks; // Max number of fuel tanks
float fuel_quantity[FG_MAX_TANKS]; float fuel_quantity[FG_MAX_TANKS];
// Gear status // Gear status
int num_wheels; uint8_t num_wheels;
bool wow[FG_MAX_WHEELS]; uint8_t wow[FG_MAX_WHEELS];
float gear_pos[FG_MAX_WHEELS]; float gear_pos[FG_MAX_WHEELS];
float gear_steer[FG_MAX_WHEELS]; float gear_steer[FG_MAX_WHEELS];
float gear_compression[FG_MAX_WHEELS]; float gear_compression[FG_MAX_WHEELS];
// Environment // Environment
time_t cur_time; // current unix time uint32_t cur_time; // current unix time
long int warp; // offset in seconds to unix time // FIXME: make this uint64_t before 2038
float visibility; // visibility in meters (for env. effects) uint32_t warp; // offset in seconds to unix time
float visibility; // visibility in meters (for env. effects)
// Control surface positions (normalized values) // Control surface positions (normalized values)
float elevator; float elevator;

View file

@ -12,12 +12,28 @@
#define _NET_GUI_HXX #define _NET_GUI_HXX
#ifndef __cplusplus // NOTE: this file defines an external interface structure. Due to
# error This library requires C++ // variability between platforms and architectures, we only used fixed
#endif // length types here. Specifically, integer types can vary in length.
// I am not aware of any platforms that don't use 4 bytes for float
// and 8 bytes for double.
#ifdef HAVE_STDINT_H
# include <stdint.h>
#elif defined( _MSC_VER ) || defined(__MINGW32__)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed __int64 int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
#else
# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
#endif
const int FG_NET_GUI_VERSION = 5; const uint16_t FG_NET_GUI_VERSION = 6;
// Define a structure containing the top level flight dynamics model // Define a structure containing the top level flight dynamics model
@ -33,11 +49,7 @@ public:
FG_MAX_TANKS = 4 FG_MAX_TANKS = 4
}; };
int version; // increment when data values change uint16_t version; // increment when data values change
int pad; // keep doubles 64-bit aligned for some
// hardware platforms, such as the Sun
// SPARC, which don't like misaligned
// data
// Positions // Positions
double longitude; // geodetic (radians) double longitude; // geodetic (radians)
@ -53,18 +65,19 @@ public:
float climb_rate; // feet per second float climb_rate; // feet per second
// Consumables // Consumables
int num_tanks; // Max number of fuel tanks uint8_t num_tanks; // Max number of fuel tanks
float fuel_quantity[FG_MAX_TANKS]; float fuel_quantity[FG_MAX_TANKS];
// Environment // Environment
time_t cur_time; // current unix time uint32_t cur_time; // current unix time
long int warp; // offset in seconds to unix time // FIXME: make this uint64_t before 2038
uint32_t warp; // offset in seconds to unix time
float ground_elev; // ground elev (meters) float ground_elev; // ground elev (meters)
// Approach // Approach
float tuned_freq; // currently tuned frequency float tuned_freq; // currently tuned frequency
float nav_radial; // target nav radial float nav_radial; // target nav radial
int in_range; // tuned navaid is in range? uint8_t in_range; // tuned navaid is in range?
float dist_nm; // distance to tuned navaid in nautical miles float dist_nm; // distance to tuned navaid in nautical miles
float course_deviation_deg; // degrees off target course float course_deviation_deg; // degrees off target course
float gs_deviation_deg; // degrees off target glide slope float gs_deviation_deg; // degrees off target glide slope

View file

@ -284,7 +284,7 @@ static FGReplayData interpolate( double time, FGReplayData f1, FGReplayData f2 )
// Gear status // Gear status
for ( i = 0; i < fdm1.num_wheels; ++i ) { for ( i = 0; i < fdm1.num_wheels; ++i ) {
result.fdm.wow[i] = weight( fdm1.wow[i], fdm2.wow[i], ratio ); result.fdm.wow[i] = (int)(weight( fdm1.wow[i], fdm2.wow[i], ratio ));
result.fdm.gear_pos[i] result.fdm.gear_pos[i]
= weight( fdm1.gear_pos[i], fdm2.gear_pos[i], ratio ); = weight( fdm1.gear_pos[i], fdm2.gear_pos[i], ratio );
result.fdm.gear_steer[i] result.fdm.gear_steer[i]