private void SaveAutoWeldHistory(bool interupted = false) { //SaveRecordButton.Enabled = false; // Disable it. var dict = new Dictionary <string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; dict["history_id"] = History.Id; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { dict["name"] = ""; dict["interupted"] = false; var history = new AutoWeldHistory(dict); history.Signals = signalCache; // Decide interupted by signal count. // We can decide interupt by pass in argument. // Fixme: Which is better? if (history.Template.Signals.Count() == signalCache.Count()) { history.Interupted = false; } else { #if DEBUG Console.WriteLine("Control signals: {0}, received signals: {1}", history.Template.Signals.Count(), signalCache.Count()); #endif history.Interupted = true; } history.Save(); } catch (Exception excp) { #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } }
private void AddButton_Click(object sender, EventArgs e) { var input = new InputBox("请输入一个名字:", "新增操作者", ""); var result = input.ShowDialog(this); if (result == DialogResult.OK) { var name = input.InputResult.Trim(); bool nameExists = false; foreach (string n in OperatorsListBox.Items) { if (n == name) { nameExists = true; break; } } if (!nameExists) { var db = new DataProcess(); db.addOperator(name); OperatorsListBox.Items.Add(name); } else { MessageBox.Show(this, "名字已存在,请勿重复添加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
private void SaveSignalDataAndClose() { var dict = new Dictionary <string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { //Fixme: Generate a meaningful name. dict["name"] = ""; var history = new History(dict); history.Signals = signalCache; history.Save(); Console.WriteLine("Signal history saved."); } catch (Exception excp) { //TODO: Save Result and crash. #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } DialogResult = DialogResult.OK; }
private void SaveAutoWeldHistory(bool interupted = false) { //SaveRecordButton.Enabled = false; // Disable it. var dict = new Dictionary<string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; dict["history_id"] = History.Id; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { dict["name"] = ""; dict["interupted"] = false; var history = new AutoWeldHistory(dict); history.Signals = signalCache; // Decide interupted by signal count. // We can decide interupt by pass in argument. // Fixme: Which is better? if (history.Template.Signals.Count() == signalCache.Count()) { history.Interupted = false; } else { #if DEBUG Console.WriteLine("Control signals: {0}, received signals: {1}", history.Template.Signals.Count(), signalCache.Count()); #endif history.Interupted = true; } history.Save(); } catch (Exception excp) { #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } }
private void SaveSignalDataAndClose() { var dict = new Dictionary<string, object>(); dict["task_name"] = TaskNameTextBox.Text.Trim(); dict["gangtao_type"] = GangTaoTypeComboBox.Text.Trim(); dict["welding_item"] = WeldingItemComboBox.Text.Trim(); dict["welding_current"] = WeldingCurrentTextBox.Text.Trim(); dict["ar_flow"] = ArGasFlowTextBox.Text.Trim(); dict["room_temperature"] = RoomTempTextBox.Text.Trim(); var op = OperatorNameComboBox.Text.Trim(); dict["operator"] = op; if (op != "") // Valid op. { var db = new DataProcess(); var ops = db.OperatorList(); if (!ops.Contains(op)) { db.addOperator(op); // Save operator } } // If all OK, close. DateTime dt = DateTime.Now; dict["created_at"] = dt; try { //Fixme: Generate a meaningful name. dict["name"] = ""; var history = new History(dict); history.Signals = signalCache; history.Save(); Console.WriteLine("Signal history saved."); } catch (Exception excp) { //TODO: Save Result and crash. #if DEBUG Console.WriteLine(excp.StackTrace); #endif throw; } DialogResult = DialogResult.OK; }