예제 #1
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            var Threshold = ThresholdConfigs.GetInstance();
            var t1        = marginUserControl1.GetUserControl();
            var t2        = marginUserControl2.GetUserControl();
            var t3        = marginUserControl3.GetUserControl();
            var t4        = marginUserControl4.GetUserControl();
            var t5        = marginUserControl5.GetUserControl();

            Threshold.Elements = new List <ThresholdElement>();
            Threshold.Elements.Add(t1);
            Threshold.Elements.Add(t2);
            Threshold.Elements.Add(t3);
            Threshold.Elements.Add(t4);
            Threshold.Elements.Add(t5);
            Threshold.AppName = ApplicationName.Text;


            if (Parent != null)
            {
                Parent.SetTextbox1("NBEL Cancer  Diagnosis Prob " + Threshold.AppName);
            }

            Threshold.SaveConfigs();


            MessageBox.Show("OK");
        }
예제 #2
0
        private void marginUserControl1_Load(object sender, EventArgs e)
        {
            var Threshold = ThresholdConfigs.GetInstance();

            ApplicationName.Text = Threshold.AppName;

            marginUserControl1.SetUserControl(Threshold.Elements[0], new SoundPlayer(Properties.Resources.Healthy));
            marginUserControl2.SetUserControl(Threshold.Elements[1], new SoundPlayer(Properties.Resources.Free_Warning));
            marginUserControl3.SetUserControl(Threshold.Elements[2], new SoundPlayer(Properties.Resources.warning));
            marginUserControl4.SetUserControl(Threshold.Elements[3], new SoundPlayer(Properties.Resources.warning_Danger));
            marginUserControl5.SetUserControl(Threshold.Elements[4], new SoundPlayer(Properties.Resources.Cancer));
        }
예제 #3
0
        public DangerLevel GetDangerLevel(double delta1, double delta2, out double Percent, int index)
        {
            //ThresholdConfigs.GetInstance();

            //int index = GetIndex();

            Percent = 0;
            var threshold = ThresholdConfigs.GetInstance().Elements;

            Percent = delta2;
            Percent = (Percent * 100 / threshold[4].ThresholdValue[index]);

            //if(delta2>delta1+1)
            //{
            //    return DangerLevel.noisy;
            //}


            if (delta2 < threshold[0].ThresholdValue[index])
            {
                return(DangerLevel.free);
            }

            if (delta2 < threshold[1].ThresholdValue[index])
            {
                return(DangerLevel.free_warning);
            }

            if (delta2 < threshold[2].ThresholdValue[index])
            {
                return(DangerLevel.warning);
            }

            if (delta2 < threshold[3].ThresholdValue[index])
            {
                return(DangerLevel.warning_danger);
            }

            if (delta2 < threshold[4].ThresholdValue[index])
            {
                return(DangerLevel.danger);
            }


            return(DangerLevel.danger);


            /*
             * Percent = 0;
             * var threshold=ConstantThreshold.GetInstance();
             *
             * Percent = delta2;
             *
             * if (delta2 < threshold.SecondFree)
             *  return DangerLevel.free;
             *
             * if (delta2 < threshold.FirstWarning)
             *  return DangerLevel.free_warning;
             *
             * if (delta2 < threshold.SecondWarning)
             *  return DangerLevel.warning;
             *
             * if (delta2 < threshold.FirstDanger)
             *  return DangerLevel.warning_danger;
             *
             * if (delta2 < threshold.SecondDanger)
             *  return DangerLevel.danger;
             *
             * Percent = threshold.SecondDanger;
             * return DangerLevel.danger;
             */

            /*
             * double onPartPercent = 100 / (int)DangerLevel.totalCount;
             *
             * if (delta1 < threshold.firstWarningThreshold)
             * {
             *  Percent = (((int)DangerLevel.free) + delta1 / threshold.firstWarningThreshold) * onPartPercent;
             *  return DangerLevel.free;
             * }
             *
             *
             * if(delta1<threshold.firstCancerThreshold)
             * {
             *  if(delta2<threshold.verylowsuspecious1)
             *  {
             *      Percent = ((int)DangerLevel.free + delta2 / threshold.verylowsuspecious1)*onPartPercent ;
             *      return DangerLevel.free;
             *  }
             *  if(delta2<threshold.lowsuspecious1)
             *  {
             *      Percent = (int)DangerLevel.verylowsuspecious + (delta2 - threshold.verylowsuspecious1) / (threshold.lowsuspecious1 - threshold.verylowsuspecious1);
             *      Percent=Percent*onPartPercent;
             *      return DangerLevel.verylowsuspecious;
             *  }
             *  if (delta2 < threshold.suspecious1)
             *  {
             *      Percent = (int)DangerLevel.lowsuspecious + (delta2 - threshold.lowsuspecious1) / (threshold.suspecious1 - threshold.lowsuspecious1);
             *      Percent = Percent * onPartPercent;
             *      return DangerLevel.lowsuspecious;
             *  }
             *
             *
             *      Percent = (int)DangerLevel.suspecious + (delta2 - threshold.suspecious1) / (threshold.firstCancerThreshold - threshold.suspecious1);
             *      if (Percent > (int)DangerLevel.dangerlow)
             *          Percent = (int)DangerLevel.dangerlow;
             *      Percent = Percent * onPartPercent;
             *      return DangerLevel.suspecious;
             *
             *
             *
             * }
             *
             * if(delta1>threshold.firstCancerThreshold)
             * {
             *  if (delta2 < threshold.verylowsuspecious2)
             *  {
             *      Percent = ((int)DangerLevel.free + delta2 / threshold.verylowsuspecious2) * onPartPercent;
             *      return DangerLevel.free;
             *  }
             *  if (delta2 < threshold.lowsuspecious2)
             *  {
             *      Percent = (int)DangerLevel.verylowsuspecious + (delta2 - threshold.verylowsuspecious2) / (threshold.lowsuspecious2 - threshold.verylowsuspecious2);
             *      Percent = Percent * onPartPercent;
             *      return DangerLevel.verylowsuspecious;
             *  }
             *  if (delta2 < threshold.suspecious2)
             *  {
             *      Percent = (int)DangerLevel.lowsuspecious + (delta2 - threshold.lowsuspecious2) / (threshold.suspecious2 - threshold.lowsuspecious2);
             *      Percent = Percent * onPartPercent;
             *      return DangerLevel.lowsuspecious;
             *  }
             *
             *  if (delta2 < threshold.dangerlow)
             *  {
             *      Percent = (int)DangerLevel.suspecious + (delta2 - threshold.suspecious2) / (threshold.dangerlow - threshold.suspecious2);
             *      Percent = Percent * onPartPercent;
             *      return DangerLevel.suspecious;
             *  }
             *
             *  if (delta2 < threshold.dangermedium)
             *  {
             *      Percent = (int)DangerLevel.dangerlow + (delta2 - threshold.dangerlow) / (threshold.dangermedium - threshold.dangerlow);
             *      Percent = Percent * onPartPercent;
             *      return DangerLevel.dangerlow;
             *  }
             *
             *  if (delta2 < threshold.dangerhigh)
             *  {
             *      Percent = (int)DangerLevel.dangermedium + (delta2 - threshold.dangermedium) / (threshold.dangerhigh - threshold.dangermedium);
             *      Percent = Percent * onPartPercent;
             *      return DangerLevel.dangermedium;
             *  }
             *
             *  Percent = (int)DangerLevel.dangerhigh + (delta2 - threshold.dangerhigh) / (200 - threshold.dangerhigh);
             *  Percent = Percent * onPartPercent;
             *
             *  if (Percent > 100)
             *      Percent = 100;
             *  return DangerLevel.dangerhigh;
             *
             * }
             *
             *
             */


            //       return DangerLevel.free;
        }
예제 #4
0
        public static void WriteDeltaToJpeg(string filePath, Spec spec, int index, int pos = 0)
        {
            try
            {
                var Tr = ThresholdConfigs.GetInstance();
                //   var index = GetIndex();

                Bitmap bitmap = null;
                using (var stream = File.OpenRead(filePath))
                {
                    bitmap = (Bitmap)Bitmap.FromStream(stream);
                }

                double percent  = 0;
                int    position = pos;
                //     string level = spec.result;
                //if (DR != (DetectionResult)0)
                //{
                //    position=300;

                //}

                var msg = string.Empty;
                if (spec.IsSaturated)
                {
                    msg = "saturated";
                }
                else
                if (spec.IsNoisy)
                {
                    msg = "noisy";
                }
                else if (spec.NoPeakDetected)
                {
                    msg = "noPeakDetected";
                }

                else
                {
                    var level = ProcessUnit.GetInstnace().GetDangerLevel(spec.delta1, spec.delta2, out percent, index);


                    if (((int)level) > -1 && level != DangerLevel.saturation)
                    {
                        msg = Tr.Elements[(int)level].ThresholdName[index];
                    }
                }

                //   Tr.Elements[(int)DangerLevel]
                using (bitmap)
                    using (var graphics = Graphics.FromImage(bitmap))
                        using (var font = new Font("Arial", 15, FontStyle.Regular))
                        {
                            String S = "ScanRate:" + spec.scanRate.ToString("####.##");
                            S += " Delta1:" + spec.delta1.ToString("0.##");
                            S += " Delta2:" + spec.delta2.ToString("0.##");
                            S += "\nMaxVoltage:" + spec.MaxVoltage.ToString("0.##");
                            S += " Voltage1:" + spec.voltageDelta1.ToString("0.##");
                            S += " Voltage2:" + spec.voltageDelta2.ToString("0.##");
                            S += "\nDangerLevel:" + msg;
                            S += "\nPercent:" + percent.ToString("0.##");
                            S += "\nSNR:" + spec.SNR.ToString("0.##");

                            graphics.DrawString(S, font, Brushes.Black, 0, position);

                            //graphics.DrawString("ScanRate:" + scanrate.ToString("####.##"), font, Brushes.Red, 0, 0);
                            // graphics.DrawString("Delta1:" + spec.delta1.ToString("####.##"), font, Brushes.Red, 0, 80);
                            //  graphics.DrawString("Delta2:" + spec.delta2.ToString("####.##"), font, Brushes.Red, 0, 160);
                            //   graphics.DrawString("DangerLevel:" + level, font, Brushes.Red, 0, 240);
                            // Important part!
                            bitmap.Save(filePath);
                        }
            }
            catch (Exception ex)
            {
            }
        }