//-----------------------------------------------------------------------------
// ThirdPartyDLL.h
//-----------------------------------------------------------------------------
#ifndef _ThirdPartyDLL_h_
#define _ThirdPartyDLL_h_

#define AEROSIMRC_MAX_CHANNELS 39

//-----------------------------------------------------------------------------
// Use the following constants as indexes for channel values
//
// The simulator uses the channel numbers for Transmitter Mode 2
// For Transmitters in different modes, the first 4 channels are mapped in the Channel Configuration Menu, to the actual stick functions
//-----------------------------------------------------------------------------
#define CH_AILERON              0
#define CH_ELEVATOR             1
#define CH_THROTTLE             2
#define CH_RUDDER               3
#define CH_5                    4
#define CH_6                    5
#define CH_7                    6

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#pragma pack (push, r1, 1)

//-----------------------------------------------------------------------------
// Simulation data exported from AeroSIM RC to DLL
//-----------------------------------------------------------------------------
struct TDataFromAeroSimRC
{
  int   nStructSize;                                         // size in bytes of TDataFromAeroSimRC

  // Simulation Data
  float fIntegrationTimeStep;                                // seconds (time between calls to AeroSIMRC_ThirdParty_Run)

  // Model data
  float fPosX;     float fPosY;     float fPosZ;             // m    (X=Right, Y=Front, Z=Up)
  float fVelX;     float fVelY;     float fVelZ;             // m/s
  float fAngVelX;  float fAngVelY;  float fAngVelZ;          // rad/s

  float fHeightAboveTerrain;                                 // m

  float fHeading;                                            // rad
  float fPitch;                                              // rad
  float fRoll;                                               // rad

  float afChannelValue_TX[AEROSIMRC_MAX_CHANNELS];                               // Channel positions at TX sticks (i.e. raw stick positions)
  float afChannelValue_RX[AEROSIMRC_MAX_CHANNELS];                               // Channel positions at RX (i.e. after TX mixes)
};

//-----------------------------------------------------------------------------
// Data that is sent from DLL to AeroSIMRC to act on the model
//-----------------------------------------------------------------------------
struct TDataToAeroSimRC
{
  int         nStructSize;                        // size in bytes of TDataToAeroSimRC

  const char *pucOnScreenDebugInfoText;           // debug string to be displayed in AeroSIM RC
  bool        bForceShowInfoText;                 // if true, the info will be displayed all the time
                                                  // if false, the info will be displayed after typing DESARROLLO during the simulation and then ALT+CTRL+L

  bool        abOverrideChannel_TX[AEROSIMRC_MAX_CHANNELS];  // true to override the value of this channel
  float       afNewChannelValue_TX[AEROSIMRC_MAX_CHANNELS];  // new value for TX sticks

  bool        abOverrideChannel_RX[AEROSIMRC_MAX_CHANNELS];  // true to override the value of this channel
  float       afNewChannelValue_RX[AEROSIMRC_MAX_CHANNELS];  // new value ar RX channels
};

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#pragma pack (pop, r1)

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#define AeroSIMRC_DLL_EXPORT  extern "C" __declspec(dllexport)

AeroSIMRC_DLL_EXPORT void  AeroSIMRC_ThirdParty_Run(const TDataFromAeroSimRC  *pTDataFromAeroSimRC,
                                                          TDataToAeroSimRC    *ptDataToAeroSimRC);


#endif
