Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MeterSettings"/> class
        /// using the specified <see cref="IConfigurationSource"/> to initialize values.
        /// </summary>
        /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param>
        private MeterSettings(IConfigurationSource source)
            : base(source)
        {
            MetricExporter         = ParseMetricExporter(source);
            ConsoleExporterEnabled = source.GetBool(ConfigurationKeys.Metrics.ConsoleExporterEnabled) ?? false;

            var instrumentations        = new Dictionary <string, MeterInstrumentation>();
            var enabledInstrumentations = source.GetString(ConfigurationKeys.Metrics.Instrumentations);

            if (enabledInstrumentations != null)
            {
                foreach (var instrumentation in enabledInstrumentations.Split(Separator))
                {
                    if (Enum.TryParse(instrumentation, out MeterInstrumentation parsedType))
                    {
                        instrumentations[instrumentation] = parsedType;
                    }
                    else
                    {
                        throw new FormatException($"The \"{instrumentation}\" is not recognized as supported metrics instrumentation and cannot be enabled");
                    }
                }
            }

            var disabledInstrumentations = source.GetString(ConfigurationKeys.Metrics.DisabledInstrumentations);

            if (disabledInstrumentations != null)
            {
                foreach (var instrumentation in disabledInstrumentations.Split(Separator))
                {
                    instrumentations.Remove(instrumentation);
                }
            }

            EnabledInstrumentations = instrumentations.Values.ToList();

            var providerPlugins = source.GetString(ConfigurationKeys.Metrics.ProviderPlugins);

            if (providerPlugins != null)
            {
                foreach (var pluginAssemblyQualifiedName in providerPlugins.Split(DotNetQualifiedNameSeparator))
                {
                    MetricPlugins.Add(pluginAssemblyQualifiedName);
                }
            }

            var additionalSources = source.GetString(ConfigurationKeys.Metrics.AdditionalSources);

            if (additionalSources != null)
            {
                foreach (var sourceName in additionalSources.Split(Separator))
                {
                    Meters.Add(sourceName);
                }
            }

            MetricsEnabled       = source.GetBool(ConfigurationKeys.Metrics.Enabled) ?? true;
            LoadMetricsAtStartup = source.GetBool(ConfigurationKeys.Metrics.LoadMeterAtStartup) ?? true;
        }
 /// <summary>
 ///		Marca una métrica
 /// </summary>
 public void Mark(double value)
 {
     Meters.Add(CreateNewHistogram(value),
                item => {
         item.Add(value);
         return(item);
     }
                );
 }
Exemplo n.º 3
0
 public MainViewModel(EnergyMetersService Service, List <EnergyMeter> energyMeters)
 {
     service = Service;
     foreach (var item in energyMeters)
     {
         var meterViewModel = new MeterViewModel(item, service, this);
         meterViewModel.Navigation = this.Navigation;
         Meters.Add(meterViewModel);
     }
     CreateCommand = new Command(async() => await Create(), () => true);
 }
 private void GetMeters(AudioAnalyzerConfigurationMonitorIDStation station, Station stationSend, int numberOfMeters)
 {
     for (int i = 0; i < station.MeterID.Count(); i++)
     {
         Meter catcherModelSend = new Meter();
         catcherModelSend.MeterID      = station.MeterID[i].MeterID;
         catcherModelSend.FriendlyName = station.MeterID[i].FriendlyName;
         catcherModelSend.IsActive     = station.MeterID[i].IsActive;
         catcherModelSend = AddDevice(catcherModelSend);
         catcherModelSend.HostIPAdress = NetworkHelpers.ResolveIpAdress();
         stationSend.ListOfMeters.Add(catcherModelSend);
         if (catcherModelSend.IsActive == true)
         {
             Meters.Add(catcherModelSend);
         }
     }
 }
        private async Task SyncAsync()
        {
            try
            {
                await PushReadsToCloud();

                SyncStatus = "Pulling...";
                await RouteSyncTable.PullAsync("PullQuery", RouteSyncTable.CreateQuery());

                SyncStatus = "Syncronized";

                ReadEndpoints   = 0;
                TotalEndpoints  = 0;
                BadLocEndpoints = 0;
            }
            catch (Exception e)
            {
                SyncStatus = "Error Syncronizing: " + e.Message;
            }
            finally
            {
                IEnumerable <JsonMeterModel> SyncMeters = await RouteSyncTable.ReadAsync();

                foreach (JsonMeterModel model in SyncMeters)
                {
                    Meters.Add(new MeterModel()
                    {
                        MeterInfo = model,
                        Location  = new Geopoint(new BasicGeoposition()
                        {
                            Latitude = model.Latitude, Longitude = model.Longitude
                        }),
                        ReadUpdated = false
                    });
                    if (Meters.Count == 20)
                    {
                        break;
                    }
                    //await Task.Delay(1);
                }
            }
        }
Exemplo n.º 6
0
        public ReadingsMetersViewModel()
        {
            IEnumerable <ZigbeeMeter> zigbeeMeters = MetersHelper.GetZigbeeMeters();

            foreach (ZigbeeMeter meter in zigbeeMeters)
            {
                var meterViewModel = new ZigbeeMeterViewModel(meter);
                Meters.Add(meterViewModel);
                meterViewModel.StatusSet += MeterViewModelOnStatusSet;
            }

            IEnumerable <MbusMeter> mbusMeters = MetersHelper.GetMbusMeters();

            foreach (MbusMeter meter in mbusMeters)
            {
                var meterViewModel = new MbusMeterViewModel(meter);
                Meters.Add(meterViewModel);
                meterViewModel.StatusSet += MeterViewModelOnStatusSet;
            }
        }
Exemplo n.º 7
0
        private void CreateDspObjects()
        {
            Debug.Console(2, "Creating DSP Objects");

            var props = JsonConvert.DeserializeObject <TesiraDspPropertiesConfig>(_dc.Properties.ToString());

            if (props == null)
            {
                return;
            }

            Debug.Console(2, this, "Props Exists");
            Debug.Console(2, this, "Here's the props string\n {0}", _dc.Properties.ToString());

            Faders.Clear();
            Presets.Clear();
            Dialers.Clear();
            States.Clear();
            Switchers.Clear();
            ControlPointList.Clear();
            Meters.Clear();
            RoomCombiners.Clear();

            if (props.FaderControlBlocks != null)
            {
                Debug.Console(2, this, "levelControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count());
                foreach (var block in props.FaderControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "LevelControlBlock Key - {0}", key);
                    var value = block.Value;

                    Faders.Add(key, new TesiraDspFaderControl(key, value, this));
                    Debug.Console(2, this, "Added LevelControlPoint {0} LevelTag: {1} MuteTag: {2}", key, value.LevelInstanceTag, value.MuteInstanceTag);
                    if (block.Value.Enabled)
                    {
                        //Add ControlPoint to the list for the watchdog
                        ControlPointList.Add(Faders[key]);
                    }
                }
            }

            if (props.SwitcherControlBlocks != null)
            {
                Debug.Console(2, this, "switcherControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count());
                foreach (var block in props.SwitcherControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "SwitcherControlBlock Key - {0}", key);
                    var value = block.Value;

                    Switchers.Add(key, new TesiraDspSwitcher(key, value, this));
                    Debug.Console(2, this, "Added TesiraSwitcher {0} InstanceTag {1}", key, value.SwitcherInstanceTag);

                    if (block.Value.Enabled)
                    {
                        //Add ControlPoint to the list for the watchdog

                        ControlPointList.Add(Switchers[key]);
                    }
                }
            }

            if (props.DialerControlBlocks != null)
            {
                Debug.Console(2, this, "DialerControlBlocks is not null - There are {0} of them", props.DialerControlBlocks.Count());
                foreach (var block in props.DialerControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "LevelControlBlock Key - {0}", key);
                    var value = block.Value;
                    Dialers.Add(key, new TesiraDspDialer(key, value, this));
                    Debug.Console(2, this, "Added DspDialer {0} ControlStatusTag: {1} DialerTag: {2}", key, value.ControlStatusInstanceTag, value.DialerInstanceTag);

                    if (block.Value.Enabled)
                    {
                        ControlPointList.Add(Dialers[key]);
                    }
                }
            }

            if (props.StateControlBlocks != null)
            {
                Debug.Console(2, this, "stateControlBlocks is not null - There are {0} of them", props.StateControlBlocks.Count());
                foreach (var block in props.StateControlBlocks)
                {
                    var key   = block.Key;
                    var value = block.Value;
                    States.Add(key, new TesiraDspStateControl(key, value, this));
                    Debug.Console(2, this, "Added DspState {0} InstanceTag: {1}", key, value.StateInstanceTag);

                    if (block.Value.Enabled)
                    {
                        ControlPointList.Add(States[key]);
                    }
                }
            }

            if (props.Presets != null)
            {
                foreach (var preset in props.Presets)
                {
                    var value = preset.Value;
                    var key   = preset.Key;
                    Presets.Add(key, value);
                    Debug.Console(2, this, "Added Preset {0} {1}", value.Label, value.PresetName);
                }
            }

            if (props.MeterControlBlocks != null)
            {
                foreach (var meter in props.MeterControlBlocks)
                {
                    var key   = meter.Key;
                    var value = meter.Value;
                    Meters.Add(key, new TesiraDspMeter(key, value, this));
                    Debug.Console(2, this, "Adding Meter {0} InstanceTag: {1}", key, value.MeterInstanceTag);

                    if (value.Enabled)
                    {
                        ControlPointList.Add(Meters[key]);
                    }
                }
            }

            if (props.CrosspointStateControlBlocks != null)
            {
                foreach (var mixer in props.CrosspointStateControlBlocks)
                {
                    var key   = mixer.Key;
                    var value = mixer.Value;
                    CrosspointStates.Add(key, new TesiraDspCrosspointState(key, value, this));
                    Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.MatrixInstanceTag);

                    if (value.Enabled)
                    {
                        ControlPointList.Add(CrosspointStates[key]);
                    }
                }
            }
            if (props.RoomCombinerControlBlocks == null)
            {
                return;
            }
            foreach (var roomCombiner in props.RoomCombinerControlBlocks)
            {
                var key   = roomCombiner.Key;
                var value = roomCombiner.Value;
                RoomCombiners.Add(key, new TesiraDspRoomCombiner(key, value, this));
                Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.RoomCombinerInstanceTag);

                if (value.Enabled)
                {
                    ControlPointList.Add(RoomCombiners[key]);
                }
            }

            //Keep me at the end of this method!
            DeviceManager.AddDevice(new TesiraDspDeviceInfo(String.Format("{0}--DeviceInfo", Key), String.Format("{0}--DeviceInfo", Name, Presets), this, Presets));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Switches the active meter tab after a user has moved the optical port to a different meter
        /// </summary>
        /// <returns></returns>
        public async Task SwitchMeters()
        {
            // Retrieves the serial number of the meter currently attached to the serial port
            string serialIdx    = CurrentTab.SerialIdx;
            string currSerialNo = Serial[serialIdx].SerialNo;
            var    tabs         = _tabs.Where(x => x.MeterSerialNo == currSerialNo);

            CurrentTab.Visible = false;

            // If the meter exists and there is a tab already created for it then switch to that tab
            // and change to Commissioning page
            if (Meters.ContainsKey(currSerialNo) && tabs.Count() == 1)
            {
                await CurrentTab.StopAsync();

                var tab = tabs.ElementAt(0);
                CurrentTab      = tab;
                tab.Visible     = true;
                tab.CurrentPage = tab.Pages[1];
            }
            // If the meter exists (imported) but there is not a tab created for it then create the tab
            // and change to the Commissioning page
            else if (Meters.ContainsKey(currSerialNo))
            {
                await CurrentTab.StopAsync();

                CreateTab(new Tuple <string, string>(serialIdx, currSerialNo));
                CurrentTab.CurrentPage = CurrentTab.Pages[1];
            }
            // If the meter does not exist, create a new meter and a new tab
            // then change to the Commissioning page
            else
            {
                Meter m = new Meter();
                m.ID = currSerialNo;
                Meters.Add(currSerialNo, m);

                // Sets the size of the meter based on the type of meter connected
                string   version = await Serial[serialIdx].GetVersion();
                string[] lines   = version.Split(new char[] { '\n', '\r' }, System.StringSplitOptions.RemoveEmptyEntries);
                if (lines[2].Split(new char[0], System.StringSplitOptions.RemoveEmptyEntries)[1].StartsWith("593"))
                {
                    string[] serials = (await Serial[serialIdx].GetChildSerial()).Split(',');
                    for (int i = 0; i < 12; i++)
                    {
                        m.Channels.Add(new Channel(i + 1));
                        m.Channels[i].Serial = serials[i];
                    }
                }

                await CurrentTab.StopAsync();

                CreateTab(new Tuple <string, string>(serialIdx, currSerialNo));
                CurrentTab.CurrentPage = CurrentTab.Pages[1];
            }

            // Initiate the async processes for the current page and modify navigation buttons
            CurrentTab.StartAsync();
            ModifyNavigation();

            // Modifies the collections that represent which tabs should be visible in the menu and which tabs
            // are present in the tab control for user interaction
            Application.Current.Dispatcher.Invoke(() =>
            {
                ModifyTabs();
            });
        }
 /// <summary>
 ///		Marca una métrica
 /// </summary>
 public void Mark()
 {
     Meters.Add(1, item => item + 1);
 }