diff --git a/src/Network/opengc.cxx b/src/Network/opengc.cxx index de7eeabd7..a661eb58c 100644 --- a/src/Network/opengc.cxx +++ b/src/Network/opengc.cxx @@ -1,8 +1,15 @@ -// opengc.cxx - Network interface program to send sim data onto a LAN +// opengc.cxx - Network interface program to send data to display processor over LAN // // Created by: J. Wojnaroski -- castle@mminternet.com // Date: 21 Nov 2001 // +// Extended from original network code developed by C. Olson +// +// Modified 12/02/01 - Update engine structure for multi-engine models +// - Added data preamble to id msg types +// +// Modified 01/23/02 - Converted portions of the Engine and Gear accesssors to properties +// - Removed data from navigation functions. OpenGC provides own nav functions // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -28,6 +35,8 @@ #include #include
#include +#include +#include
SG_USING_STD(vector); @@ -59,48 +68,84 @@ bool FGOpenGC::open() { static void collect_data( const FGInterface *fdm, ogcFGData *data ) { - //static void collect_data( ogcFGData *data ) { - - data->version_id = 0x0011; - - data->latitude = fdm->get_Longitude_deg(); - data->longitude = cur_fdm_state->get_Latitude_deg(); + + data->version_id = 0x0012; + data->longitude = fdm->get_Longitude_deg(); + data->latitude = cur_fdm_state->get_Latitude_deg(); + data->magvar = globals->get_mag()->get_magvar(); + data->pitch = cur_fdm_state->get_Theta_deg(); data->bank = cur_fdm_state->get_Phi_deg(); data->heading = cur_fdm_state->get_Psi_deg(); data->altitude = cur_fdm_state->get_Altitude(); + data->altitude_agl = cur_fdm_state->get_Altitude_AGL(); data->v_kcas = cur_fdm_state->get_V_calibrated_kts(); data->vvi = cur_fdm_state->get_Climb_Rate(); + data->mach = cur_fdm_state->get_Mach_number(); + data->groundspeed = cur_fdm_state->get_V_ground_speed(); + data->v_tas = cur_fdm_state->get_V_equiv_kts(); - data->magvar = globals->get_mag()->get_magvar(); + data->alpha = cur_fdm_state->get_Alpha(); + data->beta = cur_fdm_state->get_Beta(); + data->alpha_dot = cur_fdm_state->get_Alpha_dot(); + data->beta_dot = cur_fdm_state->get_Beta_dot(); + + data->static_temperature = cur_fdm_state->get_Static_temperature(); + data->total_temperature = cur_fdm_state->get_Total_temperature(); + + data->static_pressure = cur_fdm_state->get_Static_pressure(); + data->total_pressure = cur_fdm_state->get_Total_pressure(); + data->dynamic_pressure = cur_fdm_state->get_Dynamic_pressure(); data->rpm[0] = fgGetDouble("/engines/engine[0]/rpm"); - data->rpm[1] = fgGetDouble("/engines/engine[1]/rpm"); + data->rpm[1] = fgGetDouble("/engines/engine[1]/rpm"); - data->epr[0] = fgGetDouble("/engines/engine[0]/mp-osi"); - data->epr[1] = fgGetDouble("/engines/engine[1]/mp-osi"); + data->epr[0] = fgGetDouble("/engines/engine[0]/epr"); + data->epr[1] = fgGetDouble("/engines/engine[1]/epr"); + data->epr[2] = fgGetDouble("/engines/engine[2]/epr"); + data->epr[3] = fgGetDouble("/engines/engine[3]/epr"); data->egt[0] = fgGetDouble("/engines/engine[0]/egt-degf"); data->egt[1] = fgGetDouble("/engines/engine[1]/egt-degf"); + data->egt[2] = fgGetDouble("/engines/engine[2]/egt-degf"); + data->egt[3] = fgGetDouble("/engines/engine[3]/egt-degf"); + + data->n2_turbine[0] = fgGetDouble("/engines/engine[0]/n2"); + data->n2_turbine[1] = fgGetDouble("/engines/engine[1]/n2"); + data->n2_turbine[2] = fgGetDouble("/engines/engine[2]/n2"); + data->n2_turbine[3] = fgGetDouble("/engines/engine[3]/n2"); + + data->n1_turbine[0] = fgGetDouble("/engines/engine[0]/n1"); + data->n1_turbine[1] = fgGetDouble("/engines/engine[1]/n1"); + data->n1_turbine[2] = fgGetDouble("/engines/engine[2]/n1"); + data->n1_turbine[3] = fgGetDouble("/engines/engine[3]/n1"); + + data->fuel_flow[0] = fgGetDouble("/engines/engine[0]/fuel-flow-gph"); + data->fuel_flow[1] = fgGetDouble("/engines/engine[1]/fuel-flow-gph"); + data->fuel_flow[1] = fgGetDouble("/engines/engine[1]/fuel-flow-gph"); + data->fuel_flow[2] = fgGetDouble("/engines/engine[2]/fuel-flow-gph"); data->oil_pressure[0] = fgGetDouble("/engines/engine[0]/oil-pressure-psi"); data->oil_pressure[1] = fgGetDouble("/engines/engine[1]/oil-pressure-psi"); + data->oil_pressure[2] = fgGetDouble("/engines/engine[2]/oil-pressure-psi"); + data->oil_pressure[3] = fgGetDouble("/engines/engine[3]/oil-pressure-psi"); + data->man_pressure[0] = fgGetDouble("/engines/engine[0]/mp-osi"); + data->man_pressure[1] = fgGetDouble("/engines/engine[1]/mp-osi"); -// navigation data -// Once OPenGC develops a comparable navaids database some of this will not be required - - //data->nav1_ident = current_radiostack->get_nav1_ident(); - data->nav1_freq = current_radiostack->get_nav1_freq(); - data->nav1_radial = current_radiostack->get_nav1_sel_radial(); - data->nav1_course_dev = current_radiostack->get_nav1_heading_needle_deflection(); - - //data->nav1_ident = current_radiostack->get_nav1_ident(); - data->nav2_freq = current_radiostack->get_nav2_freq(); - data->nav2_radial = current_radiostack->get_nav2_sel_radial(); - data->nav2_course_dev = current_radiostack->get_nav2_heading_needle_deflection(); - + //data->gear_nose = p_gear[0]->GetPosition(); + //data->gear_left = p_gear[1]->GetPosition(); + //data->gear_right = p_gear[2]->GetPosition(); + + data->aileron = globals->get_controls()->get_aileron(); + //data->aileron_trim = p_Controls->get_aileron_trim(); + data->elevator = globals->get_controls()->get_elevator(); + data->elevator_trim = globals->get_controls()->get_elevator_trim(); + data->rudder = globals->get_controls()->get_rudder(); + //data->rudder_trim = p_Controls->get_rudder_trim(); + //data->flaps = fgGetDouble("/controls/flaps"); + data->flaps = globals->get_controls()->get_flaps(); } static void distribute_data( const ogcFGData *data, FGInterface *chunk ) { diff --git a/src/Network/opengc.hxx b/src/Network/opengc.hxx index f4ff1e588..ec4d393c2 100644 --- a/src/Network/opengc.hxx +++ b/src/Network/opengc.hxx @@ -1,10 +1,12 @@ -//// opengc.cxx - Network interface program to send sim data onto a LAN +//// opengc.hxx - Network interface program to send sim data onto a LAN // // Created by: J. Wojnaroski -- castle@mminternet.com // Date: 21 Nov 2001 // - +// +// Adapted from original network code developed by C. Olson +// // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the diff --git a/src/Network/opengc_data.hxx b/src/Network/opengc_data.hxx index 397c03b28..c0d39a1e0 100644 --- a/src/Network/opengc_data.hxx +++ b/src/Network/opengc_data.hxx @@ -1,9 +1,12 @@ -// opengc.hxx -- Define structure of OpenGC/FG interface parameters +// opengc_data.hxx -- Define structure of OpenGC/FG interface parameters // // Version by J. Wojnaroski for interface to Open Glass Displays // // Modified 02/12/01 - Update engine structure for multi-engine models -// - Added data preamble to id msg types +// - Added data preamble to id msg types +// +// Modified 01/23/02 - Converted portions of the Engine and Gear accesssors to properties +// - Removed data from navigation functions. OpenGC provides own // // This file defines the class/structure of the UDP packet that sends // the simulation data created by FlightGear to the glass displays. It @@ -37,12 +40,18 @@ class ogcFGData { public: - // defines msg types and contents. typedefs & classes are TBS + // defines msg types and contents. The msg_content is used as a 'pointer' to + // a predefined set of msg strings + unsigned int version_id; - unsigned int msg_id; + unsigned int msg_type; unsigned int msg_content; - unsigned short autopilot_mode; - unsigned short afds_armed_mode; + + // position + + double latitude; + double longitude; + double magvar; // flight parameters @@ -54,48 +63,58 @@ public: double v_kcas; double groundspeed; double vvi; - double mach; + double mach; + double v_tas; // true airspeed in knots - // position + // Data used by the FMC and autopilots - double latitude; - double longitude; - double magvar; + double phi_dot; + double theta_dot; + double psi_dot; + + double alpha; + double alpha_dot; + double beta; + double beta_dot; + + // Control surface positions + + double aileron; + double aileron_trim; + double elevator; + double elevator_trim; + double rudder; + double rudder_trim; + double flaps; + + // Gear positions 0 = UP and 1 = DOWN + + double gear_nose; + double gear_left; + double gear_right; // engine data - double rpm[4]; + double rpm[4]; // this is for pistons, jets see below + double n1_turbine[4]; double epr[4]; double egt[4]; + double n2_turbine[4]; double fuel_flow[4]; + double man_pressure[4]; double oil_pressure[4]; + double throttle[4]; + double mixture[4]; + double prop_advance[4]; + + // Pressures and temperatures - double n1_turbine[4]; - double n2_turbine[4]; + double static_temperature; + double total_temperature; + double static_pressure; + double total_pressure; + double dynamic_pressure; - // navigation data - // This will require a lot of related work to build the nav - // database for the ND and some msg traffic both ways to display - // and configure nav aids, freqs, courses, etc etc. OpenGC will - // most likely define an FMC to hold the database and do nav stuff - double nav1_freq; - double nav1_radial; - double nav1_course_dev; - double nav1_gs_dev; - double nav1_dme; - - double nav2_freq; - double nav2_radial; - double nav2_course_dev; - double nav2_gs_dev; - double nav2_dme; - - // some other locations serving as place holders for user defined - // variables reduces the need to update FG or OpenGC code - - double d_ogcdata[16]; - float f_ogcdata[16]; - int i_ogcdata[16]; }; #endif // _OPENGC_HXX