private void _transport_OnMessageReceived(object sender, UasMessage arg) { switch (arg.MessageId) { case UasMessages.Statustext: var stat = arg as UasStatustext; var message = new String(stat.Text); if (message.ToLower().Contains("calibration successful") || message.ToLower().Contains("calibration failed")) { IsDone = true; IsActive = false; DoneCommand.RaiseCanExecuteChanged(); UserMessage = message; } break; case UasMessages.CommandLong: var cmd = arg as UasCommandLong; if (cmd.Command == (ushort)MavCmd.AccelcalVehiclePos) { var pos = (AccelcalVehiclePos)cmd.Param1; UserMessage = "Please place vehicle " + pos.ToString(); } break; } }
void onDoneButtonClicked(object sender, EventArgs e) { if (DoneCommand != null && DoneCommand.CanExecute(null)) { DoneCommand.Execute(null); } }
public void Done() { _connectedUasManager.Active.Transport.SendMessage(UasCommands.PreflightCalibration(_connectedUasManager.Active.Uas.SystemId, _connectedUasManager.Active.Uas.ComponentId, 0, 0, 0, 0, 2, 0, 0)); BeginCommand.RaiseCanExecuteChanged(); CancelCommand.RaiseCanExecuteChanged(); DoneCommand.RaiseCanExecuteChanged(); NextCommand.RaiseCanExecuteChanged(); }
private async void RefreshSites() { if (IsBusy || !IsActive) { return; } IsBusy = true; if (firstLocation == null) { firstLocation = await _siteService.GetLocation(); if (firstLocation != null) { VisibleRegion = MapSpan.FromCenterAndRadius(new Position(firstLocation.Latitude, firstLocation.Longitude), VisibleRegion.Radius); IsBusy = false; return; } } try { var distanceRadians = DegreesToRadians(Math.Max(VisibleRegion.LatitudeDegrees, VisibleRegion.LongitudeDegrees) / 2); var sites = await _siteService.GetNearBySites(MapCenter.Latitude, MapCenter.Longitude, distanceRadians); Sites = new ObservableCollection <Site>(sites); var pins = new List <ILocationViewModel>(); foreach (var site in sites) { var localSite = site; pins.Add(new LocationViewModel { Key = site.SiteId.ToString(), Title = site.SiteName, Latitude = site.Latitude, Longitude = site.Longitude, Description = string.Format("{0}", site.IsPublic.HasValue ? site.IsPublic.Value ? "Allmän" : "Privat" : string.Empty), Command = new Command(() => DoneCommand.Execute(localSite)) }); } //UpdatePins(pins); Pins = new ObservableCollection <ILocationViewModel>(pins); } finally { IsBusy = false; } }
public void Run_ShouldSetTaskStatusToDone_WhenAValidIdIsPassed() { var command = new DoneCommand(Id: 1); var currentTask = new TaskItem(command.Id, "DESC", PriorityEnum.High, TaskStatus.NotStarted); _taskRepository.Setup(_ => _.GetTaskById(command.Id)).Returns(currentTask); _taskRepository.Setup(_ => _.UpdateTask(It.IsAny <TaskItem>())).Callback <TaskItem>(task => task.TaskStatus.Should().Be(TaskStatus.Done) ); _subject.Run(command); _taskRepository.Verify(_ => _.UpdateTask(It.IsAny <TaskItem>()), Times.Once); }
private async Task AfterMediaRetrieved(bool isShortCut) { Source = ImageSource.FromStream(() => { var stream = MediaFile.GetStreamWithImageRotatedForExternalStorage(); return(stream); }); DoneCommand.ChangeCanExecute(); //if (isShortCut) //{ // DoneCommand.Execute(null); //} await Task.CompletedTask; }
public void Execute(DoneCommand command) { CommandExecutor.SharedInstance.brain.Arm.Done(CommandExecutor.SharedInstance.RegisterId.Value, command.RetrunData); LogHandler?.Invoke($"DoneCommand({command.RetrunData}) is executed!"); lock (CommandExecutor.SharedInstance) { CommandStore.SharedInstance.CurrentCommand = null; CommandExecutor.SharedInstance.IsWaitingResponse = false; } new Thread(() => { LogHandler?.Invoke($"Will sleep 500ms for safty"); Thread.Sleep(500); CommandExecutor.SharedInstance.Execute(); }).Start(); }
public void Next() { if (IsActive) { var ack = new UasCommandAck() { TargetComponent = _connectedUasManager.Active.Uas.ComponentId, TargetSystem = _connectedUasManager.Active.Uas.SystemId, Command = 1, Result = 1, }; _connectedUasManager.Active.Transport.SendMessage(ack); } _connectedUasManager.Active.Transport.SendMessage(UasCommands.PreflightCalibration(_connectedUasManager.Active.Uas.SystemId, _connectedUasManager.Active.Uas.ComponentId, 0, 0, 0, 0, 1, 0, 0)); BeginCommand.RaiseCanExecuteChanged(); CancelCommand.RaiseCanExecuteChanged(); DoneCommand.RaiseCanExecuteChanged(); NextCommand.RaiseCanExecuteChanged(); }
//(CDLTLL) RefreshMap() with real data loading from services/mock is called only if VisibleRegion or Map-Zoom has changed private async void ReloadMapInfo() { if (IsBusy) { return; } IsBusy = true; if (_firstLocation == null) { _firstLocation = await GetLocation(); if (_firstLocation != null) { VisibleRegion = MapSpan.FromCenterAndRadius(new Position(_firstLocation.Latitude, _firstLocation.Longitude), VisibleRegion.Radius); IsBusy = false; return; } } try { var distanceRadians = DegreesToRadians(Math.Max(VisibleRegion.LatitudeDegrees, VisibleRegion.LongitudeDegrees) / 2); var center = VisibleRegion.Center; var halfheightDegrees = VisibleRegion.LatitudeDegrees / 2; var halfwidthDegrees = VisibleRegion.LongitudeDegrees / 2; var topLatitude = center.Latitude + halfheightDegrees; var leftLongitude = center.Longitude - halfwidthDegrees; var bottomLatitude = center.Latitude - halfheightDegrees; var rightLongitude = center.Longitude + halfwidthDegrees; // Adjust for Internation Date Line (+/- 180 degrees longitude) if (leftLongitude < -180) { leftLongitude = 180 + (180 + leftLongitude); } if (rightLongitude > 180) { rightLongitude = (rightLongitude - 180) - 180; } // (CDLTLL) Query and obtain data from a real service or from the mock service depending on the injected implementation var vehiclesInCurrentMapArea = await _vehiclesService.GetVehiclesInArea(this.UrlPrefix, CurrentTenantId, topLatitude, leftLongitude, bottomLatitude, rightLongitude); //(CDLTLL - Check this, not being used) Vehicles = new ObservableCollection <Vehicle>(vehiclesInCurrentMapArea); var pinsList = new List <ILocationViewModel>(); foreach (Vehicle vehicle in vehiclesInCurrentMapArea) { Vehicle localVehicle = vehicle; pinsList.Add(new LocationViewModel { Key = vehicle.Id.ToString(), Title = vehicle.Make + " " + vehicle.Model, Latitude = vehicle.Latitude, Longitude = vehicle.Longitude, Description = "LicensePlate: " + vehicle.LicensePlate, Command = new Command(() => DoneCommand.Execute(localVehicle)) }); } //UpdatePins(pins); if (Pins != null) { Pins.Clear(); } Pins = new ObservableCollection <ILocationViewModel>(pinsList); } finally { IsBusy = false; } }