static void Main(string[] args)
        {
            FSUIPCConnection.Open();

            Offset <long> playerLatitude = new Offset <long>(0x0560);

            Offset <long> playerLongitude = new Offset <long>(0x0568);

            Offset <int> autoThrottle = new Offset <int>(0x0810);

            Offset <int> flightDirector = new Offset <int>(0x2EE0);

            while (true)
            {
                FSUIPCConnection.Process();
                FsLongitude lon = new FsLongitude(playerLongitude.Value);
                FsLatitude  lat = new FsLatitude(playerLatitude.Value);

                var atSwitch = autoThrottle.Value;

                var fdSwitch = flightDirector.Value;

                Thread.Sleep(5000);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Actually broadcasts the data
        /// </summary>
        private void SendData(object sender, EventArgs e)
        {
            Log("Getting data from FSX"); // Log

            // Gets the data from FS
            FsLongitude lon = new FsLongitude(playerLongitude.Value);
            FsLatitude  lat = new FsLatitude(playerLatitude.Value);

            FSUIPCConnection.Process();               // Process the request to FSUIPC
            FSUIPCConnection.Process("AircraftInfo"); // For aicraft type

            // Checks if we have data
            if (lat.DecimalDegrees != 0 || lon.DecimalDegrees != 0)
            {
                // This will help us force the period as our decimal separator
                NumberFormatInfo nfi = new NumberFormatInfo();
                nfi.NumberDecimalSeparator = ".";
                nfi.NumberGroupSeparator   = ",";

                // Let's fill our player data object
                PlayerData playerData = new PlayerData();
                playerData.id     = "Whatever"; // Set your own ID here v
                playerData.lon    = lon.DecimalDegrees.ToString(nfi);
                playerData.lat    = lat.DecimalDegrees.ToString(nfi);
                playerData.ias    = (int)((double)airspeed.Value / 128d);                                   // Aircraft speed (KIAS)
                playerData.hdg    = (int)((double)(playerHeadingTrue.Value - magVar.Value) * 8.3819E-008d); // Heading
                playerData.alt    = (int)(playerAltitude.Value * 3.28084 / (65536d * 65536d));              // Altitude (feet)
                playerData.type   = aircraftType.Value.ToString();                                          // // our icon will depend on the engine type. For simplicity sake, we're assuming helicopter are always type 3
                playerData.icon   = (int)engineType.Value == 3 ? "heli" : "fixed";                          // Engine type. Helicopters are usually type 3 but there are some exceptions (like the default Robinson)
                playerData.pitch  = (int)(playerPitch.Value * 8.3819E-008d);
                playerData.bank   = (int)(playerBank.Value * 8.3819E-008d);
                playerData.altMb  = (int)(playerAltimeterPressure.Value * 16);
                playerData.vertAs = (int)(playerVertSpeed.Value * 60 * 3.28084 / 256);

                // And serialize it
                string data = Newtonsoft.Json.JsonConvert.SerializeObject(playerData);

                Log(string.Format("Sending data to ORTC: {0}", data)); // Log
                ortcClient.Send(txtORTCChannel.Text, data);            // Sends the data to ORTC
            }
        }