Exemple #1
0
        private void Analyse(string errorNumber, string reason, string parameter)
        {
            int parameterID = XMLWork.FindID(parameter);

            if (parameterID == 0)
            {
                analyseListBox.Items.Add(Localisation.GetInstance().Language.Equals("RU") ? "По данной ошибке нет параметра." : "There is no parameter for this error.");
            }
            else
            {
                foreach (OneRow row in TrainData.Train)
                {
                    // TODO: Propose Misha to do public static collection with main optimal parametrs of line
                    // Use normal params, and non magic
                    if (parameter.Equals("OPC_ABZ12_XT_K02"))
                    {
                        if (!(row.Input[66] > 60m && row.Input[66] < 80m))
                        {
                            analyseListBox.Items.Add(Localisation.GetInstance().Language.Equals("RU") ? "====> Ошибка!" : "====> Error!");
                            //findingErrorsDataGridView.Rows.Add(new String[] { errorNumber, reason, parameter, row.Date.TimeOfDay.ToString() });
                            return;
                        }
                    }
                    else if (parameter.Equals("OPC_ABZ36_XT_K02"))
                    {
                        if (!(row.Input[69] > 70m && row.Input[69] < 90m))
                        {
                            analyseListBox.Items.Add(Localisation.GetInstance().Language.Equals("RU") ? "====> Ошибка!" : "====> Error!");
                            //findingErrorsDataGridView.Rows.Add(new String[] { errorNumber, reason, parameter, row.Date.TimeOfDay.ToString() });
                            return;
                        }
                    }
                    else
                    {
                        if (!(row.Input[parameterID] > 10.0m && row.Input[parameterID] < 40.0m))
                        {
                            analyseListBox.Items.Add(Localisation.GetInstance().Language.Equals("RU") ? "====> Ошибка!" : "====> Error!");
                            //findingErrorsDataGridView.Rows.Add(new String[] { errorNumber, reason, parameter, row.Date.TimeOfDay.ToString()});
                            return;
                        }
                    }
                }
            }
            analyseListBox.Items.Add(Localisation.GetInstance().Language.Equals("RU") ? "Ошибки не обнаружено" : "No errors found");
            analyseListBox.Items.Add("");
        }
        public RegressionModelEquation GetRegressionModelById(int id)
        {
            string getSql = "Select RegressionModels.Id, RegressionModels.OutputParamId, OutputParams.InternalName, RegressionModels.CreationDate, RegressionModels.Name, RegressionModels.rmse, RegressionModels.NormalizeValues from RegressionModels INNER JOIN OutputParams on OutputParams.ID = RegressionModels.OutputParamId where RegressionModels.Id = @Id";
            var    reader = GetCommand(getSql, new Dictionary <string, object> {
                { "Id", id }
            });
            int      modelId, outputParamId;
            DateTime creationDate;
            string   name;
            double   rmse;
            bool     normalizeValues;

            if (reader.Read())
            {
                modelId         = Convert.ToInt32(reader["Id"].ToString());
                outputParamId   = XMLWork.FindID(reader["InternalName"].ToString());
                creationDate    = DateTime.FromOADate(Convert.ToDouble(reader["CreationDate"].ToString()));
                name            = reader["Name"].ToString();
                rmse            = Convert.ToDouble(reader["rmse"].ToString());
                normalizeValues = Convert.ToInt32(reader["NormalizeValues"].ToString()) == 1;
                reader.Close();
            }
            else
            {
                return(null);
            }

            string getParamsSql =
                "Select ParamId, InternalName, Coefficient, UpperBound, LowerBound from RegressionModelParameters LEFT OUTER JOIN InputParams on InputParams.ID = RegressionModelParameters.ParamId where ModelId = @ModelId";
            var paramsReader = GetCommand(getParamsSql, new Dictionary <string, object> {
                { "ModelId", modelId }
            });
            List <RegressionModelEquation.ModelParameter> inputParameters = new List <RegressionModelEquation.ModelParameter>();

            if (paramsReader.HasRows)
            {
                while (paramsReader.Read())
                {
                    int?paramId;
                    if (paramsReader["InternalName"] is DBNull)
                    {
                        paramId = null;
                    }
                    else
                    {
                        paramId = XMLWork.FindID(paramsReader["InternalName"].ToString());
                    }
                    double coefficient = Convert.ToDouble(paramsReader["Coefficient"].ToString());
                    double?lowerBound, upperBound;
                    if (paramsReader["LowerBound"] is DBNull)
                    {
                        lowerBound = null;
                    }
                    else
                    {
                        lowerBound = Convert.ToDouble(paramsReader["LowerBound"].ToString());
                    }
                    if (paramsReader["UpperBound"] is DBNull)
                    {
                        upperBound = null;
                    }
                    else
                    {
                        upperBound = Convert.ToDouble(paramsReader["UpperBound"].ToString());
                    }
                    inputParameters.Add(new RegressionModelEquation.ModelParameter
                    {
                        Id = paramId, Coefficient = coefficient, LowerBound = lowerBound, UpperBound = upperBound
                    });
                }
            }
            else
            {
                return(null);
            }

            return(new RegressionModelEquation(modelId, name, creationDate, rmse, outputParamId, inputParameters, normalizeValues));
        }