public DataPlavka(DataPlavka _fromDB) //копируем, но создаем массив даюл значений вместо таблицы
 {
     mark = _fromDB.mark;
     GOST = _fromDB.GOST;
     xAll = new List <DataParametr>();
     yAll = new List <DataParametr>();
     x    = new List <int>();
     y    = new List <int>();
     for (int i = 0; i < _fromDB.x.Count; i++)
     {
         x.Add(_fromDB.x[i]);
     }
     for (int i = 0; i < _fromDB.y.Count; i++)
     {
         y.Add(_fromDB.y[i]);
     }
     for (int i = 0; i < _fromDB.xAll.Count; i++)
     {
         xAll.Add(_fromDB.xAll[i]);
     }
     for (int i = 0; i < _fromDB.yAll.Count; i++)
     {
         yAll.Add(_fromDB.yAll[i]);
     }
     data = new double[_fromDB.plavka.Rows.Count, _fromDB.plavka.Columns.Count];
     for (int i = 0; i < _fromDB.plavka.Rows.Count; i++)
     {
         for (int j = 0; j < _fromDB.plavka.Columns.Count; j++)
         {
             data[i, j] = Convert.ToDouble(_fromDB.plavka.Rows[i].ItemArray[j]);
         }
     }
 }
        public DataSelect(TaskConfig w)
        {
            InitializeComponent();
            mainWindow   = w;
            dbConnection = new DBWorker();

            //подключаемся к БД и извлекаем начальную инфу о параметрах и марках стали
            if (dbConnection.isConnected)
            {
                task = new DataPlavka(dbConnection.GetPlavka(DbSelect.Columns, null));
                for (int i = 0; i < task.xAll.Count; i++)
                {
                    xListBox.Items.Add(task.xAll[i].description);
                }
                for (int i = 0; i < task.yAll.Count; i++)
                {
                    yListBox.Items.Add(task.yAll[i].description);
                }

                DataTable dt = dbConnection.GetPlavka(DbSelect.Marks, null);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    markComboBox.Items.Add(dt.Rows[i].ItemArray[0]);
                }

                gostComboBox.IsEnabled = false;
                typeComboBox.IsEnabled = false;
                dbConnection.CloseConnection();
            }
        }
示例#3
0
        private void dataMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (dataWindow == null)
            {
                dataWindow = new DataSelect(this);
            }
            dataWindow.ShowDialog();
            if (dataWindow.IsInitialized)
            {
                if (dataWindow.isChanged)
                {
                    dataWindow.isChanged = false;
                    task                = new DataPlavka(dataWindow.task);
                    Log.Text            = "Загружено " + dataWindow.task.plavka.Rows.Count.ToString() + " записей";
                    labelDataNotes.Text = "Загружено записей: " + dataWindow.task.plavka.Rows.Count.ToString();

                    dataDataGrid.ItemsSource = null;
                    dataDataGrid.ItemsSource = dataWindow.task.plavka.AsDataView();
                    if (dataDataGrid.Columns.Count < 9)
                    {
                        for (int i = 0; i < dataDataGrid.Columns.Count; i++)
                        {
                            dataDataGrid.Columns[i].Width = new DataGridLength(1, DataGridLengthUnitType.Star);
                        }
                    }

                    labelDataX.Content = "Количество исследуемых факторов - " + task.x.Count;
                    labelDataY.Content = "Количество исследуемых свойств - " + task.y.Count;
                    xBoundsData.Clear();
                    for (int i = 0; i < task.x.Count; i++)
                    {
                        xBoundsData.Add(new itemGrid(task.xAll[task.x[i]].description, -1, -1));
                    }
                    xDescrGrid.ItemsSource = xBoundsData;

                    markComboBox.Items.Clear();
                    gostComboBox.Items.Clear();
                    typeComboBox.Items.Clear();
                    typeComboBox.IsEnabled = false;
                    DBWorker  dbConnection = new DBWorker();
                    DataTable dt           = dbConnection.GetPlavka(DbSelect.Marks, null);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        markComboBox.Items.Add(dt.Rows[i].ItemArray[0]);
                    }
                    dbConnection.CloseConnection();

                    string[] temp = task.mark.Split(' ');
                    SetGOST();

                    funcGrid.Visibility     = System.Windows.Visibility.Collapsed;
                    statGrid.Visibility     = System.Windows.Visibility.Collapsed;
                    groupBoxBefore.Header   = "Начальные границы";
                    groupBoxAfter.Header    = "Дискретная модель";
                    dataExpander.IsExpanded = true;
                }
            }
        }
 public DescretOptTask(DataPlavka _task, DescrModel _model, int _numOfIntervals, int _degree, int _shift, double _eps)
 {
     task = _task;
     model = _model;
     numOfIntervals = _numOfIntervals;
         degree = _degree;
         shift = _shift;
         eps = _eps;
 }
示例#5
0
 public DescretOptTask(DataPlavka _task, DescrModel _model, int _numOfIntervals, int _degree, int _shift, double _eps)
 {
     task           = _task;
     model          = _model;
     numOfIntervals = _numOfIntervals;
     degree         = _degree;
     shift          = _shift;
     eps            = _eps;
 }
 public GostHelper()
 {
     InitializeComponent();
     DBWorker dbConnection = new DBWorker();
     task = new DataPlavka(dbConnection.GetPlavka(DbSelect.Columns, null));
     for (int i = 0; i < task.yAll.Count; i++)
         List.Add(new itemGrid(task.yAll[i].description, -1, -1));
     dbConnection.CloseConnection();
     gridGOST.ItemsSource = List;
 }
示例#7
0
        public GostHelper()
        {
            InitializeComponent();
            DBWorker dbConnection = new DBWorker();

            task = new DataPlavka(dbConnection.GetPlavka(DbSelect.Columns, null));
            for (int i = 0; i < task.yAll.Count; i++)
            {
                List.Add(new itemGrid(task.yAll[i].description, -1, -1));
            }
            dbConnection.CloseConnection();
            gridGOST.ItemsSource = List;
        }
        public int InsertModel(DataPlavka task, RegressionModel model)
        {
            OracleCommand cmd    = thisConnection.CreateCommand();
            int           ste_id = GetSTE_ID(model.mark, model.GOST);

            try
            {
                for (int j = 0; j < model.y.Count; j++)
                {
                    string names = "ID,Y_ID,STE_ID,";
                    if (model.isUpgraded)
                    {
                        for (int i = 0; i < task.x.Count; i++)
                        {
                            names += task.xAll[task.x[i]].name + "_F,";
                        }
                    }
                    for (int i = 0; i < task.x.Count; i++)
                    {
                        names += task.xAll[task.x[i]].name + ",";
                    }
                    names += "A,RMSERROR,FISHER,FISHER_VAL,DATE_REG";
                    string values = model.id.ToString() + "," + model.y[j].ToString() + "," + ste_id.ToString() + ",";
                    if (model.isUpgraded)
                    {
                        for (int i = 0; i < task.x.Count; i++)
                        {
                            values += model.typesF[i].ToString() + ",";
                        }
                    }
                    for (int i = 0; i < model.equation[j].weights.Length; i++)
                    {
                        values +=
                            (Math.Round(model.equation[j].weights[i], 15)).ToString(CultureInfo.InvariantCulture) + ",";// и свободный ЧЛЕН
                    }
                    values         += model.equation[j].rmserror.ToString(CultureInfo.InvariantCulture) + "," + model.equation[j].F.ToString(CultureInfo.InvariantCulture) + "," + Math.Round(model.equation[j].F_test, 15).ToString(CultureInfo.InvariantCulture);
                    values         += ", to_date('" + DateTime.Now.Date.ToShortDateString() + "', 'dd/mm/yyyy')";
                    cmd.CommandText = "INSERT INTO regression_models (" + names + ") values (" + values + ")";
                    cmd.ExecuteReader();
                }
            }
            catch
            {
                return(-1);
            }
            return(1);
        }
示例#9
0
 //копируем, но создаем массив даюл значений вместо таблицы
 public DataPlavka(DataPlavka _fromDB)
 {
     mark = _fromDB.mark;
     GOST = _fromDB.GOST;
     xAll = new List<DataParametr>();
     yAll = new List<DataParametr>();
     x = new List<int>();
     y = new List<int>();
     for (int i = 0; i < _fromDB.x.Count; i++) x.Add(_fromDB.x[i]);
     for (int i = 0; i < _fromDB.y.Count; i++) y.Add(_fromDB.y[i]);
     for (int i = 0; i < _fromDB.xAll.Count; i++) xAll.Add(_fromDB.xAll[i]);
     for (int i = 0; i < _fromDB.yAll.Count; i++) yAll.Add(_fromDB.yAll[i]);
     data = new double[_fromDB.plavka.Rows.Count, _fromDB.plavka.Columns.Count];
     for (int i = 0; i < _fromDB.plavka.Rows.Count; i++)
         for (int j = 0; j < _fromDB.plavka.Columns.Count; j++)
             data[i, j] = Convert.ToDouble(_fromDB.plavka.Rows[i].ItemArray[j]);
 }
示例#10
0
        public int InsertModel(DataPlavka task, DescrModel model)
        {
            OracleCommand cmd    = thisConnection.CreateCommand();
            int           ste_id = GetSTE_ID(model.mark, model.GOST);

            try
            {
                string names = "ID,STE_ID,ALPHA,BETA,U,YS,DATE_DES";
                for (int i = 0; i < model.x.Count; i++)
                {
                    names += "," + task.xAll[model.x[i]].name + "_MIN";
                }
                for (int i = 0; i < model.x.Count; i++)
                {
                    names += "," + task.xAll[model.x[i]].name;
                }

                string values = model.id.ToString() + "," + ste_id.ToString() + "," + model.alpha.ToString(CultureInfo.InvariantCulture) + ","
                                + model.beta.ToString(CultureInfo.InvariantCulture) + "," + model.criteria.ToString(CultureInfo.InvariantCulture) + ",";
                string ys = model.y[0].ToString();
                for (int w = 1; w < model.y.Count; w++)
                {
                    ys += "@" + model.y[w];
                }
                values += "'" + ys + "',";
                values += " to_date('" + DateTime.Now.Date.ToShortDateString() + "', 'dd/mm/yyyy')";

                for (int i = 0; i < task.x.Count; i++)
                {
                    values += "," + model.xBounds[i].lower.ToString(CultureInfo.InvariantCulture);
                }
                for (int i = 0; i < task.x.Count; i++)
                {
                    values += "," + model.xBounds[i].upper.ToString(CultureInfo.InvariantCulture);
                }

                cmd.CommandText = "INSERT INTO descret_models (" + names + ") values (" + values + ")";
                cmd.ExecuteReader();
            }
            catch
            {
                return(-1);
            }
            return(1);
        }
示例#11
0
        public int InsertModel(DataPlavka task, Technology technology)
        {
            OracleCommand cmd    = thisConnection.CreateCommand();
            int           ste_id = GetSTE_ID(technology.mark, technology.GOST);

            try
            {
                string names = "ID,STE_ID,REG_ID,DES_ID,DATE_TECH,BASE_ID,RMSERROR";
                for (int i = 0; i < task.x.Count; i++)
                {
                    names += "," + task.xAll[task.x[i]].name;
                }
                for (int i = 0; i < task.y.Count; i++)
                {
                    names += "," + task.yAll[task.y[i]].name;
                }
                string values = technology.id.ToString() + "," + ste_id.ToString() + "," + technology.regressID.ToString() + "," +
                                technology.descretID.ToString() + ", to_date('" + DateTime.Now.Date.ToShortDateString() + "', 'dd/mm/yyyy')," +
                                technology.baseTechnologyID.ToString() + "," + Math.Round(technology.rmserror, 15).ToString(CultureInfo.InvariantCulture);

                for (int i = 0; i < task.x.Count; i++)
                {
                    values += "," + technology.xOpt[i].ToString(CultureInfo.InvariantCulture);
                }
                for (int i = 0; i < task.y.Count; i++)
                {
                    values += "," + technology.yOpt[i].ToString(CultureInfo.InvariantCulture);
                }

                cmd.CommandText = "INSERT INTO technology (" + names + ") values (" + values + ")";
                cmd.ExecuteReader();
            }
            catch
            {
                return(-1);
            }
            return(1);
        }
        public DataSelect(TaskConfig w)
        {
            InitializeComponent();
            mainWindow = w;
            dbConnection = new DBWorker();

            //подключаемся к БД и извлекаем начальную инфу о параметрах и марках стали
            if (dbConnection.isConnected)
            {
                task = new DataPlavka(dbConnection.GetPlavka(DbSelect.Columns, null));
                for (int i = 0; i < task.xAll.Count; i++)
                        xListBox.Items.Add(task.xAll[i].description);
                for (int i = 0; i < task.yAll.Count; i++)
                    yListBox.Items.Add(task.yAll[i].description);

                DataTable dt = dbConnection.GetPlavka(DbSelect.Marks, null);
                for (int i = 0; i < dt.Rows.Count; i++)
                    markComboBox.Items.Add(dt.Rows[i].ItemArray[0]);

                gostComboBox.IsEnabled = false;
                typeComboBox.IsEnabled = false;
                dbConnection.CloseConnection();
            }
        }
        private void dataMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (dataWindow == null) dataWindow = new DataSelect(this);
            dataWindow.ShowDialog();
            if (dataWindow.IsInitialized)
                if (dataWindow.isChanged)
                {
                    dataWindow.isChanged =false;
                    task = new DataPlavka(dataWindow.task);
                    Log.Text = "Загружено " + dataWindow.task.plavka.Rows.Count.ToString() + " записей";
                    labelDataNotes.Text = "Загружено записей: " + dataWindow.task.plavka.Rows.Count.ToString();

                    dataDataGrid.ItemsSource = null;
                    dataDataGrid.ItemsSource = dataWindow.task.plavka.AsDataView();
                    if (dataDataGrid.Columns.Count < 9)
                        for (int i = 0; i < dataDataGrid.Columns.Count; i++)
                            dataDataGrid.Columns[i].Width = new DataGridLength(1, DataGridLengthUnitType.Star);

                    labelDataX.Content = "Количество исследуемых факторов - " + task.x.Count;
                    labelDataY.Content = "Количество исследуемых свойств - " + task.y.Count;
                    xBoundsData.Clear();
                    for(int i=0; i<task.x.Count; i++)
                        xBoundsData.Add(new itemGrid(task.xAll[task.x[i]].description, -1, -1));
                    xDescrGrid.ItemsSource = xBoundsData;

                    markComboBox.Items.Clear();
                    gostComboBox.Items.Clear();
                    typeComboBox.Items.Clear();
                    typeComboBox.IsEnabled = false;
                    DBWorker dbConnection = new DBWorker();
                    DataTable dt = dbConnection.GetPlavka(DbSelect.Marks, null);
                    for (int i = 0; i < dt.Rows.Count; i++)
                        markComboBox.Items.Add(dt.Rows[i].ItemArray[0]);
                    dbConnection.CloseConnection();

                    string[] temp = task.mark.Split(' ');
                    SetGOST();

                    funcGrid.Visibility = System.Windows.Visibility.Collapsed;
                    statGrid.Visibility = System.Windows.Visibility.Collapsed;
                    groupBoxBefore.Header = "Начальные границы";
                    groupBoxAfter.Header = "Дискретная модель";
                    dataExpander.IsExpanded = true;
                }
        }