Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO.Ports;
- using System.Threading;
- namespace Eurocoin_Voeding_Tester
- {
- public partial class Form1 : Form
- {
- /*initialisatie globale variable*/
- public List<byte> rxBuffer = new List<byte>();
- byte bMin12vEnabled = TRUE;
- byte b8HourEnabled;
- const byte RequestToSendVoltage = 1;
- const byte RequestToSendCurrent = 2;
- const byte ConectionCheck = 3;
- const byte RequestToSendMaxVoltage = 4;
- const byte RequestToSendMinVoltage = 5;
- const byte RequestToSendMaxError = 6;
- const byte RequestToSendMinError = 7;
- const byte RequestAll = 8;
- const byte ExtraLoad45V = 1;
- const byte ExtraLoad24V = 2;
- const byte ExtraLoad12V = 4;
- const byte ExtraLoad5V = 8;
- byte ExtraLoadControl;
- byte[] TimeRemaining = new byte[7];
- byte changeStartStop;
- byte soakteststarted;
- const byte RequestToStartSoakTest = 10;
- const byte RequestToStopSoakTest = 11;
- const byte RequestToResetValues = 12;
- byte DataRequest = 1;
- byte numberOfRequests = 7;
- bool BussySending = false;
- bool connected = false;
- byte[] Voltage45V = new byte[7];
- byte[] Voltage24V = new byte[7];
- byte[] Voltage12V = new byte[7];
- byte[] Voltage5V = new byte[7];
- byte[] Voltagem12V = new byte[7];
- byte[] VoltageMax45V = new byte[7];
- byte[] VoltageMax24V = new byte[7];
- byte[] VoltageMax12V = new byte[7];
- byte[] VoltageMax5V = new byte[7];
- byte[] VoltageMinm12V = new byte[7];
- byte[] VoltageMin45V = new byte[7];
- byte[] VoltageMin24V = new byte[7];
- byte[] VoltageMin12V = new byte[7];
- byte[] VoltageMin5V = new byte[7];
- byte[] VoltageMaxm12V = new byte[7];
- byte[] MaxError = new byte[7];
- byte[] MinError = new byte[7];
- byte EnablePowerSupply;
- byte PowersupplyIsOn;
- byte ExtraLoadStatus;
- byte SoakTestReady;
- byte SoakTestMessageShown;
- byte SoakTestBussy;
- byte Progressbar1Value;
- byte portnamecount;
- const byte TRUE = 0x01;
- const byte FALSE = 0x00;
- const byte SOH = 0x01;
- const byte KEY = 0xaa;
- byte RxByteCount_vuc = 253;
- public Form1()
- {
- InitializeComponent();
- radioButton1.Checked = true;
- radioButton3.Checked = true;
- if (checkBox1.Checked == true || checkBox2.Checked == true || checkBox3.Checked == true || checkBox4.Checked == true)
- button3.Text = "All off";
- else
- button3.Text = "All on";
- timer1.Tick += new EventHandler(timer1_Tick); // Everytime timer ticks, timer_Tick will be called
- timer1.Interval = 300; // Timer will tick evert 300ms
- timer1.Enabled = true; // Enable the timer
- timer1.Stop(); // Start the timer
- timer2.Tick += new EventHandler(timer2_Tick); // Everytime timer ticks, timer_Tick will be called
- timer2.Interval = 100; // Timer will tick evert 100ms
- timer2.Enabled = true; // Enable the timer
- timer2.Start(); // Start the timer
- timer3.Tick += new EventHandler(timer3_Tick); // Everytime timer ticks, timer_Tick will be called
- timer3.Interval = 500; // Timer will tick evert 500ms
- timer3.Enabled = true; // Enable the timer
- timer3.Start(); // Start the timer
- timer4.Tick += new EventHandler(timer4_Tick); // Everytime timer ticks, timer_Tick will be called
- timer4.Interval = ((1000 * 60) * 2); // Timer will tick every 2 min
- timer4.Enabled = true; // Enable the timer
- timer4.Stop(); // Start the timer
- this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived);
- serialPort1.ReceivedBytesThreshold = 1;
- }
- void timer1_Tick(object sender, EventArgs e)
- {
- timer1.Stop();
- if (connected == true)
- {
- connected = false;
- }
- try
- {
- serialPort1.Close();
- }
- catch { }
- BussySending = false;
- }
- void timer2_Tick(object sender, EventArgs e)
- {
- if (serialPort1.IsOpen == false)
- {
- BussySending = false;
- connected = false;
- SoakTestBussy = FALSE;
- bMin12vEnabled = TRUE;
- }
- string[] Portnames = SerialPort.GetPortNames();
- if (portnamecount > Portnames.Length)
- portnamecount = 0;
- if ((connected == false) && (Portnames.Length != 0))
- {
- for (;serialPort1.IsOpen == false; portnamecount++)
- {
- if ((Portnames.Length != 0))
- {
- if (portnamecount > (Portnames.Length - 1))
- portnamecount = 0;
- serialPort1.PortName = Portnames[portnamecount];
- Portnames = SerialPort.GetPortNames();
- try { serialPort1.Open(); }
- catch { }
- }
- else break;
- }
- }
- if (BussySending == false)
- {
- SendBlock(DataRequest);
- DataRequest++;
- if (DataRequest > numberOfRequests)
- DataRequest = 1;
- }
- if (connected == false)
- {
- toolStripStatusLabel1.Text = "Not connected";
- }
- else
- {
- toolStripStatusLabel1.Text = "Connected";
- }
- }
- void timer3_Tick(object sender, EventArgs e)
- {
- if (SoakTestReady == TRUE)
- textBox1.Text = ("Soaktest completed");
- else
- textBox1.Text = ("");
- if (checkBox1.Checked == true || checkBox2.Checked == true || checkBox3.Checked == true || checkBox4.Checked == true)
- timer4.Start();
- else
- timer4.Stop();
- if (checkBox1.Checked == true)
- ExtraLoadControl |= ExtraLoad45V;
- else
- ExtraLoadControl &= 255 - ExtraLoad45V;
- if (checkBox2.Checked == true)
- ExtraLoadControl |= ExtraLoad24V;
- else
- ExtraLoadControl &= 255 - ExtraLoad24V;
- if (checkBox3.Checked == true)
- ExtraLoadControl |= ExtraLoad12V;
- else
- ExtraLoadControl &= 255 - ExtraLoad12V;
- if (checkBox4.Checked == true)
- ExtraLoadControl |= ExtraLoad5V;
- else
- ExtraLoadControl &= 255 - ExtraLoad5V;
- if(PowersupplyIsOn == TRUE)
- button2.Text = "Stop Powersupply";
- else
- button2.Text = "Start Powersupply";
- if (SoakTestBussy == TRUE)
- {
- button6.Enabled = false;
- toolStripStatusLabel3.Text = ByteArrayToStr(TimeRemaining);
- toolStripStatusLabel2.Text = "Time left:";
- button2.Enabled = false;
- groupBox2.Enabled = false;
- groupBox3.Enabled = false;
- groupBox4.Enabled = false;
- button4.Text = "Back";
- groupBox1.Text = "live measurements (Soaktest in progress)";
- if (changeStartStop == 0x01)
- {
- if (SoakTestBussy == soakteststarted)
- {
- changeStartStop = FALSE;
- button5.Text = "Stop";
- }
- }
- else if(changeStartStop == FALSE)
- button5.Text = "Stop";
- }
- else
- {
- button6.Enabled = true;
- toolStripStatusLabel3.Text = "";
- toolStripStatusLabel2.Text = "";
- button2.Enabled = true;
- if (connected == true)
- groupBox2.Enabled = true;
- groupBox3.Enabled = true;
- groupBox4.Enabled = true;
- button4.Text = "Cancel";
- if (changeStartStop == 0x02)
- {
- if (SoakTestBussy == soakteststarted)
- {
- changeStartStop = FALSE;
- button5.Text = "Start";
- }
- }
- else if (changeStartStop == FALSE)
- button5.Text = "Start";
- if (connected == false)
- {
- groupBox2.Enabled = false;
- }
- else
- {
- groupBox2.Enabled = true;
- }
- if (button1.Visible == false)
- {
- button5.Visible = true;
- }
- groupBox1.Text = "live measurements";
- }
- toolStripProgressBar1.Value = Progressbar1Value;
- if (connected == true)
- {
- textBox3.Text = ByteArrayToStr(Voltage45V);
- textBox6.Text = ByteArrayToStr(Voltage24V);
- textBox10.Text = ByteArrayToStr(Voltage12V);
- textBox14.Text = ByteArrayToStr(Voltage5V);
- if (bMin12vEnabled == TRUE || SoakTestBussy == FALSE)
- textBox18.Text = ByteArrayToStr(Voltagem12V);
- else if (SoakTestBussy == TRUE)
- textBox18.Text = "N/A";
- textBox2.Text = ByteArrayToStr(VoltageMax45V);
- textBox7.Text = ByteArrayToStr(VoltageMax24V);
- textBox11.Text = ByteArrayToStr(VoltageMax12V);
- textBox15.Text = ByteArrayToStr(VoltageMax5V);
- if (bMin12vEnabled == TRUE || SoakTestBussy == FALSE)
- textBox19.Text = ByteArrayToStr(VoltageMinm12V);
- else if (SoakTestBussy == TRUE)
- textBox19.Text = "N/A";
- textBox4.Text = ByteArrayToStr(VoltageMin45V);
- textBox5.Text = ByteArrayToStr(VoltageMin24V);
- textBox9.Text = ByteArrayToStr(VoltageMin12V);
- textBox13.Text = ByteArrayToStr(VoltageMin5V);
- if (bMin12vEnabled == TRUE || SoakTestBussy == FALSE)
- textBox17.Text = ByteArrayToStr(VoltageMaxm12V);
- else if (SoakTestBussy == TRUE)
- textBox17.Text = "N/A";
- }
- else
- {
- textBox3.Text = "--";
- textBox6.Text = "--";
- textBox10.Text = "--";
- textBox14.Text = "--";
- textBox18.Text = "--";
- textBox2.Text = "--";
- textBox7.Text = "--";
- textBox11.Text = "--";
- textBox15.Text = "--";
- textBox19.Text = "--";
- textBox4.Text = "--";
- textBox5.Text = "--";
- textBox9.Text = "--";
- textBox13.Text = "--";
- textBox17.Text = "--";
- }
- if (MaxError[0] == 1)
- {
- textBox2.ForeColor = System.Drawing.Color.Red;
- textBox2.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox2.ForeColor = System.Drawing.Color.Black;
- textBox2.BackColor = textBox4.BackColor;
- }
- if (MaxError[1] == 1)
- {
- textBox7.ForeColor = System.Drawing.Color.Red;
- textBox7.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox7.ForeColor = System.Drawing.Color.Black;
- textBox7.BackColor = textBox4.BackColor;
- }
- if (MaxError[2] == 1)
- {
- textBox11.ForeColor = System.Drawing.Color.Red;
- textBox11.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox11.ForeColor = System.Drawing.Color.Black;
- textBox11.BackColor = textBox4.BackColor;
- }
- if (MaxError[3] == 1)
- {
- textBox15.ForeColor = System.Drawing.Color.Red;
- textBox15.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox15.ForeColor = System.Drawing.Color.Black;
- textBox15.BackColor = textBox4.BackColor;
- }
- if (bMin12vEnabled == TRUE)
- {
- if (MinError[4] == 1)
- {
- textBox19.ForeColor = System.Drawing.Color.Red;
- textBox19.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox19.ForeColor = System.Drawing.Color.Black;
- textBox19.BackColor = textBox4.BackColor;
- }
- }
- else
- {
- textBox19.ForeColor = System.Drawing.Color.Black;
- textBox19.BackColor = textBox19.BackColor;
- }
- if (MinError[0] == 1)
- {
- textBox4.ForeColor = System.Drawing.Color.Red;
- textBox4.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox4.ForeColor = System.Drawing.Color.Black;
- textBox4.BackColor = textBox4.BackColor;
- }
- if (MinError[1] == 1)
- {
- textBox5.ForeColor = System.Drawing.Color.Red;
- textBox5.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox5.ForeColor = System.Drawing.Color.Black;
- textBox5.BackColor = textBox4.BackColor;
- }
- if (MinError[2] == 1)
- {
- textBox9.ForeColor = System.Drawing.Color.Red;
- textBox9.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox9.ForeColor = System.Drawing.Color.Black;
- textBox9.BackColor = textBox4.BackColor;
- }
- if (MinError[3] == 1)
- {
- textBox13.ForeColor = System.Drawing.Color.Red;
- textBox13.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox13.ForeColor = System.Drawing.Color.Black;
- textBox13.BackColor = textBox4.BackColor;
- }
- if (bMin12vEnabled == TRUE)
- {
- if (MaxError[4] == 1)
- {
- textBox17.ForeColor = System.Drawing.Color.Red;
- textBox17.BackColor = textBox4.BackColor;
- }
- else
- {
- textBox17.ForeColor = System.Drawing.Color.Black;
- textBox17.BackColor = textBox4.BackColor;
- }
- }
- else
- {
- textBox17.ForeColor = System.Drawing.Color.Black;
- textBox17.BackColor = textBox17.BackColor;
- }
- }
- void timer4_Tick(object sender, EventArgs e)
- {
- checkBox1.Checked = false;
- checkBox2.Checked = false;
- checkBox3.Checked = false;
- checkBox4.Checked = false;
- timer4.Stop();
- MessageBox.Show("The extra loads have been switched off,\nthis happens automaticly after 2 minutes.");
- }
- public static string ByteArrayToStr(byte[] byteArray)
- {
- System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
- return encoding.GetString(byteArray);
- }
- public void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) //receive serial data
- {
- byte readbyte;
- try
- {
- while (serialPort1.BytesToRead > 0)
- {
- readbyte = (byte)serialPort1.ReadByte();
- if (RxByteCount_vuc < 30)
- {
- rxBuffer.Add(readbyte); //store data bytes in data
- RxByteCount_vuc++;
- }
- if (RxByteCount_vuc == 30) //if 30 !DATA! bytes have been received set the bytecount to start position
- {
- connected = true;
- timer1.Stop();
- RxByteCount_vuc = 253;
- serialPort1.DiscardInBuffer();
- ExecuteReceivedData();
- }
- else
- {
- if ((RxByteCount_vuc == 255) && (readbyte == KEY)) //if value of prev byte + 1 has been received reset bytecount
- {
- RxByteCount_vuc = 0;
- BussySending = true;
- }
- else
- {
- if (RxByteCount_vuc == 255)
- {
- RxByteCount_vuc = 253;
- }
- else
- {
- if ((RxByteCount_vuc == 254) && (readbyte == (255 - SOH))) //if ~SOH is next add 1 to byte count
- {
- RxByteCount_vuc = 255;
- }
- else
- {
- if (RxByteCount_vuc == 254)
- {
- RxByteCount_vuc = 253;
- }
- else
- {
- if ((RxByteCount_vuc == 253) && (readbyte == SOH)) //if ready for datablock and start of heading received reset byte counter
- {
- RxByteCount_vuc = 254;
- }
- }
- }
- }
- }
- }
- }
- }
- catch { }
- }
- private void ExecuteReceivedData ()
- {
- switch (rxBuffer[0])
- {
- case RequestToSendVoltage:
- {
- Voltage45V[0] = rxBuffer[10];
- Voltage45V[1] = rxBuffer[11];
- Voltage45V[2] = 46;
- Voltage45V[3] = rxBuffer[12];
- Voltage45V[4] = rxBuffer[13];
- Voltage45V[5] = 86;
- Voltage24V[0] = rxBuffer[14];
- Voltage24V[1] = rxBuffer[15];
- Voltage24V[2] = 46;
- Voltage24V[3] = rxBuffer[16];
- Voltage24V[4] = rxBuffer[17];
- Voltage24V[5] = 86;
- Voltage12V[0] = rxBuffer[18];
- Voltage12V[1] = rxBuffer[19];
- Voltage12V[2] = 46;
- Voltage12V[3] = rxBuffer[20];
- Voltage12V[4] = rxBuffer[21];
- Voltage12V[5] = 86;
- Voltage5V[0] = rxBuffer[22];
- Voltage5V[1] = rxBuffer[23];
- Voltage5V[2] = 46;
- Voltage5V[3] = rxBuffer[24];
- Voltage5V[4] = rxBuffer[25];
- Voltage5V[5] = 86;
- Voltagem12V[0] = 45;
- Voltagem12V[1] = rxBuffer[26];
- Voltagem12V[2] = rxBuffer[27];
- Voltagem12V[3] = 46;
- Voltagem12V[4] = rxBuffer[28];
- Voltagem12V[5] = rxBuffer[29];
- Voltagem12V[6] = 86;
- break;
- }
- case RequestToSendMaxVoltage:
- {
- VoltageMax45V[0] = rxBuffer[10];
- VoltageMax45V[1] = rxBuffer[11];
- VoltageMax45V[2] = 46;
- VoltageMax45V[3] = rxBuffer[12];
- VoltageMax45V[4] = rxBuffer[13];
- VoltageMax45V[5] = 86;
- VoltageMax24V[0] = rxBuffer[14];
- VoltageMax24V[1] = rxBuffer[15];
- VoltageMax24V[2] = 46;
- VoltageMax24V[3] = rxBuffer[16];
- VoltageMax24V[4] = rxBuffer[17];
- VoltageMax24V[5] = 86;
- VoltageMax12V[0] = rxBuffer[18];
- VoltageMax12V[1] = rxBuffer[19];
- VoltageMax12V[2] = 46;
- VoltageMax12V[3] = rxBuffer[20];
- VoltageMax12V[4] = rxBuffer[21];
- VoltageMax12V[5] = 86;
- VoltageMax5V[0] = rxBuffer[22];
- VoltageMax5V[1] = rxBuffer[23];
- VoltageMax5V[2] = 46;
- VoltageMax5V[3] = rxBuffer[24];
- VoltageMax5V[4] = rxBuffer[25];
- VoltageMax5V[5] = 86;
- VoltageMaxm12V[0] = 45;
- VoltageMaxm12V[1] = rxBuffer[26];
- VoltageMaxm12V[2] = rxBuffer[27];
- VoltageMaxm12V[3] = 46;
- VoltageMaxm12V[4] = rxBuffer[28];
- VoltageMaxm12V[5] = rxBuffer[29];
- VoltageMaxm12V[6] = 86;
- break;
- }
- case RequestToSendMinVoltage:
- {
- VoltageMin45V[0] = rxBuffer[10];
- VoltageMin45V[1] = rxBuffer[11];
- VoltageMin45V[2] = 46;
- VoltageMin45V[3] = rxBuffer[12];
- VoltageMin45V[4] = rxBuffer[13];
- VoltageMin45V[5] = 86;
- VoltageMin24V[0] = rxBuffer[14];
- VoltageMin24V[1] = rxBuffer[15];
- VoltageMin24V[2] = 46;
- VoltageMin24V[3] = rxBuffer[16];
- VoltageMin24V[4] = rxBuffer[17];
- VoltageMin24V[5] = 86;
- VoltageMin12V[0] = rxBuffer[18];
- VoltageMin12V[1] = rxBuffer[19];
- VoltageMin12V[2] = 46;
- VoltageMin12V[3] = rxBuffer[20];
- VoltageMin12V[4] = rxBuffer[21];
- VoltageMin12V[5] = 86;
- VoltageMin5V[0] = rxBuffer[22];
- VoltageMin5V[1] = rxBuffer[23];
- VoltageMin5V[2] = 46;
- VoltageMin5V[3] = rxBuffer[24];
- VoltageMin5V[4] = rxBuffer[25];
- VoltageMin5V[5] = 86;
- VoltageMinm12V[0] = 45;
- VoltageMinm12V[1] = rxBuffer[26];
- VoltageMinm12V[2] = rxBuffer[27];
- VoltageMinm12V[3] = 46;
- VoltageMinm12V[4] = rxBuffer[28];
- VoltageMinm12V[5] = rxBuffer[29];
- VoltageMinm12V[6] = 86;
- break;
- }
- case RequestToSendMaxError:
- {
- MaxError[0] = rxBuffer[10];
- MaxError[1] = rxBuffer[11];
- MaxError[2] = rxBuffer[12];
- MaxError[3] = rxBuffer[13];
- MaxError[4] = rxBuffer[14];
- break;
- }
- case RequestToSendMinError:
- {
- MinError[0] = rxBuffer[10];
- MinError[1] = rxBuffer[11];
- MinError[2] = rxBuffer[12];
- MinError[3] = rxBuffer[13];
- MinError[4] = rxBuffer[14];
- break;
- }
- case RequestToSendCurrent:
- {
- break;
- }
- case RequestToStartSoakTest:
- {
- soakteststarted = rxBuffer[10];
- break;
- }
- case RequestToStopSoakTest :
- {
- soakteststarted = rxBuffer[10];
- break;
- }
- case ConectionCheck :
- {
- SoakTestBussy = rxBuffer[10];
- Progressbar1Value = rxBuffer[11];
- PowersupplyIsOn = rxBuffer[14];
- ExtraLoadStatus = rxBuffer[15];
- TimeRemaining[0] = 48;
- TimeRemaining[1] = rxBuffer[16];
- TimeRemaining[2] = 58;
- TimeRemaining[3] = rxBuffer[17];
- TimeRemaining[4] = rxBuffer[18];
- SoakTestReady = rxBuffer[19];
- break;
- }
- }
- rxBuffer.Clear();
- BussySending = false;
- }
- private void SendBlock(byte data)
- {
- if (serialPort1.IsOpen == true)
- {
- BussySending = true;
- byte[] TransmitData;
- TransmitData = new byte[36];
- byte[] Handshake;
- Handshake = new byte[3];
- Handshake[0] = SOH;
- Handshake[1] = (255 - SOH);
- Handshake[2] = KEY;
- switch (data)
- {
- case RequestToSendMaxVoltage:
- {
- TransmitData[0] = RequestToSendMaxVoltage;
- break;
- }
- case RequestToSendMaxError :
- {
- TransmitData[0] = RequestToSendMaxError;
- break;
- }
- case RequestToSendMinError :
- {
- TransmitData[0] = RequestToSendMinError;
- break;
- }
- case RequestToSendMinVoltage:
- {
- TransmitData[0] = RequestToSendMinVoltage;
- break;
- }
- case RequestToStartSoakTest:
- {
- TransmitData[0] = data;
- TransmitData[10] = bMin12vEnabled;
- TransmitData[11] = b8HourEnabled;
- break;
- }
- case RequestToStopSoakTest:
- {
- TransmitData[0] = data;
- break;
- }
- case RequestToSendVoltage:
- {
- TransmitData[0] = data;
- break;
- }
- case RequestToSendCurrent:
- {
- TransmitData[0] = data;
- break;
- }
- case ConectionCheck:
- {
- TransmitData[0] = data;
- TransmitData[12] = ExtraLoadControl;
- TransmitData[13] = EnablePowerSupply;
- EnablePowerSupply = 0;
- break;
- }
- case RequestToResetValues:
- {
- TransmitData[0] = RequestToResetValues;
- break;
- }
- }
- try
- {
- serialPort1.Write(Handshake, 0, 3);
- serialPort1.Write(TransmitData, 0, 30);
- }
- catch
- {}
- timer1.Start();
- }
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox1.Checked == true || checkBox2.Checked == true || checkBox3.Checked == true || checkBox4.Checked == true)
- button3.Text = "All off";
- else
- button3.Text = "All on";
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (checkBox1.Checked == true || checkBox2.Checked == true || checkBox3.Checked == true || checkBox4.Checked == true)
- {
- checkBox1.Checked = false;
- checkBox2.Checked = false;
- checkBox3.Checked = false;
- checkBox4.Checked = false;
- }
- else
- {
- checkBox1.Checked = true;
- checkBox2.Checked = true;
- checkBox3.Checked = true;
- checkBox4.Checked = true;
- }
- }
- private void checkBox4_CheckedChanged_1(object sender, EventArgs e)
- {
- if (checkBox1.Checked == true || checkBox2.Checked == true || checkBox3.Checked == true || checkBox4.Checked == true)
- button3.Text = "All off";
- else
- button3.Text = "All on";
- }
- private void checkBox2_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox1.Checked == true || checkBox2.Checked == true || checkBox3.Checked == true || checkBox4.Checked == true)
- button3.Text = "All off";
- else
- button3.Text = "All on";
- }
- private void checkBox3_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox1.Checked == true || checkBox2.Checked == true || checkBox3.Checked == true || checkBox4.Checked == true)
- button3.Text = "All off";
- else
- button3.Text = "All on";
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (PowersupplyIsOn == TRUE)
- {
- if (MessageBox.Show("Are you sure you want to shut down the powersupply?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- EnablePowerSupply = TRUE;
- button2.Text = "Start Powersupply";
- }
- else
- {
- if (MessageBox.Show("Are you sure you want to start up the powersupply?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- EnablePowerSupply = TRUE;
- button2.Text = "Stop Powersupply";
- }
- }
- private void groupBox2_EnabledChanged(object sender, EventArgs e)
- {
- checkBox1.Checked = false;
- checkBox2.Checked = false;
- checkBox3.Checked = false;
- checkBox4.Checked = false;
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- groupBox5.Visible = false;
- button1.Visible = false;
- button4.Visible = true;
- button5.Visible = true;
- groupBox3.Visible = true;
- groupBox4.Visible = true;
- }
- private void button4_Click(object sender, EventArgs e)
- {
- groupBox5.Visible = true;
- button1.Visible = true;
- button4.Visible = false;
- button5.Visible = false;
- groupBox3.Visible = false;
- groupBox4.Visible = false;
- }
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- if (radioButton1.Checked == true)
- bMin12vEnabled = TRUE;
- else
- bMin12vEnabled = FALSE;
- }
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- if (radioButton2.Checked == true)
- bMin12vEnabled = FALSE;
- else
- bMin12vEnabled = TRUE;
- }
- private void radioButton3_CheckedChanged(object sender, EventArgs e)
- {
- if (radioButton3.Checked == true)
- b8HourEnabled = FALSE;
- else
- b8HourEnabled = TRUE;
- }
- private void radioButton4_CheckedChanged(object sender, EventArgs e)
- {
- if (radioButton4.Checked == true)
- b8HourEnabled = TRUE;
- else
- b8HourEnabled = FALSE;
- }
- private void button5_Click(object sender, EventArgs e)
- {
- if (SoakTestBussy == TRUE)
- {
- if (MessageBox.Show("Are you sure you want to stop the current soaktest?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
- {
- SendBlock(RequestToStopSoakTest);
- }
- }
- else
- {
- SendBlock(RequestToStartSoakTest);
- }
- }
- private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- string target = "http://www.eurocoingaming.nl";
- //Use no more than one assignment when you test this code.
- //string target = "ftp://ftp.microsoft.com";
- //string target = "C:\\Program Files\\Microsoft Visual Studio\\INSTALL.HTM";
- try
- {
- System.Diagnostics.Process.Start(target);
- }
- catch
- (
- System.ComponentModel.Win32Exception noBrowser)
- {
- if (noBrowser.ErrorCode == -2147467259)
- MessageBox.Show(noBrowser.Message);
- }
- catch (System.Exception other)
- {
- MessageBox.Show(other.Message);
- }
- }
- private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- }
- private void button6_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show("Are you sure you want to reset all values?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- SendBlock(RequestToResetValues);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment