Ejemplo n.º 1
0
 public static ConstantThreshold GetInstance()
 {
     if (_Instance == null)
     {
         _Instance = new ConstantThreshold();
     }
     return(_Instance);
 }
Ejemplo n.º 2
0
        public DetectionResult DetermineCancerOrWarningOrHealthy(out int Range, out DangerLevel DangerLevel, List <double> Currents, double[] Voltages, int IndexOfMax, Spec spec, int index)
        {
            DangerLevel = DangerLevel.free;

            DetectionResult Res = DetectionResult.Warning;

            Range = 100;

            var MaxValue = Currents[IndexOfMax];

            spec.MaxVoltage = Voltages[IndexOfMax];

            spec.voltageDelta1 = spec.MaxVoltage;
            double MinimumCurrentBeforeMax = 1000000;
            double MinimumCurrentAfterMax  = 1000000;

            //  spec =new Spec();
            spec.delta1 = 0;
            spec.delta2 = 0;

            for (int i = IndexOfMax; i > 0; i--)
            {
                if (MinimumCurrentBeforeMax > Currents[i])
                {
                    MinimumCurrentBeforeMax = Currents[i];
                }
                if (Voltages[i] < 0)
                {
                    break;
                }
            }

            for (int i = IndexOfMax; i < Currents.Count; i++)
            {
                if (MinimumCurrentAfterMax > Currents[i])
                {
                    MinimumCurrentAfterMax = Currents[i];
                    spec.voltageDelta2     = Voltages[i];
                }

                if (Voltages[i] > Voltages[i + 1])
                {
                    break;
                }
            }


            double DeltaCurrent1 = MaxValue;
            double DeltaCurrent2 = MaxValue - MinimumCurrentAfterMax;

            spec.delta1 = DeltaCurrent1;
            spec.delta2 = DeltaCurrent2;

            var Threshold = ConstantThreshold.GetInstance();

            double percent;
            var    dangerLavel = GetDangerLevel(spec.delta1, spec.delta2, out percent, index);


            spec.DangerLevel = dangerLavel;

            switch (dangerLavel)
            {
            case DangerLevel.free:
            case DangerLevel.free_warning:
                Res = DetectionResult.Healthy;
                break;

            case DangerLevel.danger:
                Res = DetectionResult.Cancer;
                break;


            case DangerLevel.warning:
            case DangerLevel.warning_danger:
                Res = DetectionResult.Warning;
                break;
            }


            return(Res);
        }