Exemplo n.º 1
0
        private void UpdateProperties(FanControlInfo info)
        {
            FanStatus status = null;

            if ((info.FanStatus == null) || (info.FanStatus.Length <= fanIndex))
            {
                status = new FanStatus();
            }
            else
            {
                status = info.FanStatus[fanIndex];
            }

            Set(ref currentFanSpeed, status.CurrentFanSpeed, nameof(CurrentFanSpeed));
            Set(ref targetFanSpeed, status.TargetFanSpeed, nameof(TargetFanSpeed));
            Set(ref fanDisplayName, status.FanDisplayName, nameof(FanDisplayName));
            Set(ref fanSpeedSteps, status.FanSpeedSteps, nameof(FanSpeedSteps));
            Set(ref isAutoFanControlEnabled, status.AutoControlEnabled, nameof(IsAutoFanControlEnabled));
            Set(ref isCriticalModeEnabled, status.CriticalModeEnabled, nameof(IsCriticalModeEnabled));

            if (status.AutoControlEnabled)
            {
                // set the current speed level to (highest possible value) + 1 to indicate autmatic control
                Set(ref currentFanSpeedLevel, status.FanSpeedSteps + 1, nameof(CurrentFanSpeedLevel));
            }
            else
            {
                int level = (int)Math.Round((status.TargetFanSpeed / 100.0) * status.FanSpeedSteps);
                Set(ref currentFanSpeedLevel, level, nameof(CurrentFanSpeedLevel));
            }
        }
 public FanSwitchCommand(FanStatus status, bool toggle = false)
 {
   if (toggle)
   {
     Status = status == FanStatus.Off ? FanStatus.On: FanStatus.Off;
   }
   else
   {
     Status = status;
   }
 }
        public override string dumpToString()
        {
            string toRet = "";

            toRet += "Fan:    " + FanStatus.ToString();
            toRet += "\nLamp:   " + LampStatus.ToString();
            toRet += "\nTemp:   " + TempStatus.ToString();
            toRet += "\nCover:  " + CoverStatus.ToString();
            toRet += "\nFilter: " + FilterStatus.ToString();
            toRet += "\nOther:  " + OtherStatus.ToString();
            return(toRet);
        }
Exemplo n.º 4
0
        public FanControl(FanControlOptions options)
        {
            MessageBus.Subscribe(new ClockComponent(options));

            MessageBus.Subscribe(new DataFetchComponent(options));

            MessageBus.Subscribe(new TrackingEventDeliveryComponent(e => DataRecieved?.Invoke(e) ?? Task.CompletedTask));

            MessageBus.Subscribe(new PowerComponent());
            MessageBus.Subscribe(new CoolDownComponent());
            MessageBus.Subscribe(new GoStandByComponent(options));
            MessageBus.Subscribe(new StartUpCoolingComponent(options));
            MessageBus.Subscribe(new StandByCoolingComponent(options));

            MessageBus.Subscribe(new FanControlComponent(options, e => FanStatus?.Invoke(e)));
        }
Exemplo n.º 5
0
Arquivo: Program.cs Projeto: 602p/nbfc
        private static void PrintFanStatus(FanStatus status)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("Fan display name\t: {0}", status.FanDisplayName);
            sb.AppendLine();
            sb.AppendFormat("Auto control enabled\t: {0}", status.AutoControlEnabled);
            sb.AppendLine();
            sb.AppendFormat("Critical mode enabled\t: {0}", status.CriticalModeEnabled);
            sb.AppendLine();
            sb.AppendFormat(CultureInfo.InvariantCulture, "Current fan speed\t: {0:0.00}", status.CurrentFanSpeed);
            sb.AppendLine();
            sb.AppendFormat(CultureInfo.InvariantCulture, "Target fan speed\t: {0:0.00}", status.TargetFanSpeed);
            sb.AppendLine();
            sb.AppendFormat("Fan speed steps\t\t: {0}", status.FanSpeedSteps);
            sb.AppendLine();

            Console.WriteLine(sb.ToString());
        }
Exemplo n.º 6
0
        private void UpdateFanControllerViewModels(FanStatus[] status)
        {
            for (int i = 0; i < status.Length; i++)
            {
                FanStatus fs = status[i];

                if (i >= viewModel.FanControllers.Count)
                {
                    FanControllerViewModel vm = new FanControllerViewModel(this, i)
                    {
                        CurrentFanSpeed         = fs.CurrentFanSpeed,
                        TargetFanSpeed          = fs.TargetFanSpeed,
                        FanDisplayName          = fs.FanDisplayName,
                        FanSpeedSteps           = fs.FanSpeedSteps,
                        IsAutoFanControlEnabled = fs.AutoControlEnabled,
                        IsCriticalModeEnabled   = fs.CriticalModeEnabled
                    };

                    if (fs.AutoControlEnabled)
                    {
                        vm.FanSpeedSliderValue = fs.FanSpeedSteps;
                    }
                    else
                    {
                        vm.FanSpeedSliderValue = (int)Math.Round((fs.TargetFanSpeed / 100.0) * fs.FanSpeedSteps);
                    }

                    viewModel.FanControllers.Add(vm);
                }
                else
                {
                    FanControllerViewModel vm = viewModel.FanControllers[i];

                    vm.CurrentFanSpeed         = fs.CurrentFanSpeed;
                    vm.TargetFanSpeed          = fs.TargetFanSpeed;
                    vm.FanDisplayName          = fs.FanDisplayName;
                    vm.FanSpeedSteps           = fs.FanSpeedSteps;
                    vm.IsAutoFanControlEnabled = fs.AutoControlEnabled;
                    vm.IsCriticalModeEnabled   = fs.CriticalModeEnabled;
                }
            }
        }
Exemplo n.º 7
0
        private void UpdateFanControllerViewModels(FanStatus[] status)
        {
            for (int i = 0; i < status.Length; i++)
            {
                FanStatus fs = status[i];

                if (i >= viewModel.FanControllers.Count)
                {
                    FanControllerViewModel vm = new FanControllerViewModel(this, i)
                    {
                        CurrentFanSpeed = fs.CurrentFanSpeed,
                        TargetFanSpeed = fs.TargetFanSpeed,
                        FanDisplayName = fs.FanDisplayName,
                        FanSpeedSteps = fs.FanSpeedSteps,
                        IsAutoFanControlEnabled = fs.AutoControlEnabled,
                        IsCriticalModeEnabled = fs.CriticalModeEnabled
                    };

                    if (fs.AutoControlEnabled)
                    {
                        vm.FanSpeedSliderValue = fs.FanSpeedSteps;
                    }
                    else
                    {
                        vm.FanSpeedSliderValue = (int)Math.Round((fs.TargetFanSpeed / 100.0) * fs.FanSpeedSteps);
                    }

                    viewModel.FanControllers.Add(vm);
                }
                else
                {
                    FanControllerViewModel vm = viewModel.FanControllers[i];

                    vm.CurrentFanSpeed = fs.CurrentFanSpeed;
                    vm.TargetFanSpeed = fs.TargetFanSpeed;
                    vm.FanDisplayName = fs.FanDisplayName;
                    vm.FanSpeedSteps = fs.FanSpeedSteps;
                    vm.IsAutoFanControlEnabled = fs.AutoControlEnabled;
                    vm.IsCriticalModeEnabled = fs.CriticalModeEnabled;
                }
            }
        }
Exemplo n.º 8
0
Arquivo: Program.cs Projeto: qzcw/nbfc
        private static void PrintFanStatus(FanStatus status)
        {
            var sb = new StringBuilder();
            sb.AppendFormat("Fan display name\t: {0}", status.FanDisplayName);
            sb.AppendLine();
            sb.AppendFormat("Auto control enabled\t: {0}", status.AutoControlEnabled);
            sb.AppendLine();
            sb.AppendFormat("Critical mode enabled\t: {0}", status.CriticalModeEnabled);
            sb.AppendLine();
            sb.AppendFormat(CultureInfo.InvariantCulture, "Current fan speed\t: {0:0.00}", status.CurrentFanSpeed);
            sb.AppendLine();
            sb.AppendFormat(CultureInfo.InvariantCulture, "Target fan speed\t: {0:0.00}", status.TargetFanSpeed);
            sb.AppendLine();
            sb.AppendFormat("Fan speed steps\t\t: {0}", status.FanSpeedSteps);
            sb.AppendLine();

            Console.WriteLine(sb.ToString());
        }
 public async void HandleNewTemperature(object sender, TemperatureData data)
 {
   Debug.WriteLine($"New temperature data received {data.Temperature} fanstatus = {data.FanStatus}");
   _lastTemperatureData = data;
   _lastTemperatureData.Timestamp = DateTimeOffset.UtcNow;
   if (_lastFanStatus != _lastTemperatureData.FanStatus && _isProcessing)
   {
     _isProcessing = false;
     _lastFanStatus = _lastTemperatureData.FanStatus;
     await UpdateFirstPageStatus();
   }
   else if (_lastToggleUse.IsSecondsAgo(Settings.FanSwitchQueueTtl) && _isProcessing)
   {
     _isProcessing = false;
     _lastFanStatus = _lastTemperatureData.FanStatus;
     await UpdateFirstPageStatus();
   }
   else if (!_isProcessing)
   {
     _lastFanStatus = _lastTemperatureData.FanStatus;
   }
 }