public override void HandleMessage(Notification notification) { if (!String.IsNullOrEmpty(notification.PayloadType)) { switch (notification.PayloadType) { case "DeviceArchive": var archive = JsonConvert.DeserializeObject <DeviceArchive>(notification.Payload); DispatcherServices.Invoke(() => { DeviceMessages.Insert(0, archive); }); break; case "LagoVista.IoT.DeviceManagement.Core.Models.Device": DispatcherServices.Invoke(() => { Device = JsonConvert.DeserializeObject <Device>(notification.Payload); }); break; } Debug.WriteLine("----"); Debug.WriteLine(notification.PayloadType); Debug.WriteLine(notification.Payload); Debug.WriteLine("BYTES: " + notification.Payload.Length); Debug.WriteLine("----"); } else { Debug.WriteLine(notification.Text); } }
private async Task ReceiveDataFromAzure() { #if IOTHUB while (_azureIoTHubClient != null) { var message = await _azureIoTHubClient.ReceiveAsync(); if (message != null) { try { var msg = new Models.ReceivedMessage(message.GetBytes()); msg.MessageId = message.MessageId; msg.Topic = message.To; DispatcherServices.Invoke(() => ReceivedMessageList.Insert(0, msg)); // Received a new message, display it // We received the message, indicate IoTHub we treated it await _azureIoTHubClient.CompleteAsync(message); } catch { await _azureIoTHubClient.RejectAsync(message); } } } #else await Task.FromResult(default(object)); #endif }
private void GCodeFileManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Machine.GCodeFileManager.HasValidFile)) { DispatcherServices.Invoke(RefreshCommandExecuteStatus); } }
private void _machine_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Machine.Mode)) { DispatcherServices.Invoke(() => { OpenEagleBoardFileCommand.RaiseCanExecuteChanged(); CloseEagleBoardFileCommand.RaiseCanExecuteChanged(); OpenHeightMapCommand.RaiseCanExecuteChanged(); OpenGCodeCommand.RaiseCanExecuteChanged(); ClearGCodeCommand.RaiseCanExecuteChanged(); SetMetricUnitsCommand.RaiseCanExecuteChanged(); SetImperialUnitsCommand.RaiseCanExecuteChanged(); ShowBottomEtchingGCodeCommand.RaiseCanExecuteChanged(); ShowTopEtchingGCodeCommand.RaiseCanExecuteChanged(); ApplyHeightMapCommand.RaiseCanExecuteChanged(); }); } if (e.PropertyName == nameof(Machine.GCodeFileManager.HasValidFile)) { ArcToLineCommand.RaiseCanExecuteChanged(); ApplyHeightMapCommand.RaiseCanExecuteChanged(); } }
private void _mqttClient_CommandReceived(object sender, MqttMsgPublishEventArgs e) { var msg = new Models.ReceivedMessage(e.Message); msg.Topic = e.Topic; msg.MessageId = e.MessageId; DispatcherServices.Invoke(() => ReceivedMessageList.Insert(0, msg)); }
private void HeightMapManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Machine.HeightMapManager.HeightMap) || e.PropertyName == nameof(Machine.HeightMapManager.HeightMap.Status)) { DispatcherServices.Invoke(RefreshCommandExecuteStatus); } }
private void GCodeFileManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Machine.GCodeFileManager.HasValidFile)) { DispatcherServices.Invoke(() => { ApplyHeightMapCommand.RaiseCanExecuteChanged(); }); } }
static Data() { customerService = new CustomerServices(); dispatcherServices = new DispatcherServices(); driverServices = new DriverServices(); driveServices = new DriveServices(); commentServices = new CommentService(); drivers = driverServices.RetriveAllDrivers(); dispatchers = dispatcherServices.RetriveAllDispatchers(); }
private void _machine_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Machine.IsInitialized) || e.PropertyName == nameof(Machine.Mode) || e.PropertyName == nameof(Machine.Settings) || e.PropertyName == nameof(Machine.Status) || e.PropertyName == nameof(Machine.Connected) || e.PropertyName == nameof(Machine.Settings.CurrentSerialPort)) { DispatcherServices.Invoke(RefreshCommandExecuteStatus); } }
private void AddMessage(Client.Core.Models.Notification notification) { if (!String.IsNullOrEmpty(notification.Text)) { DispatcherServices.Invoke(() => { MessagesFromServer.Insert(0, notification); if (MessagesFromServer.Count > 100) { MessagesFromServer.RemoveAt(100); } }); } }
private void HeightMapManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Machine.HeightMapManager.HasHeightMap) || e.PropertyName == nameof(Machine.HeightMapManager.Status) || e.PropertyName == nameof(Machine.HeightMapManager.HeightMapDirty)) { DispatcherServices.Invoke(() => { ApplyHeightMapCommand.RaiseCanExecuteChanged(); SaveHeightMapCommand.RaiseCanExecuteChanged(); StartProbeHeightMapCommand.RaiseCanExecuteChanged(); ClearHeightMapCommand.RaiseCanExecuteChanged(); }); } }
/// <summary> /// Асинхронная загрузка сценария /// </summary> /// <param name="cancellation"></param> /// <param name="progress"></param> /// <returns></returns> private async Task LoadAsync(CancellationToken cancellation, IProgress <string> progress) { await await Task.Factory.StartNew(async() => { await DataHolder.Instance.ReleaseMedia(false, progress, cancellation); progress.Report("Загрузка данных"); Thread.Sleep(3000); if (DataHolder.Instance.LoadAllData(mFileName, progress, cancellation)) { Debug.Assert(Path.GetDirectoryName(mFileName) != null, "Path.GetDirectoryName(mFileName) != null"); } else { while (true) { if (cancellation.IsCancellationRequested) { break; } Thread.Sleep(100); } } if (cancellation.IsCancellationRequested) { await DataHolder.Instance.ClearAllData(); return(TaskExtension.Delay(1)); } DispatcherServices.BeginInvoke(() => { DynamicText = Constants.cChangeScenarioText; IndicatorLoad = Indicators.Warn.GetColor(); IndicatorCreate = Indicators.Warn.GetColor(); IndicatorSave = Indicators.Accept.GetColor(); ScenarioItem loadedScenario = Scenarios.FirstOrDefault(s => s.ScenarioInfo.Key.Equals(mFileName)); if (loadedScenario == null) { loadedScenario = new ScenarioItem(new KeyValuePair <string, string>(mFileName, DataHolder.Instance.ScenarioProperties.ScenarioName)); loadedScenario.Selecting += NewScenatioItemOnSelecting; Scenarios.Add(loadedScenario); } loadedScenario.SelecteItem(); }); return(TaskExtension.Delay(1)); }, cancellation).ConfigureAwait(false); }
private void PCBManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Machine.PCBManager.HasBoard) || e.PropertyName == nameof(Machine.PCBManager.HasProject) || e.PropertyName == nameof(Machine.PCBManager.HasTopEtching) || e.PropertyName == nameof(Machine.PCBManager.HasBottomEtching)) { DispatcherServices.Invoke(() => { ApplyHeightMapCommand.RaiseCanExecuteChanged(); ShowHoldDownGCodeCommand.RaiseCanExecuteChanged(); ShowDrillGCodeCommand.RaiseCanExecuteChanged(); ShowCutoutMillingGCodeCommand.RaiseCanExecuteChanged(); ShowTopEtchingGCodeCommand.RaiseCanExecuteChanged(); ShowBottomEtchingGCodeCommand.RaiseCanExecuteChanged(); }); } }
/// <summary> /// Асинхронная выгрузка сценария /// </summary> /// <param name="path">путь к выгрузки</param> /// <param name="cancellation"></param> /// <param name="progress"></param> /// <param name="rewrite">True-перезаписать старые данные</param> /// <returns></returns> private async Task UploadScenarioAsync(string path, CancellationToken cancellation, IProgress <string> progress, bool rewrite = true) { await Task.Factory.StartNew(async() => { progress.Report("Сохранение сценария"); Thread.SpinWait(1000); DataHolder.Instance.TargetDirectory = path; if (rewrite) { progress.Report("Очистка старых данных"); DataHolder.Instance.PrepareForRewriteScenario(); } if (!DataHolder.Instance.UpLoadData(path, progress, cancellation)) { // DataHolder.Instance.ScenarioProperties.Folder = Path.GetDirectoryName(mFileName); //else while (true) { if (cancellation.IsCancellationRequested) { break; } Thread.Sleep(100); } } if (cancellation.IsCancellationRequested) { await DataHolder.Instance.ClearAllData(); return(TaskExtension.Delay(1)); } DispatcherServices.BeginInvoke(() => { DynamicText = Constants.cChangeScenarioText; IndicatorLoad = Indicators.Warn.GetColor(); IndicatorCreate = Indicators.Warn.GetColor(); IndicatorSave = Indicators.Accept.GetColor(); }); return(TaskExtension.Delay(1)); }, cancellation).Unwrap().ConfigureAwait(false); }
private void RefreshTimerTick(object state) { DispatcherServices.Invoke(() => { RaisePropertyChanged(nameof(IsmBotConnected)); RaisePropertyChanged(nameof(IsNetworkConnected)); RaisePropertyChanged(nameof(IsCompassConnected)); RaisePropertyChanged(nameof(AreClientsConnected)); if (IsCompassConnected) { CompassMessage = $"Online: {_connectionManager.SensorManager.Compass.RawX.Value}x{_connectionManager.SensorManager.Compass.RawY.Value}"; } else { CompassMessage = "Compass Offline"; } if (ConnectionManager.Server != null) { ClientsMessage = $"{ConnectionManager.Server.Clients.Count} Clients Connected"; } else { ClientsMessage = "Not Connected"; } if (IsNetworkConnected && ConnectionManager.Server != null) { NetworkMessage = "IP Address: " + GetLocalIp(); } else { NetworkMessage = "Network Offline"; } }); }
private void EnableActions() { DispatcherServices.Invoke(() => { CanDeployHost = false; CanPauseApplication = false; CanReloadSolution = false; CanRemoveServer = false; CanRestartServer = false; CanRestartContainer = false; CanStartApplication = false; CanStopApplication = false; CanUpdateRuntime = false; ShowIsBusy = false; switch (Host.Status.Value) { case HostStatus.Offline: CanDeployHost = true; break; case HostStatus.FailedDeployment: case HostStatus.HostHealthCheckFailed: CanRestartServer = true; CanRemoveServer = true; CanUpdateRuntime = true; break; case HostStatus.Running: CanRestartServer = true; CanRemoveServer = true; CanUpdateRuntime = true; switch (Instance.Status.Value) { case DeploymentInstanceStates.FatalError: case DeploymentInstanceStates.FailedToInitialize: CanRestartContainer = true; CanReloadSolution = true; break; case DeploymentInstanceStates.Offline: CanRestartContainer = true; CanReloadSolution = true; CanStartApplication = true; CanReloadSolution = true; break; case DeploymentInstanceStates.Paused: CanRestartContainer = true; CanReloadSolution = true; CanStopApplication = true; CanStartApplication = true; break; case DeploymentInstanceStates.Stopped: CanRestartContainer = true; CanReloadSolution = true; CanStartApplication = true; break; case DeploymentInstanceStates.Running: CanRestartContainer = true; CanReloadSolution = true; CanPauseApplication = true; CanStopApplication = true; break; default: ShowIsBusy = true; break; } break; default: ShowIsBusy = true; break; } }); }