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 LoadOperatorsList() { OperatorsListBox.Items.Clear(); var db = new DataProcess(); var operatorList = db.OperatorList(); operatorList.ForEach((item) => { OperatorsListBox.Items.Add(item); }); }
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; }
// Load static data from database to UI. private void loadWeldingDataLists() { var db = new DataProcess(); var gangtaoList = db.GangTaoList(); gangtaoList.ForEach((item) => { GangTaoTypeComboBox.Items.Add(item); }); var operatorList = db.OperatorList(); operatorList.ForEach((item) => { OperatorNameComboBox.Items.Add(item); }); var weldingItemList = db.WeldingItemList(); weldingItemList.ForEach((item) => { WeldingItemComboBox.Items.Add(item); }); }
// Load static data from database to UI. private void loadWeldingDataLists() { #if DEBUG sendMessageInfoLabel.Visible = true; sendMessageButton.Visible = true; #else sendMessageInfoLabel.Visible = false; sendMessageButton.Visible = false; #endif var db = new DataProcess(); var gangtaoList = db.GangTaoList(); gangtaoList.ForEach((item) => { GangTaoTypeComboBox.Items.Add(item); }); var operatorList = db.OperatorList(); operatorList.ForEach((item) => { OperatorNameComboBox.Items.Add(item); }); var weldingItemList = db.WeldingItemList(); weldingItemList.ForEach((item) => { WeldingItemComboBox.Items.Add(item); }); }
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; }