Ejemplo n.º 1
0
        private static void Connect_Minolta_0()
        {
            m_ICa200 = new Ca200();

            if (m_ICa200 == null)
            {
                MessageBox.Show("Не установлен драйвер для Minolta CA-210.\nБаланс белого не будет доступен.",
                                "Driver Minolta CA210 not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                isConnectedMinolta = false;
                return;
            }
            //write_info("Подключение к Minolta. Ожидайте...");
            try
            {
                m_ICa200.AutoConnect();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка! Не удалось подключиться к Минолте по USB.\nПроверьте USB соединение с Минолтой.\n\n\n\n\n\n" + ex,
                                "Не удается подключить к Минолте по USB", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //this.buttonConnectUSB.Enabled = true;
                isConnectedMinolta = false;
                return;
            }
            Thread.Sleep(50);
            isConnectedMinolta = true;
            m_ICas             = (ICas)m_ICa200.Cas;
            m_ICa     = (ICa)m_ICas.get_ItemOfNumber(1);
            m_IProbe  = (IProbe)m_ICa.SingleProbe;
            m_IMemory = (IMemory)m_ICa.Memory;
            Thread.Sleep(50);
            loopInit_CA210();
            //write_info("Подключение Minolta завершенно.");
        }
Ejemplo n.º 2
0
        public static async Task <T> GetEventually <T>(IProbe <T> probe, int timeout)
            where T : class
        {
            var poller = new Poller(timeout);

            return(await poller.GetAsync(probe));
        }
        public CollectExecutionManager CreateExecutionManagerForTheSuccessScenario(ProbeResult resultForRegistry, ProbeResult resultForFamily)
        {
            MockRepository mocks = new MockRepository();

            probeManager             = mocks.DynamicMock <IProbeManager>();
            probe                    = mocks.DynamicMock <IProbe>();
            familyProbe              = mocks.DynamicMock <IProbe>();
            dataProvider             = mocks.DynamicMock <IDataProvider>();
            systemInformationService = mocks.DynamicMock <ISystemInformationService>();
            connectionContext        = this.CreateConnectionContext();

            CollectInfo collectInfo = new CollectInfo()
            {
                ObjectTypes = ovalObjects
            };

            Expect.Call(probeManager.GetProbesFor(null, FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(this.GetSelectedProbes());
            Expect.Call(probeManager.GetSystemInformationService(FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(systemInformationService);
            Expect.Call(probe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForRegistry);
            Expect.Call(familyProbe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForFamily);
            Expect.Call(dataProvider.GetSession()).Repeat.Any().Return(session).IgnoreArguments();
            Expect.Call(dataProvider.GetTransaction(session)).Repeat.Any().Return(new Transaction(session)).IgnoreArguments();
            Expect.Call(systemInformationService.GetSystemInformationFrom(target)).IgnoreArguments().Return(this.GetExpectedSystemInformation());

            mocks.ReplayAll();

            return(new CollectExecutionManager(probeManager)
            {
                Target = target, connectionContext = connectionContext
            });
        }
Ejemplo n.º 4
0
 public AvgView(IProbe one, params double[] others)
 {
     Requires.NotNull(one, others);
     var x = others.Sum();
     double d = (1 + others.Length);
     m_f = () => (one.ValueDouble + x) / d;
 }
        public CollectExecutionManager CreateExecutionManagerWWithInvalidCredentialsScenario(ProbeResult resultForRegistry, ProbeResult resultForFamily)
        {
            MockRepository mocks = new MockRepository();

            probeManager = mocks.DynamicMock <IProbeManager>();
            probe        = mocks.DynamicMock <IProbe>();
            familyProbe  = mocks.DynamicMock <IProbe>();
            dataProvider = mocks.DynamicMock <IDataProvider>();

            CollectInfo collectInfo = new CollectInfo()
            {
                ObjectTypes = ovalObjects
            };

            Expect.Call(probeManager.GetProbesFor(null, FamilyEnumeration.windows)).IgnoreArguments().Return(GetSelectedProbes());
            Expect.Call(probe.Execute(connectionContext, target, collectInfo)).Throw(new InvalidCredentialsException("The credentials is not valid", null));
            Expect.Call(familyProbe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Return(resultForFamily);
            Expect.Call(dataProvider.GetSession()).Repeat.Any().Return(session).IgnoreArguments();
            Expect.Call(dataProvider.GetTransaction(session)).Repeat.Any().Return(new Transaction(session)).IgnoreArguments();

            mocks.ReplayAll();

            return(new CollectExecutionManager(probeManager)
            {
                Target = target, connectionContext = connectionContext
            });
        }
Ejemplo n.º 6
0
 public virtual void OnProbeFound()
 {
     if (Probe == null)
     {
         Probe = Pointers.Probe.Ensure(transform, ProbeName);
     }
 }
Ejemplo n.º 7
0
 private static void Connect_Minolta_0()
 {
     if (PublicData.m_ICa200 == null)
     {
         MessageBox.Show("Не установлен драйвер для Minolta CA-210.\nБаланс белого не будет доступен.",
                         "Driver Minolta CA210 not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
         isConnectedMinolta = false;
         return;
     }
     PublicData.write_info("Подключение к Minolta. Ожидайте...");
     try
     {
         m_ICa200.AutoConnect();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error! Check USB connection please.\n" + ex.Info(),
                         "Can't connect USB CA210", MessageBoxButtons.OK, MessageBoxIcon.Error);
         //this.buttonConnectUSB.Enabled = true;
         isConnectedMinolta = false;
         return;
     }
     Thread.Sleep(50);
     uPowerStatus       = true;
     isConnectedMinolta = true;
     m_ICas             = (ICas)m_ICa200.Cas;
     m_ICa     = (ICa)m_ICas.get_ItemOfNumber(1);
     m_IProbe  = (IProbe)m_ICa.SingleProbe;
     m_IMemory = (IMemory)m_ICa.Memory;
     Thread.Sleep(50);
     loopInit_CA210();
     PublicData.write_info("Подключение Minolta завершенно.");
 }
Ejemplo n.º 8
0
 public MultiplyView(IProbe one, double other)
 {
     if (one is null)
     {
         throw new ArgumentNullException(nameof(one));
     }
     m_f = () => one.ValueDouble * other;
 }
Ejemplo n.º 9
0
 public void SetMember(string name, IProbe probe)
 {
     if (probe == null)
     {
         throw new ArgumentNullException();
     }
     m_probes[name] = new NamedProbe(name, probe);
 }
Ejemplo n.º 10
0
        public void AddProbe(DateTime nextPoll, IProbe probe)
        {
            while (_list.IndexOfKey(nextPoll) != -1)
            {
                nextPoll += TimeSpan.FromMilliseconds(1);
            }

            _list.Add(nextPoll, probe);
        }
Ejemplo n.º 11
0
 public ProbeController(IProbe probe, string name, Config.ProbeType probeType, int startingTargetTemp)
 {
     _probe = probe;
     Name = name;
     ProbeType = probeType;
     TargetTemp = startingTargetTemp;
     State = Config.ProbeState.Unavailable;
     TargetReachedTimes = new System.Collections.ArrayList();
     TargetReachedTimespans = new System.Collections.Stack();
 }
Ejemplo n.º 12
0
            public NamedProbe(string name, IProbe probe)
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentNullException();
                }

                Name  = name;
                Probe = probe ?? throw new ArgumentNullException();
            }
Ejemplo n.º 13
0
 public ProbeController(IProbe probe, string name, Config.ProbeType probeType, int startingTargetTemp)
 {
     _probe                 = probe;
     Name                   = name;
     ProbeType              = probeType;
     TargetTemp             = startingTargetTemp;
     State                  = Config.ProbeState.Unavailable;
     TargetReachedTimes     = new System.Collections.ArrayList();
     TargetReachedTimespans = new System.Collections.Stack();
 }
Ejemplo n.º 14
0
            public SnapshotProbeTimeSpan(IProbe <TimeSpan> probe)
            {
                if (probe == null)
                {
                    throw new ArgumentNullException();
                }
                m_probe = probe;
                m_base  = -probe.Value.Ticks;

                Telemetry.OnReset += (s, e) => m_base = 0;
            }
Ejemplo n.º 15
0
            public SnapshotProbeDouble(IProbe <double> probe)
            {
                if (probe == null)
                {
                    throw new ArgumentNullException();
                }
                m_probe = probe;
                m_base  = -probe.Value;

                Telemetry.OnReset += (s, e) => m_base = 0;
            }
Ejemplo n.º 16
0
        public static IDisposable Register(string name, IProbe probe)
        {
            Requires.NotEmpty(name);
            Requires.NotNull(probe);

            lock (s_namedProbes)
                s_namedProbes[name] = probe;

            return(Disposable.Create(
                       () => { lock (s_namedProbes) s_namedProbes.Remove(name); }
                       ));
        }
        private SelectedProbe CreateSelectedProbe <T>(IProbe probe, string capability, FamilyEnumeration plataform, CollectRequest collectRequest) where T : ObjectType
        {
            SelectedProbe selectedProbe = new SelectedProbe(probe,
                                                            collectRequest.GetObjectTypes(session).OfType <T>(),
                                                            new ProbeCapabilities()
            {
                OvalObject    = capability,
                PlataformName = plataform
            });

            return(selectedProbe);
        }
Ejemplo n.º 18
0
 public RatioView(IProbe nominator, IProbe denominator)
 {
     if (nominator is null)
     {
         throw new ArgumentNullException(nameof(nominator));
     }
     if (denominator is null)
     {
         throw new ArgumentNullException(nameof(denominator));
     }
     m_f = () => nominator.ValueDouble / denominator.ValueDouble;
 }
Ejemplo n.º 19
0
 public RatioView(IProbe nominator, double denominator)
 {
     if (nominator is null)
     {
         throw new ArgumentNullException(nameof(nominator));
     }
     if (denominator == 0.0)
     {
         throw new ArgumentOutOfRangeException(nameof(denominator));
     }
     m_f = () => nominator.ValueDouble / denominator;
 }
Ejemplo n.º 20
0
 public SubtractView(IProbe one, params IProbe[] others)
 {
     if (one is null)
     {
         throw new ArgumentNullException(nameof(one));
     }
     if (others is null)
     {
         throw new ArgumentNullException(nameof(others));
     }
     m_f = () => one.ValueDouble - others.Sum(x => x.ValueDouble);
 }
Ejemplo n.º 21
0
 public MaxView(IProbe one, params IProbe[] others)
 {
     if (one is null)
     {
         throw new ArgumentNullException(nameof(one));
     }
     if (others is null)
     {
         throw new ArgumentNullException(nameof(others));
     }
     m_f = () => Math.Max(one.ValueDouble, others.Max(x => x.ValueDouble));
 }
Ejemplo n.º 22
0
        public MonitoringJob(TargetRecord targetRecord, IProbe probe, ILogger <MonitoringJob> logger)
        {
            targetRecord.VerifyNotNull(nameof(targetRecord))
            .VerifyAssert(x => !x.ReadyUrl.IsEmpty(), x => nameof(x.ReadyUrl))
            .VerifyAssert(x => x.FrequencyInSeconds != null, x => nameof(x.FrequencyInSeconds));

            probe.VerifyNotNull(nameof(probe));
            logger.VerifyNotNull(nameof(logger));

            _targetRecord = targetRecord;
            _probe        = probe;
            _logger       = logger;
        }
Ejemplo n.º 23
0
            public SubtractView(IProbe one, params double[] others)
            {
                if (one is null)
                {
                    throw new ArgumentNullException(nameof(one));
                }
                if (others is null)
                {
                    throw new ArgumentNullException(nameof(others));
                }
                var x = others.Sum();

                m_f = () => one.ValueDouble - x;
            }
Ejemplo n.º 24
0
            public MaxView(IProbe one, params double[] others)
            {
                if (one is null)
                {
                    throw new ArgumentNullException(nameof(one));
                }
                if (others is null)
                {
                    throw new ArgumentNullException(nameof(others));
                }
                var x = others.Max();

                m_f = () => Math.Max(one.ValueDouble, x);
            }
Ejemplo n.º 25
0
        public static void Disconnect_CA210()
        {
            try
            {
                m_ICa.RemoteMode = 0;

                m_ICa    = null;
                m_ICa200 = null;
                m_IProbe = null;
                m_ICas   = null;
                m_IProbe = null;
            }
            catch { }
        }
Ejemplo n.º 26
0
 public ProbeMonitor(ILogger <ProbeMonitor> logger, IOptions <ProbeMonitorConfig> options, IServiceScopeFactory scopeFactory)
 {
     _logger = logger;
     ProbeMonitorConfig.Validate(options.Value);
     _probeFailureTolerance = options.Value.FailureTolerance;
     _aliveThreshold        = options.Value.AliveThreshold;
     _errorPenaltyPoints    = options.Value.ErrorPenaltyPoints;
     _probe = scopeFactory.CreateScope().ServiceProvider.GetRequiredService <AsterManagerRemote>();
     _probe.ProbeInitiated += ProbeInitiated;
     _probe.ProbeFinished  += ProbeFinished;
     _probe.ProbeErrored   += ProbeErrored;
     _timer          = new Timer(TimeSpan.FromSeconds(options.Value.Interval).TotalMilliseconds);
     _timer.Elapsed += TimerElapsed;
 }
 public void Handle(IDictionary<string, string> context, IProbe probe)
 {
     probe.ReferencesCount++;
     if (context.ContainsKey(this.Subject))
     {
         probe.Trace("{0} - subject: {1} evaluating...", this.GetType().Name, this.Subject);
         int explicitNoneNegatingNegativeCount = 0;
         bool hasExplicitPositiveReferencesForCurrentSubject = false;
         foreach (var condition in Conditions)
         {
             var b = condition.Evaluate(context[this.Subject]);
             probe.Trace("{0} - condidtion {1} evaluated to {2}", this.GetType().Name, condition.GetType().Name, b);
             // if condition matched
             if (b)
             {
                 if (condition.Negate)
                 {
                     probe.Trace("{0} excluded value because condidtion {1} evaluated to true and was negated", this.GetType().Name, condition.GetType().Name, b);
                     probe.Exclude = true;
                     break;
                 }
                 else
                 {
                     probe.ExplicitPositiveReferencesCount++;
                     hasExplicitPositiveReferencesForCurrentSubject = true;
                 }
             }
             // if condition did not match
             else
             {
                 if (condition.Negate)
                 {
                     probe.Trace("{0} - added explicit positive reference, because condidtion {1} evaluated to false and was negated", this.GetType().Name, condition.GetType().Name, b);
                     probe.ExplicitPositiveReferencesCount++;
                     hasExplicitPositiveReferencesForCurrentSubject = true;
                 }
                 else
                 {
                     explicitNoneNegatingNegativeCount++;
                 }
             }
         }
         if (explicitNoneNegatingNegativeCount > 0 && !hasExplicitPositiveReferencesForCurrentSubject)
         {
             probe.Trace("excluded value bacause it has no explicit positive references count and {0} explicit none nagating negative references", explicitNoneNegatingNegativeCount);
             probe.Exclude = true;
         }
     }
 }
Ejemplo n.º 28
0
        public void Check(IProbe probe)
        {
            var timeout = new Timeout(_timeoutMillis);

            while (!probe.IsSatisfied)
            {
                if (timeout.HasTimedOut())
                {
                    Assert.Fail(DescribeFailureOf(probe));
                }
                Thread.Sleep(_pollDelayMillis);

                probe.Sample();
            }
        }
Ejemplo n.º 29
0
            public RatePerSecondView(Telemetry.IProbe counter)
            {
                Requires.NotNull(counter);
                m_counter = counter;
                m_stopwatch.Start();
                m_lastValue = counter.ValueDouble;

                Telemetry.OnReset += (s, e) =>
                {
                    m_stopwatch.Restart();
                    m_lastValue = 0;
                    m_lastTicks = 0;
                    m_result = 0;
                };
            }
Ejemplo n.º 30
0
        public void Check(IProbe probe)
        {
            var timeout = new Timeout(_timeoutMillis);

            while (!probe.IsSatisfied())
            {
                if (timeout.HasTimedOut())
                {
                    throw new AssertErrorException(DescribeFailureOf(probe));
                }

                Thread.Sleep(_pollDelayMillis);
                probe.SampleAsync();
            }
        }
Ejemplo n.º 31
0
        public void Check(IProbe probe)
        {
            var timeout = new Timeout(_timeoutMillis);

            while (!probe.IsSatisfied)
            {
                if (timeout.HasTimedOut())
                {
                    Assert.Fail(DescribeFailureOf(probe));
                }
                Thread.Sleep(_pollDelayMillis);

                probe.Sample();
            }
        }
Ejemplo n.º 32
0
            public AvgView(IProbe one, params IProbe[] others)
            {
                if (one is null)
                {
                    throw new ArgumentNullException(nameof(one));
                }
                if (others is null)
                {
                    throw new ArgumentNullException(nameof(others));
                }

                double d = (1 + others.Length);

                m_f = () => (one.ValueDouble + others.Sum(x => x.ValueDouble)) / d;
            }
Ejemplo n.º 33
0
        public IProbe Create(IProbableElement parent, Point point)
        {
            var me      = parent as IMachineElement;
            var id      = ++_probeCount;
            var factory = Ioc.SimpleIoc <IProbePointTransformerFactory> .GetInstance();

            var    t     = factory.GetTransformer(me);
            var    p     = t.Transform(point, true);
            IProbe probe = null;

            if (t is IProbePointChangableTransformer ct)
            {
                probe = new ProbePointChangableViewModel()
                {
                    ProbeId     = id,
                    Name        = $"Point probe ({id})",
                    Parent      = me,
                    X           = point.X,
                    Y           = point.Y,
                    Z           = point.Z,
                    RelativeX   = p.X,
                    RelativeY   = p.Y,
                    RelativeZ   = p.Z,
                    IsVisible   = true,
                    Transformer = ct
                };
            }
            else
            {
                probe = new PointProbeViewModel()
                {
                    ProbeId   = id,
                    Name      = $"Point probe ({id})",
                    Parent    = me,
                    X         = point.X,
                    Y         = point.Y,
                    Z         = point.Z,
                    RelativeX = p.X,
                    RelativeY = p.Y,
                    RelativeZ = p.Z,
                    IsVisible = true
                };
            }

            me.Children.Add(probe as IMachineElement);

            return(probe);
        }
Ejemplo n.º 34
0
 private string DescribeFailureOf(IProbe probe)
 {
     return "Timeout of " + _timeoutMillis + "ms expired.\n"
         + probe.FailureMessage;
 }
Ejemplo n.º 35
0
 public SelectedProbe(IProbe probe, IEnumerable<ObjectType> objectTypes, ProbeCapabilities capability)
 {
     this.probe = probe;
     this.ObjectTypes = objectTypes;
     this.Capability = capability;
 }