Exemplo n.º 1
0
        private void BuildCircuit()
        {
            string filepath = _fileSelectorFactoryAdapter.GetPathFromFile(_selectedFileName);

            _mc.BuildCircuit(filepath);

            Inputs.Clear();
            _mc.getInputs().ForEach(i => Inputs.Add(new NodeViewModel(i, this)));

            Nodes.Clear();
            _mc.getNodes().ForEach(i => Nodes.Add(new NodeViewModel(i, this)));

            Probes.Clear();
            _mc.getProbes().ForEach(i => Probes.Add(new NodeViewModel(i, this)));

            base.RaisePropertyChanged();
            _mc.Run();
        }
Exemplo n.º 2
0
        internal IAutoHealthCheckContext AddProbe <TProbe>()
            where TProbe : class, IProbe
        {
            // validate type is not an interface
            if (typeof(TProbe).IsInterface)
            {
                throw new InvalidOperationException("Probe cannot be an interface.");
            }

            // validate type is not abstract
            if (typeof(TProbe).IsAbstract)
            {
                throw new InvalidOperationException("Probe cannot be abstract.");
            }

            if (Probes.All(p => p != typeof(TProbe)))
            {
                Probes.Add(typeof(TProbe));
            }

            return(this);
        }
Exemplo n.º 3
0
        private async void OnOpened(object sender, EventArgs _)
        {
            Device = FindDevice();
            try
            {
                await MonitoringMode(true);

                Console.WriteLine($"-- Listening on {Device.Name}, hit 'Enter' to stop...");

                Task.Run(() =>
                {
                    while (true)
                    {
                        Probes.Clear();
                        foreach (var kvp in ProbeCache.Cache)
                        {
                            foreach (var ce in kvp.Value)
                            {
                                Probes.Add(ce);
                            }
                        }
                        Beacons.Clear();
                        foreach (var kvp in BeaconCache.Cache)
                        {
                            foreach (var ce in kvp.Value)
                            {
                                Beacons.Add(ce);
                            }
                        }
                        Thread.Sleep(1000);
                    }
                }).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }