;;;; -*- mode:lisp;coding:utf-8 -*-
;;;;**************************************************************************
;;;;FILE:               net-fdm-24.lisp
;;;;LANGUAGE:           Common-Lisp
;;;;SYSTEM:             Common-Lisp
;;;;USER-INTERFACE:     NONE
;;;;DESCRIPTION
;;;;
;;;;    Defines the net-fdm version 24 message format.
;;;;
;;;;    Defines a structure containing the top level flight dynamics model
;;;;    parameters.
;;;;
;;;;AUTHORS
;;;;    <PJB> Pascal J. Bourguignon <pjb@ogamita.com>
;;;;MODIFICATIONS
;;;;    2011-04-07 <PJB> Created.
;;;;BUGS
;;;;LEGAL
;;;;    GPL
;;;;
;;;;    Copyright Pascal J. Bourguignon 2011 - 2011
;;;;
;;;;    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 License, or (at your option) any later version.
;;;;
;;;;    This program is distributed in the hope that it will be
;;;;    useful, but WITHOUT ANY WARRANTY; without even the implied
;;;;    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;;;;    PURPOSE.  See the GNU General Public License for more details.
;;;;
;;;;    You should have received a copy of the GNU General Public
;;;;    License along with this program; if not, write to the Free
;;;;    Software Foundation, Inc., 59 Temple Place, Suite 330,
;;;;    Boston, MA 02111-1307 USA
;;;;**************************************************************************

(defpackage "COM.OGAMITA.FGFS.NET-FDM-24"
  (:use "COMMON-LISP"
        "COM.OGAMITA.FGFS.BINARY-PACKET")
  (:export
   "NET-FDM" "NET-FDM-P" "MAKE-NET-FDM" "COPY-NET-FDM"
   "MAKE-NET-FDM-BUFFER" "SERIALIZE" "DESERIALIZE"
   "NET-FDM-VERSION" "NET-FDM-PADDING" "NET-FDM-LONGITUDE"
   "NET-FDM-LATITUDE" "NET-FDM-ALTITUDE" "NET-FDM-AGL" "NET-FDM-PHI"
   "NET-FDM-THETA" "NET-FDM-PSI" "NET-FDM-ALPHA" "NET-FDM-BETA"
   "NET-FDM-PHIDOT" "NET-FDM-THETADOT" "NET-FDM-PSIDOT" "NET-FDM-VCAS"
   "NET-FDM-CLIMB-RATE" "NET-FDM-V-NORTH" "NET-FDM-V-EAST"
   "NET-FDM-V-DOWN" "NET-FDM-V-WIND-BODY-NORTH"
   "NET-FDM-V-WIND-BODY-EAST" "NET-FDM-V-WIND-BODY-DOWN"
   "NET-FDM-A-X-PILOT" "NET-FDM-A-Y-PILOT" "NET-FDM-A-Z-PILOT"
   "NET-FDM-STALL-WARNING" "NET-FDM-SLIP-DEG" "NET-FDM-NUM-ENGINES"
   "NET-FDM-ENG-STATE" "NET-FDM-RPM" "NET-FDM-FUEL-FLOW"
   "NET-FDM-FUEL-PX" "NET-FDM-EGT" "NET-FDM-CHT" "NET-FDM-MP-OSI"
   "NET-FDM-TIT" "NET-FDM-OIL-TEMP" "NET-FDM-OIL-PX"
   "NET-FDM-NUM-TANKS" "NET-FDM-FUEL-QUANTITY" "NET-FDM-NUM-WHEELS"
   "NET-FDM-WOW" "NET-FDM-GEAR-POS" "NET-FDM-GEAR-STEER"
   "NET-FDM-GEAR-COMPRESSION" "NET-FDM-CUR-TIME" "NET-FDM-WARP"
   "NET-FDM-VISIBILITY" "NET-FDM-ELEVATOR" "NET-FDM-ELEVATOR-TRIM-TAB"
   "NET-FDM-LEFT-FLAP" "NET-FDM-RIGHT-FLAP" "NET-FDM-LEFT-AILERON"
   "NET-FDM-RIGHT-AILERON" "NET-FDM-RUDDER" "NET-FDM-NOSE-WHEEL"
   "NET-FDM-SPEEDBRAKE" "NET-FDM-SPOILERS"
   "+VERSION+"
   "+FG-MAX-ENGINES+" "+FG-MAX-WHEELS+" "+FG-MAX-TANKS+"
   )
  (:documentation "
Defines the net-fdm version 24 message format.

Defines a structure containing the top level flight dynamics model
parameters.

"))
(in-package "COM.OGAMITA.FGFS.NET-FDM-24")



(eval-when (:execute :compile-toplevel :load-toplevel)
  (defconstant +version+ 24) ; FG_NET_FDM_VERSION
  (defconstant +fg-max-engines+ 4)
  (defconstant +fg-max-wheels+  3)
  (defconstant +fg-max-tanks+   4))


(define-message net-fdm ()
  (version           (unsigned-byte 32)  #.+version+) ; increment when data values change
  (padding           (unsigned-byte 32))              ; padding

  ;; Positions
  (longitude         double-float)    ; geodetic (radians)
  (latitude          double-float)    ; geodetic (radians)
  (altitude          double-float)    ; above sea level (meters)
  (agl               single-float)    ; above ground level (meters)
  (phi               single-float)    ; roll (radians)
  (theta             single-float)    ; pitch (radians)
  (psi               single-float)    ; yaw or true heading (radians)
  (alpha             single-float)    ; angle of attack (radians)
  (beta              single-float)    ; side slip angle (radians)

  ;; Velocities
  (phidot            single-float)     ; roll rate (radians/sec)
  (thetadot          single-float)     ; pitch rate (radians/sec)
  (psidot            single-float)     ; yaw rate (radians/sec)
  (vcas              single-float)     ; calibrated airspeed
  (climb-rate        single-float)     ; feet per second
  (v-north           single-float) ; north velocity in local/body frame, fps
  (v-east            single-float) ; east velocity in local/body frame, fps
  (v-down            single-float) ; down/vertical velocity in local/body frame, fps
  (v-wind-body-north single-float) ; north velocity in local/body frame
                                        ; relative to local airmass, fps
  (v-wind-body-east  single-float) ; east velocity in local/body frame
                                        ; relative to local airmass, fps
  (v-wind-body-down  single-float) ; down/vertical velocity in local/body
                                        ; frame relative to local airmass, fps

  ;; Accelerations
  (A-X-pilot         single-float)   ; X accel in body frame ft/sec^2
  (A-Y-pilot         single-float)   ; Y accel in body frame ft/sec^2
  (A-Z-pilot         single-float)   ; Z accel in body frame ft/sec^2

  ;; Stall
  (stall-warning     single-float) ; 0.0 - 1.0 indicating the amount of stall
  (slip-deg          single-float) ; slip ball deflection

  ;; Pressure

  ;; Engine status
  (num-engines (unsigned-byte 32))     ; Number of valid engines
  (eng-state   (vector (unsigned-byte 32) #.+FG-MAX-ENGINES+)) ; Engine state (off, cranking, running FG-MAX-ENGINES))
  (rpm         (vector single-float #.+FG-MAX-ENGINES+)) ; Engine RPM rev/min
  (fuel-flow   (vector single-float #.+FG-MAX-ENGINES+)) ; Fuel flow gallons/hr
  (fuel-px     (vector single-float #.+FG-MAX-ENGINES+)) ; Fuel pressure psi
  (egt         (vector single-float #.+FG-MAX-ENGINES+)) ; Exhaust gas temp deg F
  (cht         (vector single-float #.+FG-MAX-ENGINES+)) ; Cylinder head temp deg F
  (mp-osi      (vector single-float #.+FG-MAX-ENGINES+)) ; Manifold pressure
  (tit         (vector single-float #.+FG-MAX-ENGINES+)) ; Turbine Inlet Temperature
  (oil-temp    (vector single-float #.+FG-MAX-ENGINES+)) ; Oil temp deg F
  (oil-px      (vector single-float #.+FG-MAX-ENGINES+)) ; Oil pressure psi

  ;; Consumables
  (num-tanks         (unsigned-byte 32)) ; Max number of fuel tanks
  (fuel-quantity     (vector single-float #.+FG-MAX-TANKS+))

  ;; Gear status
  (num-wheels        (unsigned-byte 32))
  (wow               (vector (unsigned-byte 32) #.+FG-MAX-WHEELS+))
  (gear-pos          (vector single-float #.+FG-MAX-WHEELS+))
  (gear-steer        (vector single-float #.+FG-MAX-WHEELS+))
  (gear-compression  (vector single-float #.+FG-MAX-WHEELS+))

  ;; Environment
  (cur-time          (unsigned-byte 32)) ; current unix time
                                        ; FIXME: make this uint64-t before 2038
  (warp              (signed-byte 32)) ; offset in seconds to unix time
  (visibility        single-float) ; visibility in meters (for env. effects)

  ;; Control surface positions (normalized values)
  (elevator          single-float)
  (elevator-trim-tab single-float)
  (left-flap         single-float)
  (right-flap        single-float)
  (left-aileron      single-float)
  (right-aileron     single-float)
  (rudder            single-float)
  (nose-wheel        single-float)
  (speedbrake        single-float)
  (spoilers          single-float))



;;;; THE END ;;;;
ViewGit