Пример #1
0
        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();
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
     }
 }
Пример #5
0
        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);
     }
 }
Пример #7
0
 private void GCodeFileManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(Machine.GCodeFileManager.HasValidFile))
     {
         DispatcherServices.Invoke(() =>
         {
             ApplyHeightMapCommand.RaiseCanExecuteChanged();
         });
     }
 }
 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);
             }
         });
     }
 }
Пример #10
0
 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();
         });
     }
 }
Пример #11
0
 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();
         });
     }
 }
Пример #12
0
        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;
                }
            });
        }