Пример #1
0
        /// <summary>
        /// Request X-Plane to close, a notification message will appear
        /// </summary>
        public void QuitXPlane()
        {
            var dg = new XPDatagram();

            dg.Add("QUIT");

            client.Send(dg.Get(), dg.Len);
        }
Пример #2
0
        public void SendCommand(XPlaneCommand command)
        {
            var dg = new XPDatagram();

            dg.Add("CMND");
            dg.Add(command.Command);

            client.Send(dg.Get(), dg.Len);
        }
Пример #3
0
        /// <summary>
        /// Informs X-Plane to change the value of the DataRef
        /// </summary>
        /// <param name="dataref">DataRef that will be changed</param>
        /// <param name="value">New value of the DataRef</param>
        public void SetDataRefValue(string dataref, string value)
        {
            var dg = new XPDatagram(509);

            dg.Add("DREF");
            dg.Add(value);
            dg.Add(dataref);
            client.Send(dg.Bytes, dg.Bytes.Length);
        }
Пример #4
0
        /// <summary>
        /// Inform X-Plane that a system is back to normal functioning
        /// </summary>
        /// <param name="system">Integer value representing the system to recover</param>
        public void Recover(int system)
        {
            var dg = new XPDatagram();

            dg.Add("RECO");

            dg.Add(system.ToString(EnCulture));

            client.Send(dg.Get(), dg.Len);
        }
Пример #5
0
        /// <summary>
        /// Inform X-Plane that a system is failed
        /// </summary>
        /// <param name="system">Integer value representing the system to fail</param>
        public void Fail(int system)
        {
            var dg = new XPDatagram();

            dg.Add("FAIL");

            dg.Add(system.ToString(EnCulture));

            client.Send(dg.Get(), dg.Len);
        }
Пример #6
0
        /// <summary>
        /// Informs X-Plane to change the value of the DataRef
        /// </summary>
        /// <param name="dataref">DataRef that will be changed</param>
        /// <param name="value">New value of the DataRef</param>
        public void SetDataRefValue(string dataref, string value)
        {
            var dg = new XPDatagram();

            dg.Add("DREF");
            dg.Add(value);
            dg.Add(dataref);
            dg.FillTo(509);

            client.Send(dg.Get(), dg.Len);
        }
Пример #7
0
        /// <summary>
        /// Sends a command
        /// </summary>
        /// <param name="command">Command to send</param>
        public void SendCommand(XPlaneCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var dg = new XPDatagram("CMND", command.Command);

            client.Send(dg.Bytes, dg.Bytes.Length);
        }
Пример #8
0
        /// <summary>
        /// Sends a command
        /// </summary>
        /// <param name="command">Command to send</param>
        public void SendCommand(XPlaneCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var dg = new XPDatagram();

            dg.Add("CMND");
            dg.Add(command.Command);

            client.Send(dg.Get(), dg.Len);
        }
Пример #9
0
        private void RequestDataRef(DataRefElement element)
        {
            if (client != null)
            {
                var dg = new XPDatagram();
                dg.Add("RREF");
                dg.Add(element.Frequency);
                dg.Add(element.Id);
                dg.Add(element.DataRef);
                dg.FillTo(413);

                client.Send(dg.Get(), dg.Len);

                OnLog?.Invoke($"Requested {element.DataRef}@{element.Frequency}Hz with Id:{element.Id}");
            }
        }
Пример #10
0
        private void RequestDataRef(DataRefElement element)
        {
            if (client == null)
            {
                return;
            }
            var dg = new XPDatagram(413);

            dg.Add("RREF");
            dg.Add(element.Frequency);
            dg.Add(element.Id);
            dg.Add(element.DataRef);
            client.Send(dg.Bytes, dg.Bytes.Length);

            OnLog?.Invoke($"Requested {element.DataRef}@{element.Frequency}Hz with Id:{element.Id}");
        }
Пример #11
0
        public void Unsubscribe(string dataref)
        {
            var dr = DataRefs.SingleOrDefault(d => d.DataRef == dataref);

            if (dr != null)
            {
                var dg = new XPDatagram();
                dg.Add("RREF");
                dg.Add(dr.Id);
                dg.Add(0);
                dg.Add(dataref);
                dg.FillTo(413);

                client.Send(dg.Get(), dg.Len);

                OnLog?.Invoke($"Unsubscribed from {dataref}");
            }
        }
Пример #12
0
        /// <summary>
        /// Informs X-Plane to stop sending this DataRef
        /// </summary>
        /// <param name="dataref">DataRef to unsubscribe from</param>
        public void Unsubscribe(DataRefElement dataref)
        {
            if (!DataRefs.ContainsKey(dataref.Id))
            {
                return;
            }
            var dr = DataRefs[dataref.Id];
            var dg = new XPDatagram(413);

            dg.Add("RREF");
            dg.Add(dr.Id);
            dg.Add(0);
            dg.Add(dataref.DataRef);
            client.Send(dg.Bytes, dg.Bytes.Length);
            DataRefs.Remove(dr.Id);

            OnLog?.Invoke($"Unsubscribed from {dataref.DataRef}");
        }
Пример #13
0
        /// <summary>
        /// Informs X-Plane to stop sending this DataRef
        /// </summary>
        /// <param name="dataref">DataRef to unsubscribe to</param>
        public void Unsubscribe(string dataref)
        {
            var dr_list = DataRefs.Where(d => d.DataRef == dataref).ToArray();

            foreach (var dr in dr_list)
            {
                var dg = new XPDatagram();
                dg.Add("RREF");
                dg.Add(dr.Id);
                dg.Add(0);
                dg.Add(dataref);
                dg.FillTo(413);

                client.Send(dg.Get(), dg.Len);
                DataRefs.Remove(dr);

                OnLog?.Invoke($"Unsubscribed from {dataref}");
            }
        }
Пример #14
0
        /// <summary>
        /// Inform X-Plane that a system is back to normal functioning
        /// </summary>
        /// <param name="system">Integer value representing the system to recover</param>
        public void Recover(int system)
        {
            var dg = new XPDatagram("RECO", system.ToString(EnCulture));

            client.Send(dg.Bytes, dg.Bytes.Length);
        }
Пример #15
0
        /// <summary>
        /// Inform X-Plane that a system is failed
        /// </summary>
        /// <param name="system">Integer value representing the system to fail</param>
        public void Fail(int system)
        {
            var dg = new XPDatagram("FAIL", system.ToString(EnCulture));

            client.Send(dg.Bytes, dg.Bytes.Length);
        }
Пример #16
0
        /// <summary>
        /// Request X-Plane to close, a notification message will appear
        /// </summary>
        public void QuitXPlane()
        {
            var dg = new XPDatagram("QUIT");

            client.Send(dg.Bytes, dg.Bytes.Length);
        }