[simpits-tech] Flightdata F4 SPK3

Michi Hirczy simpits-tech@simpits.org
Thu, 26 Sep 2002 12:03:29 +0200


This is a multi-part message in MIME format.
--------------060306020200080708040202
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit

hi Jim!

I attachted the flightdata.h  and my (rob's *g*) visual basic equivalent 
for SP3.

greetings
michi



--------------060306020200080708040202
Content-Type: text/plain;
 name="Main.bas"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Main.bas"

Attribute VB_Name = "Module1"
Public Type FlightData
'  This data is compiled from the flightdata.h file
'  In VB, a 'float' converts to a 'single', which is 4 bytes
'  and an 'integer' is 'long' 4 bytes.  Strings are defined as the
'  number of bytes in the string
' version for SP2
  x As Single               'x in Ft
  y As Single               'y
  z As Single               'z
  xDot As Single            'xDot  ft/sec
  yDot As Single            'yDot
  zDot As Single            'zDot
  alpha As Single           'alpha  AOA in degrees
  beta As Single            'beta
  gamma As Single           'gamma  radians (?)
  pitch As Single           'pitch  radians
  roll As Single            'roll
  yaw As Single             'yaw
  mach As Single            'mach
  kias As Single            'kias  knots
  vt As Single              'vt    ft/sec
  gs As Single              'gs
  windOffset As Single      'windOffset to FPM (radians)
  nozzlePos As Single       'nozzlePos 0-100%
  internalFuel As Single    'internalFuel lbs
  externalFuel As Single    'externalFuel
  fuelFlow As Single        'fuelFlow lbs/hr
  rpm As Single             'rpm 0-103%
  ftit As Single            'ftit degrees C
  gearPos As Single         'gearPos 0 = up, 1 = down
  speedBrake As Single      'speedBrake 0 closed, 1 = 60 degr
  epuFuel As Single         'epuFuel 0-100%
  oilPressure As Single     'oilPressure 0-100%
  lightBits As Long         'lightbits
  headPitch As Single       'Input  radians
  headRoll As Single        'Input
  headYaw As Single         'Input
  lightBits2 As Long        'New lightbits
  lightBits3 As Long        'New lightbits
  ChaffCount As Single      'Chaff Counter
  FlareCount As Single      'Flare Counter
  NoseGearPos As Single     'Nose Gear
  LeftGearPos As Single     'Left Gear
  RightGearPos As Single    'Right Gear
  AdiIlsHosPos As Single    'Horizontal ILS Bar (ADI)
  AdiIlsVerPos As Single    'Vertical ILS Bar
  courseState As Long       'HSI State
  headingState As Long      'HSI State
  totalStates As Long       'HSI State
  courseDeviation As Single 'HSI Value
  desiredCourse As Single   'HSI Value
  distanceToBeacon As Single 'HSI Value
  bearingToBeacon As Single 'HSI Value
  currentHeading As Single  'HSI Value
  desiredHeading As Single  'HSI Value
  deviationLimit As Single  'HSI Value
  halfDeviationLimit As Single 'HSI Value
  localizerCourse As Single 'HSI Value
  airbaseX As Single        'HSI Value
  airbaseY As Single        'HSI Value
  totalValues As Single     'HSI Value
  hsiBits As Long           'HSI Flags
  DEDLines(1 To 5) As String * 26 'DED Lines
  Invert(1 To 5) As String * 26  'Inverted DED Lines
  PFLLines(1 To 5) As String * 26 'PFL Lines
  PFLInvert(1 To 5) As String * 26  'Inverted PFL Lines
  UFCTChan As Long       'Tacan Channel
  AUXTChan As Long       'Tacan Channel
  RwrObjectCount As Long            'RWR
  RWRSymbol(1 To 20) As Long        'RWR
  bearing(1 To 20) As Single        'RWR
  missileActivity(1 To 20) As Long  'RWR
  missileLaunch(1 To 20) As Long    'RWR
  selected(1 To 20) As Long         'RWR
  lethality(1 To 20) As Single      'RWR
  fwd As Single         'fuel values
  aft As Single
  total As Single
  IsSet As Long
  IsSet2 As Long
  IsSet3 As Long
  IsSetHsi As Long
  VersionNum As Long
End Type

Global F As FlightData, lightBit(29), lightBit2(25), lightBit3(12), hsiBit(14)
Global SharedMemHandle As Long, SharedMemPointer As Long
Declare Function OpenFileMapping Lib "kernel32" Alias "OpenFileMappingA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Declare Function MapViewOfFile Lib "kernel32" (ByVal hFileMappingObject As Long, ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long)
Declare Function UnmapViewOfFile Lib "kernel32" (lpBaseAddress As Any) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Sub Main()
 FILE_MAP_READ = &H4
 
 lightBit(1) = &H1             ' MasterCaution
 lightBit(2) = &H2             ' TF
 lightBit(3) = &H4             ' OBS
 lightBit(4) = &H8             ' ALT
 lightBit(5) = &H20            ' ENG_FIRE
 lightBit(6) = &H40            ' CONFIG
 lightBit(7) = &H80            ' HYD
 lightBit(8) = &H100           ' OIL
 lightBit(9) = &H200          ' DUAL
 lightBit(10) = &H400          ' CAN
 lightBit(11) = &H800          ' T_L_CFG
 lightBit(12) = &H1000         ' AOAAbove
 lightBit(13) = &H2000         ' AOAOn
 lightBit(14) = &H4000         ' AOABelow
 lightBit(15) = &H8000         ' RefuelRDY
 lightBit(16) = &H10000        ' RefuelAR
 lightBit(17) = &H20000        ' RefuelDSC
 lightBit(18) = &H40000        ' FltControlSys
 lightBit(19) = &H80000        ' LEFlaps
 lightBit(20) = &H100000       ' EngineFault
 lightBit(21) = &H200000       ' Overheat
 lightBit(22) = &H400000       ' FuelLow
 lightBit(23) = &H800000       ' Avionics
 lightBit(24) = &H1000000      ' RadarAlt
 lightBit(25) = &H2000000      ' IFF
 lightBit(26) = &H4000000      ' ECM
 lightBit(27) = &H8000000      ' Hook
 lightBit(28) = &H10000000     ' NWSFail
 lightBit(29) = &H20000000     ' CabinPress
 lightBit2(1) = &H1            ' HandOff
 lightBit2(2) = &H2            ' Launch
 lightBit2(3) = &H4            ' PriMode
 lightBit2(4) = &H8            ' Naval
 lightBit2(5) = &H10           ' Unk
 lightBit2(6) = &H20           ' TgtSep
 lightBit2(7) = &H1000         ' AuxSrch
 lightBit2(8) = &H2000         ' AuxAct
 lightBit2(9) = &H4000         ' AuxLow
 lightBit2(10) = &H8000        ' AuxPwr
 lightBit2(11) = &H10000       ' EcmPwr
 lightBit2(12) = &H20000       ' EcmFail
 lightBit2(13) = &H40000       ' FwdFuelLow
 lightBit2(14) = &H80000       ' AftFuelLow
 lightBit2(15) = &H100000      ' EPUOn
 lightBit2(16) = &H200000      ' JFSOn
 lightBit2(17) = &H400000      ' SEC
 lightBit2(18) = &H800000      ' OXY_LOW
 lightBit2(19) = &H1000000     ' PROBEHEAT
 lightBit2(20) = &H2000000     ' SEAT_ARM
 lightBit2(21) = &H4000000     ' BUC
 lightBit2(22) = &H8000000     ' FUEL_OIL_HOT
 lightBit2(23) = &H10000000    ' ANTI_SKID
 lightBit2(24) = &H20000000    ' TFR_ENGAGED
 lightBit2(25) = &H40000000    ' GEARHANDLE
 lightBit3(1) = &H1            ' Flcspmg
 lightBit3(2) = &H2            ' MainGen
 lightBit3(3) = &H4            ' StbyGen
 lightBit3(4) = &H8            ' EPUGen
 lightBit3(5) = &H10           ' EPUpmg
 lightBit3(6) = &H20           ' ToFlcs
 lightBit3(7) = &H40           ' FlcsRly
 lightBit3(8) = &H80           ' BatFail
 lightBit3(9) = &H100          ' Hydrazine
 lightBit3(10) = &H200         ' Air
 lightBit3(11) = &H400         ' Elec_Fault
 lightBit3(12) = &H800         ' Lef_Fault
 
 hsiBit(1) = &H1                           'HSI TO True
 hsiBit(2) = &H2                           'HSI ILS WARN
 hsiBit(3) = &H4                           'HSI CRS WARN
 hsiBit(4) = &H8                           'HSI FLAG INIT
 hsiBit(5) = &H10                          'HSI Total Flags (?)
 hsiBit(6) = &H20                          'ADI OFF Flag
 hsiBit(7) = &H40                          'ADI AUX Flag
 hsiBit(8) = &H80                          'ADI GS Flag
 hsiBit(9) = &H100                         'ADI LOC Flag
 hsiBit(10) = &H200                        'ADI OFF Flag
 hsiBit(11) = &H400                        'HSI OFF Flag
 hsiBit(12) = &H800                        'VVI OFF Flag
 hsiBit(13) = &H1000               'AOA OFF Flag
 hsiBit(14) = &H2000               'AVTR Light


StartMemCheck:

SharedMemHandle = OpenFileMapping(FILE_MAP_READ, True, "FalconSharedMemoryArea")

If SharedMemHandle Then
  SharedMemPointer = MapViewOfFile(SharedMemHandle, FILE_MAP_READ, 0, 0, 0)
Else
  Form1.Caption = "Waiting for Falcon to Start"
  CloseHandle (SharedMemHandle)
  Call Pause(2)
  GoTo StartMemCheck
End If
Form1.Caption = "Connected to Falcon 4"
' Start timer for polling
' Form1.Timer1.Interval = Val(GetInfo("Timer", "Interval"))
Form1.Timer1.Enabled = True

End Sub

Sub Pause(S)
  S = S + Timer
  While Timer < S
    DoEvents
  Wend
End Sub


--------------060306020200080708040202
Content-Type: text/plain;
 name="flightData.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="flightData.h"

#ifndef _FLIGHT_DATA_H
#define _FLIGHT_DATA_H
// SP3 
class FlightData
{
   public:
      enum LightBits
      {
         MasterCaution = 0x1,

         // Brow Lights
         TF        = 0x2,
         OBS       = 0x4,
         ALT       = 0x8,
         ENG_FIRE  = 0x20,
		 CONFIG	   = 0x40,
         HYD       = 0x80,
         OIL       = 0x100,
         DUAL      = 0x200,
         CAN       = 0x400,
         T_L_CFG   = 0x800,

         // AOA Indexers
         AOAAbove  = 0x1000,
         AOAOn     = 0x2000,
         AOABelow  = 0x4000,

         // Refuel/NWS
         RefuelRDY = 0x8000,
         RefuelAR  = 0x10000,
         RefuelDSC = 0x20000,

         // Caution Lights
         FltControlSys = 0x40000,
         LEFlaps       = 0x80000,
         EngineFault   = 0x100000,
         Overheat      = 0x200000,
         FuelLow       = 0x400000,
         Avionics      = 0x800000,
         RadarAlt      = 0x1000000,
         IFF           = 0x2000000,
         ECM           = 0x4000000,
         Hook          = 0x8000000,
         NWSFail       = 0x10000000,
         CabinPress    = 0x20000000
      };

	  enum LightBits2
      {
         // Threat Warning Prime
		 HandOff      =       0x1,
         Launch       =	      0x2,
         PriMode      =       0x4,
         Naval        =       0x8,
         Unk          =      0x10,
         TgtSep       =      0x20,

         // Aux Threat Warning
         AuxSrch      =    0x1000,
         AuxAct       =    0x2000,
         AuxLow       =    0x4000,
         AuxPwr       =    0x8000,

         // ECM
		 EcmPwr       =   0x10000,
         EcmFail      =   0x20000,

         // Caution Lights
         FwdFuelLow   =   0x40000,
         AftFuelLow   =   0x80000,

		 //Engine lights
		 EPUOn		  =	  0x100000,
		 JFSOn		  =	  0x200000,
		 SEC		  =	  0x400000,

		 OXY_LOW	  =   0x800000,
		 PROBEHEAT	  =   0x1000000,
		 SEAT_ARM	  =   0x2000000,
		 BUC		  =   0x4000000,
		 FUEL_OIL_HOT =   0x8000000,
		 ANTI_SKID	  =   0x10000000,
		 TFR_ENGAGED  =   0x20000000,
		 GEARHANDLE	  =	  0x40000000,
	  };

	  enum LightBits3
	  {
		  FlcsPmg		=	0x1,
		  MainGen		=	0x2,
		  StbyGen		=	0x4,
		  EpuGen		=	0x8,
		  EpuPmg		=	0x10,
		  ToFlcs		=	0x20,
		  FlcsRly		=	0x40,
		  BatFail		=	0x80,
		  Hydrazine		=	0x100,
		  Air			=	0x200,
		  Elec_Fault	=	0x400,
		  Lef_Fault		=	0x800,
	  };

	  enum HsiBits
	  {
		ToTrue        = 0x01,	// HSI_FLAG_TO_TRUE
	    IlsWarning    = 0x02,	// HSI_FLAG_ILS_WARN
	    CourseWarning = 0x04,	// HSI_FLAG_CRS_WARN
	    Init          = 0x08,	// HSI_FLAG_INIT
	    TotalFlags    = 0x10,	// HSI_FLAG_TOTAL_FLAGS ???
		ADI_OFF		  = 0x20,	// ADI OFF Flag
		ADI_AUX		  = 0x40,	// ADI AUX Flag
		ADI_GS		  = 0x80,	// ADI GS FLAG
		ADI_LOC		  = 0x100,	// ADI LOC FLAG
		HSI_OFF		  = 0x200,	// HSI OFF Flag
		BUP_ADI_OFF	  = 0x400,	// Backup ADI Off Flag
		VVI			  = 0x800,	// VVI OFF Flag
		AOA			  = 0x1000,	// AOA OFF Flag
		AVTR		  = 0x2000,	// AVTR Light
	  };



      // These are outputs from the sim
      float x;            // Ownship North (Ft)
      float y;            // Ownship East (Ft)
      float z;            // Ownship Down (Ft)
      float xDot;         // Ownship North Rate (ft/sec)
      float yDot;         // Ownship East Rate (ft/sec)
      float zDot;         // Ownship Down Rate (ft/sec)
      float alpha;        // Ownship AOA (Degrees)
      float beta;         // Ownship Beta (Degrees)
      float gamma;        // Ownship Gamma (Radians)
      float pitch;        // Ownship Pitch (Radians)
      float roll;         // Ownship Pitch (Radians)
      float yaw;          // Ownship Pitch (Radians)
      float mach;         // Ownship Mach number
      float kias;         // Ownship Indicated Airspeed (Knots)
      float vt;           // Ownship True Airspeed (Ft/Sec)
      float gs;           // Ownship Normal Gs
      float windOffset;   // Wind delta to FPM (Radians)
      float nozzlePos;    // Ownship engine nozzle percent open (0-100)
      float internalFuel; // Ownship internal fuel (Lbs)
      float externalFuel; // Ownship external fuel (Lbs)
      float fuelFlow;     // Ownship fuel flow (Lbs/Hour)
      float rpm;          // Ownship engine rpm (Percent 0-103)
      float ftit;         // Ownship Forward Turbine Inlet Temp (Degrees C)
      float gearPos;      // Ownship Gear position 0 = up, 1 = down;
      float speedBrake;   // Ownship speed brake position 0 = closed, 1 = 60 Degrees open
      float epuFuel;      // Ownship EPU fuel (Percent 0-100)
      float oilPressure;  // Ownship Oil Pressure (Percent 0-100)
      int   lightBits;    // Cockpit Indicator Lights, one bit per bulb. See enum

      // These are inputs. Use them carefully
      float headPitch;    // Head pitch offset from design eye (radians)
      float headRoll;     // Head roll offset from design eye (radians)
      float headYaw;      // Head yaw offset from design eye (radians)

      // new lights
	  int   lightBits2;         // Cockpit Indicator Lights, one bit per bulb. See enum
	  int   lightBits3;         // Cockpit Indicator Lights, one bit per bulb. See enum

	  // chaff/flare
      float ChaffCount;	        // Number of Chaff left
	  float FlareCount;         // Number of Flare left

	  // landing gear
	  float NoseGearPos;        // Position of the nose landinggear
	  float LeftGearPos;        // Position of the left landinggear
	  float RightGearPos;       // Position of the right landinggear

	  // ADI values
	  float AdiIlsHorPos;       // Position of horizontal ILS bar
	  float AdiIlsVerPos;       // Position of vertical ILS bar

	  // HSI states
	  int courseState;          // HSI_STA_CRS_STATE
	  int headingState;         // HSI_STA_HDG_STATE
	  int totalStates;          // HSI_STA_TOTAL_STATES ???

	  // HSI values
	  float	courseDeviation;	// HSI_VAL_CRS_DEVIATION
	  float	desiredCourse;		// HSI_VAL_DESIRED_CRS
	  float distanceToBeacon;   // HSI_VAL_DISTANCE_TO_BEACON
	  float	bearingToBeacon;	// HSI_VAL_BEARING_TO_BEACON
	  float currentHeading;		// HSI_VAL_CURRENT_HEADING
	  float	desiredHeading;		// HSI_VAL_DESIRED_HEADING
	  float deviationLimit;		// HSI_VAL_DEV_LIMIT
	  float halfDeviationLimit; // HSI_VAL_HALF_DEV_LIMIT
	  float localizerCourse;	// HSI_VAL_LOCALIZER_CRS
	  float airbaseX;			// HSI_VAL_AIRBASE_X
	  float airbaseY;			// HSI_VAL_AIRBASE_Y
	  float totalValues;		// HSI_VAL_TOTAL_VALUES  ???

	  float TrimPitch;	// Value of trim in pitch axis, -0.5 to +0.5
	  float TrimRoll;	// Value of trim in roll axis, -0.5 to +0.5
	  float TrimYaw;	// Value of trim in yaw axis, -0.5 to +0.5

	  // HSI flags
	  int hsiBits;              // HSI flags

	  //DED Lines
	  char DEDLines[5][26];	//25 usable chars
	  char Invert[5][26];	//25 usable chars

	  //PFL Lines
	  char PFLLines[5][26];	 //25 usable chars
	  char PFLInvert[5][26]; //25 usable chars

	  //TacanChannel
	  int UFCTChan, AUXTChan;

      // RWR
	  int           RwrObjectCount;
	  int           RWRsymbol[20];
	  float         bearing[20];
      unsigned long missileActivity[20];
	  unsigned long missileLaunch[20];
      unsigned long selected[20];
      float         lethality[20];

	  //fuel values
	  float fwd, aft, total;

      void SetLightBit (int newBit) {lightBits |= newBit;};
      void ClearLightBit (int newBit) {lightBits &= ~newBit;};
      int  IsSet (int newBit) {return ((lightBits & newBit) ? TRUE : FALSE);};

      void SetLightBit2 (int newBit) {lightBits2 |= newBit;};
      void ClearLightBit2 (int newBit) {lightBits2 &= ~newBit;};
      int  IsSet2 (int newBit) {return ((lightBits2 & newBit) ? TRUE : FALSE);};

	  void SetLightBit3 (int newBit) {lightBits3 |= newBit;};
      void ClearLightBit3 (int newBit) {lightBits3 &= ~newBit;};
      int  IsSet3 (int newBit) {return ((lightBits3 & newBit) ? TRUE : FALSE);};

      void SetHsiBit (int newBit) {hsiBits |= newBit;};
      void ClearHsiBit (int newBit) {hsiBits &= ~newBit;};
      int  IsSetHsi (int newBit) {return ((hsiBits & newBit) ? TRUE : FALSE);};

	  int VersionNum;	//Version of Memarea
};

extern FlightData cockpitFlightData;
#endif

--------------060306020200080708040202--