Example #1
0
        private async Task InitializeOverlayEntryDict()
        {
            _overlayEntryCore.OverlayEntryDict.Clear();

            try
            {
                var sensors = await _sensorService.GetSensorEntries();

                if (sensors != null)
                {
                    foreach (var sensor in sensors)
                    {
                        var dictEntry = CreateOverlayEntry(sensor);
                        var id        = sensor.Identifier.ToString();
                        if (!_overlayEntryCore.OverlayEntryDict.ContainsKey(id))
                        {
                            _overlayEntryCore.OverlayEntryDict.Add(id, dictEntry);
                        }
                    }
                }

                _overlayEntryCore.OverlayEntryCoreCompletionSource.SetResult(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while getting sensors.");
            }
        }
Example #2
0
        public async Task <IEnumerable <ISensorEntry> > GetWrappedSensorEntries()
        {
            var sensorEntries = await _sensorService.GetSensorEntries();

            var wrappedEntries = sensorEntries.Select(WrapSensorEntry);

            if (!_sensorConfig.HasConfigFile
                // reset config when hardware has changed
                || _sensorConfig.SensorEntryCount != sensorEntries.Count())
            {
                _sensorConfig.ResetConfig();
                wrappedEntries.ForEach(SetIsActiveDefault);
                await SaveSensorConfig();
            }

            return(wrappedEntries);
        }