private static void LoadAllStoragedSignals(IPsnDataStorage storage, IPsnProtocolConfiguration config) { var psnLogsInStorage = storage.PsnDatas.ToList(); Log("Число ПСН логов на устройстве: " + psnLogsInStorage.Count); Log("Конфигурация ПСН: " + config.Information); Log("Загрузка всех сигналов для всех логов..."); foreach (var psnLog in psnLogsInStorage) { Console.WriteLine("PsnLog " + psnLog); foreach (var psnDev in config.PsnDevices) { Log("Работаем с абонентом ПСН: " + psnDev.Name); IPsnData log = psnLog; IPsnProtocolDeviceConfiguration dev = psnDev; config.ForeachPsnMeterSignal(psnDev.Address, (cmdPartConfiguration, parameterConfiguration) => { var points = log.LoadTrend(config, cmdPartConfiguration, parameterConfiguration, DateTime.Now); Console.WriteLine(dev.Name + "/" + parameterConfiguration.Name + " = " + points.Count); return(false); }); } } }
private void RebuildMetersUnsafe() { _meters.Clear(); foreach (var dev in _psnConfigurationLowLevel.PsnDevices) { var channels = new ObservableCollection <IPsnChannel>(); var meter = new PsnMeterSimple(dev.Name, channels); _psnConfigurationLowLevel.ForeachPsnMeterSignal(dev.Address, (cmdPartCfg, paramCfg) => { Guid chId; try { chId = Guid.Parse(_unicSignalIdStorage.GetValue(paramCfg.Id.IdentyString)); } catch { // no value in storage or wrong value format: chId = Guid.NewGuid(); _unicSignalIdStorage.SetValue(paramCfg.Id.IdentyString, chId.ToString()); } try { channels.Add( new PsnChannelSimple( chId, Guid.Parse(paramCfg.Id.IdentyString), // can trhow exception paramCfg.Name, paramCfg.IsBitSignal ? TrendType.Discrete : TrendType.Analogue, new PsnChannelTrendLoaderSimple(paramCfg, cmdPartCfg, _psnData, _psnConfigurationLowLevel, _psnDataInformation), _uiNotifier, _bworker, meter)); } catch { // TODO: remove empty catch } return(false); // no stops needed }); _meters.Add(meter); } if (_psnConfigurationLowLevel.MergedDevices == null) { return; } foreach (var dev in _psnConfigurationLowLevel.MergedDevices) { var channels = new ObservableCollection <IPsnChannel>(); var meter = new PsnMeterSimple(dev.Name, channels); foreach (var parameter in dev.Parameters) { Guid chId; try { chId = Guid.Parse(_unicSignalIdStorage.GetValue(parameter.Id.IdentyString)); } catch { // no value in storage or wrong value format: chId = Guid.NewGuid(); _unicSignalIdStorage.SetValue(parameter.Id.IdentyString, chId.ToString()); } channels.Add( new PsnChannelSimple( chId, Guid.Parse(parameter.Id.IdentyString), // can throw exception parameter.Name, TrendType.Analogue, new PsnChannelTrendLoaderMerged(parameter, _psnData, _psnConfigurationLowLevel, _psnDataInformation), _uiNotifier, _bworker, meter)); } _meters.Add(meter); } }