From ff1013d480b1dca311f2b8d69b6f8927a25900df Mon Sep 17 00:00:00 2001 From: "T.Thang Vo-Doan" Date: Thu, 19 Nov 2020 21:01:57 +0100 Subject: [PATCH 01/36] change calibration function of the thermistor --- Programs/Serial_005/Serial_005.ino | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Programs/Serial_005/Serial_005.ino b/Programs/Serial_005/Serial_005.ino index 7a999fb..4ced6af 100644 --- a/Programs/Serial_005/Serial_005.ino +++ b/Programs/Serial_005/Serial_005.ino @@ -70,8 +70,8 @@ #define NCP18XH103F03RB 3380.0f,298.15f,10000.0f // B,T0,R0 // temperature calculation correction - linear fit coefficients. Applied only for t in Celsius -#define LR_CORR_SLOPE 0.8433 -#define LR_CORR_INTERCEPT 4.2213 +#define LR_CORR_SLOPE 0.96 +#define LR_CORR_INTERCEPT 2.6 // STATES FOR STATE MACHINE #define INIT 'I' @@ -123,7 +123,7 @@ double consKp=1, consKi=0.05, consKd=0.25; //1, 0.25 double Setpoint; //Define Variables we'll be connecting to PID's double Input_MIDDLE, Output_MIDDLE, Setpoint_MIDDLE,Input_UPPER, Input_BOX, Setpoint_UPPER, Output_UPPER,Input_MIDDLE_2,Input_EXTRA, Output_EXTRA, Setpoint_EXTRA; -double threshold_BOX=60; +double threshold_BOX=45; //PID Controller for Heater PID PID_MIDDLE(&Input_MIDDLE_2, &Output_MIDDLE, &Setpoint_MIDDLE, consKp, consKi, consKd, DIRECT); @@ -377,17 +377,15 @@ void loop () { void play_sound() { + for (int i = 0; i < 10; i++) + { + tone(SOUND, 3000, 5000); + delay(1000); + noTone(SOUND); + delay(1000); + + } - tone(SOUND, 3000, 5000); - delay(1000); - tone(SOUND, 1000, 5000); - delay(1000); - tone(SOUND, 2000, 5000); - delay(1000); - tone(SOUND, 500, 5000); - delay(1000); - noTone(SOUND); - delay(1000); //tone(piezoPin, 1000, 500); //delay(1000); } From 2fdb5db078cbc66b85955d6d7c17893f0153bd1c Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 2 Dec 2020 17:21:27 +0100 Subject: [PATCH 02/36] write to csv live, removed last comma from all rows --- .../Miriam_Serial/Miriam/Control.cs | 183 ++++++++++-------- 1 file changed, 99 insertions(+), 84 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 3d6cb85..56f84c3 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -57,6 +57,8 @@ public partial class Control : Form private Dictionary temperatureInfoMap; private Dictionary currentTemperatureInfo; + private string csv_filename; + public Control() { InitializeComponent(); @@ -357,6 +359,13 @@ private void AskHeat_Click(object sender, EventArgs e) } + private void AppendToCsv(string value) + { + //[AT] value has the ',' after the last value, don't write it to the csv + File.AppendAllText(csv_filename, value.TrimEnd(',') + Environment.NewLine, Encoding.UTF8); + Console.WriteLine("Append to csv: {0}", value); + } + private void AppendData(string value) { if (InvokeRequired) @@ -365,123 +374,129 @@ private void AppendData(string value) return; } Data.Items.Add(value); + AppendToCsv(value); + } + private void CreateCsv(string header) + { + csv_filename = folderName + @"\miriam_" + DateTime.Now.ToString("yyyyddMM_HHmmss") + ".csv"; + Console.WriteLine(); + Console.WriteLine("Creating csv: {0}", csv_filename); + File.WriteAllText(csv_filename, header.Remove(header.Length-1,1) + Environment.NewLine, Encoding.UTF8); } private void ButtonStart_Click(object sender, EventArgs e) { - if(started == false) - { - Results.Visible = true; - Form f = Control.ActiveForm; - f.Size = new Size(f.Size.Width, 750); - started = true; - Results.Visible = true; - Results.Anchor |= AnchorStyles.Bottom; - port_measurement = COM.Text; + if (started) return; + + Results.Visible = true; + Form f = Control.ActiveForm; + f.Size = new Size(f.Size.Width, 750); + started = true; + Results.Visible = true; + Results.Anchor |= AnchorStyles.Bottom; + port_measurement = COM.Text; - DateTime localDate = DateTime.Now; + DateTime localDate = DateTime.Now; - duration = localDate.Hour * 60 * 60 + localDate.Minute * 60 + localDate.Second + - Convert.ToInt32(CboxDuration.Text) * 60; + duration = localDate.Hour * 60 * 60 + localDate.Minute * 60 + localDate.Second + + Convert.ToInt32(CboxDuration.Text) * 60; - betweenMesSec = Convert.ToInt32(CboxInterval.Text); + betweenMesSec = Convert.ToInt32(CboxInterval.Text); - Boolean noneFound = true; - List dupl = new List(); - // clear duplicates - for (int i = 0; i < Plate.RowCount; i++) + Boolean noneFound = true; + List dupl = new List(); + // clear duplicates + for (int i = 0; i < Plate.RowCount; i++) + { + for (int j = 0; j < Plate.ColumnCount; j++) { - for (int j = 0; j < Plate.ColumnCount; j++) + if (Plate.Rows[i].Cells[j].Value != null) { - if (Plate.Rows[i].Cells[j].Value != null) + if (!Plate.Rows[i].Cells[j].Value.ToString().Equals("")) { - if (!Plate.Rows[i].Cells[j].Value.ToString().Equals("")) + for (int k = 0; k < dupl.Count; k++) { - for (int k = 0; k < dupl.Count; k++) + if (dupl[k].Equals(Plate.Rows[i].Cells[j].Value.ToString())) { - if (dupl[k].Equals(Plate.Rows[i].Cells[j].Value.ToString())) - { - Plate.Rows[i].Cells[j].Value = Plate.Rows[i].Cells[j].Value.ToString() + "_"; - } - + Plate.Rows[i].Cells[j].Value = Plate.Rows[i].Cells[j].Value.ToString() + "_"; } - dupl.Add(Plate.Rows[i].Cells[j].Value.ToString()); - noneFound = false; + } - } else - { - Plate.Rows[i].Cells[j].Value = ""; + dupl.Add(Plate.Rows[i].Cells[j].Value.ToString()); + noneFound = false; } - + } else + { + Plate.Rows[i].Cells[j].Value = ""; } + } + } - if (noneFound) - { - Plate.Rows[0].Cells[0].Value = "TimeTrack"; - } + if (noneFound) + { + Plate.Rows[0].Cells[0].Value = "TimeTrack"; + } - List list = new List(); //[AT] list of wells with names - int counter = 5; - //string msg = "Time,U,M,"; // [AT] csv file header. - string msg = "Time,U,M,Extra,Box,"; // [AT] csv file header. + List list = new List(); //[AT] list of wells with names + int counter = 5; + //string msg = "Time,U,M,"; // [AT] csv file header. + string msg = "Time,U,M,Extra,Box,"; // [AT] csv file header. - for (int i = 0; i < Plate.RowCount; i++) + for (int i = 0; i < Plate.RowCount; i++) + { + for (int j = 0; j < Plate.ColumnCount; j++) { - for (int j = 0; j < Plate.ColumnCount; j++) - { - msg += Plate.Rows[i].Cells[j].Value.ToString() + ","; - if (!Plate.Rows[i].Cells[j].Value.ToString().Equals("")) - { - list.Add(counter); - } - counter += 1; - } - } - Data.Items.Add(msg); //[AT] Data -- invisible ListBox - arrayNames = msg; //[AT] header - - Color[] clr; - - clr = new Color[10]; - clr[0] = Color.Red; - clr[1] = Color.Blue; - clr[2] = Color.Chocolate; - clr[3] = Color.Green; - clr[4] = Color.Black; - clr[5] = Color.Aqua; - clr[6] = Color.DimGray; - clr[7] = Color.DarkViolet; - clr[8] = Color.DeepPink; - clr[9] = Color.Gray; - - int clrsUsed = 0; - - //[AT] add series for all named wells - for (int i = 0; i < list.Count; i++) - { - Results.Series.Add(msg.Split(',')[list[i]]); - Results.Series[msg.Split(',')[list[i]]].ChartType = - SeriesChartType.FastLine; - Results.Series[msg.Split(',')[list[i]]].Color = clr[clrsUsed]; - clrsUsed += 1; - if (clrsUsed > 9) + msg += Plate.Rows[i].Cells[j].Value.ToString() + ","; + if (!Plate.Rows[i].Cells[j].Value.ToString().Equals("")) { - clrsUsed = 0; + list.Add(counter); } + counter += 1; } + } + Data.Items.Add(msg); //[AT] Data -- invisible ListBox + arrayNames = msg; //[AT] header + + CreateCsv(msg); + + Color[] clr; - // put to background to force to close if program exit - assay_thread.IsBackground = true; + clr = new Color[10]; + clr[0] = Color.Red; + clr[1] = Color.Blue; + clr[2] = Color.Chocolate; + clr[3] = Color.Green; + clr[4] = Color.Black; + clr[5] = Color.Aqua; + clr[6] = Color.DimGray; + clr[7] = Color.DarkViolet; + clr[8] = Color.DeepPink; + clr[9] = Color.Gray; - assay_thread.Start(); + int clrsUsed = 0; + + //[AT] add series for all named wells + for (int i = 0; i < list.Count; i++) + { + Results.Series.Add(msg.Split(',')[list[i]]); + Results.Series[msg.Split(',')[list[i]]].ChartType = + SeriesChartType.FastLine; + Results.Series[msg.Split(',')[list[i]]].Color = clr[clrsUsed]; + clrsUsed += 1; + if (clrsUsed > 9) + { + clrsUsed = 0; + } } - + // put to background to force to close if program exit + assay_thread.IsBackground = true; + assay_thread.Start(); } // [AT] appends result to the plot From f138a08022965501fed617e49ff0e93efe4eea47 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Tue, 8 Dec 2020 13:15:11 +0100 Subject: [PATCH 03/36] + form with melting settings; storing them in app settings; melting func not tested in reality; ino: add melting to list of states --- .../Miriam_Serial/Miriam/App.config | 12 ++ .../Miriam_Serial/Miriam/Control.Designer.cs | 17 +- .../Miriam_Serial/Miriam/Control.cs | 176 ++++++++++++--- .../Miriam/FormSettings.Designer.cs | 204 ++++++++++++++++++ .../Miriam_Serial/Miriam/FormSettings.cs | 68 ++++++ .../Miriam_Serial/Miriam/FormSettings.resx | 120 +++++++++++ .../Miriam_Serial/Miriam/Miriam.csproj | 9 + .../Miriam_Serial/Miriam/Program.cs | 3 +- .../Miriam/Properties/Settings.Designer.cs | 48 +++++ .../Miriam/Properties/Settings.settings | 12 ++ Programs/Serial_003/Serial_003.ino | 3 +- 11 files changed, 637 insertions(+), 35 deletions(-) create mode 100644 Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs create mode 100644 Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs create mode 100644 Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/App.config b/Programs/Serial_003/Miriam_Serial/Miriam/App.config index 830da40..ab70923 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/App.config +++ b/Programs/Serial_003/Miriam_Serial/Miriam/App.config @@ -31,6 +31,18 @@ 45 + + 80 + + + 80 + + + 80 + + + 30 + \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs index 379fe40..97c11eb 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs @@ -64,6 +64,7 @@ private void InitializeComponent() this.CboxTempE = new System.Windows.Forms.ComboBox(); this.labelThr = new System.Windows.Forms.Label(); this.CboxTempThr = new System.Windows.Forms.ComboBox(); + this.buttonChangeSettings = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.Plate)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.Results)).BeginInit(); this.SuspendLayout(); @@ -210,7 +211,7 @@ private void InitializeComponent() this.Results.Location = new System.Drawing.Point(5, 375); this.Results.Margin = new System.Windows.Forms.Padding(2); this.Results.Name = "Results"; - this.Results.Size = new System.Drawing.Size(539, 332); + this.Results.Size = new System.Drawing.Size(531, 332); this.Results.TabIndex = 25; this.Results.Text = "chart1"; this.Results.Visible = false; @@ -356,12 +357,23 @@ private void InitializeComponent() this.CboxTempThr.Size = new System.Drawing.Size(82, 21); this.CboxTempThr.TabIndex = 40; // + // buttonChangeSettings + // + this.buttonChangeSettings.Location = new System.Drawing.Point(308, 98); + this.buttonChangeSettings.Name = "buttonChangeSettings"; + this.buttonChangeSettings.Size = new System.Drawing.Size(75, 23); + this.buttonChangeSettings.TabIndex = 42; + this.buttonChangeSettings.Text = "Settings..."; + this.buttonChangeSettings.UseVisualStyleBackColor = true; + this.buttonChangeSettings.Click += new System.EventHandler(this.buttonChangeSettings_Click); + // // Control // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlDark; - this.ClientSize = new System.Drawing.Size(563, 375); + this.ClientSize = new System.Drawing.Size(555, 373); + this.Controls.Add(this.buttonChangeSettings); this.Controls.Add(this.labelThr); this.Controls.Add(this.CboxTempThr); this.Controls.Add(this.labelTempE); @@ -435,6 +447,7 @@ private void InitializeComponent() private ComboBox CboxTempE; private Label labelThr; private ComboBox CboxTempThr; + private Button buttonChangeSettings; } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 56f84c3..f7cb9a2 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -14,6 +14,7 @@ using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using Microsoft.VisualBasic.FileIO; +//using Miriam_Serial; /* * Miriam control @@ -40,7 +41,7 @@ namespace Miriam { public partial class Control : Form { - private int duration; + private int time_to_stop_assay; private string arrayNames; private int maximumValue = 0; private string port_measurement = ""; @@ -58,10 +59,96 @@ public partial class Control : Form private Dictionary currentTemperatureInfo; private string csv_filename; + FormSettings SettingsForm; + + public static bool melting_enabled; + public static Dictionary settings_melting = new Dictionary + { + { "TUp", "80" }, + { "TMiddle", "80" }, + { "TExtra", "80" }, + { "Interval", "30" } + }; + + private static string ArduinoReadout(SerialPort serialPort, string command) + { + serialPort.Write(command + "\r\n"); + string ReceivedData; + bool conti = true; + do + { + ReceivedData = serialPort.ReadLine(); + if (ReceivedData.Contains('$')) + { + conti = false; + } + } while (conti); + + ReceivedData = ReceivedData.Replace("$", ""); + ReceivedData = ReceivedData.Replace("\r", ""); + ReceivedData = ReceivedData.Replace("\n", ""); + + return ReceivedData; + } + + public class SerialPortForHeat : SerialPort + { + public SerialPortForHeat(string portname) + { + PortName = portname; + DataBits = 8; + Parity = Parity.None; + StopBits = StopBits.One; + BaudRate = 9600; + + // Set the read/write timeouts + ReadTimeout = 500; + WriteTimeout = 500; + } + + public void start_heat(string t_up, string t_middle, string t_extra, string threshold = "", bool melting=false) + { + try + { + Open(); + DiscardOutBuffer(); + DiscardInBuffer(); + + String ReceivedData; + + var s = ArduinoReadout(this, "M " + t_middle); + Console.WriteLine(s); + + s = ArduinoReadout(this, "U " + t_up); + Console.WriteLine(s); + + s = ArduinoReadout(this, "E " + t_extra); + Console.WriteLine(s); + + if (threshold != "") + s = ArduinoReadout(this, "T " + threshold); + Console.WriteLine(s); + + string heat_command = melting ? "W" : "H"; + s = ArduinoReadout(this, heat_command); + Console.WriteLine(s); + // [AT] maybe sleep here a bit? + } + catch (Exception exc) + { + // [AT] todo: show exception + // MessageBox.Show("Serial could not be opened, please check that the device is correct one"); + MessageBox.Show(exc.ToString()); + this.Close(); + } + } + }; + public Control() { InitializeComponent(); + SettingsForm = new FormSettings(); assay_thread = new System.Threading.Thread(new System.Threading.ThreadStart(doAssay)); temperatureInfoMap = new Dictionary { @@ -145,28 +232,17 @@ private void ParseTemperatureInfo(string received_data) } } + private bool temperature_reached() + { + bool t_up = float.Parse(currentTemperatureInfo["Up"]) - float.Parse(settings_melting["TUp"]) >= 0; + bool t_mid = float.Parse(currentTemperatureInfo["Middle"]) - float.Parse(settings_melting["TMiddle"]) >= 0; + bool t_extra = float.Parse(currentTemperatureInfo["Extra"]) - float.Parse(settings_melting["TExtra"]) >= 0; + return t_up && t_mid && t_extra; + } // private void ArduinoCommand(SerialPort serialPort, string command) // { } - private string ArduinoReadout(SerialPort serialPort, string command) - { - serialPort.Write(command + "\r\n"); - string ReceivedData; - bool conti = true; - do - { - ReceivedData = serialPort.ReadLine(); - if (ReceivedData.Contains('$')) - { - conti = false; - } - } while (conti); - ReceivedData = ReceivedData.Replace("$", ""); - ReceivedData = ReceivedData.Replace("\r", ""); - ReceivedData = ReceivedData.Replace("\n", ""); - - return ReceivedData; - } + private void CreateEmptyPlate() { @@ -400,7 +476,7 @@ private void ButtonStart_Click(object sender, EventArgs e) DateTime localDate = DateTime.Now; - duration = localDate.Hour * 60 * 60 + localDate.Minute * 60 + localDate.Second + + time_to_stop_assay = localDate.Hour * 60 * 60 + localDate.Minute * 60 + localDate.Second + Convert.ToInt32(CboxDuration.Text) * 60; betweenMesSec = Convert.ToInt32(CboxInterval.Text); @@ -628,20 +704,27 @@ private void doAssay() bool cont_assay = true; int loop = 0; Boolean assay_ready = false; - + bool now_melting = false; + bool stop_condition = false; do { DateTime current = DateTime.Now; // AT: time when the current measurement started - int endCycle = current.Hour * 60 * 60 + current.Minute * 60 + current.Second; + int time_current_measurement = current.Hour * 60 * 60 + current.Minute * 60 + current.Second; string timestr = current.ToString("s"); //[AT] "s" -- sortable datetime format - // AT:stop if the specified duration passed (from the textbox) - if (_exiting || (duration < endCycle)) + if (!now_melting) stop_condition = (time_to_stop_assay < time_current_measurement); + else stop_condition = temperature_reached(); + + // AT:stop if the specified duration passed (from the textbox) + if (_exiting || stop_condition) { cont_assay = false; - if (!_exiting) + if (!_exiting) // not exiting on form close + { assay_ready = true; + if (now_melting) now_melting = false; // after melting don't do melting again. + } } // [AT][?] why recreate this object for every cycle? Would it be enough to create once? + can put it in a child class @@ -720,22 +803,20 @@ private void doAssay() Console.WriteLine("end sleep 2"); serialPort.Close(); - } catch (Exception exc) { - MessageBox.Show("Serial could not be opened, please check that the device is correct one"); + MessageBox.Show("Serial could not be opened, please check that the device is correct one.\n"+ exc.ToString()); serialPort.Close(); } - Boolean timeRunning = true; // wait until getting the next measurement do { DateTime wait = DateTime.Now; - if (endCycle + betweenMesSec < wait.Hour * 60 * 60 + wait.Minute * 60 + wait.Second) + if (time_current_measurement + betweenMesSec < wait.Hour * 60 * 60 + wait.Minute * 60 + wait.Second) { timeRunning = false; } @@ -743,6 +824,13 @@ private void doAssay() } while (timeRunning); loop += 1; + if (assay_ready & melting_enabled) + { + assay_ready = false; + cont_assay = true; + apply_settings_melting(); + now_melting = true; + } } while (cont_assay && (!_exiting)); @@ -756,6 +844,16 @@ private void doAssay() MessageBox.Show("Assay Aborted"); } + private void apply_settings_melting() + { + Console.WriteLine(settings_melting); + betweenMesSec = Convert.ToInt32(settings_melting["Interval"]); + + SerialPortForHeat serialPort = new SerialPortForHeat(port_measurement); + serialPort.start_heat(settings_melting["TUp"], settings_melting["TMiddle"], settings_melting["TExtra"], melting: true); + serialPort.Close(); + } + private void ButtonWrite_Click(object sender, EventArgs e) { try @@ -808,6 +906,12 @@ private void Control_FormClosing(object sender, FormClosingEventArgs e) Miriam_Serial.Properties.Settings.Default.settTemperatureExtra = CboxTempE.Text; Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold = CboxTempThr.Text; Miriam_Serial.Properties.Settings.Default.settDuration = CboxDuration.Text; + Miriam_Serial.Properties.Settings.Default.settInterval = CboxInterval.Text; + + settings_melting["TUp"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureUp; + settings_melting["TMiddle"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureMid; + settings_melting["TExtra"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureExtra; + settings_melting["Interval"] = Miriam_Serial.Properties.Settings.Default.meltInterval; Console.WriteLine(Miriam_Serial.Properties.Settings.Default.settFolderRes); Miriam_Serial.Properties.Settings.Default.Save(); @@ -875,7 +979,19 @@ private void Control_Load(object sender, EventArgs e) CboxTempM.Text = Miriam_Serial.Properties.Settings.Default.settTemperatureMid; CboxTempE.Text = Miriam_Serial.Properties.Settings.Default.settTemperatureExtra; CboxDuration.Text = Miriam_Serial.Properties.Settings.Default.settDuration; + CboxInterval.Text = Miriam_Serial.Properties.Settings.Default.settInterval; CboxTempThr.Text = Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold; + + settings_melting["TUp"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureUp; + settings_melting["TMiddle"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureMid; + settings_melting["TExtra"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureExtra; + settings_melting["Interval"] = Miriam_Serial.Properties.Settings.Default.meltInterval; + + } + + private void buttonChangeSettings_Click(object sender, EventArgs e) + { + SettingsForm.ShowDialog(); } } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs new file mode 100644 index 0000000..b344754 --- /dev/null +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs @@ -0,0 +1,204 @@ +namespace Miriam +{ + partial class FormSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOk = new System.Windows.Forms.Button(); + this.checkBoxEnableMelting = new System.Windows.Forms.CheckBox(); + this.panelMelting = new System.Windows.Forms.Panel(); + this.labelTempE = new System.Windows.Forms.Label(); + this.CboxTempE = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.CboxInterval = new System.Windows.Forms.ComboBox(); + this.LabelTempU = new System.Windows.Forms.Label(); + this.LabelTempM = new System.Windows.Forms.Label(); + this.CboxTempU = new System.Windows.Forms.ComboBox(); + this.CboxTempM = new System.Windows.Forms.ComboBox(); + this.panelMelting.SuspendLayout(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(713, 415); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 1; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOk + // + this.buttonOk.AccessibleDescription = "Save settings and exit"; + this.buttonOk.Location = new System.Drawing.Point(632, 415); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); + // + // checkBoxEnableMelting + // + this.checkBoxEnableMelting.AutoSize = true; + this.checkBoxEnableMelting.Location = new System.Drawing.Point(27, 21); + this.checkBoxEnableMelting.Name = "checkBoxEnableMelting"; + this.checkBoxEnableMelting.Size = new System.Drawing.Size(90, 17); + this.checkBoxEnableMelting.TabIndex = 3; + this.checkBoxEnableMelting.Text = "Melting curve"; + this.checkBoxEnableMelting.UseVisualStyleBackColor = true; + this.checkBoxEnableMelting.CheckedChanged += new System.EventHandler(this.checkBoxEnableMelting_CheckedChanged); + // + // panelMelting + // + this.panelMelting.Controls.Add(this.labelTempE); + this.panelMelting.Controls.Add(this.CboxTempE); + this.panelMelting.Controls.Add(this.label1); + this.panelMelting.Controls.Add(this.CboxInterval); + this.panelMelting.Controls.Add(this.LabelTempU); + this.panelMelting.Controls.Add(this.LabelTempM); + this.panelMelting.Controls.Add(this.CboxTempU); + this.panelMelting.Controls.Add(this.CboxTempM); + this.panelMelting.Enabled = false; + this.panelMelting.Location = new System.Drawing.Point(12, 45); + this.panelMelting.Name = "panelMelting"; + this.panelMelting.Size = new System.Drawing.Size(221, 122); + this.panelMelting.TabIndex = 4; + // + // labelTempE + // + this.labelTempE.AutoSize = true; + this.labelTempE.Location = new System.Drawing.Point(62, 65); + this.labelTempE.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.labelTempE.Name = "labelTempE"; + this.labelTempE.Size = new System.Drawing.Size(57, 13); + this.labelTempE.TabIndex = 47; + this.labelTempE.Text = "Extra temp"; + // + // CboxTempE + // + this.CboxTempE.FormattingEnabled = true; + this.CboxTempE.Location = new System.Drawing.Point(123, 62); + this.CboxTempE.Margin = new System.Windows.Forms.Padding(2); + this.CboxTempE.Name = "CboxTempE"; + this.CboxTempE.Size = new System.Drawing.Size(82, 21); + this.CboxTempE.TabIndex = 46; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(20, 93); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(99, 13); + this.label1.TabIndex = 45; + this.label1.Text = "Measure interval [s]"; + // + // CboxInterval + // + this.CboxInterval.FormattingEnabled = true; + this.CboxInterval.Location = new System.Drawing.Point(123, 90); + this.CboxInterval.Margin = new System.Windows.Forms.Padding(2); + this.CboxInterval.Name = "CboxInterval"; + this.CboxInterval.Size = new System.Drawing.Size(82, 21); + this.CboxInterval.TabIndex = 44; + // + // LabelTempU + // + this.LabelTempU.AutoSize = true; + this.LabelTempU.Location = new System.Drawing.Point(57, 37); + this.LabelTempU.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.LabelTempU.Name = "LabelTempU"; + this.LabelTempU.Size = new System.Drawing.Size(62, 13); + this.LabelTempU.TabIndex = 43; + this.LabelTempU.Text = "Upper temp"; + // + // LabelTempM + // + this.LabelTempM.AutoSize = true; + this.LabelTempM.Location = new System.Drawing.Point(55, 9); + this.LabelTempM.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.LabelTempM.Name = "LabelTempM"; + this.LabelTempM.Size = new System.Drawing.Size(64, 13); + this.LabelTempM.TabIndex = 42; + this.LabelTempM.Text = "Middle temp"; + // + // CboxTempU + // + this.CboxTempU.FormattingEnabled = true; + this.CboxTempU.Location = new System.Drawing.Point(123, 34); + this.CboxTempU.Margin = new System.Windows.Forms.Padding(2); + this.CboxTempU.Name = "CboxTempU"; + this.CboxTempU.Size = new System.Drawing.Size(82, 21); + this.CboxTempU.TabIndex = 41; + // + // CboxTempM + // + this.CboxTempM.FormattingEnabled = true; + this.CboxTempM.Location = new System.Drawing.Point(123, 6); + this.CboxTempM.Margin = new System.Windows.Forms.Padding(2); + this.CboxTempM.Name = "CboxTempM"; + this.CboxTempM.Size = new System.Drawing.Size(82, 21); + this.CboxTempM.TabIndex = 40; + // + // FormSettings + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.panelMelting); + this.Controls.Add(this.checkBoxEnableMelting); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.buttonCancel); + this.Name = "FormSettings"; + this.Text = "Miriam Settings"; + this.Load += new System.EventHandler(this.FormSettings_Load); + this.panelMelting.ResumeLayout(false); + this.panelMelting.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.CheckBox checkBoxEnableMelting; + private System.Windows.Forms.Panel panelMelting; + private System.Windows.Forms.Label labelTempE; + private System.Windows.Forms.ComboBox CboxTempE; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox CboxInterval; + private System.Windows.Forms.Label LabelTempU; + private System.Windows.Forms.Label LabelTempM; + private System.Windows.Forms.ComboBox CboxTempU; + private System.Windows.Forms.ComboBox CboxTempM; + } +} \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs new file mode 100644 index 0000000..421c71e --- /dev/null +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + + +namespace Miriam +{ + public partial class FormSettings : Form + { + public FormSettings() + { + InitializeComponent(); + + for (int i = 70; i < 90; i++) + { + CboxTempM.Items.Add(i); + } + for (int i = 80; i < 110; i++) + { + CboxTempU.Items.Add(i); + } + for (int i = 60; i < 110; i++) + { + CboxTempE.Items.Add(i); + } + for (int i = 11; i < 100; i++) + { + CboxInterval.Items.Add(i); + } + + } + + private void buttonOk_Click(object sender, EventArgs e) + { + Control.melting_enabled = checkBoxEnableMelting.Checked; + Control.settings_melting["TUp"] = CboxTempU.Text; + Control.settings_melting["TMiddle"] = CboxTempM.Text; + Control.settings_melting["TExtra"] = CboxTempE.Text; + Control.settings_melting["Interval"] = CboxInterval.Text; + this.DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + } + + private void checkBoxEnableMelting_CheckedChanged(object sender, EventArgs e) + { + panelMelting.Enabled = checkBoxEnableMelting.Checked; + } + + private void FormSettings_Load(object sender, EventArgs e) + { + checkBoxEnableMelting.Checked = Control.melting_enabled; + CboxTempU.Text = Control.settings_melting["TUp"]; + CboxTempM.Text = Control.settings_melting["TMiddle"]; + CboxTempE.Text = Control.settings_melting["TExtra"]; + CboxInterval.Text = Control.settings_melting["Interval"]; + } + } +} diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj b/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj index 956efce..616f6fb 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj @@ -57,11 +57,20 @@ Control.cs + + Form + + + FormSettings.cs + Control.cs + + FormSettings.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Program.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Program.cs index 2a5f1bf..f952651 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Program.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Program.cs @@ -21,7 +21,8 @@ public static void Main(String[] args) Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Control()); + Control MainForm = new Control(); + Application.Run(MainForm); } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs index 7fab78c..eb09d59 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs @@ -106,5 +106,53 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio this["settBoxTemperatureThreshold"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("80")] + public string meltTemperatureUp { + get { + return ((string)(this["meltTemperatureUp"])); + } + set { + this["meltTemperatureUp"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("80")] + public string meltTemperatureMid { + get { + return ((string)(this["meltTemperatureMid"])); + } + set { + this["meltTemperatureMid"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("80")] + public string meltTemperatureExtra { + get { + return ((string)(this["meltTemperatureExtra"])); + } + set { + this["meltTemperatureExtra"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("30")] + public string meltInterval { + get { + return ((string)(this["meltInterval"])); + } + set { + this["meltInterval"] = value; + } + } } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings index 92b911e..4fc7f03 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings @@ -23,5 +23,17 @@ 45 + + 80 + + + 80 + + + 80 + + + 30 + \ No newline at end of file diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index ddc5290..f7fe93a 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -139,7 +139,7 @@ enum { }; byte states[] = { - INIT, CANCEL, HEAT_BOARDS, INFO, SET_TEMP_UPPER, SET_TEMP_MIDDLE,SET_TEMP_EXTRA, READ_ASSAY, PLAY_SOUND, STATUS_LED_ON, STATUS_LED_OFF, SET_BOX_THR}; + INIT, CANCEL, HEAT_BOARDS, INFO, SET_TEMP_UPPER, SET_TEMP_MIDDLE,SET_TEMP_EXTRA, READ_ASSAY, PLAY_SOUND, STATUS_LED_ON, STATUS_LED_OFF, SET_BOX_THR, MELT_HEAT}; // serial data @@ -281,7 +281,6 @@ void loop () { HEAT_ON = false; MELT_ON = true; heat_alarm = true; - Serial.println(F("MELTING BOARDS$")); From b636c4a27ac736e4aedbf8adb1fc1ac344b3b2f6 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Tue, 8 Dec 2020 13:32:01 +0100 Subject: [PATCH 04/36] fixed filename format to yyyymmdd... --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index f7cb9a2..2ebc339 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -455,7 +455,7 @@ private void AppendData(string value) private void CreateCsv(string header) { - csv_filename = folderName + @"\miriam_" + DateTime.Now.ToString("yyyyddMM_HHmmss") + ".csv"; + csv_filename = folderName + @"\miriam_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; Console.WriteLine(); Console.WriteLine("Creating csv: {0}", csv_filename); File.WriteAllText(csv_filename, header.Remove(header.Length-1,1) + Environment.NewLine, Encoding.UTF8); From 1c49af2ff6967ee27a193d70220ea35afa4e3e62 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 9 Dec 2020 12:33:21 +0100 Subject: [PATCH 05/36] fix melting stopping --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 2ebc339..efd384a 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -239,10 +239,6 @@ private bool temperature_reached() bool t_extra = float.Parse(currentTemperatureInfo["Extra"]) - float.Parse(settings_melting["TExtra"]) >= 0; return t_up && t_mid && t_extra; } -// private void ArduinoCommand(SerialPort serialPort, string command) -// { } - - private void CreateEmptyPlate() { @@ -723,7 +719,7 @@ private void doAssay() if (!_exiting) // not exiting on form close { assay_ready = true; - if (now_melting) now_melting = false; // after melting don't do melting again. + //if (now_melting) now_melting = false; // after melting don't do melting again. } } @@ -824,7 +820,8 @@ private void doAssay() } while (timeRunning); loop += 1; - if (assay_ready & melting_enabled) + // if need to start melting after the measurements were taken for specified duration + if ((!now_melting) && assay_ready && melting_enabled) { assay_ready = false; cont_assay = true; From a2b79d555ab21a28c9f24a9aee1008d31a51e876 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 9 Dec 2020 16:26:44 +0100 Subject: [PATCH 06/36] fixed float convertion bug; add tolerance parameter for melting --- .../Miriam_Serial/Miriam/App.config | 3 ++ .../Miriam_Serial/Miriam/Control.cs | 32 ++++++++++++------- .../Miriam/FormSettings.Designer.cs | 27 +++++++++++++++- .../Miriam_Serial/Miriam/FormSettings.cs | 1 + .../Miriam/Properties/Settings.Designer.cs | 12 +++++++ .../Miriam/Properties/Settings.settings | 3 ++ 6 files changed, 66 insertions(+), 12 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/App.config b/Programs/Serial_003/Miriam_Serial/Miriam/App.config index ab70923..5c8dd58 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/App.config +++ b/Programs/Serial_003/Miriam_Serial/Miriam/App.config @@ -43,6 +43,9 @@ 30 + + 1 + \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index efd384a..d6f2d26 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; +using System.Globalization; using System.IO; using System.IO.Ports; using System.Linq; @@ -67,7 +68,8 @@ public partial class Control : Form { "TUp", "80" }, { "TMiddle", "80" }, { "TExtra", "80" }, - { "Interval", "30" } + { "Interval", "30" }, + { "Tolerance", "0.1"} }; private static string ArduinoReadout(SerialPort serialPort, string command) @@ -148,7 +150,7 @@ public void start_heat(string t_up, string t_middle, string t_extra, string thre public Control() { InitializeComponent(); - SettingsForm = new FormSettings(); + assay_thread = new System.Threading.Thread(new System.Threading.ThreadStart(doAssay)); temperatureInfoMap = new Dictionary { @@ -233,10 +235,16 @@ private void ParseTemperatureInfo(string received_data) } private bool temperature_reached() - { - bool t_up = float.Parse(currentTemperatureInfo["Up"]) - float.Parse(settings_melting["TUp"]) >= 0; - bool t_mid = float.Parse(currentTemperatureInfo["Middle"]) - float.Parse(settings_melting["TMiddle"]) >= 0; - bool t_extra = float.Parse(currentTemperatureInfo["Extra"]) - float.Parse(settings_melting["TExtra"]) >= 0; + { + float eps = float.Parse(settings_melting["Tolerance"], CultureInfo.InvariantCulture); + + float t_up_val = float.Parse(currentTemperatureInfo["Up"], CultureInfo.InvariantCulture); + float t_mid_val = float.Parse(currentTemperatureInfo["Middle"], CultureInfo.InvariantCulture); + float t_extra_val = float.Parse(currentTemperatureInfo["Extra"], CultureInfo.InvariantCulture); + + bool t_up = (t_up_val - float.Parse(settings_melting["TUp"]) >= -eps); + bool t_mid = float.Parse(currentTemperatureInfo["Middle"]) - float.Parse(settings_melting["TMiddle"], CultureInfo.InvariantCulture) >= -eps; + bool t_extra = float.Parse(currentTemperatureInfo["Extra"]) - float.Parse(settings_melting["TExtra"], CultureInfo.InvariantCulture) >= -eps; return t_up && t_mid && t_extra; } @@ -905,10 +913,11 @@ private void Control_FormClosing(object sender, FormClosingEventArgs e) Miriam_Serial.Properties.Settings.Default.settDuration = CboxDuration.Text; Miriam_Serial.Properties.Settings.Default.settInterval = CboxInterval.Text; - settings_melting["TUp"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureUp; - settings_melting["TMiddle"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureMid; - settings_melting["TExtra"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureExtra; - settings_melting["Interval"] = Miriam_Serial.Properties.Settings.Default.meltInterval; + Miriam_Serial.Properties.Settings.Default.meltTemperatureUp = settings_melting["TUp"]; + Miriam_Serial.Properties.Settings.Default.meltTemperatureMid = settings_melting["TMiddle"]; + Miriam_Serial.Properties.Settings.Default.meltTemperatureExtra = settings_melting["TExtra"]; + Miriam_Serial.Properties.Settings.Default.meltInterval = settings_melting["Interval"]; + Miriam_Serial.Properties.Settings.Default.meltTolerance = settings_melting["Tolerance"]; Console.WriteLine(Miriam_Serial.Properties.Settings.Default.settFolderRes); Miriam_Serial.Properties.Settings.Default.Save(); @@ -983,7 +992,8 @@ private void Control_Load(object sender, EventArgs e) settings_melting["TMiddle"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureMid; settings_melting["TExtra"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureExtra; settings_melting["Interval"] = Miriam_Serial.Properties.Settings.Default.meltInterval; - + settings_melting["Tolerance"] = Miriam_Serial.Properties.Settings.Default.meltTolerance; + SettingsForm = new FormSettings(); } private void buttonChangeSettings_Click(object sender, EventArgs e) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs index b344754..96f52b5 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs @@ -40,6 +40,8 @@ private void InitializeComponent() this.LabelTempM = new System.Windows.Forms.Label(); this.CboxTempU = new System.Windows.Forms.ComboBox(); this.CboxTempM = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.CboxTolerance = new System.Windows.Forms.ComboBox(); this.panelMelting.SuspendLayout(); this.SuspendLayout(); // @@ -77,6 +79,8 @@ private void InitializeComponent() // // panelMelting // + this.panelMelting.Controls.Add(this.label2); + this.panelMelting.Controls.Add(this.CboxTolerance); this.panelMelting.Controls.Add(this.labelTempE); this.panelMelting.Controls.Add(this.CboxTempE); this.panelMelting.Controls.Add(this.label1); @@ -88,7 +92,7 @@ private void InitializeComponent() this.panelMelting.Enabled = false; this.panelMelting.Location = new System.Drawing.Point(12, 45); this.panelMelting.Name = "panelMelting"; - this.panelMelting.Size = new System.Drawing.Size(221, 122); + this.panelMelting.Size = new System.Drawing.Size(221, 159); this.panelMelting.TabIndex = 4; // // labelTempE @@ -167,6 +171,25 @@ private void InitializeComponent() this.CboxTempM.Size = new System.Drawing.Size(82, 21); this.CboxTempM.TabIndex = 40; // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(20, 120); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(85, 13); + this.label2.TabIndex = 49; + this.label2.Text = "Tolerance [deg.]"; + // + // CboxTolerance + // + this.CboxTolerance.FormattingEnabled = true; + this.CboxTolerance.Location = new System.Drawing.Point(123, 117); + this.CboxTolerance.Margin = new System.Windows.Forms.Padding(2); + this.CboxTolerance.Name = "CboxTolerance"; + this.CboxTolerance.Size = new System.Drawing.Size(82, 21); + this.CboxTolerance.TabIndex = 48; + // // FormSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -200,5 +223,7 @@ private void InitializeComponent() private System.Windows.Forms.Label LabelTempM; private System.Windows.Forms.ComboBox CboxTempU; private System.Windows.Forms.ComboBox CboxTempM; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox CboxTolerance; } } \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs index 421c71e..b55be08 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -63,6 +63,7 @@ private void FormSettings_Load(object sender, EventArgs e) CboxTempM.Text = Control.settings_melting["TMiddle"]; CboxTempE.Text = Control.settings_melting["TExtra"]; CboxInterval.Text = Control.settings_melting["Interval"]; + CboxTolerance.Text = Control.settings_melting["Tolerance"]; } } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs index eb09d59..b846d15 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs @@ -154,5 +154,17 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio this["meltInterval"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1")] + public string meltTolerance { + get { + return ((string)(this["meltTolerance"])); + } + set { + this["meltTolerance"] = value; + } + } } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings index 4fc7f03..8e69037 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings @@ -35,5 +35,8 @@ 30 + + 1 + \ No newline at end of file From 1730cf4f0fd4105e5263de7b234664a1f686cd44 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 9 Dec 2020 16:45:21 +0100 Subject: [PATCH 07/36] ci: store artifact attempt --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 335d45b..9a73870 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,11 @@ jobs: run: nuget restore Programs/Serial_003/Miriam_Serial/Miriam.sln - name: build run: msbuild Programs/Serial_003/Miriam_Serial/Miriam.sln /p:Configuration=Release /p:Platform="Any CPU" + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: executable + path: D:\a\Miriam\Miriam\Programs\Serial_003\Miriam_Serial\MiriamTests\bin\Release\Miriam_Serial.exe build-arduino: # Based on https://legion2.github.io/2020/03/27/from-arduino-builder-to-arduino-cli.html From 4e5875363b9b267ca9b0dbc356a172bda9ae1b9b Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 9 Dec 2020 20:26:09 +0100 Subject: [PATCH 08/36] rearrange for better time intervals --- .../Miriam_Serial/Miriam/Control.cs | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index d6f2d26..eeb2f00 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -727,7 +727,6 @@ private void doAssay() if (!_exiting) // not exiting on form close { assay_ready = true; - //if (now_melting) now_melting = false; // after melting don't do melting again. } } @@ -816,26 +815,29 @@ private void doAssay() Boolean timeRunning = true; - // wait until getting the next measurement - do - { - DateTime wait = DateTime.Now; - if (time_current_measurement + betweenMesSec < wait.Hour * 60 * 60 + wait.Minute * 60 + wait.Second) - { - timeRunning = false; - } - Thread.Sleep(100); - } while (timeRunning); - loop += 1; - - // if need to start melting after the measurements were taken for specified duration - if ((!now_melting) && assay_ready && melting_enabled) + if ((!now_melting) && assay_ready && melting_enabled) { assay_ready = false; cont_assay = true; apply_settings_melting(); - now_melting = true; - } + now_melting = true; + } + + if (cont_assay) + { + // wait until getting the next measurement + do + { + DateTime wait = DateTime.Now; + if (time_current_measurement + betweenMesSec < wait.Hour * 60 * 60 + wait.Minute * 60 + wait.Second) + { + timeRunning = false; + } + Thread.Sleep(100); + } while (timeRunning); + loop += 1; + } + // if need to start melting after the measurements were taken for specified duration } while (cont_assay && (!_exiting)); From e0f919a9051df04d800d4c49209da72b0d6bb0e1 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 9 Dec 2020 20:32:39 +0100 Subject: [PATCH 09/36] +setting melting on/off --- Programs/Serial_003/Miriam_Serial/Miriam/App.config | 3 +++ Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 3 +++ .../Miriam/Properties/Settings.Designer.cs | 12 ++++++++++++ .../Miriam/Properties/Settings.settings | 3 +++ 4 files changed, 21 insertions(+) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/App.config b/Programs/Serial_003/Miriam_Serial/Miriam/App.config index 5c8dd58..06771ab 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/App.config +++ b/Programs/Serial_003/Miriam_Serial/Miriam/App.config @@ -46,6 +46,9 @@ 1 + + False + \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index eeb2f00..58863bc 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -921,6 +921,8 @@ private void Control_FormClosing(object sender, FormClosingEventArgs e) Miriam_Serial.Properties.Settings.Default.meltInterval = settings_melting["Interval"]; Miriam_Serial.Properties.Settings.Default.meltTolerance = settings_melting["Tolerance"]; + Miriam_Serial.Properties.Settings.Default.meltingEnabled = melting_enabled; + Console.WriteLine(Miriam_Serial.Properties.Settings.Default.settFolderRes); Miriam_Serial.Properties.Settings.Default.Save(); @@ -995,6 +997,7 @@ private void Control_Load(object sender, EventArgs e) settings_melting["TExtra"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureExtra; settings_melting["Interval"] = Miriam_Serial.Properties.Settings.Default.meltInterval; settings_melting["Tolerance"] = Miriam_Serial.Properties.Settings.Default.meltTolerance; + melting_enabled = Miriam_Serial.Properties.Settings.Default.meltingEnabled; SettingsForm = new FormSettings(); } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs index b846d15..c45b070 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs @@ -166,5 +166,17 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio this["meltTolerance"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool meltingEnabled { + get { + return ((bool)(this["meltingEnabled"])); + } + set { + this["meltingEnabled"] = value; + } + } } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings index 8e69037..1eb0ff3 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings @@ -38,5 +38,8 @@ 1 + + False + \ No newline at end of file From 86c3e5b57f2e0d11d78c89ceee2f819d18d06c36 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Fri, 11 Dec 2020 13:07:23 +0100 Subject: [PATCH 10/36] fix temperature threshold check --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 58863bc..2291eb3 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -242,9 +242,9 @@ private bool temperature_reached() float t_mid_val = float.Parse(currentTemperatureInfo["Middle"], CultureInfo.InvariantCulture); float t_extra_val = float.Parse(currentTemperatureInfo["Extra"], CultureInfo.InvariantCulture); - bool t_up = (t_up_val - float.Parse(settings_melting["TUp"]) >= -eps); - bool t_mid = float.Parse(currentTemperatureInfo["Middle"]) - float.Parse(settings_melting["TMiddle"], CultureInfo.InvariantCulture) >= -eps; - bool t_extra = float.Parse(currentTemperatureInfo["Extra"]) - float.Parse(settings_melting["TExtra"], CultureInfo.InvariantCulture) >= -eps; + bool t_up = (t_up_val - float.Parse(settings_melting["TUp"], CultureInfo.InvariantCulture) >= -eps); + bool t_mid = (t_mid_val - float.Parse(settings_melting["TMiddle"], CultureInfo.InvariantCulture) >= -eps); + bool t_extra = (t_extra_val - float.Parse(settings_melting["TExtra"], CultureInfo.InvariantCulture) >= -eps); return t_up && t_mid && t_extra; } From e8dcb52eaf796a3b1cb96b4b223e3c1a1cd1546d Mon Sep 17 00:00:00 2001 From: tatthangvd <46362142+tatthangvd@users.noreply.github.com> Date: Mon, 14 Dec 2020 06:12:20 +0100 Subject: [PATCH 11/36] update melting tune --- Programs/Serial_003/Serial_003.ino | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index f7fe93a..2aab04b 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -239,6 +239,7 @@ void loop () { case CANCEL: HEAT_ON = false; + MELT_ON = false; Output_MIDDLE = 0; Output_UPPER = 0; @@ -278,7 +279,6 @@ void loop () { break; case MELT_HEAT: - HEAT_ON = false; MELT_ON = true; heat_alarm = true; @@ -722,7 +722,7 @@ void SetTunings_PID() { else { //we're far from setpoint, use aggressive tuning parameters - PID_MIDDLE.SetTunings(aggKp/1, aggKi/1, aggKd/1); + PID_MIDDLE.SetTunings(aggKp, aggKi, aggKd); } if(Setpoint_UPPERSetpoint_EXTRA) @@ -744,7 +744,7 @@ void SetTunings_PID() { else { //we're far from setpoint, use aggressive tuning parameters - PID_EXTRA.SetTunings(aggKp/8, aggKi/8, aggKd/8); + PID_EXTRA.SetTunings(aggKp/10, aggKi/10, aggKd/10); } } @@ -758,37 +758,37 @@ void SetTunings_PID_Melt() { gap2 = abs(Setpoint_UPPER - Temperature(TH_UPPERBED,T_CELSIUS,NCP18XH103F03RB,10000.0f)); //distance away from setpoint gap3 = abs(Setpoint_EXTRA - Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)); //distance away from setpoint - if(Temperature(TH_MIDDLEBED_2,T_CELSIUS,NCP18XH103F03RB,10000.0f)>Setpoint_MIDDLE) + if(Temperature(TH_MIDDLEBED_2,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65) { //we're close to setpoint, use conservative tuning parameters - PID_MIDDLE.SetTunings(consKp, consKi, consKd); + PID_MIDDLE.SetTunings(consKp/40, consKi/40, consKd/40); Output_MIDDLE = 0; } else { //we're far from setpoint, use aggressive tuning parameters - PID_MIDDLE.SetTunings(aggKp/80, aggKi/80, aggKd/80); + PID_MIDDLE.SetTunings(aggKp, aggKi, aggKd); } - if(Setpoint_UPPER65) { //we're close to setpoint, use conservative tuning parameters - PID_UPPER.SetTunings(consKp, consKi, consKd); + PID_UPPER.SetTunings(consKp/40, consKi/40, consKd/40); Output_UPPER = 0; } else { //we're far from setpoint, use aggressive tuning parameters - PID_UPPER.SetTunings(aggKp/80, aggKi/80, aggKd/80); + PID_UPPER.SetTunings(aggKp, aggKi, aggKd); } - if(Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)>Setpoint_EXTRA) + if(Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65) { //we're close to setpoint, use conservative tuning parameters - PID_EXTRA.SetTunings(consKp, consKi, consKd); + PID_EXTRA.SetTunings(consKp/50, consKi/50, consKd/50); Output_EXTRA = 0; } else { //we're far from setpoint, use aggressive tuning parameters - PID_EXTRA.SetTunings(aggKp/100, aggKi/100, aggKd/100); + PID_EXTRA.SetTunings(aggKp/10, aggKi/10, aggKd/10); } } From b6ddf056470f19fe2312f13e3eb8883d87637b5e Mon Sep 17 00:00:00 2001 From: tatthangvd <46362142+tatthangvd@users.noreply.github.com> Date: Mon, 14 Dec 2020 06:34:56 +0100 Subject: [PATCH 12/36] Update Serial_003.ino --- Programs/Serial_003/Serial_003.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index 2aab04b..6edc610 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -758,7 +758,7 @@ void SetTunings_PID_Melt() { gap2 = abs(Setpoint_UPPER - Temperature(TH_UPPERBED,T_CELSIUS,NCP18XH103F03RB,10000.0f)); //distance away from setpoint gap3 = abs(Setpoint_EXTRA - Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)); //distance away from setpoint - if(Temperature(TH_MIDDLEBED_2,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65) + if(Temperature(TH_MIDDLEBED_2,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) { //we're close to setpoint, use conservative tuning parameters PID_MIDDLE.SetTunings(consKp/40, consKi/40, consKd/40); Output_MIDDLE = 0; @@ -769,7 +769,7 @@ void SetTunings_PID_Melt() { PID_MIDDLE.SetTunings(aggKp, aggKi, aggKd); } - if(Temperature(TH_UPPERBED,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65) + if(Temperature(TH_UPPERBED,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) { //we're close to setpoint, use conservative tuning parameters PID_UPPER.SetTunings(consKp/40, consKi/40, consKd/40); Output_UPPER = 0; @@ -780,7 +780,7 @@ void SetTunings_PID_Melt() { PID_UPPER.SetTunings(aggKp, aggKi, aggKd); } - if(Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65) + if(Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) { //we're close to setpoint, use conservative tuning parameters PID_EXTRA.SetTunings(consKp/50, consKi/50, consKd/50); Output_EXTRA = 0; From 0784be382c7d52e855e7ea2850c6de514e1fd747 Mon Sep 17 00:00:00 2001 From: tatthangvd <46362142+tatthangvd@users.noreply.github.com> Date: Mon, 14 Dec 2020 11:38:06 +0100 Subject: [PATCH 13/36] Update Serial_003.ino --- Programs/Serial_003/Serial_003.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index 6edc610..d2c3c97 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -760,8 +760,8 @@ void SetTunings_PID_Melt() { if(Temperature(TH_MIDDLEBED_2,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) { //we're close to setpoint, use conservative tuning parameters - PID_MIDDLE.SetTunings(consKp/40, consKi/40, consKd/40); - Output_MIDDLE = 0; + PID_MIDDLE.SetTunings(consKp/25, consKi/25, consKd/25); + } else { @@ -771,8 +771,8 @@ void SetTunings_PID_Melt() { if(Temperature(TH_UPPERBED,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) { //we're close to setpoint, use conservative tuning parameters - PID_UPPER.SetTunings(consKp/40, consKi/40, consKd/40); - Output_UPPER = 0; + PID_UPPER.SetTunings(consKp/25, consKi/25, consKd/25); + } else { @@ -783,7 +783,7 @@ void SetTunings_PID_Melt() { if(Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) { //we're close to setpoint, use conservative tuning parameters PID_EXTRA.SetTunings(consKp/50, consKi/50, consKd/50); - Output_EXTRA = 0; + } else { From d0fcb6eff0f1239afa20ce034ed9137d5cefb4eb Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Tue, 22 Dec 2020 18:48:40 +0100 Subject: [PATCH 14/36] added the controls to the form --- .../Miriam/FormSettings.Designer.cs | 279 ++++++++++++++++-- 1 file changed, 257 insertions(+), 22 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs index 96f52b5..fda19f8 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs @@ -32,6 +32,8 @@ private void InitializeComponent() this.buttonOk = new System.Windows.Forms.Button(); this.checkBoxEnableMelting = new System.Windows.Forms.CheckBox(); this.panelMelting = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.CboxTolerance = new System.Windows.Forms.ComboBox(); this.labelTempE = new System.Windows.Forms.Label(); this.CboxTempE = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); @@ -40,14 +42,32 @@ private void InitializeComponent() this.LabelTempM = new System.Windows.Forms.Label(); this.CboxTempU = new System.Windows.Forms.ComboBox(); this.CboxTempM = new System.Windows.Forms.ComboBox(); - this.label2 = new System.Windows.Forms.Label(); - this.CboxTolerance = new System.Windows.Forms.ComboBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.label5 = new System.Windows.Forms.Label(); + this.comboBox3 = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.comboBox4 = new System.Windows.Forms.ComboBox(); + this.comboBox5 = new System.Windows.Forms.ComboBox(); + this.comboBox7 = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label_results_folder = new System.Windows.Forms.Label(); + this.buttonSaveAs = new System.Windows.Forms.Button(); + this.label11 = new System.Windows.Forms.Label(); this.panelMelting.SuspendLayout(); + this.panel1.SuspendLayout(); this.SuspendLayout(); // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(713, 415); + this.buttonCancel.Location = new System.Drawing.Point(333, 382); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.buttonCancel.TabIndex = 1; @@ -58,7 +78,7 @@ private void InitializeComponent() // buttonOk // this.buttonOk.AccessibleDescription = "Save settings and exit"; - this.buttonOk.Location = new System.Drawing.Point(632, 415); + this.buttonOk.Location = new System.Drawing.Point(252, 382); this.buttonOk.Name = "buttonOk"; this.buttonOk.Size = new System.Drawing.Size(75, 23); this.buttonOk.TabIndex = 2; @@ -69,7 +89,7 @@ private void InitializeComponent() // checkBoxEnableMelting // this.checkBoxEnableMelting.AutoSize = true; - this.checkBoxEnableMelting.Location = new System.Drawing.Point(27, 21); + this.checkBoxEnableMelting.Location = new System.Drawing.Point(25, 222); this.checkBoxEnableMelting.Name = "checkBoxEnableMelting"; this.checkBoxEnableMelting.Size = new System.Drawing.Size(90, 17); this.checkBoxEnableMelting.TabIndex = 3; @@ -90,11 +110,30 @@ private void InitializeComponent() this.panelMelting.Controls.Add(this.CboxTempU); this.panelMelting.Controls.Add(this.CboxTempM); this.panelMelting.Enabled = false; - this.panelMelting.Location = new System.Drawing.Point(12, 45); + this.panelMelting.Location = new System.Drawing.Point(10, 246); this.panelMelting.Name = "panelMelting"; this.panelMelting.Size = new System.Drawing.Size(221, 159); this.panelMelting.TabIndex = 4; // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(20, 120); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(85, 13); + this.label2.TabIndex = 49; + this.label2.Text = "Tolerance [deg.]"; + // + // CboxTolerance + // + this.CboxTolerance.FormattingEnabled = true; + this.CboxTolerance.Location = new System.Drawing.Point(123, 117); + this.CboxTolerance.Margin = new System.Windows.Forms.Padding(2); + this.CboxTolerance.Name = "CboxTolerance"; + this.CboxTolerance.Size = new System.Drawing.Size(82, 21); + this.CboxTolerance.TabIndex = 48; + // // labelTempE // this.labelTempE.AutoSize = true; @@ -171,30 +210,205 @@ private void InitializeComponent() this.CboxTempM.Size = new System.Drawing.Size(82, 21); this.CboxTempM.TabIndex = 40; // - // label2 + // panel1 // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(20, 120); - this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(85, 13); - this.label2.TabIndex = 49; - this.label2.Text = "Tolerance [deg.]"; + this.panel1.Controls.Add(this.label8); + this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.comboBox7); + this.panel1.Controls.Add(this.comboBox1); + this.panel1.Controls.Add(this.label4); + this.panel1.Controls.Add(this.comboBox2); + this.panel1.Controls.Add(this.label5); + this.panel1.Controls.Add(this.comboBox3); + this.panel1.Controls.Add(this.label6); + this.panel1.Controls.Add(this.label7); + this.panel1.Controls.Add(this.comboBox4); + this.panel1.Controls.Add(this.comboBox5); + this.panel1.Enabled = false; + this.panel1.Location = new System.Drawing.Point(11, 30); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(221, 185); + this.panel1.TabIndex = 6; // - // CboxTolerance + // comboBox1 // - this.CboxTolerance.FormattingEnabled = true; - this.CboxTolerance.Location = new System.Drawing.Point(123, 117); - this.CboxTolerance.Margin = new System.Windows.Forms.Padding(2); - this.CboxTolerance.Name = "CboxTolerance"; - this.CboxTolerance.Size = new System.Drawing.Size(82, 21); - this.CboxTolerance.TabIndex = 48; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(123, 122); + this.comboBox1.Margin = new System.Windows.Forms.Padding(2); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(82, 21); + this.comboBox1.TabIndex = 48; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(62, 67); + this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(57, 13); + this.label4.TabIndex = 47; + this.label4.Text = "Extra temp"; + // + // comboBox2 + // + this.comboBox2.FormattingEnabled = true; + this.comboBox2.Location = new System.Drawing.Point(123, 64); + this.comboBox2.Margin = new System.Windows.Forms.Padding(2); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(82, 21); + this.comboBox2.TabIndex = 46; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(20, 125); + this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(99, 13); + this.label5.TabIndex = 45; + this.label5.Text = "Measure interval [s]"; + // + // comboBox3 + // + this.comboBox3.FormattingEnabled = true; + this.comboBox3.Location = new System.Drawing.Point(123, 93); + this.comboBox3.Margin = new System.Windows.Forms.Padding(2); + this.comboBox3.Name = "comboBox3"; + this.comboBox3.Size = new System.Drawing.Size(82, 21); + this.comboBox3.TabIndex = 44; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(57, 38); + this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(62, 13); + this.label6.TabIndex = 43; + this.label6.Text = "Upper temp"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(55, 9); + this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(64, 13); + this.label7.TabIndex = 42; + this.label7.Text = "Middle temp"; + // + // comboBox4 + // + this.comboBox4.FormattingEnabled = true; + this.comboBox4.Location = new System.Drawing.Point(123, 35); + this.comboBox4.Margin = new System.Windows.Forms.Padding(2); + this.comboBox4.Name = "comboBox4"; + this.comboBox4.Size = new System.Drawing.Size(82, 21); + this.comboBox4.TabIndex = 41; + // + // comboBox5 + // + this.comboBox5.FormattingEnabled = true; + this.comboBox5.Location = new System.Drawing.Point(123, 6); + this.comboBox5.Margin = new System.Windows.Forms.Padding(2); + this.comboBox5.Name = "comboBox5"; + this.comboBox5.Size = new System.Drawing.Size(82, 21); + this.comboBox5.TabIndex = 40; + // + // comboBox7 + // + this.comboBox7.FormattingEnabled = true; + this.comboBox7.Location = new System.Drawing.Point(123, 151); + this.comboBox7.Margin = new System.Windows.Forms.Padding(2); + this.comboBox7.Name = "comboBox7"; + this.comboBox7.Size = new System.Drawing.Size(82, 21); + this.comboBox7.TabIndex = 50; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(22, 96); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(97, 13); + this.label3.TabIndex = 51; + this.label3.Text = "Box temp threshold"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(47, 154); + this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(72, 13); + this.label8.TabIndex = 52; + this.label8.Text = "Duration [min]"; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(266, 91); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(86, 20); + this.textBox1.TabIndex = 7; + this.textBox1.Text = "miriam"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(266, 75); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(80, 13); + this.label9.TabIndex = 8; + this.label9.Text = "Filename prefix:"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(266, 20); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(112, 13); + this.label10.TabIndex = 9; + this.label10.Text = "Results storage folder:"; + // + // label_results_folder + // + this.label_results_folder.AutoSize = true; + this.label_results_folder.Location = new System.Drawing.Point(266, 45); + this.label_results_folder.Name = "label_results_folder"; + this.label_results_folder.Size = new System.Drawing.Size(75, 13); + this.label_results_folder.TabIndex = 10; + this.label_results_folder.Text = "(results_folder)"; + // + // buttonSaveAs + // + this.buttonSaveAs.Location = new System.Drawing.Point(380, 12); + this.buttonSaveAs.Name = "buttonSaveAs"; + this.buttonSaveAs.Size = new System.Drawing.Size(28, 29); + this.buttonSaveAs.TabIndex = 36; + this.buttonSaveAs.Text = "..."; + this.buttonSaveAs.UseVisualStyleBackColor = true; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(22, 9); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(110, 13); + this.label11.TabIndex = 37; + this.label11.Text = "Measurement settings"; // // FormSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(423, 415); + this.Controls.Add(this.label11); + this.Controls.Add(this.buttonSaveAs); + this.Controls.Add(this.label_results_folder); + this.Controls.Add(this.label10); + this.Controls.Add(this.label9); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.panel1); this.Controls.Add(this.panelMelting); this.Controls.Add(this.checkBoxEnableMelting); this.Controls.Add(this.buttonOk); @@ -204,6 +418,8 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.FormSettings_Load); this.panelMelting.ResumeLayout(false); this.panelMelting.PerformLayout(); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -225,5 +441,24 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox CboxTempM; private System.Windows.Forms.Label label2; private System.Windows.Forms.ComboBox CboxTolerance; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.ComboBox comboBox3; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.ComboBox comboBox4; + private System.Windows.Forms.ComboBox comboBox5; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox comboBox7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label_results_folder; + private System.Windows.Forms.Button buttonSaveAs; + private System.Windows.Forms.Label label11; } } \ No newline at end of file From 4da18bbb2a32234cbc6c4872679837163a028135 Mon Sep 17 00:00:00 2001 From: an_ti Date: Mon, 28 Dec 2020 20:46:20 +0300 Subject: [PATCH 15/36] moved measurement settings --- .../Miriam_Serial/Miriam/Control.Designer.cs | 154 +--------------- .../Miriam_Serial/Miriam/Control.cs | 87 ++++----- .../Miriam/FormSettings.Designer.cs | 171 +++++++++--------- .../Miriam_Serial/Miriam/FormSettings.cs | 53 ++++++ 4 files changed, 177 insertions(+), 288 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs index 97c11eb..23ecc71 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs @@ -35,12 +35,6 @@ private void InitializeComponent() System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Control)); this.ButtonStart = new System.Windows.Forms.Button(); - this.LabelTempU = new System.Windows.Forms.Label(); - this.LabelTempM = new System.Windows.Forms.Label(); - this.LabelDuration = new System.Windows.Forms.Label(); - this.CboxTempU = new System.Windows.Forms.ComboBox(); - this.CboxTempM = new System.Windows.Forms.ComboBox(); - this.CboxDuration = new System.Windows.Forms.ComboBox(); this.Plate = new System.Windows.Forms.DataGridView(); this.LabelTempUC = new System.Windows.Forms.Label(); this.LabelTempMC = new System.Windows.Forms.Label(); @@ -51,8 +45,6 @@ private void InitializeComponent() this.ButtonWrite = new System.Windows.Forms.Button(); this.COM_label = new System.Windows.Forms.Label(); this.COM = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.CboxInterval = new System.Windows.Forms.ComboBox(); this.buttonFillAll = new System.Windows.Forms.Button(); this.buttonClearAll = new System.Windows.Forms.Button(); this.buttonSaveAs = new System.Windows.Forms.Button(); @@ -60,10 +52,6 @@ private void InitializeComponent() this.folderBrowserSaveRes = new System.Windows.Forms.FolderBrowserDialog(); this.LabelTempBoxC = new System.Windows.Forms.Label(); this.LabelTempEC = new System.Windows.Forms.Label(); - this.labelTempE = new System.Windows.Forms.Label(); - this.CboxTempE = new System.Windows.Forms.ComboBox(); - this.labelThr = new System.Windows.Forms.Label(); - this.CboxTempThr = new System.Windows.Forms.ComboBox(); this.buttonChangeSettings = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.Plate)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.Results)).BeginInit(); @@ -80,63 +68,6 @@ private void InitializeComponent() this.ButtonStart.UseVisualStyleBackColor = true; this.ButtonStart.Click += new System.EventHandler(this.ButtonStart_Click); // - // LabelTempU - // - this.LabelTempU.AutoSize = true; - this.LabelTempU.Location = new System.Drawing.Point(103, 51); - this.LabelTempU.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.LabelTempU.Name = "LabelTempU"; - this.LabelTempU.Size = new System.Drawing.Size(62, 13); - this.LabelTempU.TabIndex = 18; - this.LabelTempU.Text = "Upper temp"; - // - // LabelTempM - // - this.LabelTempM.AutoSize = true; - this.LabelTempM.Location = new System.Drawing.Point(11, 51); - this.LabelTempM.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.LabelTempM.Name = "LabelTempM"; - this.LabelTempM.Size = new System.Drawing.Size(64, 13); - this.LabelTempM.TabIndex = 17; - this.LabelTempM.Text = "Middle temp"; - // - // LabelDuration - // - this.LabelDuration.AutoSize = true; - this.LabelDuration.Location = new System.Drawing.Point(11, 85); - this.LabelDuration.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.LabelDuration.Name = "LabelDuration"; - this.LabelDuration.Size = new System.Drawing.Size(69, 13); - this.LabelDuration.TabIndex = 16; - this.LabelDuration.Text = "Duration[min]"; - // - // CboxTempU - // - this.CboxTempU.FormattingEnabled = true; - this.CboxTempU.Location = new System.Drawing.Point(103, 64); - this.CboxTempU.Margin = new System.Windows.Forms.Padding(2); - this.CboxTempU.Name = "CboxTempU"; - this.CboxTempU.Size = new System.Drawing.Size(82, 21); - this.CboxTempU.TabIndex = 15; - // - // CboxTempM - // - this.CboxTempM.FormattingEnabled = true; - this.CboxTempM.Location = new System.Drawing.Point(11, 64); - this.CboxTempM.Margin = new System.Windows.Forms.Padding(2); - this.CboxTempM.Name = "CboxTempM"; - this.CboxTempM.Size = new System.Drawing.Size(82, 21); - this.CboxTempM.TabIndex = 14; - // - // CboxDuration - // - this.CboxDuration.FormattingEnabled = true; - this.CboxDuration.Location = new System.Drawing.Point(11, 100); - this.CboxDuration.Margin = new System.Windows.Forms.Padding(2); - this.CboxDuration.Name = "CboxDuration"; - this.CboxDuration.Size = new System.Drawing.Size(82, 21); - this.CboxDuration.TabIndex = 13; - // // Plate // this.Plate.AllowDrop = true; @@ -246,25 +177,6 @@ private void InitializeComponent() this.COM.Size = new System.Drawing.Size(82, 21); this.COM.TabIndex = 29; // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(103, 87); - this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(99, 13); - this.label1.TabIndex = 31; - this.label1.Text = "Measure interval [s]"; - // - // CboxInterval - // - this.CboxInterval.FormattingEnabled = true; - this.CboxInterval.Location = new System.Drawing.Point(103, 102); - this.CboxInterval.Margin = new System.Windows.Forms.Padding(2); - this.CboxInterval.Name = "CboxInterval"; - this.CboxInterval.Size = new System.Drawing.Size(99, 21); - this.CboxInterval.TabIndex = 30; - // // buttonFillAll // this.buttonFillAll.Location = new System.Drawing.Point(388, 98); @@ -319,47 +231,9 @@ private void InitializeComponent() this.LabelTempEC.TabIndex = 36; this.LabelTempEC.Text = "Temperature Extra:"; // - // labelTempE - // - this.labelTempE.AutoSize = true; - this.labelTempE.Location = new System.Drawing.Point(196, 51); - this.labelTempE.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.labelTempE.Name = "labelTempE"; - this.labelTempE.Size = new System.Drawing.Size(57, 13); - this.labelTempE.TabIndex = 39; - this.labelTempE.Text = "Extra temp"; - // - // CboxTempE - // - this.CboxTempE.FormattingEnabled = true; - this.CboxTempE.Location = new System.Drawing.Point(196, 64); - this.CboxTempE.Margin = new System.Windows.Forms.Padding(2); - this.CboxTempE.Name = "CboxTempE"; - this.CboxTempE.Size = new System.Drawing.Size(82, 21); - this.CboxTempE.TabIndex = 38; - // - // labelThr - // - this.labelThr.AutoSize = true; - this.labelThr.Location = new System.Drawing.Point(221, 87); - this.labelThr.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.labelThr.Name = "labelThr"; - this.labelThr.Size = new System.Drawing.Size(97, 13); - this.labelThr.TabIndex = 41; - this.labelThr.Text = "Box temp threshold"; - // - // CboxTempThr - // - this.CboxTempThr.FormattingEnabled = true; - this.CboxTempThr.Location = new System.Drawing.Point(221, 100); - this.CboxTempThr.Margin = new System.Windows.Forms.Padding(2); - this.CboxTempThr.Name = "CboxTempThr"; - this.CboxTempThr.Size = new System.Drawing.Size(82, 21); - this.CboxTempThr.TabIndex = 40; - // // buttonChangeSettings // - this.buttonChangeSettings.Location = new System.Drawing.Point(308, 98); + this.buttonChangeSettings.Location = new System.Drawing.Point(8, 53); this.buttonChangeSettings.Name = "buttonChangeSettings"; this.buttonChangeSettings.Size = new System.Drawing.Size(75, 23); this.buttonChangeSettings.TabIndex = 42; @@ -372,19 +246,13 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlDark; - this.ClientSize = new System.Drawing.Size(555, 373); + this.ClientSize = new System.Drawing.Size(555, 375); this.Controls.Add(this.buttonChangeSettings); - this.Controls.Add(this.labelThr); - this.Controls.Add(this.CboxTempThr); - this.Controls.Add(this.labelTempE); - this.Controls.Add(this.CboxTempE); this.Controls.Add(this.LabelTempBoxC); this.Controls.Add(this.LabelTempEC); this.Controls.Add(this.buttonSaveAs); this.Controls.Add(this.buttonClearAll); this.Controls.Add(this.buttonFillAll); - this.Controls.Add(this.label1); - this.Controls.Add(this.CboxInterval); this.Controls.Add(this.COM); this.Controls.Add(this.COM_label); this.Controls.Add(this.ButtonWrite); @@ -395,12 +263,6 @@ private void InitializeComponent() this.Controls.Add(this.LabelTempMC); this.Controls.Add(this.LabelTempUC); this.Controls.Add(this.Plate); - this.Controls.Add(this.LabelTempU); - this.Controls.Add(this.LabelTempM); - this.Controls.Add(this.LabelDuration); - this.Controls.Add(this.CboxTempU); - this.Controls.Add(this.CboxTempM); - this.Controls.Add(this.CboxDuration); this.Controls.Add(this.ButtonStart); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Margin = new System.Windows.Forms.Padding(2); @@ -418,12 +280,6 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Button ButtonStart; - private System.Windows.Forms.Label LabelTempU; - private System.Windows.Forms.Label LabelTempM; - private System.Windows.Forms.Label LabelDuration; - private System.Windows.Forms.ComboBox CboxTempU; - private System.Windows.Forms.ComboBox CboxTempM; - private System.Windows.Forms.ComboBox CboxDuration; private System.Windows.Forms.DataGridView Plate; private Label LabelTempUC; private Label LabelTempMC; @@ -434,8 +290,6 @@ private void InitializeComponent() private Button ButtonWrite; private Label COM_label; private ComboBox COM; - private Label label1; - private ComboBox CboxInterval; private Button buttonFillAll; private Button buttonClearAll; private Button buttonSaveAs; @@ -443,10 +297,6 @@ private void InitializeComponent() private FolderBrowserDialog folderBrowserSaveRes; private Label LabelTempBoxC; private Label LabelTempEC; - private Label labelTempE; - private ComboBox CboxTempE; - private Label labelThr; - private ComboBox CboxTempThr; private Button buttonChangeSettings; } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 2291eb3..31c454c 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -71,7 +71,16 @@ public partial class Control : Form { "Interval", "30" }, { "Tolerance", "0.1"} }; - + public struct SettingsMeasurement + { + public double TUp; + public double TMiddle; + public double TExtra; + public double TThreshold; + public int MeasureIntervalSec; + public double DurationMin; + } + public static SettingsMeasurement settings_measurement; private static string ArduinoReadout(SerialPort serialPort, string command) { serialPort.Write(command + "\r\n"); @@ -150,7 +159,7 @@ public void start_heat(string t_up, string t_middle, string t_extra, string thre public Control() { InitializeComponent(); - + settings_measurement = new SettingsMeasurement(); assay_thread = new System.Threading.Thread(new System.Threading.ThreadStart(doAssay)); temperatureInfoMap = new Dictionary { @@ -180,37 +189,6 @@ public Control() } - for (int i = 55; i < 70; i++) - { - CboxTempM.Items.Add(i); - } - for (int i = 80; i < 90; i++) - { - CboxTempU.Items.Add(i); - } - for (int i = 55; i < 90; i++) - { - CboxTempE.Items.Add(i); - } - for (int i = 40; i < 80; i++) - { - CboxTempThr.Items.Add(i); - } - - for (int i = 0; i < 150; i++) - { - CboxDuration.Items.Add(i); - } - for (int i = 10; i < 600; i++) - { - CboxInterval.Items.Add(i); // AT: minimum time a measurement takes is 11 seconds - } - CboxTempU.Text = "90"; - CboxTempM.Text = "65"; - CboxTempE.Text = "65"; - CboxDuration.Text = "120"; - CboxInterval.Text = "10"; - //CreatePlate(); CreateEmptyPlate(); // todo: load from file button @@ -342,16 +320,16 @@ private void ButtonHeat_Click(object sender, EventArgs e) //RecievedData = serialPort.ReadLine(); //serialPort.DataReceived += new SerialDataReceivedEventHandler(responseHandler); // [AT] SW 'M param' (middle wanted temperature, i.e. M 63) - FW 'temperatureMiddleSet' - var s = ArduinoReadout(serialPort, "M " + CboxTempM.Text); + var s = ArduinoReadout(serialPort, "M " + settings_measurement.TMiddle.ToString()); Console.WriteLine(s); - s = ArduinoReadout(serialPort, "U " + CboxTempU.Text); + s = ArduinoReadout(serialPort, "U " + settings_measurement.TUp.ToString()); Console.WriteLine(s); - s = ArduinoReadout(serialPort, "E " + CboxTempE.Text); + s = ArduinoReadout(serialPort, "E " + settings_measurement.TExtra.ToString()); Console.WriteLine(s); - s = ArduinoReadout(serialPort, "T " + CboxTempThr.Text); + s = ArduinoReadout(serialPort, "T " + settings_measurement.TThreshold.ToString()); Console.WriteLine(s); s = ArduinoReadout(serialPort, "H"); @@ -481,9 +459,9 @@ private void ButtonStart_Click(object sender, EventArgs e) time_to_stop_assay = localDate.Hour * 60 * 60 + localDate.Minute * 60 + localDate.Second + - Convert.ToInt32(CboxDuration.Text) * 60; + Convert.ToInt32(settings_measurement.DurationMin * 60); - betweenMesSec = Convert.ToInt32(CboxInterval.Text); + betweenMesSec = settings_measurement.MeasureIntervalSec; Boolean noneFound = true; List dupl = new List(); @@ -908,12 +886,18 @@ private void Control_FormClosing(object sender, FormClosingEventArgs e) savePlateCells(cells_fname); Miriam_Serial.Properties.Settings.Default.settFolderRes = folderBrowserSaveRes.SelectedPath; - Miriam_Serial.Properties.Settings.Default.settTemperatureMid = CboxTempM.Text; - Miriam_Serial.Properties.Settings.Default.settTemperatureUp = CboxTempU.Text; - Miriam_Serial.Properties.Settings.Default.settTemperatureExtra = CboxTempE.Text; - Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold = CboxTempThr.Text; - Miriam_Serial.Properties.Settings.Default.settDuration = CboxDuration.Text; - Miriam_Serial.Properties.Settings.Default.settInterval = CboxInterval.Text; + //Miriam_Serial.Properties.Settings.Default.settTemperatureMid = CboxTempM.Text; + //Miriam_Serial.Properties.Settings.Default.settTemperatureUp = CboxTempU.Text; + //Miriam_Serial.Properties.Settings.Default.settTemperatureExtra = CboxTempE.Text; + //Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold = CboxTempThr.Text; + //Miriam_Serial.Properties.Settings.Default.settDuration = CboxDuration.Text; + //Miriam_Serial.Properties.Settings.Default.settInterval = CboxInterval.Text; + Miriam_Serial.Properties.Settings.Default.settTemperatureMid = settings_measurement.TMiddle.ToString(); + Miriam_Serial.Properties.Settings.Default.settTemperatureUp = settings_measurement.TUp.ToString(); + Miriam_Serial.Properties.Settings.Default.settTemperatureExtra = settings_measurement.TExtra.ToString(); + Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold = settings_measurement.TThreshold.ToString(); + Miriam_Serial.Properties.Settings.Default.settDuration = settings_measurement.DurationMin.ToString(); + Miriam_Serial.Properties.Settings.Default.settInterval = settings_measurement.MeasureIntervalSec.ToString(); Miriam_Serial.Properties.Settings.Default.meltTemperatureUp = settings_melting["TUp"]; Miriam_Serial.Properties.Settings.Default.meltTemperatureMid = settings_melting["TMiddle"]; @@ -985,12 +969,13 @@ private void Control_Load(object sender, EventArgs e) folderBrowserSaveRes.SelectedPath = Miriam_Serial.Properties.Settings.Default.settFolderRes; } Console.WriteLine("folder: {0}", folderName); - CboxTempU.Text = Miriam_Serial.Properties.Settings.Default.settTemperatureUp; - CboxTempM.Text = Miriam_Serial.Properties.Settings.Default.settTemperatureMid; - CboxTempE.Text = Miriam_Serial.Properties.Settings.Default.settTemperatureExtra; - CboxDuration.Text = Miriam_Serial.Properties.Settings.Default.settDuration; - CboxInterval.Text = Miriam_Serial.Properties.Settings.Default.settInterval; - CboxTempThr.Text = Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold; + settings_measurement.TMiddle = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureMid); + settings_measurement.TUp = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureUp); + settings_measurement.TExtra = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureExtra); + settings_measurement.DurationMin = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settDuration); + settings_measurement.MeasureIntervalSec = Convert.ToInt32(Miriam_Serial.Properties.Settings.Default.settInterval); + settings_measurement.TThreshold = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold); + settings_melting["TUp"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureUp; settings_melting["TMiddle"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureMid; diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs index fda19f8..17f0e00 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs @@ -43,18 +43,18 @@ private void InitializeComponent() this.CboxTempU = new System.Windows.Forms.ComboBox(); this.CboxTempM = new System.Windows.Forms.ComboBox(); this.panel1 = new System.Windows.Forms.Panel(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.cBoxMesDuration = new System.Windows.Forms.ComboBox(); + this.cBoxMesInterval = new System.Windows.Forms.ComboBox(); this.label4 = new System.Windows.Forms.Label(); - this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.cBoxMesETemp = new System.Windows.Forms.ComboBox(); this.label5 = new System.Windows.Forms.Label(); - this.comboBox3 = new System.Windows.Forms.ComboBox(); + this.cBoxMesThrTemp = new System.Windows.Forms.ComboBox(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); - this.comboBox4 = new System.Windows.Forms.ComboBox(); - this.comboBox5 = new System.Windows.Forms.ComboBox(); - this.comboBox7 = new System.Windows.Forms.ComboBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); + this.cBoxMesUTemp = new System.Windows.Forms.ComboBox(); + this.cBoxMesMTemp = new System.Windows.Forms.ComboBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); @@ -214,30 +214,58 @@ private void InitializeComponent() // this.panel1.Controls.Add(this.label8); this.panel1.Controls.Add(this.label3); - this.panel1.Controls.Add(this.comboBox7); - this.panel1.Controls.Add(this.comboBox1); + this.panel1.Controls.Add(this.cBoxMesDuration); + this.panel1.Controls.Add(this.cBoxMesInterval); this.panel1.Controls.Add(this.label4); - this.panel1.Controls.Add(this.comboBox2); + this.panel1.Controls.Add(this.cBoxMesETemp); this.panel1.Controls.Add(this.label5); - this.panel1.Controls.Add(this.comboBox3); + this.panel1.Controls.Add(this.cBoxMesThrTemp); this.panel1.Controls.Add(this.label6); this.panel1.Controls.Add(this.label7); - this.panel1.Controls.Add(this.comboBox4); - this.panel1.Controls.Add(this.comboBox5); - this.panel1.Enabled = false; + this.panel1.Controls.Add(this.cBoxMesUTemp); + this.panel1.Controls.Add(this.cBoxMesMTemp); this.panel1.Location = new System.Drawing.Point(11, 30); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(221, 185); this.panel1.TabIndex = 6; // - // comboBox1 + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(47, 154); + this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(72, 13); + this.label8.TabIndex = 52; + this.label8.Text = "Duration [min]"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(22, 96); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(97, 13); + this.label3.TabIndex = 51; + this.label3.Text = "Box temp threshold"; + // + // cBoxMesDuration // - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Location = new System.Drawing.Point(123, 122); - this.comboBox1.Margin = new System.Windows.Forms.Padding(2); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(82, 21); - this.comboBox1.TabIndex = 48; + this.cBoxMesDuration.FormattingEnabled = true; + this.cBoxMesDuration.Location = new System.Drawing.Point(123, 151); + this.cBoxMesDuration.Margin = new System.Windows.Forms.Padding(2); + this.cBoxMesDuration.Name = "cBoxMesDuration"; + this.cBoxMesDuration.Size = new System.Drawing.Size(82, 21); + this.cBoxMesDuration.TabIndex = 50; + // + // cBoxMesInterval + // + this.cBoxMesInterval.FormattingEnabled = true; + this.cBoxMesInterval.Location = new System.Drawing.Point(123, 122); + this.cBoxMesInterval.Margin = new System.Windows.Forms.Padding(2); + this.cBoxMesInterval.Name = "cBoxMesInterval"; + this.cBoxMesInterval.Size = new System.Drawing.Size(82, 21); + this.cBoxMesInterval.TabIndex = 48; // // label4 // @@ -249,14 +277,14 @@ private void InitializeComponent() this.label4.TabIndex = 47; this.label4.Text = "Extra temp"; // - // comboBox2 + // cBoxMesETemp // - this.comboBox2.FormattingEnabled = true; - this.comboBox2.Location = new System.Drawing.Point(123, 64); - this.comboBox2.Margin = new System.Windows.Forms.Padding(2); - this.comboBox2.Name = "comboBox2"; - this.comboBox2.Size = new System.Drawing.Size(82, 21); - this.comboBox2.TabIndex = 46; + this.cBoxMesETemp.FormattingEnabled = true; + this.cBoxMesETemp.Location = new System.Drawing.Point(123, 64); + this.cBoxMesETemp.Margin = new System.Windows.Forms.Padding(2); + this.cBoxMesETemp.Name = "cBoxMesETemp"; + this.cBoxMesETemp.Size = new System.Drawing.Size(82, 21); + this.cBoxMesETemp.TabIndex = 46; // // label5 // @@ -268,14 +296,15 @@ private void InitializeComponent() this.label5.TabIndex = 45; this.label5.Text = "Measure interval [s]"; // - // comboBox3 + // cBoxMesThrTemp // - this.comboBox3.FormattingEnabled = true; - this.comboBox3.Location = new System.Drawing.Point(123, 93); - this.comboBox3.Margin = new System.Windows.Forms.Padding(2); - this.comboBox3.Name = "comboBox3"; - this.comboBox3.Size = new System.Drawing.Size(82, 21); - this.comboBox3.TabIndex = 44; + this.cBoxMesThrTemp.FormatString = "N2"; + this.cBoxMesThrTemp.FormattingEnabled = true; + this.cBoxMesThrTemp.Location = new System.Drawing.Point(123, 93); + this.cBoxMesThrTemp.Margin = new System.Windows.Forms.Padding(2); + this.cBoxMesThrTemp.Name = "cBoxMesThrTemp"; + this.cBoxMesThrTemp.Size = new System.Drawing.Size(82, 21); + this.cBoxMesThrTemp.TabIndex = 44; // // label6 // @@ -297,52 +326,24 @@ private void InitializeComponent() this.label7.TabIndex = 42; this.label7.Text = "Middle temp"; // - // comboBox4 - // - this.comboBox4.FormattingEnabled = true; - this.comboBox4.Location = new System.Drawing.Point(123, 35); - this.comboBox4.Margin = new System.Windows.Forms.Padding(2); - this.comboBox4.Name = "comboBox4"; - this.comboBox4.Size = new System.Drawing.Size(82, 21); - this.comboBox4.TabIndex = 41; - // - // comboBox5 - // - this.comboBox5.FormattingEnabled = true; - this.comboBox5.Location = new System.Drawing.Point(123, 6); - this.comboBox5.Margin = new System.Windows.Forms.Padding(2); - this.comboBox5.Name = "comboBox5"; - this.comboBox5.Size = new System.Drawing.Size(82, 21); - this.comboBox5.TabIndex = 40; - // - // comboBox7 + // cBoxMesUTemp // - this.comboBox7.FormattingEnabled = true; - this.comboBox7.Location = new System.Drawing.Point(123, 151); - this.comboBox7.Margin = new System.Windows.Forms.Padding(2); - this.comboBox7.Name = "comboBox7"; - this.comboBox7.Size = new System.Drawing.Size(82, 21); - this.comboBox7.TabIndex = 50; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(22, 96); - this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(97, 13); - this.label3.TabIndex = 51; - this.label3.Text = "Box temp threshold"; + this.cBoxMesUTemp.FormattingEnabled = true; + this.cBoxMesUTemp.Location = new System.Drawing.Point(123, 35); + this.cBoxMesUTemp.Margin = new System.Windows.Forms.Padding(2); + this.cBoxMesUTemp.Name = "cBoxMesUTemp"; + this.cBoxMesUTemp.Size = new System.Drawing.Size(82, 21); + this.cBoxMesUTemp.TabIndex = 41; // - // label8 + // cBoxMesMTemp // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(47, 154); - this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(72, 13); - this.label8.TabIndex = 52; - this.label8.Text = "Duration [min]"; + this.cBoxMesMTemp.FormatString = "N2"; + this.cBoxMesMTemp.FormattingEnabled = true; + this.cBoxMesMTemp.Location = new System.Drawing.Point(123, 6); + this.cBoxMesMTemp.Margin = new System.Windows.Forms.Padding(2); + this.cBoxMesMTemp.Name = "cBoxMesMTemp"; + this.cBoxMesMTemp.Size = new System.Drawing.Size(82, 21); + this.cBoxMesMTemp.TabIndex = 40; // // textBox1 // @@ -442,17 +443,17 @@ private void InitializeComponent() private System.Windows.Forms.Label label2; private System.Windows.Forms.ComboBox CboxTolerance; private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ComboBox cBoxMesInterval; private System.Windows.Forms.Label label4; - private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.ComboBox cBoxMesETemp; private System.Windows.Forms.Label label5; - private System.Windows.Forms.ComboBox comboBox3; + private System.Windows.Forms.ComboBox cBoxMesThrTemp; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; - private System.Windows.Forms.ComboBox comboBox4; - private System.Windows.Forms.ComboBox comboBox5; + private System.Windows.Forms.ComboBox cBoxMesUTemp; + private System.Windows.Forms.ComboBox cBoxMesMTemp; private System.Windows.Forms.Label label3; - private System.Windows.Forms.ComboBox comboBox7; + private System.Windows.Forms.ComboBox cBoxMesDuration; private System.Windows.Forms.Label label8; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label9; diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs index b55be08..26fb819 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -34,15 +34,59 @@ public FormSettings() CboxInterval.Items.Add(i); } + + for (int i = 55; i < 70; i++) + { + cBoxMesMTemp.Items.Add(i); + } + for (int i = 80; i < 90; i++) + { + cBoxMesUTemp.Items.Add(i); + } + for (int i = 55; i < 90; i++) + { + cBoxMesETemp.Items.Add(i); + + } + for (int i = 40; i < 80; i++) + { + cBoxMesThrTemp.Items.Add(i); + } + + for (int i = 0; i < 150; i++) + { + cBoxMesDuration.Items.Add(i); + } + for (int i = 10; i < 600; i++) + { + cBoxMesInterval.Items.Add(i); + //CboxInterval.Items.Add(i); // AT: minimum time a measurement takes is 11 seconds + } + //CboxTempU.Text = "90"; + //CboxTempM.Text = "65"; + //CboxTempE.Text = "65"; + ////CboxDuration.Text = "120"; + //CboxInterval.Text = "10"; + } private void buttonOk_Click(object sender, EventArgs e) { + // apply assay settings + Control.settings_measurement.TMiddle = Convert.ToDouble(cBoxMesMTemp.Text); + Control.settings_measurement.TUp = Convert.ToDouble(cBoxMesUTemp.Text); + Control.settings_measurement.TExtra = Convert.ToDouble(cBoxMesETemp.Text); + Control.settings_measurement.TThreshold = Convert.ToDouble(cBoxMesThrTemp.Text); + Control.settings_measurement.MeasureIntervalSec = Convert.ToInt32(cBoxMesInterval.Text); + Control.settings_measurement.DurationMin = Convert.ToDouble(cBoxMesDuration.Text); + + // apply melting settings Control.melting_enabled = checkBoxEnableMelting.Checked; Control.settings_melting["TUp"] = CboxTempU.Text; Control.settings_melting["TMiddle"] = CboxTempM.Text; Control.settings_melting["TExtra"] = CboxTempE.Text; Control.settings_melting["Interval"] = CboxInterval.Text; + this.DialogResult = DialogResult.OK; } @@ -58,12 +102,21 @@ private void checkBoxEnableMelting_CheckedChanged(object sender, EventArgs e) private void FormSettings_Load(object sender, EventArgs e) { + // melting settings checkBoxEnableMelting.Checked = Control.melting_enabled; CboxTempU.Text = Control.settings_melting["TUp"]; CboxTempM.Text = Control.settings_melting["TMiddle"]; CboxTempE.Text = Control.settings_melting["TExtra"]; CboxInterval.Text = Control.settings_melting["Interval"]; CboxTolerance.Text = Control.settings_melting["Tolerance"]; + + // measurement settings + cBoxMesMTemp.Text = Control.settings_measurement.TMiddle.ToString(); + cBoxMesUTemp.Text = Control.settings_measurement.TUp.ToString(); + cBoxMesETemp.Text = Control.settings_measurement.TExtra.ToString(); + cBoxMesThrTemp.Text = Control.settings_measurement.TThreshold.ToString(); + cBoxMesInterval.Text = Control.settings_measurement.MeasureIntervalSec.ToString(); + cBoxMesDuration.Text = Control.settings_measurement.DurationMin.ToString(); } } } From 7e722b723cf3d6f997ce80d3f12f95ce43261163 Mon Sep 17 00:00:00 2001 From: an_ti Date: Tue, 29 Dec 2020 15:48:09 +0300 Subject: [PATCH 16/36] moved folder setting --- .../Miriam_Serial/Miriam/Control.Designer.cs | 31 +++------------- .../Miriam_Serial/Miriam/Control.cs | 19 +++------- .../Miriam_Serial/Miriam/Control.resx | 3 -- .../Miriam/FormSettings.Designer.cs | 37 +++++++++++-------- .../Miriam_Serial/Miriam/FormSettings.cs | 17 +++++++++ .../Miriam_Serial/Miriam/FormSettings.resx | 3 ++ 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs index 23ecc71..d530c9a 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs @@ -31,8 +31,8 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Control)); this.ButtonStart = new System.Windows.Forms.Button(); this.Plate = new System.Windows.Forms.DataGridView(); @@ -47,9 +47,7 @@ private void InitializeComponent() this.COM = new System.Windows.Forms.ComboBox(); this.buttonFillAll = new System.Windows.Forms.Button(); this.buttonClearAll = new System.Windows.Forms.Button(); - this.buttonSaveAs = new System.Windows.Forms.Button(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.folderBrowserSaveRes = new System.Windows.Forms.FolderBrowserDialog(); this.LabelTempBoxC = new System.Windows.Forms.Label(); this.LabelTempEC = new System.Windows.Forms.Label(); this.buttonChangeSettings = new System.Windows.Forms.Button(); @@ -135,10 +133,10 @@ private void InitializeComponent() // this.Results.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - chartArea1.Name = "ChartArea1"; - this.Results.ChartAreas.Add(chartArea1); - legend1.Name = "Legend1"; - this.Results.Legends.Add(legend1); + chartArea2.Name = "ChartArea1"; + this.Results.ChartAreas.Add(chartArea2); + legend2.Name = "Legend1"; + this.Results.Legends.Add(legend2); this.Results.Location = new System.Drawing.Point(5, 375); this.Results.Margin = new System.Windows.Forms.Padding(2); this.Results.Name = "Results"; @@ -197,20 +195,6 @@ private void InitializeComponent() this.buttonClearAll.UseVisualStyleBackColor = true; this.buttonClearAll.Click += new System.EventHandler(this.buttonClearAll_Click); // - // buttonSaveAs - // - this.buttonSaveAs.Location = new System.Drawing.Point(521, 7); - this.buttonSaveAs.Name = "buttonSaveAs"; - this.buttonSaveAs.Size = new System.Drawing.Size(28, 29); - this.buttonSaveAs.TabIndex = 35; - this.buttonSaveAs.Text = "..."; - this.buttonSaveAs.UseVisualStyleBackColor = true; - this.buttonSaveAs.Click += new System.EventHandler(this.buttonSaveAs_Click); - // - // folderBrowserSaveRes - // - this.folderBrowserSaveRes.Description = "Select the directory to save the measurements data"; - // // LabelTempBoxC // this.LabelTempBoxC.AutoSize = true; @@ -250,7 +234,6 @@ private void InitializeComponent() this.Controls.Add(this.buttonChangeSettings); this.Controls.Add(this.LabelTempBoxC); this.Controls.Add(this.LabelTempEC); - this.Controls.Add(this.buttonSaveAs); this.Controls.Add(this.buttonClearAll); this.Controls.Add(this.buttonFillAll); this.Controls.Add(this.COM); @@ -292,9 +275,7 @@ private void InitializeComponent() private ComboBox COM; private Button buttonFillAll; private Button buttonClearAll; - private Button buttonSaveAs; private SaveFileDialog saveFileDialog1; - private FolderBrowserDialog folderBrowserSaveRes; private Label LabelTempBoxC; private Label LabelTempEC; private Button buttonChangeSettings; diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 31c454c..a259d03 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -52,7 +52,7 @@ public partial class Control : Form private readonly int nGridCols = 12; private readonly string cells_fname = @".cells.tsv"; private int betweenMesSec; - private string folderName; + public static string folderName; private volatile bool _exiting = false; private Thread assay_thread; @@ -884,7 +884,7 @@ private void Control_FormClosing(object sender, FormClosingEventArgs e) _exiting = true; savePlateCells(cells_fname); - Miriam_Serial.Properties.Settings.Default.settFolderRes = folderBrowserSaveRes.SelectedPath; + Miriam_Serial.Properties.Settings.Default.settFolderRes = folderName; //Miriam_Serial.Properties.Settings.Default.settTemperatureMid = CboxTempM.Text; //Miriam_Serial.Properties.Settings.Default.settTemperatureUp = CboxTempU.Text; @@ -946,27 +946,18 @@ private void savePlateCells(string filename, string sep="\t") File.WriteAllLines(filename, output, System.Text.Encoding.UTF8); } - private void buttonSaveAs_Click(object sender, EventArgs e) - { - // Show the FolderBrowserDialog. - DialogResult result = folderBrowserSaveRes.ShowDialog(); - if (result == DialogResult.OK) - { - folderName = folderBrowserSaveRes.SelectedPath; - } - } - private void Control_Load(object sender, EventArgs e) { Console.WriteLine(Miriam_Serial.Properties.Settings.Default.settFolderRes); if (Miriam_Serial.Properties.Settings.Default.settFolderRes == "") { - folderName = folderBrowserSaveRes.RootFolder.ToString(); + folderName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + //folderBrowserSaveRes.RootFolder.ToString(); } else { folderName = Miriam_Serial.Properties.Settings.Default.settFolderRes; - folderBrowserSaveRes.SelectedPath = Miriam_Serial.Properties.Settings.Default.settFolderRes; + //folderBrowserSaveRes.SelectedPath = Miriam_Serial.Properties.Settings.Default.settFolderRes; } Console.WriteLine("folder: {0}", folderName); settings_measurement.TMiddle = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureMid); diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx b/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx index c2cb6de..53e294d 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx @@ -120,9 +120,6 @@ 17, 17 - - 153, 17 - diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs index 17f0e00..17f1ac4 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs @@ -58,9 +58,10 @@ private void InitializeComponent() this.textBox1 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); - this.label_results_folder = new System.Windows.Forms.Label(); this.buttonSaveAs = new System.Windows.Forms.Button(); this.label11 = new System.Windows.Forms.Label(); + this.folderBrowserSaveRes = new System.Windows.Forms.FolderBrowserDialog(); + this.textBoxFolder = new System.Windows.Forms.TextBox(); this.panelMelting.SuspendLayout(); this.panel1.SuspendLayout(); this.SuspendLayout(); @@ -371,23 +372,15 @@ private void InitializeComponent() this.label10.TabIndex = 9; this.label10.Text = "Results storage folder:"; // - // label_results_folder - // - this.label_results_folder.AutoSize = true; - this.label_results_folder.Location = new System.Drawing.Point(266, 45); - this.label_results_folder.Name = "label_results_folder"; - this.label_results_folder.Size = new System.Drawing.Size(75, 13); - this.label_results_folder.TabIndex = 10; - this.label_results_folder.Text = "(results_folder)"; - // // buttonSaveAs // - this.buttonSaveAs.Location = new System.Drawing.Point(380, 12); + this.buttonSaveAs.Location = new System.Drawing.Point(490, 39); this.buttonSaveAs.Name = "buttonSaveAs"; - this.buttonSaveAs.Size = new System.Drawing.Size(28, 29); + this.buttonSaveAs.Size = new System.Drawing.Size(28, 20); this.buttonSaveAs.TabIndex = 36; this.buttonSaveAs.Text = "..."; this.buttonSaveAs.UseVisualStyleBackColor = true; + this.buttonSaveAs.Click += new System.EventHandler(this.buttonSaveAs_Click); // // label11 // @@ -398,14 +391,27 @@ private void InitializeComponent() this.label11.TabIndex = 37; this.label11.Text = "Measurement settings"; // + // folderBrowserSaveRes + // + this.folderBrowserSaveRes.Description = "Select the directory to save the measurements data"; + // + // textBoxFolder + // + this.textBoxFolder.Location = new System.Drawing.Point(269, 39); + this.textBoxFolder.Name = "textBoxFolder"; + this.textBoxFolder.ReadOnly = true; + this.textBoxFolder.Size = new System.Drawing.Size(222, 20); + this.textBoxFolder.TabIndex = 38; + this.textBoxFolder.Text = "(results folder)"; + // // FormSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(423, 415); + this.ClientSize = new System.Drawing.Size(539, 415); + this.Controls.Add(this.textBoxFolder); this.Controls.Add(this.label11); this.Controls.Add(this.buttonSaveAs); - this.Controls.Add(this.label_results_folder); this.Controls.Add(this.label10); this.Controls.Add(this.label9); this.Controls.Add(this.textBox1); @@ -458,8 +464,9 @@ private void InitializeComponent() private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label10; - private System.Windows.Forms.Label label_results_folder; private System.Windows.Forms.Button buttonSaveAs; private System.Windows.Forms.Label label11; + private System.Windows.Forms.FolderBrowserDialog folderBrowserSaveRes; + private System.Windows.Forms.TextBox textBoxFolder; } } \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs index 26fb819..8524e07 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -87,6 +87,9 @@ private void buttonOk_Click(object sender, EventArgs e) Control.settings_melting["TExtra"] = CboxTempE.Text; Control.settings_melting["Interval"] = CboxInterval.Text; + // results storage folder + Control.folderName = folderBrowserSaveRes.SelectedPath; + this.DialogResult = DialogResult.OK; } @@ -117,6 +120,20 @@ private void FormSettings_Load(object sender, EventArgs e) cBoxMesThrTemp.Text = Control.settings_measurement.TThreshold.ToString(); cBoxMesInterval.Text = Control.settings_measurement.MeasureIntervalSec.ToString(); cBoxMesDuration.Text = Control.settings_measurement.DurationMin.ToString(); + + // results storage folder + folderBrowserSaveRes.SelectedPath = Control.folderName; + textBoxFolder.Text = folderBrowserSaveRes.SelectedPath; + } + + private void buttonSaveAs_Click(object sender, EventArgs e) + { + // Show the FolderBrowserDialog. + DialogResult result = folderBrowserSaveRes.ShowDialog(); + if (result == DialogResult.OK) + { + textBoxFolder.Text = folderBrowserSaveRes.SelectedPath; + } } } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx index 1af7de1..a05b20e 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file From cf4cb1bc6b02be380141e9494c3fbab3bbde0ee0 Mon Sep 17 00:00:00 2001 From: an_ti Date: Tue, 29 Dec 2020 18:36:08 +0300 Subject: [PATCH 17/36] + filename prefix setting --- .../Serial_003/Miriam_Serial/Miriam/App.config | 3 +++ .../Serial_003/Miriam_Serial/Miriam/Control.cs | 14 ++++++++++---- .../Miriam/FormSettings.Designer.cs | 18 +++++++++--------- .../Miriam_Serial/Miriam/FormSettings.cs | 4 +++- .../Miriam/Properties/Settings.Designer.cs | 14 +++++++++++++- .../Miriam/Properties/Settings.settings | 3 +++ 6 files changed, 41 insertions(+), 15 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/App.config b/Programs/Serial_003/Miriam_Serial/Miriam/App.config index 06771ab..3d28200 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/App.config +++ b/Programs/Serial_003/Miriam_Serial/Miriam/App.config @@ -49,6 +49,9 @@ False + + miriam + \ No newline at end of file diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index a259d03..c11363e 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -63,6 +63,7 @@ public partial class Control : Form FormSettings SettingsForm; public static bool melting_enabled; + public static string filename_prefix; public static Dictionary settings_melting = new Dictionary { { "TUp", "80" }, @@ -437,7 +438,7 @@ private void AppendData(string value) private void CreateCsv(string header) { - csv_filename = folderName + @"\miriam_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; + csv_filename = folderName + @"\" + filename_prefix + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; Console.WriteLine(); Console.WriteLine("Creating csv: {0}", csv_filename); File.WriteAllText(csv_filename, header.Remove(header.Length-1,1) + Environment.NewLine, Encoding.UTF8); @@ -853,9 +854,9 @@ private void ButtonWrite_Click(object sender, EventArgs e) } //after your loop - //[AT] todo: change path option + //string fname = "Miriam_serial_data.csv"; - string fname = folderName + @"\miriam_" + DateTime.Now.ToString("yyyyddMM_HHmmss") + ".csv"; + string fname = folderName + @"\"+filename_prefix+"_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; Console.WriteLine(); Console.WriteLine("Saving csv: {0}", fname); // string fname = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Miriam_serial_data.csv"; @@ -907,6 +908,8 @@ private void Control_FormClosing(object sender, FormClosingEventArgs e) Miriam_Serial.Properties.Settings.Default.meltingEnabled = melting_enabled; + Miriam_Serial.Properties.Settings.Default.filenamePrefix = filename_prefix; + Console.WriteLine(Miriam_Serial.Properties.Settings.Default.settFolderRes); Miriam_Serial.Properties.Settings.Default.Save(); @@ -952,7 +955,7 @@ private void Control_Load(object sender, EventArgs e) if (Miriam_Serial.Properties.Settings.Default.settFolderRes == "") { folderName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - //folderBrowserSaveRes.RootFolder.ToString(); + //folderBrowserSaveRes.RootFolder.ToString(); - } else { @@ -974,6 +977,9 @@ private void Control_Load(object sender, EventArgs e) settings_melting["Interval"] = Miriam_Serial.Properties.Settings.Default.meltInterval; settings_melting["Tolerance"] = Miriam_Serial.Properties.Settings.Default.meltTolerance; melting_enabled = Miriam_Serial.Properties.Settings.Default.meltingEnabled; + + filename_prefix = Miriam_Serial.Properties.Settings.Default.filenamePrefix; + SettingsForm = new FormSettings(); } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs index 17f1ac4..9292e21 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs @@ -55,7 +55,7 @@ private void InitializeComponent() this.label7 = new System.Windows.Forms.Label(); this.cBoxMesUTemp = new System.Windows.Forms.ComboBox(); this.cBoxMesMTemp = new System.Windows.Forms.ComboBox(); - this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBoxFnamePrefix = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.buttonSaveAs = new System.Windows.Forms.Button(); @@ -346,13 +346,13 @@ private void InitializeComponent() this.cBoxMesMTemp.Size = new System.Drawing.Size(82, 21); this.cBoxMesMTemp.TabIndex = 40; // - // textBox1 + // textBoxFnamePrefix // - this.textBox1.Location = new System.Drawing.Point(266, 91); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(86, 20); - this.textBox1.TabIndex = 7; - this.textBox1.Text = "miriam"; + this.textBoxFnamePrefix.Location = new System.Drawing.Point(266, 91); + this.textBoxFnamePrefix.Name = "textBoxFnamePrefix"; + this.textBoxFnamePrefix.Size = new System.Drawing.Size(86, 20); + this.textBoxFnamePrefix.TabIndex = 7; + this.textBoxFnamePrefix.Text = "miriam"; // // label9 // @@ -414,7 +414,7 @@ private void InitializeComponent() this.Controls.Add(this.buttonSaveAs); this.Controls.Add(this.label10); this.Controls.Add(this.label9); - this.Controls.Add(this.textBox1); + this.Controls.Add(this.textBoxFnamePrefix); this.Controls.Add(this.panel1); this.Controls.Add(this.panelMelting); this.Controls.Add(this.checkBoxEnableMelting); @@ -461,7 +461,7 @@ private void InitializeComponent() private System.Windows.Forms.Label label3; private System.Windows.Forms.ComboBox cBoxMesDuration; private System.Windows.Forms.Label label8; - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBoxFnamePrefix; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label10; private System.Windows.Forms.Button buttonSaveAs; diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs index 8524e07..65b887d 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -87,8 +87,9 @@ private void buttonOk_Click(object sender, EventArgs e) Control.settings_melting["TExtra"] = CboxTempE.Text; Control.settings_melting["Interval"] = CboxInterval.Text; - // results storage folder + // results storage Control.folderName = folderBrowserSaveRes.SelectedPath; + Control.filename_prefix = textBoxFnamePrefix.Text; this.DialogResult = DialogResult.OK; } @@ -124,6 +125,7 @@ private void FormSettings_Load(object sender, EventArgs e) // results storage folder folderBrowserSaveRes.SelectedPath = Control.folderName; textBoxFolder.Text = folderBrowserSaveRes.SelectedPath; + textBoxFnamePrefix.Text = Control.filename_prefix; } private void buttonSaveAs_Click(object sender, EventArgs e) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs index c45b070..0e4aa95 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace Miriam_Serial.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -178,5 +178,17 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio this["meltingEnabled"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("miriam")] + public string filenamePrefix { + get { + return ((string)(this["filenamePrefix"])); + } + set { + this["filenamePrefix"] = value; + } + } } } diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings index 1eb0ff3..1c4e1e1 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/Settings.settings @@ -41,5 +41,8 @@ False + + miriam + \ No newline at end of file From b9a4cbb4cdac0ce7167af53d8a14bebd92dc0eb6 Mon Sep 17 00:00:00 2001 From: tatthangvd <46362142+tatthangvd@users.noreply.github.com> Date: Mon, 11 Jan 2021 13:22:49 +0100 Subject: [PATCH 18/36] update melt tuning --- Programs/Serial_003/Serial_003.ino | 36 +++++------------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index d2c3c97..17728e4 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -758,38 +758,14 @@ void SetTunings_PID_Melt() { gap2 = abs(Setpoint_UPPER - Temperature(TH_UPPERBED,T_CELSIUS,NCP18XH103F03RB,10000.0f)); //distance away from setpoint gap3 = abs(Setpoint_EXTRA - Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)); //distance away from setpoint - if(Temperature(TH_MIDDLEBED_2,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) - { //we're close to setpoint, use conservative tuning parameters - PID_MIDDLE.SetTunings(consKp/25, consKi/25, consKd/25); - - } - else - { - //we're far from setpoint, use aggressive tuning parameters - PID_MIDDLE.SetTunings(aggKp, aggKi, aggKd); - } + + PID_MIDDLE.SetTunings(consKp/40, consKi/40, consKd/40); - if(Temperature(TH_UPPERBED,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) - { //we're close to setpoint, use conservative tuning parameters - PID_UPPER.SetTunings(consKp/25, consKi/25, consKd/25); - - } - else - { - //we're far from setpoint, use aggressive tuning parameters - PID_UPPER.SetTunings(aggKp, aggKi, aggKd); - } - - if(Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)>65.0f) - { //we're close to setpoint, use conservative tuning parameters - PID_EXTRA.SetTunings(consKp/50, consKi/50, consKd/50); + PID_UPPER.SetTunings(consKp/40, consKi/40, consKd/40); + + PID_EXTRA.SetTunings(consKp/80, consKi/80, consKd/80); - } - else - { - //we're far from setpoint, use aggressive tuning parameters - PID_EXTRA.SetTunings(aggKp/10, aggKi/10, aggKd/10); - } + } From cb8884b66134e85f28c273f44fc9d997efaa3834 Mon Sep 17 00:00:00 2001 From: an_ti Date: Mon, 11 Jan 2021 19:43:30 +0300 Subject: [PATCH 19/36] start melting commands sequence changed --- .../Miriam_Serial/Miriam/Control.cs | 47 ++++++++++++------- Programs/Serial_003/Serial_003.ino | 3 +- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 2291eb3..8c2dab8 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -103,12 +103,12 @@ public SerialPortForHeat(string portname) StopBits = StopBits.One; BaudRate = 9600; - // Set the read/write timeouts - ReadTimeout = 500; + // Set the read/write timeouts + ReadTimeout = 5000; WriteTimeout = 500; } - public void start_heat(string t_up, string t_middle, string t_extra, string threshold = "", bool melting=false) + public bool start_heat(string t_up, string t_middle, string t_extra, string threshold = "", bool melting=false) { try { @@ -116,9 +116,18 @@ public void start_heat(string t_up, string t_middle, string t_extra, string thre DiscardOutBuffer(); DiscardInBuffer(); - String ReceivedData; + string heat_command = melting ? "W" : "H"; + + //String ReceivedData; + String s; - var s = ArduinoReadout(this, "M " + t_middle); + if (melting) + { + s = ArduinoReadout(this, heat_command); + Console.WriteLine(s); + } + + s = ArduinoReadout(this, "M " + t_middle); Console.WriteLine(s); s = ArduinoReadout(this, "U " + t_up); @@ -131,9 +140,11 @@ public void start_heat(string t_up, string t_middle, string t_extra, string thre s = ArduinoReadout(this, "T " + threshold); Console.WriteLine(s); - string heat_command = melting ? "W" : "H"; - s = ArduinoReadout(this, heat_command); - Console.WriteLine(s); + if (!melting) + { + s = ArduinoReadout(this, heat_command); + Console.WriteLine(s); + } // [AT] maybe sleep here a bit? } catch (Exception exc) @@ -142,7 +153,9 @@ public void start_heat(string t_up, string t_middle, string t_extra, string thre // MessageBox.Show("Serial could not be opened, please check that the device is correct one"); MessageBox.Show(exc.ToString()); this.Close(); + return false; } + return true; } }; @@ -817,12 +830,14 @@ private void doAssay() if ((!now_melting) && assay_ready && melting_enabled) { - assay_ready = false; cont_assay = true; - apply_settings_melting(); - now_melting = true; - } - + if (apply_settings_melting()) + { + now_melting = true; + assay_ready = false; + } + } + if (cont_assay) { // wait until getting the next measurement @@ -851,14 +866,14 @@ private void doAssay() MessageBox.Show("Assay Aborted"); } - private void apply_settings_melting() - { + private bool apply_settings_melting() { Console.WriteLine(settings_melting); betweenMesSec = Convert.ToInt32(settings_melting["Interval"]); SerialPortForHeat serialPort = new SerialPortForHeat(port_measurement); - serialPort.start_heat(settings_melting["TUp"], settings_melting["TMiddle"], settings_melting["TExtra"], melting: true); + bool started = serialPort.start_heat(settings_melting["TUp"], settings_melting["TMiddle"], settings_melting["TExtra"], melting: true); serialPort.Close(); + return started; } private void ButtonWrite_Click(object sender, EventArgs e) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index 17728e4..990a760 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -280,7 +280,8 @@ void loop () { case MELT_HEAT: MELT_ON = true; - heat_alarm = true; +// heat_alarm = true; + heat_alarm = false; Serial.println(F("MELTING BOARDS$")); From 75041e3f61fdfc69300d0b5ab64265d1b0511bca Mon Sep 17 00:00:00 2001 From: tatthangvd <46362142+tatthangvd@users.noreply.github.com> Date: Tue, 12 Jan 2021 08:42:24 +0100 Subject: [PATCH 20/36] add melt_init --- Programs/Serial_003/Serial_003.ino | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index 990a760..e3a8aef 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -87,6 +87,7 @@ #define STATUS_LED_OFF 'o' #define SET_BOX_THR 'T' #define MELT_HEAT 'W' +#define MELT_INIT 'w' int MUL[6] = { @@ -139,7 +140,7 @@ enum { }; byte states[] = { - INIT, CANCEL, HEAT_BOARDS, INFO, SET_TEMP_UPPER, SET_TEMP_MIDDLE,SET_TEMP_EXTRA, READ_ASSAY, PLAY_SOUND, STATUS_LED_ON, STATUS_LED_OFF, SET_BOX_THR, MELT_HEAT}; + INIT, CANCEL, HEAT_BOARDS, INFO, SET_TEMP_UPPER, SET_TEMP_MIDDLE,SET_TEMP_EXTRA, READ_ASSAY, PLAY_SOUND, STATUS_LED_ON, STATUS_LED_OFF, SET_BOX_THR, MELT_HEAT, MELT_INIT}; // serial data @@ -236,6 +237,26 @@ void loop () { state = 'I'; break; + case MELT_INIT: + + HEAT_ON = false; + MELT_ON = false; + + Output_MIDDLE = 100; + Output_UPPER = 100; + Output_EXTRA = 100; + computePIDs(); + + Serial.println(F("INIT MELT$")); + + //turn the PID's off +// PID_MIDDLE.SetMode(MANUAL); +// PID_UPPER.SetMode(MANUAL); +// PID_EXTRA.SetMode(MANUAL); + + state = defaultState; + break; + case CANCEL: HEAT_ON = false; From 9512dcfa2d45da4a7258367790c3f9e24169fdc6 Mon Sep 17 00:00:00 2001 From: an_ti Date: Tue, 12 Jan 2021 12:28:17 +0300 Subject: [PATCH 21/36] add melt init on software side --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 8c2dab8..9af45f4 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -123,6 +123,8 @@ public bool start_heat(string t_up, string t_middle, string t_extra, string thre if (melting) { + s = ArduinoReadout(this, "w"); // melt init sets the output values + Console.WriteLine(s); s = ArduinoReadout(this, heat_command); Console.WriteLine(s); } @@ -137,8 +139,10 @@ public bool start_heat(string t_up, string t_middle, string t_extra, string thre Console.WriteLine(s); if (threshold != "") + { s = ArduinoReadout(this, "T " + threshold); Console.WriteLine(s); + } if (!melting) { From 4688c990762a30fef80270f2bb7f28cd4e09c5b0 Mon Sep 17 00:00:00 2001 From: an_ti Date: Tue, 12 Jan 2021 18:50:24 +0300 Subject: [PATCH 22/36] Add PID output values to CSV --- .../Miriam_Serial/Miriam/Control.cs | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 9af45f4..eae5693 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -56,6 +56,8 @@ public partial class Control : Form private volatile bool _exiting = false; private Thread assay_thread; + private int ninfo; + private Dictionary temperatureInfoMap; private Dictionary currentTemperatureInfo; @@ -174,14 +176,22 @@ public Control() { "Up", 4 }, { "Middle", 5 }, { "Extra", 9 }, - { "Box", 10 } + { "Box", 10 }, + { "OutUp", 1 }, + { "OutMiddle", 0 }, + { "OutExtra", 6 }, + }; currentTemperatureInfo = new Dictionary { { "Up", "" }, { "Middle", "" }, { "Extra", "" }, - { "Box", "" } + { "Box", "" }, + { "OutUp", "" }, + { "OutMiddle", "" }, + { "OutExtra", "" }, + }; string[] ports = SerialPort.GetPortNames(); @@ -538,9 +548,13 @@ private void ButtonStart_Click(object sender, EventArgs e) } List list = new List(); //[AT] list of wells with names + int counter = 5; //string msg = "Time,U,M,"; // [AT] csv file header. string msg = "Time,U,M,Extra,Box,"; // [AT] csv file header. + msg += "OutU, OutM, OutE,"; // add output values + counter += 3; + ninfo = counter; for (int i = 0; i < Plate.RowCount; i++) { @@ -554,7 +568,9 @@ private void ButtonStart_Click(object sender, EventArgs e) } counter += 1; } - } + } + Console.WriteLine(msg); + Data.Items.Add(msg); //[AT] Data -- invisible ListBox arrayNames = msg; //[AT] header @@ -604,8 +620,8 @@ private void AppendResult(string value) this.Invoke(new Action(AppendResult), new object[] { value }); return; } - - for(int i = 5;i Date: Thu, 14 Jan 2021 14:58:04 +0100 Subject: [PATCH 23/36] add firmware version: 0.1.0 --- Programs/Serial_003/Serial_003.ino | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index e3a8aef..3d19420 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -32,6 +32,7 @@ #include #include "MyStatusLed.h" +#define FIRMWARE_VERSION "0.1.0" // Started with 0.1.0 //Selector ping #define SEL_1 46 // Selector ping 1 @@ -88,7 +89,7 @@ #define SET_BOX_THR 'T' #define MELT_HEAT 'W' #define MELT_INIT 'w' - +#define VERSION 'V' int MUL[6] = { A0,A1,A2,A3,A4,A5}; // Multiplexer 1 @@ -140,7 +141,7 @@ enum { }; byte states[] = { - INIT, CANCEL, HEAT_BOARDS, INFO, SET_TEMP_UPPER, SET_TEMP_MIDDLE,SET_TEMP_EXTRA, READ_ASSAY, PLAY_SOUND, STATUS_LED_ON, STATUS_LED_OFF, SET_BOX_THR, MELT_HEAT, MELT_INIT}; + INIT, CANCEL, HEAT_BOARDS, INFO, SET_TEMP_UPPER, SET_TEMP_MIDDLE,SET_TEMP_EXTRA, READ_ASSAY, PLAY_SOUND, STATUS_LED_ON, STATUS_LED_OFF, SET_BOX_THR, MELT_HEAT, MELT_INIT, VERSION}; // serial data @@ -313,6 +314,13 @@ void loop () { state = defaultState; break; + case VERSION: + Serial.print(F("firmware_version: ")); + Serial.print(FIRMWARE_VERSION); + Serial.println("$"); + state = defaultState; + break; + case INFO: Serial.println(String(Output_MIDDLE) + "," + String(Output_UPPER) + "," + From c6b243bfa2b34abe58d4c432acdf2b76b32fd574 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Fri, 15 Jan 2021 22:38:49 +0100 Subject: [PATCH 24/36] +software version; version check; fix timeout (back to 500); set version numbers to 2.0.0 --- .../Miriam_Serial/Miriam/Control.Designer.cs | 12 +-- .../Miriam_Serial/Miriam/Control.cs | 84 +++++++++++++++++-- .../Miriam_Serial/Miriam/Control.resx | 3 + .../Miriam_Serial/Miriam/Miriam.csproj | 1 - .../Miriam/Properties/AssemblyInfo.cs | 4 +- .../Miriam_Serial/MiriamTests/ControlTests.cs | 22 ++++- Programs/Serial_003/Serial_003.ino | 4 +- 7 files changed, 109 insertions(+), 21 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs index d530c9a..44c8795 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.Designer.cs @@ -31,8 +31,8 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Control)); this.ButtonStart = new System.Windows.Forms.Button(); this.Plate = new System.Windows.Forms.DataGridView(); @@ -133,10 +133,10 @@ private void InitializeComponent() // this.Results.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - chartArea2.Name = "ChartArea1"; - this.Results.ChartAreas.Add(chartArea2); - legend2.Name = "Legend1"; - this.Results.Legends.Add(legend2); + chartArea1.Name = "ChartArea1"; + this.Results.ChartAreas.Add(chartArea1); + legend1.Name = "Legend1"; + this.Results.Legends.Add(legend1); this.Results.Location = new System.Drawing.Point(5, 375); this.Results.Margin = new System.Windows.Forms.Padding(2); this.Results.Name = "Results"; diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 55f1678..b85db35 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Net; using System.Net.Sockets; +using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -116,7 +117,7 @@ public SerialPortForHeat(string portname) BaudRate = 9600; // Set the read/write timeouts - ReadTimeout = 5000; + ReadTimeout = 500; WriteTimeout = 500; } @@ -175,10 +176,10 @@ public bool start_heat(string t_up, string t_middle, string t_extra, string thre } }; - public Control() { InitializeComponent(); + settings_measurement = new SettingsMeasurement(); assay_thread = new System.Threading.Thread(new System.Threading.ThreadStart(doAssay)); temperatureInfoMap = new Dictionary @@ -211,11 +212,27 @@ public Control() COM.Items.Add(ports[i]); } - if (ports.Length != 0) + foreach (string port in ports) { - COM.SelectedIndex = 0; + try + { + if(check_firmware_version(port)) + { + COM.SelectedItem = port; + break; + } + } + catch (Exception exc) + { + Console.Write(exc.ToString()); + Console.WriteLine(); + } } + if (ports.Length != 0 && COM.SelectedIndex == -1) + { + COM.SelectedIndex = 0; + } //CreatePlate(); CreateEmptyPlate(); @@ -225,6 +242,45 @@ public Control() //Results.Visible = true; } + private bool check_firmware_version(string port) + { + SerialPort serial = new SerialPortForHeat(port); + + serial.Open(); + try + { + Console.WriteLine(port); + + serial.DiscardInBuffer(); + serial.DiscardOutBuffer(); + + string ver = ArduinoReadout(serial, "V"); + bool result = check_version(ver); + serial.Close(); + return result; + } + catch (Exception exc) + { + serial.Close(); + throw exc; + } + + } + + public bool check_version(string firmware_version) + { + Assembly assembly = Assembly.GetExecutingAssembly(); + System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); + string version = fvi.FileVersion; + + Console.WriteLine("software version:" + version); + Console.WriteLine("firmware version:" + firmware_version); + var v0 = Convert.ToInt32(firmware_version.Split('.')[0]); + var v1 = Convert.ToInt32(firmware_version.Split('.')[1]); + + return (v0 == fvi.FileMajorPart) && (v1 == fvi.FileMinorPart); + } + private void ParseTemperatureInfo(string received_data) { Console.WriteLine(received_data); @@ -475,17 +531,31 @@ private void ButtonStart_Click(object sender, EventArgs e) { if (started) return; + port_measurement = COM.Text; + + try + { + if (!check_firmware_version(port_measurement)) + { + MessageBox.Show("Version of firmware does not match version of Software! Please update."); + return; + } + } + catch (TimeoutException exc) + { + string complain = "Serial could not be opened, please check that the device is correct one"; + MessageBox.Show(complain + "\n\n" + exc.ToString()); + return; + } + Results.Visible = true; Form f = Control.ActiveForm; f.Size = new Size(f.Size.Width, 750); started = true; Results.Visible = true; Results.Anchor |= AnchorStyles.Bottom; - port_measurement = COM.Text; - DateTime localDate = DateTime.Now; - time_to_stop_assay = localDate.Hour * 60 * 60 + localDate.Minute * 60 + localDate.Second + Convert.ToInt32(settings_measurement.DurationMin * 60); diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx b/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx index 53e294d..fec1525 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.resx @@ -120,6 +120,9 @@ 17, 17 + + 37 + diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj b/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj index 616f6fb..6bb9b0a 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Miriam.csproj @@ -95,7 +95,6 @@ - diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/AssemblyInfo.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/AssemblyInfo.cs index 79c795e..660bb92 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Properties/AssemblyInfo.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0")] +[assembly: AssemblyFileVersion("2.0.0")] diff --git a/Programs/Serial_003/Miriam_Serial/MiriamTests/ControlTests.cs b/Programs/Serial_003/Miriam_Serial/MiriamTests/ControlTests.cs index c26b9e5..7603c48 100644 --- a/Programs/Serial_003/Miriam_Serial/MiriamTests/ControlTests.cs +++ b/Programs/Serial_003/Miriam_Serial/MiriamTests/ControlTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -28,15 +29,30 @@ public void RearrangeColumnOrderTest() string[] srows = { "A", "B", "C", "D", "E", "F", "G", "H" }; string[] scolumns_correct = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }; string[] scolumns_rearranged = { "11", "12", "9", "10", "7", "8", "5", "6", "3", "4", "1", "2" }; - string s_correct=""; - string s_output=""; + string s_correct = ""; + string s_output = ""; for (int i = 0; i < srows.Length; i++) for (int j = 0; j < scolumns_correct.Length; j++) { s_output += srows[i] + scolumns_rearranged[j] + ","; - s_correct += srows[i] + scolumns_correct[j] + ","; + s_correct += srows[i] + scolumns_correct[j] + ","; } Assert.AreEqual(s_correct, tControl.RearrangeColumnOrder(s_output)); } + + [TestMethod()] + public void check_versionTest() + { + var tControl = new Control(); + //Assembly assembly = Assembly.GetExecutingAssembly(); + //System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); + //string version = fvi.FileVersion; + //Console.WriteLine(version); + // Console.WriteLine(version.Split('.')[0]); + Assert.IsTrue(tControl.check_version("2.0.0")); + Assert.IsTrue(tControl.check_version("2.0.1")); + Assert.IsFalse(tControl.check_version("1.1.1")); + Assert.IsFalse(tControl.check_version("2.1.1")); + } } } \ No newline at end of file diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index 3d19420..40cffb4 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -32,7 +32,7 @@ #include #include "MyStatusLed.h" -#define FIRMWARE_VERSION "0.1.0" // Started with 0.1.0 +#define FIRMWARE_VERSION "2.0.0" // first release 2.0.0 //Selector ping #define SEL_1 46 // Selector ping 1 @@ -315,7 +315,7 @@ void loop () { break; case VERSION: - Serial.print(F("firmware_version: ")); +// Serial.print(F("firmware_version: ")); Serial.print(FIRMWARE_VERSION); Serial.println("$"); state = defaultState; From 11b2f453e05d2568316ba1554a16b11718173eda Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Mon, 18 Jan 2021 00:40:44 +0100 Subject: [PATCH 25/36] save data to tsv with metadata --- .../Miriam_Serial/Miriam/Control.cs | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index b85db35..6671f8a 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -43,6 +43,7 @@ namespace Miriam { public partial class Control : Form { + private System.Diagnostics.FileVersionInfo file_version_info; private int time_to_stop_assay; private string arrayNames; private int maximumValue = 0; @@ -67,6 +68,9 @@ public partial class Control : Form public static bool melting_enabled; public static string filename_prefix; + public static char datafile_separator; + public string firmware_version; + public string software_version; public static Dictionary settings_melting = new Dictionary { { "TUp", "80" }, @@ -179,6 +183,12 @@ public bool start_heat(string t_up, string t_middle, string t_extra, string thre public Control() { InitializeComponent(); + datafile_separator = '\t'; + //datafile_separator = ','; + + Assembly assembly = Assembly.GetExecutingAssembly(); + file_version_info = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); + software_version = file_version_info.FileVersion; settings_measurement = new SettingsMeasurement(); assay_thread = new System.Threading.Thread(new System.Threading.ThreadStart(doAssay)); @@ -267,18 +277,18 @@ private bool check_firmware_version(string port) } - public bool check_version(string firmware_version) + public bool check_version(string val) { - Assembly assembly = Assembly.GetExecutingAssembly(); - System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); - string version = fvi.FileVersion; - - Console.WriteLine("software version:" + version); + //Assembly assembly = Assembly.GetExecutingAssembly(); + //System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); + //string version = fvi.FileVersion; + firmware_version = val; + Console.WriteLine("software version:" + software_version); Console.WriteLine("firmware version:" + firmware_version); var v0 = Convert.ToInt32(firmware_version.Split('.')[0]); var v1 = Convert.ToInt32(firmware_version.Split('.')[1]); - return (v0 == fvi.FileMajorPart) && (v1 == fvi.FileMinorPart); + return (v0 == file_version_info.FileMajorPart) && (v1 == file_version_info.FileMinorPart); } private void ParseTemperatureInfo(string received_data) @@ -503,8 +513,11 @@ private void AskHeat_Click(object sender, EventArgs e) private void AppendToCsv(string value) { + string append_string = value.TrimEnd(',') + Environment.NewLine; + append_string = append_string.Replace(',', datafile_separator); + //[AT] value has the ',' after the last value, don't write it to the csv - File.AppendAllText(csv_filename, value.TrimEnd(',') + Environment.NewLine, Encoding.UTF8); + File.AppendAllText(csv_filename, append_string, Encoding.UTF8); Console.WriteLine("Append to csv: {0}", value); } @@ -521,10 +534,15 @@ private void AppendData(string value) private void CreateCsv(string header) { - csv_filename = folderName + @"\" + filename_prefix + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; + // header - comma-separated + string file_ext = datafile_separator == '\t' ? ".tsv" : ".csv"; + header = header.Replace(',', datafile_separator); + csv_filename = folderName + @"\" + filename_prefix + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + file_ext; Console.WriteLine(); - Console.WriteLine("Creating csv: {0}", csv_filename); - File.WriteAllText(csv_filename, header.Remove(header.Length-1,1) + Environment.NewLine, Encoding.UTF8); + Console.WriteLine("Creating csv: {0}", csv_filename); + string metadata = "# {" + $"software-version: {software_version}, firmware-version: {firmware_version}" + "}"; + File.WriteAllText(csv_filename, metadata + Environment.NewLine, Encoding.UTF8); + File.AppendAllText(csv_filename, header.Remove(header.Length - 1, 1) + Environment.NewLine, Encoding.UTF8); } private void ButtonStart_Click(object sender, EventArgs e) @@ -535,7 +553,7 @@ private void ButtonStart_Click(object sender, EventArgs e) try { - if (!check_firmware_version(port_measurement)) + if (!check_firmware_version(port_measurement)) // changes firmware_version //todo: refactor: fwv=get_firmware_version(port); if !check_v() ... { MessageBox.Show("Version of firmware does not match version of Software! Please update."); return; @@ -617,7 +635,7 @@ private void ButtonStart_Click(object sender, EventArgs e) } counter += 1; } - } + } Console.WriteLine(msg); Data.Items.Add(msg); //[AT] Data -- invisible ListBox From 4a7c026fd4289d4ed347d1f24cc383203abf05da Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Mon, 18 Jan 2021 00:42:28 +0100 Subject: [PATCH 26/36] fix string<->double convertion --- .../Serial_003/Miriam_Serial/Miriam/Control.cs | 14 +++++++++----- .../Miriam/FormSettings.Designer.cs | 1 + .../Miriam_Serial/Miriam/FormSettings.cs | 18 +++++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 6671f8a..74bdfb5 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -81,6 +81,7 @@ public partial class Control : Form }; public struct SettingsMeasurement { + // in the firmware all the temperatures are converted to int! public double TUp; public double TMiddle; public double TExtra; @@ -183,6 +184,8 @@ public bool start_heat(string t_up, string t_middle, string t_extra, string thre public Control() { InitializeComponent(); + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + datafile_separator = '\t'; //datafile_separator = ','; @@ -804,6 +807,7 @@ private void cancelHeat() private void doAssay() { + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; // Boolean cont = true; bool cont_assay = true; int loop = 0; @@ -1083,12 +1087,12 @@ private void Control_Load(object sender, EventArgs e) //folderBrowserSaveRes.SelectedPath = Miriam_Serial.Properties.Settings.Default.settFolderRes; } Console.WriteLine("folder: {0}", folderName); - settings_measurement.TMiddle = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureMid); - settings_measurement.TUp = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureUp); - settings_measurement.TExtra = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureExtra); - settings_measurement.DurationMin = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settDuration); + settings_measurement.TMiddle = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureMid, CultureInfo.InvariantCulture); + settings_measurement.TUp = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureUp, CultureInfo.InvariantCulture); + settings_measurement.TExtra = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureExtra, CultureInfo.InvariantCulture); + settings_measurement.DurationMin = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settDuration, CultureInfo.InvariantCulture); settings_measurement.MeasureIntervalSec = Convert.ToInt32(Miriam_Serial.Properties.Settings.Default.settInterval); - settings_measurement.TThreshold = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold); + settings_measurement.TThreshold = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold, CultureInfo.InvariantCulture); settings_melting["TUp"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureUp; diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs index 9292e21..f0d5a45 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.Designer.cs @@ -267,6 +267,7 @@ private void InitializeComponent() this.cBoxMesInterval.Name = "cBoxMesInterval"; this.cBoxMesInterval.Size = new System.Drawing.Size(82, 21); this.cBoxMesInterval.TabIndex = 48; + this.cBoxMesInterval.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.cBoxMesInterval_KeyPress); // // label4 // diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs index 65b887d..4f43076 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; +using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -73,12 +74,12 @@ public FormSettings() private void buttonOk_Click(object sender, EventArgs e) { // apply assay settings - Control.settings_measurement.TMiddle = Convert.ToDouble(cBoxMesMTemp.Text); - Control.settings_measurement.TUp = Convert.ToDouble(cBoxMesUTemp.Text); - Control.settings_measurement.TExtra = Convert.ToDouble(cBoxMesETemp.Text); - Control.settings_measurement.TThreshold = Convert.ToDouble(cBoxMesThrTemp.Text); + Control.settings_measurement.TMiddle = Convert.ToDouble(cBoxMesMTemp.Text, CultureInfo.InvariantCulture); + Control.settings_measurement.TUp = Convert.ToDouble(cBoxMesUTemp.Text, CultureInfo.InvariantCulture); + Control.settings_measurement.TExtra = Convert.ToDouble(cBoxMesETemp.Text, CultureInfo.InvariantCulture); + Control.settings_measurement.TThreshold = Convert.ToDouble(cBoxMesThrTemp.Text, CultureInfo.InvariantCulture); Control.settings_measurement.MeasureIntervalSec = Convert.ToInt32(cBoxMesInterval.Text); - Control.settings_measurement.DurationMin = Convert.ToDouble(cBoxMesDuration.Text); + Control.settings_measurement.DurationMin = Convert.ToDouble(cBoxMesDuration.Text, CultureInfo.InvariantCulture); // apply melting settings Control.melting_enabled = checkBoxEnableMelting.Checked; @@ -137,5 +138,12 @@ private void buttonSaveAs_Click(object sender, EventArgs e) textBoxFolder.Text = folderBrowserSaveRes.SelectedPath; } } + + private void cBoxMesInterval_KeyPress(object sender, KeyPressEventArgs e) + { + + e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar); + + } } } From 1c483fce6795b49e160b97998fc9b066af97c55b Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Tue, 19 Jan 2021 11:13:02 +0100 Subject: [PATCH 27/36] ino: float input of temperature settings --- Programs/Serial_003/Serial_003.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index 40cffb4..e01b55d 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -352,7 +352,7 @@ void loop () { case SET_TEMP_UPPER: - Setpoint_UPPER = parameters.toInt(); + Setpoint_UPPER = parameters.toFloat(); Serial.print(F("NEW UPPER TEMP:")); Serial.print(Setpoint_UPPER); Serial.println("$"); @@ -362,7 +362,7 @@ void loop () { case SET_TEMP_MIDDLE: - Setpoint_MIDDLE = parameters.toInt(); + Setpoint_MIDDLE = parameters.toFloat(); Serial.print(F("NEW MIDDLE TEMP:")); Serial.print(Setpoint_MIDDLE); Serial.println("$"); @@ -372,7 +372,7 @@ void loop () { break; case SET_TEMP_EXTRA: - Setpoint_EXTRA = parameters.toInt(); + Setpoint_EXTRA = parameters.toFloat(); Serial.print(F("NEW EXTRA TEMP:")); Serial.print(Setpoint_EXTRA); Serial.println("$"); @@ -412,7 +412,7 @@ void loop () { case SET_BOX_THR: - threshold_BOX = parameters.toInt(); + threshold_BOX = parameters.toFloat(); Serial.print(F("NEW TEMP THRESHOLD:")); Serial.print(threshold_BOX); Serial.println("$"); From bb9706d1018093d28fa56d9c7d1618cb0ebdb731 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Tue, 19 Jan 2021 11:18:13 +0100 Subject: [PATCH 28/36] fix applying tolerance setting --- Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs index 4f43076..1373b8f 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -87,6 +87,7 @@ private void buttonOk_Click(object sender, EventArgs e) Control.settings_melting["TMiddle"] = CboxTempM.Text; Control.settings_melting["TExtra"] = CboxTempE.Text; Control.settings_melting["Interval"] = CboxInterval.Text; + Control.settings_melting["Tolerance"] = CboxTolerance.Text; // results storage Control.folderName = folderBrowserSaveRes.SelectedPath; From 72b2b262ca5598f3ebddda065ff5a2f6f1a6f9e8 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Tue, 19 Jan 2021 11:19:32 +0100 Subject: [PATCH 29/36] save csv: comma-separated, metadata 2 strings --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 74bdfb5..dc9fe14 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -186,8 +186,10 @@ public Control() InitializeComponent(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; - datafile_separator = '\t'; - //datafile_separator = ','; + //datafile_separator = '\t'; // windows doesn't handle tsv files very well :( + datafile_separator = ','; //csv + //datafile_separator = ';'; + Assembly assembly = Assembly.GetExecutingAssembly(); file_version_info = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); @@ -195,6 +197,8 @@ public Control() settings_measurement = new SettingsMeasurement(); assay_thread = new System.Threading.Thread(new System.Threading.ThreadStart(doAssay)); + + // indices in the arduino "i" readout temperatureInfoMap = new Dictionary { { "Up", 4 }, @@ -204,8 +208,8 @@ public Control() { "OutUp", 1 }, { "OutMiddle", 0 }, { "OutExtra", 6 }, - }; + currentTemperatureInfo = new Dictionary { { "Up", "" }, @@ -543,7 +547,7 @@ private void CreateCsv(string header) csv_filename = folderName + @"\" + filename_prefix + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + file_ext; Console.WriteLine(); Console.WriteLine("Creating csv: {0}", csv_filename); - string metadata = "# {" + $"software-version: {software_version}, firmware-version: {firmware_version}" + "}"; + string metadata = $"# software-version: {software_version}\n# firmware-version: {firmware_version}"; File.WriteAllText(csv_filename, metadata + Environment.NewLine, Encoding.UTF8); File.AppendAllText(csv_filename, header.Remove(header.Length - 1, 1) + Environment.NewLine, Encoding.UTF8); } From d6e9e4bbb4ab03bfafd69d1ae36cc7c37a8f73dd Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Tue, 19 Jan 2021 16:36:20 +0100 Subject: [PATCH 30/36] fix exception handling during version check --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index dc9fe14..6ce16ed 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -241,7 +241,7 @@ public Control() } catch (Exception exc) { - Console.Write(exc.ToString()); + Console.Write("Version check failed: " + exc.ToString()); Console.WriteLine(); } } @@ -262,10 +262,9 @@ public Control() private bool check_firmware_version(string port) { SerialPort serial = new SerialPortForHeat(port); - - serial.Open(); try { + serial.Open(); Console.WriteLine(port); serial.DiscardInBuffer(); @@ -562,11 +561,17 @@ private void ButtonStart_Click(object sender, EventArgs e) { if (!check_firmware_version(port_measurement)) // changes firmware_version //todo: refactor: fwv=get_firmware_version(port); if !check_v() ... { - MessageBox.Show("Version of firmware does not match version of Software! Please update."); + MessageBox.Show($"Version of firmware ({firmware_version}) does not match version of software ({software_version})! Please update."); return; } } catch (TimeoutException exc) + { + string complain = "Timeout reading from Serial Port"; + MessageBox.Show(complain + "\n\n" + exc.ToString()); + return; + } + catch (UnauthorizedAccessException exc) { string complain = "Serial could not be opened, please check that the device is correct one"; MessageBox.Show(complain + "\n\n" + exc.ToString()); From 6f191672609a9706041880998c2e32973845ffbf Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 20 Jan 2021 14:29:25 +0100 Subject: [PATCH 31/36] ensure convertion of decimal numbers works everywhere --- .../Miriam_Serial/Miriam/Control.cs | 39 ++++++++++++------- .../Miriam_Serial/Miriam/FormSettings.cs | 17 +++++--- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 6ce16ed..778bdd3 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -184,6 +184,8 @@ public bool start_heat(string t_up, string t_middle, string t_extra, string thre public Control() { InitializeComponent(); + + //for correct string <-> double convertion using '.' as a decimal separator Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //datafile_separator = '\t'; // windows doesn't handle tsv files very well :( @@ -314,15 +316,17 @@ private void ParseTemperatureInfo(string received_data) private bool temperature_reached() { - float eps = float.Parse(settings_melting["Tolerance"], CultureInfo.InvariantCulture); + //for correct string <-> double convertion using '.' as a decimal separator + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + float eps = float.Parse(settings_melting["Tolerance"]); - float t_up_val = float.Parse(currentTemperatureInfo["Up"], CultureInfo.InvariantCulture); - float t_mid_val = float.Parse(currentTemperatureInfo["Middle"], CultureInfo.InvariantCulture); - float t_extra_val = float.Parse(currentTemperatureInfo["Extra"], CultureInfo.InvariantCulture); + float t_up_val = float.Parse(currentTemperatureInfo["Up"]); + float t_mid_val = float.Parse(currentTemperatureInfo["Middle"]); + float t_extra_val = float.Parse(currentTemperatureInfo["Extra"]); - bool t_up = (t_up_val - float.Parse(settings_melting["TUp"], CultureInfo.InvariantCulture) >= -eps); - bool t_mid = (t_mid_val - float.Parse(settings_melting["TMiddle"], CultureInfo.InvariantCulture) >= -eps); - bool t_extra = (t_extra_val - float.Parse(settings_melting["TExtra"], CultureInfo.InvariantCulture) >= -eps); + bool t_up = (t_up_val - float.Parse(settings_melting["TUp"]) >= -eps); + bool t_mid = (t_mid_val - float.Parse(settings_melting["TMiddle"]) >= -eps); + bool t_extra = (t_extra_val - float.Parse(settings_melting["TExtra"]) >= -eps); return t_up && t_mid && t_extra; } @@ -417,8 +421,9 @@ private void ButtonHeat_Click(object sender, EventArgs e) String ReceivedData; - //RecievedData = serialPort.ReadLine(); - //serialPort.DataReceived += new SerialDataReceivedEventHandler(responseHandler); + //for correct string <-> double convertion using '.' as a decimal separator + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + // [AT] SW 'M param' (middle wanted temperature, i.e. M 63) - FW 'temperatureMiddleSet' var s = ArduinoReadout(serialPort, "M " + settings_measurement.TMiddle.ToString()); Console.WriteLine(s); @@ -1096,13 +1101,17 @@ private void Control_Load(object sender, EventArgs e) //folderBrowserSaveRes.SelectedPath = Miriam_Serial.Properties.Settings.Default.settFolderRes; } Console.WriteLine("folder: {0}", folderName); - settings_measurement.TMiddle = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureMid, CultureInfo.InvariantCulture); - settings_measurement.TUp = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureUp, CultureInfo.InvariantCulture); - settings_measurement.TExtra = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureExtra, CultureInfo.InvariantCulture); - settings_measurement.DurationMin = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settDuration, CultureInfo.InvariantCulture); + + //for correct string <-> double convertion using '.' as a decimal separator + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + +// settings_measurement.TMiddle = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureMid, CultureInfo.InvariantCulture); + settings_measurement.TMiddle = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureMid); + settings_measurement.TUp = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureUp); + settings_measurement.TExtra = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settTemperatureExtra); + settings_measurement.DurationMin = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settDuration); settings_measurement.MeasureIntervalSec = Convert.ToInt32(Miriam_Serial.Properties.Settings.Default.settInterval); - settings_measurement.TThreshold = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold, CultureInfo.InvariantCulture); - + settings_measurement.TThreshold = Convert.ToDouble(Miriam_Serial.Properties.Settings.Default.settBoxTemperatureThreshold); settings_melting["TUp"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureUp; settings_melting["TMiddle"] = Miriam_Serial.Properties.Settings.Default.meltTemperatureMid; diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs index 1373b8f..a03b058 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/FormSettings.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -73,13 +74,16 @@ public FormSettings() private void buttonOk_Click(object sender, EventArgs e) { + //for correct string <-> double convertion using '.' as a decimal separator + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + // apply assay settings - Control.settings_measurement.TMiddle = Convert.ToDouble(cBoxMesMTemp.Text, CultureInfo.InvariantCulture); - Control.settings_measurement.TUp = Convert.ToDouble(cBoxMesUTemp.Text, CultureInfo.InvariantCulture); - Control.settings_measurement.TExtra = Convert.ToDouble(cBoxMesETemp.Text, CultureInfo.InvariantCulture); - Control.settings_measurement.TThreshold = Convert.ToDouble(cBoxMesThrTemp.Text, CultureInfo.InvariantCulture); + Control.settings_measurement.TMiddle = Convert.ToDouble(cBoxMesMTemp.Text); + Control.settings_measurement.TUp = Convert.ToDouble(cBoxMesUTemp.Text); + Control.settings_measurement.TExtra = Convert.ToDouble(cBoxMesETemp.Text); + Control.settings_measurement.TThreshold = Convert.ToDouble(cBoxMesThrTemp.Text); Control.settings_measurement.MeasureIntervalSec = Convert.ToInt32(cBoxMesInterval.Text); - Control.settings_measurement.DurationMin = Convert.ToDouble(cBoxMesDuration.Text, CultureInfo.InvariantCulture); + Control.settings_measurement.DurationMin = Convert.ToDouble(cBoxMesDuration.Text); // apply melting settings Control.melting_enabled = checkBoxEnableMelting.Checked; @@ -108,6 +112,9 @@ private void checkBoxEnableMelting_CheckedChanged(object sender, EventArgs e) private void FormSettings_Load(object sender, EventArgs e) { + //for correct string <-> double convertion using '.' as a decimal separator + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + // melting settings checkBoxEnableMelting.Checked = Control.melting_enabled; CboxTempU.Text = Control.settings_melting["TUp"]; From 37b7316f1f2b8459d9988aef4567dc3d12c37fb9 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 20 Jan 2021 17:35:07 +0100 Subject: [PATCH 32/36] refactoring --- .../Miriam_Serial/Miriam/Control.cs | 238 +++++++----------- 1 file changed, 88 insertions(+), 150 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 778bdd3..b6a9fe8 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -125,7 +125,28 @@ public SerialPortForHeat(string portname) ReadTimeout = 500; WriteTimeout = 500; } + public bool cancel() + { + try + { + Open(); + DiscardOutBuffer(); + DiscardInBuffer(); + string s = ArduinoReadout(this, "C"); + Console.WriteLine(s); + + Close(); + return true; + } + catch (Exception e) + { + MessageBox.Show("SerialPort error \n" + e.Message); + Close(); + return false; + //throw; + } + } public bool start_heat(string t_up, string t_middle, string t_extra, string threshold = "", bool melting=false) { try @@ -171,9 +192,8 @@ public bool start_heat(string t_up, string t_middle, string t_extra, string thre } catch (Exception exc) { - // [AT] todo: show exception - // MessageBox.Show("Serial could not be opened, please check that the device is correct one"); - MessageBox.Show(exc.ToString()); + string whatiam = melting ? "melting" : "heating"; + MessageBox.Show($"Could not start {whatiam}. Serial port error:\n" + exc.Message); this.Close(); return false; } @@ -394,71 +414,37 @@ private void AutofillPlate() private void ButtonHeat_Click(object sender, EventArgs e) { - // Set upper temperature - - SerialPort serialPort = null; - - // Create a new SerialPort object with default settings. - serialPort = new SerialPort(); - - // Allow the user to set the appropriate properties. - serialPort.PortName = COM.Text; - port_heating = COM.Text; - serialPort.DataBits = 8; - serialPort.Parity = Parity.None; - serialPort.StopBits = StopBits.One; - serialPort.BaudRate = 9600; - - // Set the read/write timeouts - serialPort.ReadTimeout = 500; - serialPort.WriteTimeout = 500; - - try - { - serialPort.Open(); - serialPort.DiscardOutBuffer(); - serialPort.DiscardInBuffer(); - - String ReceivedData; - - //for correct string <-> double convertion using '.' as a decimal separator - Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; - - // [AT] SW 'M param' (middle wanted temperature, i.e. M 63) - FW 'temperatureMiddleSet' - var s = ArduinoReadout(serialPort, "M " + settings_measurement.TMiddle.ToString()); - Console.WriteLine(s); - - s = ArduinoReadout(serialPort, "U " + settings_measurement.TUp.ToString()); - Console.WriteLine(s); - - s = ArduinoReadout(serialPort, "E " + settings_measurement.TExtra.ToString()); - Console.WriteLine(s); - - s = ArduinoReadout(serialPort, "T " + settings_measurement.TThreshold.ToString()); - Console.WriteLine(s); + SerialPortForHeat serialPort = new SerialPortForHeat(COM.Text); + - s = ArduinoReadout(serialPort, "H"); - Console.WriteLine(s); - // [AT] maybe sleep here a bit? + try + { + bool heat_started = serialPort.start_heat(settings_measurement.TUp.ToString(), + settings_measurement.TMiddle.ToString(), settings_measurement.TExtra.ToString(), + threshold: settings_measurement.TThreshold.ToString(), melting: false); - ReceivedData = ArduinoReadout(serialPort, "i"); - ParseTemperatureInfo(ReceivedData); -// AppendHeatLabel("Temperature U:" + currentTemperatureInfo["Up"] + "," + "Temperature M:" + currentTemperatureInfo["Middle"]); - AppendHeatLabel("Temperature U:" + currentTemperatureInfo["Up"] + "," + - "Temperature M:" + currentTemperatureInfo["Middle"] + "," + - "Temperature Extra:" + currentTemperatureInfo["Extra"] + "," + - "Temperature Box:" + currentTemperatureInfo["Box"]); + if (heat_started) + { + port_heating = COM.Text; + string ReceivedData = ArduinoReadout(serialPort, "i"); + ParseTemperatureInfo(ReceivedData); + // AppendHeatLabel("Temperature U:" + currentTemperatureInfo["Up"] + "," + "Temperature M:" + currentTemperatureInfo["Middle"]); + AppendHeatLabel("Temperature U:" + currentTemperatureInfo["Up"] + "," + + "Temperature M:" + currentTemperatureInfo["Middle"] + "," + + "Temperature Extra:" + currentTemperatureInfo["Extra"] + "," + + "Temperature Box:" + currentTemperatureInfo["Box"]); - // AppendHeatLabel("Temperature U:" + ReceivedData.Split(',')[4] + "," + "Temperature M:" + ReceivedData.Split(',')[5]); - Console.WriteLine(); - Console.WriteLine("i output: {0}", ReceivedData); + // AppendHeatLabel("Temperature U:" + ReceivedData.Split(',')[4] + "," + "Temperature M:" + ReceivedData.Split(',')[5]); + Console.WriteLine(); + Console.WriteLine("i output: {0}", ReceivedData); - serialPort.Close(); + serialPort.Close(); + } } catch (Exception exc) { // [AT] todo: show exception - MessageBox.Show("Serial could not be opened, please check that the device is correct one"); + MessageBox.Show("Serial could not be opened, please check that the device is correct one\n"+exc.Message); serialPort.Close(); } @@ -482,21 +468,10 @@ private void AppendHeatLabel(string value) private void AskHeat_Click(object sender, EventArgs e) { - SerialPort serialPort = null; + SerialPortForHeat serialPort = null; - // Create a new SerialPort object with default settings. - serialPort = new SerialPort(); - - // Allow the user to set the appropriate properties. - serialPort.PortName = COM.Text; - serialPort.DataBits = 8; - serialPort.Parity = Parity.None; - serialPort.StopBits = StopBits.One; - serialPort.BaudRate = 9600; - - // Set the read/write timeouts - serialPort.ReadTimeout = 500; - serialPort.WriteTimeout = 500; + // Create a new SerialPort object with appropriate settings. + serialPort = new SerialPortForHeat(COM.Text); try { @@ -521,14 +496,14 @@ private void AskHeat_Click(object sender, EventArgs e) } } - - private void AppendToCsv(string value) + private void AppendToCsv(string value, bool live=true, string filename="") { string append_string = value.TrimEnd(',') + Environment.NewLine; append_string = append_string.Replace(',', datafile_separator); - + if (live) + filename = csv_filename; //[AT] value has the ',' after the last value, don't write it to the csv - File.AppendAllText(csv_filename, append_string, Encoding.UTF8); + File.AppendAllText(filename, append_string, Encoding.UTF8); Console.WriteLine("Append to csv: {0}", value); } @@ -543,17 +518,18 @@ private void AppendData(string value) AppendToCsv(value); } - private void CreateCsv(string header) + private string CreateCsv(string header) { // header - comma-separated string file_ext = datafile_separator == '\t' ? ".tsv" : ".csv"; header = header.Replace(',', datafile_separator); - csv_filename = folderName + @"\" + filename_prefix + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + file_ext; + string filename = folderName + @"\" + filename_prefix + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + file_ext; Console.WriteLine(); Console.WriteLine("Creating csv: {0}", csv_filename); string metadata = $"# software-version: {software_version}\n# firmware-version: {firmware_version}"; - File.WriteAllText(csv_filename, metadata + Environment.NewLine, Encoding.UTF8); - File.AppendAllText(csv_filename, header.Remove(header.Length - 1, 1) + Environment.NewLine, Encoding.UTF8); + File.WriteAllText(filename, metadata + Environment.NewLine, Encoding.UTF8); + File.AppendAllText(filename, header.Remove(header.Length - 1, 1) + Environment.NewLine, Encoding.UTF8); + return filename; } private void ButtonStart_Click(object sender, EventArgs e) @@ -658,7 +634,7 @@ private void ButtonStart_Click(object sender, EventArgs e) Data.Items.Add(msg); //[AT] Data -- invisible ListBox arrayNames = msg; //[AT] header - CreateCsv(msg); + csv_filename = CreateCsv(msg); Color[] clr; @@ -767,56 +743,25 @@ public string ReverseColumnOrder(String received_vals) } return ans; } - private void cancelHeat() + private bool cancelHeat() { - SerialPort serialPortCancel = null; - try + + string portname = ""; + if (port_measurement == "") { - // Create a new SerialPort object with default settings. - serialPortCancel = new SerialPort(); - - if (port_measurement == "") - { - serialPortCancel.PortName = port_heating; - } - else - { - serialPortCancel.PortName = port_measurement; - } - if (serialPortCancel.PortName == "") - { - serialPortCancel.PortName = COM.Text; - } - - - serialPortCancel.DataBits = 8; - serialPortCancel.Parity = Parity.None; - serialPortCancel.StopBits = StopBits.One; - serialPortCancel.BaudRate = 9600; - - // Set the read/write timeouts - serialPortCancel.ReadTimeout = 500; - serialPortCancel.WriteTimeout = 500; - - serialPortCancel.Open(); - serialPortCancel.DiscardOutBuffer(); - serialPortCancel.DiscardInBuffer(); - - String ReceivedData; - //RecievedData = serialPort.ReadLine(); - //serialPort.DataReceived += new SerialDataReceivedEventHandler(responseHandler); - - string s = ArduinoReadout(serialPortCancel, "C"); - Console.WriteLine(s); - - serialPortCancel.Close(); + if (port_heating != "") portname = port_heating; } - catch (Exception exc) + else { - MessageBox.Show("Serial could not be opened, please check that the device is correct one"); - serialPortCancel.Close(); + portname = port_measurement; + } + if (portname=="") + { + portname = COM.Text; } + SerialPortForHeat serialPortCancel = new SerialPortForHeat(portname); + return serialPortCancel.cancel(); } private void doAssay() @@ -960,8 +905,11 @@ private void doAssay() // Cancel the heat // [AT] don't do canceling here, but only on exit? - cancelHeat(); - + bool heat_canceled = cancelHeat(); + + if (!heat_canceled) + MessageBox.Show("Warning! Heat was not canceled"); + if (assay_ready) MessageBox.Show("Assay ready"); else if(_exiting) @@ -982,28 +930,20 @@ private void ButtonWrite_Click(object sender, EventArgs e) { try { - //before your loop - var csv = new StringBuilder(); - - for(int i = 0; i Date: Wed, 27 Jan 2021 12:38:07 +0100 Subject: [PATCH 33/36] update melt parameters --- Programs/Serial_003/Serial_003.ino | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Programs/Serial_003/Serial_003.ino b/Programs/Serial_003/Serial_003.ino index e01b55d..23b3a7f 100644 --- a/Programs/Serial_003/Serial_003.ino +++ b/Programs/Serial_003/Serial_003.ino @@ -55,7 +55,7 @@ //Heater pins #define HEAT_MIDDLE 2 // Heat 1 #define HEAT_UPPER 3 // Heat 2 -#define HEAT_EXTRA 23 // Heat 3 +#define HEAT_EXTRA 5 // Heat 3 //LED Sensors pin #define PANEL_LED 22 @@ -446,10 +446,10 @@ void setPin(int outputPin) { void Read_Assay() { //set the PIDs to zero to boost LED power - Output_MIDDLE = 0; - Output_UPPER = 0; - Output_EXTRA = 0; - computePIDs(); + // Output_MIDDLE = 0; + // Output_UPPER = 0; + // Output_EXTRA = 0; + // computePIDs(); // digitalWrite(22,HIGH); //// analogWrite(4,125); @@ -752,10 +752,10 @@ void SetTunings_PID() { else { //we're far from setpoint, use aggressive tuning parameters - PID_MIDDLE.SetTunings(aggKp, aggKi, aggKd); + PID_MIDDLE.SetTunings(aggKp/3, aggKi/3, aggKd/3); } - if(Setpoint_UPPERSetpoint_UPPER) { //we're close to setpoint, use conservative tuning parameters PID_UPPER.SetTunings(consKp, consKi, consKd); Output_UPPER = 0; @@ -774,7 +774,7 @@ void SetTunings_PID() { else { //we're far from setpoint, use aggressive tuning parameters - PID_EXTRA.SetTunings(aggKp/10, aggKi/10, aggKd/10); + PID_EXTRA.SetTunings(aggKp/5, aggKi/5, aggKd/5); } } @@ -789,11 +789,11 @@ void SetTunings_PID_Melt() { gap3 = abs(Setpoint_EXTRA - Temperature(TH_EXTRA,T_CELSIUS,NCP18XH103F03RB,10000.0f)); //distance away from setpoint - PID_MIDDLE.SetTunings(consKp/40, consKi/40, consKd/40); + PID_MIDDLE.SetTunings(consKp/50, consKi/50, consKd/50); - PID_UPPER.SetTunings(consKp/40, consKi/40, consKd/40); + PID_UPPER.SetTunings(consKp/20, consKi/20, consKd/20); - PID_EXTRA.SetTunings(consKp/80, consKi/80, consKd/80); + PID_EXTRA.SetTunings(consKp/50, consKi/50, consKd/50); } From 3d28fdde34a508dd860b1407894c8e6ae81f0de9 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Wed, 3 Feb 2021 20:22:29 +0100 Subject: [PATCH 34/36] renamed columns in the csv --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index b6a9fe8..99b6140 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -300,7 +300,9 @@ private bool check_firmware_version(string port) catch (Exception exc) { serial.Close(); - throw exc; + throw; + //todo: check if the line below works + //throw new Exception("Version check failed.", exc); } } @@ -611,8 +613,10 @@ private void ButtonStart_Click(object sender, EventArgs e) int counter = 5; //string msg = "Time,U,M,"; // [AT] csv file header. - string msg = "Time,U,M,Extra,Box,"; // [AT] csv file header. - msg += "OutU, OutM, OutE,"; // add output values + //string msg = "Time,U,M,Extra,Box,"; // [AT] csv file header. + string msg = "Time,TemperatureUpper,TemperatureLower,TemperatureWire,TemperatureBox,"; + //msg += "OutU, OutM, OutE,"; // add output values + msg += "HeatCommandUpper,HeatCommandLower,HeatCommandWire,"; counter += 3; ninfo = counter; From bf3e9aa38127d4651c7f3ada448148c85372099b Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Thu, 4 Feb 2021 17:01:09 +0100 Subject: [PATCH 35/36] smarter exception handling for version check --- .../Serial_003/Miriam_Serial/Miriam/Control.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index 99b6140..cb609cd 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -299,10 +299,9 @@ private bool check_firmware_version(string port) } catch (Exception exc) { - serial.Close(); - throw; - //todo: check if the line below works - //throw new Exception("Version check failed.", exc); + serial.Close(); + exc.Data.Add("UserMessage", "Version check failed. Does the firmware have a version number?"); + throw; } } @@ -551,12 +550,20 @@ private void ButtonStart_Click(object sender, EventArgs e) catch (TimeoutException exc) { string complain = "Timeout reading from Serial Port"; + if (exc.Data.Contains("UserMessage")) + { + complain = exc.Data["UserMessage"].ToString(); + } MessageBox.Show(complain + "\n\n" + exc.ToString()); return; } catch (UnauthorizedAccessException exc) { string complain = "Serial could not be opened, please check that the device is correct one"; + if (exc.Data.Contains("UserMessage")) + { + complain = exc.Data["UserMessage"].ToString(); + } MessageBox.Show(complain + "\n\n" + exc.ToString()); return; } From e3d2dc4a7efeabc476b87c95688506f15b3ae168 Mon Sep 17 00:00:00 2001 From: Anna Titova Date: Thu, 4 Feb 2021 17:05:23 +0100 Subject: [PATCH 36/36] fix error message --- Programs/Serial_003/Miriam_Serial/Miriam/Control.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs index cb609cd..9e6fd48 100644 --- a/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs +++ b/Programs/Serial_003/Miriam_Serial/Miriam/Control.cs @@ -300,7 +300,7 @@ private bool check_firmware_version(string port) catch (Exception exc) { serial.Close(); - exc.Data.Add("UserMessage", "Version check failed. Does the firmware have a version number?"); + exc.Data.Add("UserMessage", "Version check failed. Check that the correct serial port is selected. Does the firmware have a version number?"); throw; }