Esempio n. 1
0
        public void FixedUpdate()
        {
            var vessel          = FlightGlobals.ActiveVessel;
            var altitude        = vessel.altitude;
            var velocity        = vessel.speed;
            var accel           = vessel.acceleration.magnitude;
            var latitude        = vessel.latitude;
            var longitude       = vessel.longitude;
            var dynamicPressure = vessel.dynamicPressurekPa;
            var staticPressure  = vessel.staticPressurekPa;


            TelemtryMessage message = new TelemtryMessage();

            message.Altitude        = altitude;
            message.Velocity        = velocity;
            message.Acceleration    = accel;
            message.Latitude        = latitude;
            message.Longitude       = longitude;
            message.DynamicPressure = dynamicPressure;
            message.StaticPressure  = staticPressure;


            try
            {
                var delay = message.Altitude / (3 * Mathf.Pow(10, 8));
                message.Delay = delay;
                if ((DateTime.Now - startTime).Seconds > delay)
                {
                    SendData(message);
                    startTime = DateTime.Now;
                }
            }
            catch (Exception ex)
            {
                Debug.Log("KSP Telemetry Error: " + ex.Message + " Stack: " + ex.StackTrace);
            }
        }
Esempio n. 2
0
        private void SendData(TelemtryMessage message)
        {
            var messageStr = $"alt:{message.Altitude};vel:{message.Velocity};acc:{message.Acceleration};lat:{message.Latitude};lng:{message.Longitude};dpr:{message.DynamicPressure};spr:{message.StaticPressure};";

            _networkClient.Send(messageStr);
        }