private Task ArmedAndSignedIn(Models.FlightData flightData)
        {
            _messagesService.AddMessageAsync("Armed");

            //return Task.FromResult(0);
            return(null);
        }
        private async Task SendTelemetry(Models.FlightData flightData)
        {
            if (_settings.CurrentFlightId == null)
            {
                await _messagesService.AddMessageAsync(
                    new Message("Not sending telemetry as no current flight ID is set."));

                return;
            }
            try
            {
                var lat             = (float)flightData.CurrentPosition.Latitude;
                var lon             = (float)flightData.CurrentPosition.Longitude;
                var alt             = (ushort)flightData.CurrentPosition.Altitude;
                var courseInRadians = flightData.CurrentPosition.Course / 180 * Math.PI;
                var xVel            = (float)(Math.Sin(courseInRadians) * flightData.CurrentPosition.Speed);
                var yVel            = (float)(Math.Cos(courseInRadians) * flightData.CurrentPosition.Speed);
                var zVel            = flightData.CurrentPosition.VerticalSpeed;


                // Create dataStructure
                var udpMessage = new UavPositionReport
                {
                    GpsTimestamp      = DateTime.UtcNow,
                    Pos               = new Position(lat, lon, 0),
                    Alt               = new Altitude(alt, AltitudeDatum.Agl, 1),
                    Velocity          = new Velocity(xVel, yVel, zVel, 1),
                    IsAirborne        = AirborneStatus.Airborne,
                    SatellitesVisible = 3
                };

                var telemetryId = Guid.Parse(_settings.CurrentTelemetryId);
                var telemetry   = new TelemetryEvent <UavPositionReport>(telemetryId, udpMessage)
                {
                    SequenceNumber = _sequenceNumber
                };

                var message = string.Format($"Sending Telemetry {flightData.CurrentPosition.Latitude}, {flightData.CurrentPosition.Longitude}, {flightData.CurrentPosition.Altitude}");
                await _messagesService.AddMessageAsync(new Message(message));

                _client.SendTelemetry(telemetry, _settings.TelemetryHostName, _settings.TelemetryPortNumber, _settings.EncryptionKey);
                _sequenceNumber += 1;
            }
            catch (Exception)
            {
                await _messagesService.AddMessageAsync(new Message("ERROR: Sending telemetry failed."));
            }
        }
Esempio n. 3
0
        private async Task SubmitFlightReport(Models.FlightData flightData)
        {
            if (!IsSignedIn)
            {
                return;
            }

            await _messagesService.AddMessageAsync(new Message($"ARMED: {flightData.CurrentPosition.Latitude},{flightData.CurrentPosition.Longitude}"));

            if (!_settings.FlightReportEnable || _settings.CurrentFlightReportId != null)
            {
                return;
            }

            try
            {
                var centerPoint = new PointLatLng(flightData.CurrentPosition.Latitude,
                                                  flightData.CurrentPosition.Longitude);
                var bufferedBoundingRadius = 500;
                var flightPlan             = _missionPlanner.GetFlightPlan();
                if (flightPlan != null)
                {
                    centerPoint.Lat        = flightPlan.CenterLatitude;
                    centerPoint.Lng        = flightPlan.CenterLongitude;
                    bufferedBoundingRadius = Math.Max(flightPlan.BoundingRadius + 50, bufferedBoundingRadius);
                }

                _settings.CurrentFlightReportId = await _client.CreateFlightReport(
                    _settings.FlightReportName,
                    _settings.FlightReportCommercial,
                    DateTime.Now,
                    DateTime.Now.Add(_settings.FlightReportTimeSpan),
                    centerPoint,
                    bufferedBoundingRadius);

                await _messagesService.AddMessageAsync(new Message($"Flight plan {_settings.CurrentFlightReportId} created"));
                await UpdateMapData(_missionPlanner.FlightDataMap);
            }
            catch (Exception ex)
            {
                await _messagesService.AddMessageAsync(new Message($"Creating flight plan failed. {ex}"));
            }
        }
Esempio n. 4
0
        private async Task CompleteFlightReport(Models.FlightData flightData)
        {
            await _messagesService.AddMessageAsync(new Message($"DISARMED: {flightData.CurrentPosition.Latitude},{flightData.CurrentPosition.Longitude}"));

            if (_settings.CurrentFlightReportId == null)
            {
                return;
            }
            try
            {
                await _client.CompleteFlightReport(_settings.CurrentFlightReportId);

                _settings.CurrentFlightReportId = null;
                await _messagesService.AddMessageAsync(new Message($"Flight plan {_settings.CurrentFlightReportId} marked as complete"));
                await UpdateMapData(_missionPlanner.FlightDataMap);
            }
            catch (Exception ex)
            {
                await _messagesService.AddMessageAsync(new Message($"Marking flight plan {_settings.CurrentFlightReportId} as complete failed. {ex}"));
            }
        }
 private Task FlightDisarmed(Models.FlightData flightData)
 {
     _sequenceNumber = 0;
     return(Task.CompletedTask);
 }
 private void DisarmedAndSignedIn(Models.FlightData flightData)
 {
     _messagesService.AddMessageAsync("Disarmed.");
 }