/// <summary>
        /// Request and/or write data packets.
        /// For what the data represents, see XPlane docs.
        /// If you do not want to change the data put -999
        /// </summary>
        /// <param name="index">Index of data packet, can be found in XPlane</param>
        /// <param name="data1"></param>
        /// <param name="data2"></param>
        /// <param name="data3"></param>
        /// <param name="data4"></param>
        /// <param name="data5"></param>
        /// <param name="data6"></param>
        /// <param name="data7"></param>
        /// <param name="data8"></param>
        public void ReadWriteDataPacket(byte index, float data1, float data2, float data3, float data4,
                                        float data5, float data6, float data7, float data8)
        {
            var packet = new XplaneDATAPacket(index, data1, data2, data3, data4, data5, data6, data7, data8);

            Send(packet);
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            // receive DataREF over port
            using (UDPReceiver receiver = new UDPReceiver(IPAddress.Any, 49004))
                using (XplaneUDPSender sender = new XplaneUDPSender(IPAddress.Parse("127.0.0.1"), 49000))
                {
                    // data package, should be enabled in xplane
                    XplaneDATAPacket throttleOff = new XplaneDATAPacket(25, 0, 0, 0, 0, 0, 0, 0, 0);
                    XplaneDATAPacket throttleOn  = new XplaneDATAPacket(25, 1, 0, 0, 0, 0, 0, 0, 0);

                    // data ref, does not need to be enabled in xplane to edit
                    XplaneDREFPacket batteryOn  = new XplaneDREFPacket(1, "sim/cockpit/electrical/battery_on");
                    XplaneDREFPacket batteryOff = new XplaneDREFPacket(0, "sim/cockpit/electrical/battery_on");

                    while (true)
                    {
                        //drefReceiver.Listen(true);  <-- blocks thread

                        if (Console.KeyAvailable)
                        {
                            var key = Console.ReadKey();
                            if (key.Key == ConsoleKey.O)
                            {
                                // these three statements do the same
                                sender.Send(batteryOff);
                                //sender.WriteDref(batteryOff);
                                //sender.WriteDref(0, "sim/cockpit/electrical/battery_on");

                                Console.WriteLine("Battery Off");
                            }
                            if (key.Key == ConsoleKey.P)
                            {
                                sender.Send(batteryOn);
                                Console.WriteLine("Battery On");
                            }
                            if (key.Key == ConsoleKey.K)
                            {
                                sender.Send(throttleOff);
                            }
                            if (key.Key == ConsoleKey.L)
                            {
                                sender.Send(throttleOn);
                            }

                            if (key.Key == ConsoleKey.Escape)
                            {
                                break;
                            }
                        }
                    }
                }

            Environment.Exit(0);
        }
 /// <summary>
 /// Request and/or write data packets.
 /// For what the data represents, see XPlane docs.
 /// If you do not want to change the data put -999
 /// </summary>
 public void ReadWriteDataPacket(XplaneDATAPacket packet)
 {
     Send(packet);
 }