Ejemplo n.º 1
0
        public static List <ResultDiagnostics> CalculShaft(Machine machine)
        {
            List <ResultDiagnostics> results = new List <ResultDiagnostics>();
            ResultDiagnostics        result  = new ResultDiagnostics();
            FL     fl       = model.FL.Get();            // выгрузили данные с файла
            double maxShaft = 0;
            double fiftyHz  = 0;                         // значение при 50Гц
            List <Tuple <double, double> > list = fl.fl; // получаем герцы и значение
            var f = list[0].Item2;

            fiftyHz = list.FirstOrDefault(x => x.Item1 == 50).Item2;
            foreach (KTS item in machine.Shaft)
            {
                var flShaft = list.Where(x => x.Item1 > item.beginp);
                flShaft = flShaft.Where(x => x.Item1 < item.endp);
                List <double> listSort = new List <double>();
                listSort.AddRange(flShaft.Select(x => x.Item2));
                for (int i = 0; i < listSort.Count(); i++)
                {
                    if (((listSort[i] / fiftyHz) * item.a + item.b) > maxShaft)
                    {
                        maxShaft = ((listSort[i] / fiftyHz) * item.a + item.b);
                    }
                }
                result.file  = fl.FileName;
                result.a     = item.a;
                result.b     = item.b;
                result.begin = item.beginp;
                result.end   = item.endp;
                result.value = maxShaft;
                if (maxShaft <= machine.typestatus.nicely)
                {
                    result.level = "Дефектов не обнаружено!";
                }
                else if ((maxShaft <= machine.typestatus.acceptably) && (maxShaft > machine.typestatus.nicely))
                {
                    result.level = "Слабый";
                }
                else if ((maxShaft <= machine.typestatus.limited) && (maxShaft > machine.typestatus.acceptably) && (maxShaft > machine.typestatus.nicely))
                {
                    result.level = "Средний";
                }
                else
                {
                    result.level = "Сильный";
                }
                results.Add(result);
            }
            return(results);
        }
        public void Add(Machine machine, ResultDiagnostics result)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            string sql = "call AddEngineResult(" +
                         "\'" + result.file + "\'," + result.value.ToString() + ",\'" + result.level + "\',\'" + result.date.ToString("yyyy-MM-dd HH:mm:ss") + "\',"
                         + machine.ID + ");";
            MySqlCommand cmd = new MySqlCommand();

            using (MySqlConnection conn = DBUtils.GetDBConnection())
            {
                try
                {
                    conn.Open();
                    cmd.Connection  = conn;
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Ejemplo n.º 3
0
        public static List <ResultDiagnostics> CalculEngine(Machine machine)
        {
            List <ResultDiagnostics> results = new List <ResultDiagnostics>();
            ResultDiagnostics        result  = new ResultDiagnostics();
            FL     fl         = model.FL.Get();          // выгрузили данные с файла
            double averEngine = 0;
            double fiftyHz    = 0;                       // значение при 50Гц
            List <Tuple <double, double> > list = fl.fl; // получаем герцы и значение
            var f = list[0].Item2;

            fiftyHz = list.FirstOrDefault(x => x.Item1 == 50).Item2;
            foreach (KTS item in machine.Engine)
            {
                var flEngine = list.Where(x => x.Item1 > item.beginp);
                flEngine = flEngine.Where(x => x.Item1 < item.endp);
                List <double> listSort = new List <double>();
                listSort.AddRange(flEngine.Select(x => x.Item2));
                averEngine   = listSort.Average() / fiftyHz;
                result.file  = fl.FileName;
                result.a     = item.a;
                result.b     = item.b;
                result.begin = item.beginp;
                result.end   = item.endp;
                result.value = averEngine;
                if (averEngine > 0.7)
                {
                    result.level = "Да";
                }
                else
                {
                    result.level = "Нет";
                }
                results.Add(result);
            }
            return(results);
        }