| 1 | // net_ctrls.hxx -- defines a common net I/O interface to the flight |
| 2 | // sim controls |
| 3 | // |
| 4 | // Written by Curtis Olson - http://www.flightgear.org/~curt |
| 5 | // Started July 2001. |
| 6 | // |
| 7 | // This file is in the Public Domain, and comes with no warranty. |
| 8 | // |
| 9 | // $Id$ |
| 10 | |
| 11 | |
| 12 | #ifndef _NET_CTRLS_HXX |
| 13 | #define _NET_CTRLS_HXX |
| 14 | |
| 15 | #include <simgear/misc/stdint.hxx> |
| 16 | |
| 17 | // NOTE: this file defines an external interface structure. Due to |
| 18 | // variability between platforms and architectures, we only used fixed |
| 19 | // length types here. Specifically, integer types can vary in length. |
| 20 | // I am not aware of any platforms that don't use 4 bytes for float |
| 21 | // and 8 bytes for double. |
| 22 | |
| 23 | // !!! IMPORTANT !!! |
| 24 | /* There is some space reserved in the protocol for future use. |
| 25 | * When adding a new type, add it just before the "reserved" definition |
| 26 | * and subtract the size of this new type from the RESERVED_SPACE definition |
| 27 | * (1 for (u)int32_t or float and 2 for double). |
| 28 | * |
| 29 | * This way the protocol will be forward and backward compatible until |
| 30 | * RESERVED_SPACE becomes zero. |
| 31 | */ |
| 32 | |
| 33 | #define RESERVED_SPACE 25 |
| 34 | const uint32_t FG_NET_CTRLS_VERSION = 27; |
| 35 | |
| 36 | |
| 37 | // Define a structure containing the control parameters |
| 38 | |
| 39 | class FGNetCtrls { |
| 40 | |
| 41 | public: |
| 42 | |
| 43 | enum { |
| 44 | FG_MAX_ENGINES = 4, |
| 45 | FG_MAX_WHEELS = 16, |
| 46 | FG_MAX_TANKS = 8 |
| 47 | }; |
| 48 | |
| 49 | uint32_t version; // increment when data values change |
| 50 | |
| 51 | // Aero controls |
| 52 | double aileron; // -1 ... 1 |
| 53 | double elevator; // -1 ... 1 |
| 54 | double rudder; // -1 ... 1 |
| 55 | double aileron_trim; // -1 ... 1 |
| 56 | double elevator_trim; // -1 ... 1 |
| 57 | double rudder_trim; // -1 ... 1 |
| 58 | double flaps; // 0 ... 1 |
| 59 | double spoilers; |
| 60 | double speedbrake; |
| 61 | |
| 62 | // Aero control faults |
| 63 | uint32_t flaps_power; // true = power available |
| 64 | uint32_t flap_motor_ok; |
| 65 | |
| 66 | // Engine controls |
| 67 | uint32_t num_engines; // number of valid engines |
| 68 | uint32_t master_bat[FG_MAX_ENGINES]; |
| 69 | uint32_t master_alt[FG_MAX_ENGINES]; |
| 70 | uint32_t magnetos[FG_MAX_ENGINES]; |
| 71 | uint32_t starter_power[FG_MAX_ENGINES];// true = starter power |
| 72 | double throttle[FG_MAX_ENGINES]; // 0 ... 1 |
| 73 | double mixture[FG_MAX_ENGINES]; // 0 ... 1 |
| 74 | double condition[FG_MAX_ENGINES]; // 0 ... 1 |
| 75 | uint32_t fuel_pump_power[FG_MAX_ENGINES];// true = on |
| 76 | double prop_advance[FG_MAX_ENGINES]; // 0 ... 1 |
| 77 | uint32_t feed_tank_to[4]; |
| 78 | uint32_t reverse[4]; |
| 79 | |
| 80 | |
| 81 | // Engine faults |
| 82 | uint32_t engine_ok[FG_MAX_ENGINES]; |
| 83 | uint32_t mag_left_ok[FG_MAX_ENGINES]; |
| 84 | uint32_t mag_right_ok[FG_MAX_ENGINES]; |
| 85 | uint32_t spark_plugs_ok[FG_MAX_ENGINES]; // false = fouled plugs |
| 86 | uint32_t oil_press_status[FG_MAX_ENGINES];// 0 = normal, 1 = low, 2 = full fail |
| 87 | uint32_t fuel_pump_ok[FG_MAX_ENGINES]; |
| 88 | |
| 89 | // Fuel management |
| 90 | uint32_t num_tanks; // number of valid tanks |
| 91 | uint32_t fuel_selector[FG_MAX_TANKS]; // false = off, true = on |
| 92 | uint32_t xfer_pump[5]; // specifies transfer from array |
| 93 | // value tank to tank specified by |
| 94 | // int value |
| 95 | uint32_t cross_feed; // false = off, true = on |
| 96 | |
| 97 | // Brake controls |
| 98 | double brake_left; |
| 99 | double brake_right; |
| 100 | double copilot_brake_left; |
| 101 | double copilot_brake_right; |
| 102 | double brake_parking; |
| 103 | |
| 104 | // Landing Gear |
| 105 | uint32_t gear_handle; // true=gear handle down; false= gear handle up |
| 106 | |
| 107 | // Switches |
| 108 | uint32_t master_avionics; |
| 109 | |
| 110 | // nav and Comm |
| 111 | double comm_1; |
| 112 | double comm_2; |
| 113 | double nav_1; |
| 114 | double nav_2; |
| 115 | |
| 116 | // wind and turbulance |
| 117 | double wind_speed_kt; |
| 118 | double wind_dir_deg; |
| 119 | double turbulence_norm; |
| 120 | |
| 121 | // temp and pressure |
| 122 | double temp_c; |
| 123 | double press_inhg; |
| 124 | |
| 125 | // other information about environment |
| 126 | double hground; // ground elevation (meters) |
| 127 | double magvar; // local magnetic variation in degs. |
| 128 | |
| 129 | // hazards |
| 130 | uint32_t icing; // icing status could me much |
| 131 | // more complex but I'm |
| 132 | // starting simple here. |
| 133 | |
| 134 | // simulation control |
| 135 | uint32_t speedup; // integer speedup multiplier |
| 136 | uint32_t freeze; // 0=normal |
| 137 | // 0x01=master |
| 138 | // 0x02=position |
| 139 | // 0x04=fuel |
| 140 | |
| 141 | // --- New since FlightGear 0.9.10 (FG_NET_CTRLS_VERSION = 27) |
| 142 | |
| 143 | // --- Add new variables just before this line. |
| 144 | |
| 145 | uint32_t reserved[RESERVED_SPACE]; // 100 bytes reserved for future use. |
| 146 | }; |
| 147 | |
| 148 | |
| 149 | #endif // _NET_CTRLS_HXX |
| 150 | |
| 151 |