Exemplo n.º 1
0
        private void Refresh <T>(T changedKpi, Action <DeviceIndicatorsModel, T> updater) where T : IIndicatorBase
        {
            var kpis   = _coreData.GetParent <IDeviceIndicators>(changedKpi);
            var device = _coreData.GetParent <IDevice>(kpis);
            var id     = _coreData.GetId(device);

            var localDevice = Devices.FirstOrDefault(s => s.DeviceId == id);

            if (localDevice == null)
            {
                localDevice = new DeviceIndicatorsModel {
                    DeviceId = id
                };
                if (id != _coreData.ThisDeviceId)
                {
                    Devices.Insert(0, localDevice);
                }
                else
                {
                    Devices.Add(localDevice);
                }

                UpdateDeviceNames();
            }

            updater(localDevice, changedKpi);
        }
Exemplo n.º 2
0
        private void RefreshCloudIn(DeviceIndicatorsModel localDevice, IIndicatorCloudIn cloudIn)
        {
            var state   = cloudIn.State;
            var bitrate = state == IndicatorState.Disabled ? 0 : cloudIn.Bitrate;

            var r = localDevice.CloudIn;

            r.State.Value = state;

            if (state == IndicatorState.Ok || state == IndicatorState.Warning)
            {
                r.Value.Value      = $"{bitrate / 1000}";
                r.SmallValue.Value = $".{(bitrate % 1000) / 100}";
            }
            else
            {
                r.Value.Value      = $"E";
                r.SmallValue.Value = null;
            }

            r.DetailedDescription.Value = state switch
            {
                IndicatorState.Ok => "Stream from cloud is Ok",
                IndicatorState.Warning => "Bitrate from cloud is lower than expected",
                IndicatorState.Error => "Stream from cloud is failed",
                _ => "?"
            };
        }
Exemplo n.º 3
0
        private void RefreshCloudOut(DeviceIndicatorsModel localDevice, IIndicatorCloudOut cloudOut)
        {
            var state = cloudOut.State;

            var bitrate = state == IndicatorState.Disabled ? 0 : cloudOut.Bitrate;

            _streamSettings.SetActualBitrate(bitrate, cloudOut.State);

            var r = localDevice.CloudOut;

            r.State.Value = state;

            if (state == IndicatorState.Ok || state == IndicatorState.Warning || state == IndicatorState.Warning2)
            {
                r.Value.Value      = $"{bitrate / 1000}";
                r.SmallValue.Value = $".{(bitrate % 1000) / 100}";
            }
            else
            {
                r.Value.Value      = $"E";
                r.SmallValue.Value = null;
            }

            r.DetailedDescription.Value = state switch
            {
                IndicatorState.Ok => "Stream to cloud is Ok",
                IndicatorState.Warning => "Bitrate is lower then requested",
                IndicatorState.Warning2 => "Bitrate is VERY low",
                IndicatorState.Error => "Stream to cloud is UNSTABLE",
                IndicatorState.Error2 => "Stream to cloud FAILED",
                _ => "?"
            };
        }
Exemplo n.º 4
0
        private void RefreshEncoderData(DeviceIndicatorsModel device, IIndicatorEncoder input)
        {
            if (input?.Data != null)
            {
                device.Encoder.ChartModel.AddValue(input.Data.Q, 12);
                device.Encoder.OutputFps.AddValue(input.Data.O, _coreData.Settings.Fps);
            }

            RefreshEncoderState(device, input);
        }
Exemplo n.º 5
0
        private void RefreshCpu(DeviceIndicatorsModel device, IIndicatorCpu input)
        {
            var cpu  = device.Cpu;
            var load = input.Load;

            cpu.Value.Value = load.ToString();
            cpu.State.Value = input.State;

            cpu.DetailedDescription.Value = cpu.State.Value switch
            {
                IndicatorState.Ok => $"CPU load {load}% is normal",
                IndicatorState.Warning => $"CPU load {load}% is ABOVE normal",
                IndicatorState.Error => $"CPU load {load}% is OVERLOADED",
                _ => "?"
            };
            device.Cpu.Processes.Value = input.Top;
        }
Exemplo n.º 6
0
        private void RefreshVpnState(DeviceIndicatorsModel local, IIndicatorVpn data)
        {
            Reset(local.Vpn, data);

            var vpn = local.Vpn;

            vpn.State.Value = data.State;

            vpn.DetailedDescription.Value = vpn.State.Value switch
            {
                IndicatorState.Ok => "VPN established and works",
                IndicatorState.Warning => "Connecting...",
                IndicatorState.Error => "Failed. VPN is reconnecting...",
                _ => "?"
            };

            vpn.Value.Value = vpn.State.Value switch
            {
                IndicatorState.Ok => "ok",
                IndicatorState.Warning => "...",
                IndicatorState.Error => "E",
                _ => "?"
            };
        }
Exemplo n.º 7
0
        private void RefreshEncoderState(DeviceIndicatorsModel device, IIndicatorEncoder input)
        {
            var encoder = device.Encoder;

            encoder.State.Value = input.State;
            encoder.Value.Value = encoder.State.Value switch
            {
                IndicatorState.Ok => "ok",
                IndicatorState.Warning => "W",
                IndicatorState.Warning2 => "W",
                IndicatorState.Error => "E",
                IndicatorState.Error2 => "E",
                _ => "?"
            };

            encoder.DetailedDescription.Value = encoder.State.Value switch
            {
                IndicatorState.Ok => "Inputs and Encoder work Ok",
                IndicatorState.Warning => "FPS is low. Encoder may be overloaded.",
                IndicatorState.Error => "Encoder is overloaded",
                IndicatorState.Error2 => "One or more video/audio sources failed",
                _ => "?"
            };
        }