Example #1
0
 private Task TestBulb(LampStateEnum currentState)
 {
     return(Task.Run(() =>
     {
         if (CurrentSensor.GetState().Result != CurrentSensorStateEnum.Flowing)
         {
             var badBulb = Bulbs.FirstOrDefault(b => b.GetState().Result == BulbStateEnum.On);
             badBulb?.MarkInOp(true);
         }
         else
         {
             var badBulb = Bulbs.FirstOrDefault(b => b.GetState().Result == BulbStateEnum.InOperable);
             if (badBulb == null)
             {
                 return;
             }
             if (badBulb.BulbType == BulbTypeEnum.Green && currentState == LampStateEnum.Go ||
                 badBulb.BulbType == BulbTypeEnum.Yellow && currentState == LampStateEnum.Caution ||
                 badBulb.BulbType == BulbTypeEnum.Red && currentState == LampStateEnum.Stop)
             {
                 badBulb.MarkInOp(false);
             }
         }
     }));
 }
        public CurrentSensorViewModel(CurrentSensor sensor)
        {
            this.Sensor = sensor;

            this.Name         = this.Sensor.SensorInformation.ObserveProperty(self => self.Name).ToReadOnlyReactiveProperty();
            this.IsConnected  = this.ObserveRecentDeviceProperty(self => self.IsConnected).ToReadOnlyReactiveProperty().AddTo(this.disposables);
            this.Current      = this.ObserveRecentDeviceProperty(self => self.Current).ToReadOnlyReactiveProperty().AddTo(this.disposables);
            this.BatteryLevel = this.ObserveRecentDeviceProperty(self => self.BatteryLevel).ToReadOnlyReactiveProperty().AddTo(this.disposables);
        }
Example #3
0
 private void ButtonSensorZeroFieldsOnClickAsync()
 {
     if (CurrentSensor != null)
     {
         Task.Run(() => CurrentSensor.ZeroFields());
     }
     else
     {
         DebugLog.Enqueue("Error: sensor not selected");
     }
 }
Example #4
0
        private void TextBoxCommandStringOnKeyDown(object parameter)
        {
            KeyEventArgs e = (KeyEventArgs)parameter;

            if (CurrentSensor != null && PediatricSensorData.CanSendCommands)
            {
                switch (e.Key)
                {
                case Key.Add:
                    CurrentSensor.SendCommand("+");
                    TextBoxCommandStringText = String.Empty;
                    break;

                case Key.Subtract:
                    CurrentSensor.SendCommand("-");
                    TextBoxCommandStringText = String.Empty;
                    break;

                case Key.OemPlus:
                    CurrentSensor.SendCommand("+");
                    TextBoxCommandStringText = String.Empty;
                    break;

                case Key.OemMinus:
                    CurrentSensor.SendCommand("-");
                    TextBoxCommandStringText = String.Empty;
                    break;

                case Key.Enter:
                    CurrentSensor.SendCommand(TextBoxCommandStringText);
                    TextBoxCommandStringText = String.Empty;
                    RaisePropertyChanged("CommandHistory");
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (e.Key == Key.Enter && CurrentSensor == null)
                {
                    DebugLog.Enqueue($"Can't send commands - sensor sensor not selected");
                    TextBoxCommandStringText = String.Empty;
                }
                if (e.Key == Key.Enter && !PediatricSensorData.CanSendCommands)
                {
                    DebugLog.Enqueue($"Can't send commands - other operations are running");
                    TextBoxCommandStringText = String.Empty;
                }
            }
        }