private void InitializeInputParametersTable() { using (var cmd = Connection.CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = "select ID from InputParams"; var reader = cmd.ExecuteReader(); if (reader.HasRows) { return; } } var inputParams = TrainData.nameParameter.Values.Where(o => o.StartsWith("OPC")); RemoveAllFromTable("InputParams"); using (var cmd = Connection.CreateCommand()) { cmd.CommandType = CommandType.Text; StringBuilder insertCommand = new StringBuilder("Insert into InputParams (ID, InternalName, RussianName, EnglishName) VALUES "); int counter = 0; foreach (var inputParam in inputParams) { insertCommand.Append( $"(@ID{counter}, @InternalName{counter}, @RussianName{counter}, @EnglishName{counter}), "); cmd.Parameters.AddWithValue($"ID{counter}", counter); cmd.Parameters.AddWithValue($"InternalName{counter}", inputParam); cmd.Parameters.AddWithValue($"RussianName{counter}", XMLWork.FindNameWithScada(inputParam, "ru-RU")); cmd.Parameters.AddWithValue($"EnglishName{counter}", XMLWork.FindNameWithScada(inputParam, "en-US")); counter++; } insertCommand.Remove(insertCommand.Length - 2, 2); cmd.CommandText = insertCommand.ToString(); var i = cmd.ExecuteNonQuery(); } }
private void Shortest_Tree(TreeNode test_tree, List <IndexVertex> vertex, int index) { int numberTrue = 0; int numberFalse = 0; if (test_tree.attribute.values != null) { for (int i = 0; i < test_tree.attribute.values.Count; i++) { TreeNode childNode = test_tree.getChildByBranchName(test_tree.attribute.values[i]); if (childNode.attributeName == "False") { numberFalse++; } else if (childNode.attributeName == "True") { numberTrue++; } else { vertex.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.DarkRed)); int number = vertex.Count; Shortest_Tree(childNode, vertex, number - 1); } if ((numberTrue <= 1) && (numberFalse <= 1)) { vertex.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.DeepPink)); int number = vertex.Count; Shortest_Tree(childNode, vertex, number - 1); } } } }
private void PrintNode_group(DM.DecisionTree.TreeNode test_tree, List <IndexVertex> vertex, int index, string groupParamName) { if (test_tree.attribute.values != null) { for (int i = 0; i < test_tree.attribute.values.Count; i++) { TreeNode childNode = test_tree.getChildByBranchName(test_tree.attribute.values[i]); if (childNode.attributeName != groupParamName) { vertex.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.DarkOrange)); int number = vertex.Count; PrintNode_group(childNode, vertex, number - 1, groupParamName); } } } }
private void Shortest_TreeGroup(TreeNode test_tree, List <IndexVertex> vertex, int index, string groupParamName) { int numberTrue = 0; int numberFalse = 0; if (test_tree.attribute.values != null) { for (int i = 0; i < test_tree.attribute.values.Count; i++) { TreeNode childNode = test_tree.getChildByBranchName(test_tree.attribute.values[i]); if (childNode.attributeName != groupParamName) { if (childNode.attributeName == "False") { numberFalse++; } else if (childNode.attributeName == "True") { numberTrue++; } else { vertex.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.Gold)); int number = vertex.Count; Shortest_TreeGroup(childNode, vertex, number - 1, groupParamName); } if ((numberTrue == 1) && (childNode.attributeName == "True")) { vertex.Add(new IndexVertex(childNode.attributeName + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.Goldenrod)); int number = vertex.Count; Shortest_TreeGroup(childNode, vertex, number - 1, groupParamName); } else if ((numberFalse == 1) && (childNode.attributeName == "False")) { vertex.Add(new IndexVertex(childNode.attributeName + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.Lime)); int number = vertex.Count; Shortest_TreeGroup(childNode, vertex, number - 1, groupParamName); } } } } }
private void PrintNode_Color(TreeNode test_tree, List <IndexVertex> vertex, int index, string groupParamName, OneRow test_item, int deep) { if (test_tree.attribute.values != null) { for (int i = 0; i < test_tree.attribute.values.Count; i++) { if (test_tree.attribute.AttributeName != -1) { newValue = test_item.Input[test_tree.attribute.AttributeName]; } if ((newValue >= test_tree.attribute.values[i].Item1) && (newValue <= test_tree.attribute.values[i].Item2) && (deep == current_deep)) { TreeNode childNode = test_tree.getChildByBranchName(test_tree.attribute.values[i]); if (childNode.attributeName != groupParamName) { vertex.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.Yellow)); int number = vertex.Count; current_deep++; PrintNode_Color(childNode, vertex, number - 1, groupParamName, test_item, deep + 1); current_deep--; } } else { TreeNode childNode = test_tree.getChildByBranchName(test_tree.attribute.values[i]); if (childNode.attributeName != groupParamName) { vertex.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.White)); int number = vertex.Count; current_deep++; PrintNode_Color(childNode, vertex, number - 1, groupParamName, test_item, deep); current_deep--; } } } } }
public GraphControl(bool v_neuro, int caseNumb, object test_value, string groupParam, object test_item, string language) { this.language = language; TreeNode test_tree = (TreeNode)test_value; Graph = new PocGraph(true); List <IndexVertex> currentVerices = new List <IndexVertex>(); switch (caseNumb) { case 1: { #region Full_tree+group currentVerices.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language), -1, null, Brushes.Yellow)); // PrintNode(test_tree, currentVerices, 0); PrintNode_group(test_tree, currentVerices, 0, groupParam); foreach (IndexVertex vertex in currentVerices) { Graph.AddVertex(vertex.vertex); } for (int i = 1; i < currentVerices.Count; i++) { AddNewGraphEdge(currentVerices[currentVerices[i].index].vertex, currentVerices[i].vertex, currentVerices[i].d1); } break; #endregion } case 2: { #region Short+group currentVerices.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + test_tree.Positive + "|" + test_tree.Negative, -1, null, Brushes.Brown)); Shortest_TreeGroup(test_tree, currentVerices, 0, groupParam); foreach (IndexVertex vertex in currentVerices) { Graph.AddVertex(vertex.vertex); } for (int i = 1; i < currentVerices.Count; i++) { AddNewGraphEdge(currentVerices[currentVerices[i].index].vertex, currentVerices[i].vertex, currentVerices[i].d1); } break; #endregion } case 3: { #region podsvetka if (Graph != null) { Graph.Clear(); } currentVerices.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language), -1, null, Brushes.Yellow)); // PrintNode(test_tree, currentVerices, 0); OneRow test_items = (OneRow)test_item; PrintNode_Color(test_tree, currentVerices, 0, groupParam, test_items, 0); foreach (IndexVertex vertex in currentVerices) { Graph.AddVertex(vertex.vertex); } for (int i = 1; i < currentVerices.Count; i++) { AddNewGraphEdge(currentVerices[currentVerices[i].index].vertex, currentVerices[i].vertex, currentVerices[i].d1); } break; #endregion } case 4: { if (Graph != null) { Graph.Clear(); } Tuple <decimal, decimal> d1 = new Tuple <decimal, decimal>(1.0m, 1.0m); currentVerices.Add(new IndexVertex("Настройки OCS неверны?", 0, d1, Brushes.White)); currentVerices.Add(new IndexVertex("Слишком высокая температура смеси?", 0, d1, Brushes.White)); currentVerices.Add(new IndexVertex("Неправильная форма расплава?", 1, d1, Brushes.White)); currentVerices.Add(new IndexVertex("Выглядит блестяще-черными/красно коричневыми?", 2, d1, Brushes.White)); currentVerices.Add(new IndexVertex("Точки выглядят матово-черными?", 3, d1, Brushes.White)); currentVerices.Add(new IndexVertex("Черные точки по краям?", 4, d1, Brushes.White)); currentVerices.Add(new IndexVertex("Сделать запись QRQC", 5, d1, Brushes.Green)); currentVerices.Add(new IndexVertex("Сообщить мастеру", 6, d1, Brushes.Orange)); currentVerices.Add(new IndexVertex("Настроить OCS", 0, d1, Brushes.Green)); currentVerices.Add(new IndexVertex("Снизить температуру смеси в горячем смесителе или время пребывания в горячем смесителе", 1, d1, Brushes.Green)); currentVerices.Add(new IndexVertex("Расплав должен вытекать наружу, подогнать контризгиб. Следить за профилем.", 2, d1, Brushes.Green)); currentVerices.Add(new IndexVertex("Снижать скорость пока пленка не станет чистой", 3, d1, Brushes.Green)); currentVerices.Add(new IndexVertex("Увеличить стабилизатор не больше допустимого (1.1%)", 11, d1, Brushes.Green)); currentVerices.Add(new IndexVertex("Остановить линию", 4, d1, Brushes.Red)); currentVerices.Add(new IndexVertex("Почистить нож, головку и корпус кнеттера", 13, d1, Brushes.Green)); currentVerices.Add(new IndexVertex("Остановить линию", 5, d1, Brushes.Red)); currentVerices.Add(new IndexVertex("Почистить щетки запорные кольца", 15, d1, Brushes.Green)); foreach (IndexVertex vertex in currentVerices) { Graph.AddVertex(vertex.vertex); } for (int i = 1; i < currentVerices.Count; i++) { AddNewGraphEdge(currentVerices[currentVerices[i].index].vertex, currentVerices[i].vertex, currentVerices[i].d1); } AddNewGraphEdge(currentVerices[8].vertex, currentVerices[6].vertex, d1); AddNewGraphEdge(currentVerices[9].vertex, currentVerices[6].vertex, d1); AddNewGraphEdge(currentVerices[10].vertex, currentVerices[6].vertex, d1); AddNewGraphEdge(currentVerices[12].vertex, currentVerices[6].vertex, d1); AddNewGraphEdge(currentVerices[14].vertex, currentVerices[6].vertex, d1); AddNewGraphEdge(currentVerices[16].vertex, currentVerices[6].vertex, d1); break; } } }