public Form1() { InitializeComponent(); map = PMap.CreateGraphics(); string[] ports = SerialPort.GetPortNames(); cbxCom.Items.AddRange(ports); UART.ReadTimeout = 2000; //UART.DataReceived += new SerialDataReceivedEventHandler(data); UART.BaudRate = 115200; UART.Parity = Parity.None; UART.StopBits = StopBits.One; timer1.Interval = 300; timerForSentCoordinate.Interval = 400; //initial state of settings cbxLevel.Text = "Low"; cbxTime.Text = "None"; btnChay.Enabled = false; btnDung.Enabled = false; btnDung.BackColor = Color.FromArgb(33, 42, 52); btnTime.Enabled = false; btnTime.BackColor = Color.FromArgb(33, 42, 52); chbxAuto.Enabled = false; chbxMan.Enabled = false; cbxLevel.Enabled = false; cbxTime.Enabled = false; //initial state of controller btnback.Enabled = false; btnleft.Enabled = false; btnstop.Enabled = false; btnright.Enabled = false; btnstraight.Enabled = false; //initial state of panel P1.Hide(); P2.Hide(); P3.Hide(); P4.Hide(); P6.Hide(); P5.Show(); P8.Hide(); PMap.Hide(); P5.BringToFront(); picturemenu.Hide(); startX = PMap.Width / 2; startY = PMap.Height / 2; //startTmpX = PMap.Width / 2; startTmpY = PMap.Height / 2; //label1.Text = ""; }
//Select Start time private void btnTime_Click(object sender, EventArgs e) { if (P8.Visible == true) { P8.Hide(); } else { P8.Show(); } }
private void P2_Click(object sender, EventArgs e) { P8.Hide(); }
private void btnChay_Click(object sender, EventArgs e) { #region select mode if (chbxMan.Checked == true) { Mode = "m"; //label on controller page lblwarn.Text = "THE MACHINE IS BEING IN MANUAL MODE."; lblwarn.ForeColor = Color.Green; //enable controller btnback.Enabled = true; btnback.BackColor = Color.LightSeaGreen; btnleft.Enabled = true; btnleft.BackColor = Color.LightSeaGreen; btnstop.Enabled = true; btnright.Enabled = true; btnright.BackColor = Color.LightSeaGreen; btnstraight.Enabled = true; btnstraight.BackColor = Color.LightSeaGreen; //save start time startHour = hour; startMin = minute; timeOut = 0; } if (chbxAuto.Checked == true) { Mode = "a"; lblwarn.Text = "THE MACHINE IS BEING IN AUTO MODE."; lblwarn.ForeColor = Color.DarkOrange; //select start time if (txtHour.Text == "") { txtHour.Text = "00"; } if (txtMinute.Text == "") { txtMinute.Text = "00"; } if (txtHour.Text == "00" && txtMinute.Text == "00") { startHour = hour; startMin = minute; timeOut = 0; tempHour = Convert.ToDouble(hour); tempMinute = Convert.ToDouble(minute); } else { timeOut = 1; startHour = string.Format("{0:00}", txtHour.Text); tempHour = Convert.ToDouble(txtHour.Text); startMin = string.Format("{0:00}", txtMinute.Text); tempMinute = Convert.ToDouble(txtMinute.Text); } } if (chbxAuto.Checked == false && chbxMan.Checked == false) { MessageBox.Show("Please select mode."); return; } #endregion #region select level vaccum //select level for vaccum if (cbxLevel.Text == "Low") { set_point = "L"; } if (cbxLevel.Text == "Medium") { set_point = "M"; } if (cbxLevel.Text == "High") { set_point = "H"; } #endregion #region select time up if (cbxTime.Text == "None" || cbxTime.Text == "") { time = 0; cbxTime.Text = "None"; timeUp = 0; Time = string.Format("{0:00}", time); } else { time = Convert.ToDouble(cbxTime.Text); Time = string.Format("{0:00}", cbxTime.Text); timeUp = 1; } #endregion #region send data //send data data = "S" + set_point + Time + startHour + startMin + Mode; UART.Write(data); timer1.Enabled = true; #endregion //change state of button lblwarning.Text = ""; stopTemp = 1; btnChay.Text = "STARTED"; btnDung.Enabled = true; btnDung.BackColor = Color.Teal; btnChay.Enabled = false; btnChay.BackColor = Color.Green; //disable Setting chbxAuto.Enabled = false; chbxMan.Enabled = false; cbxLevel.Enabled = false; cbxTime.Enabled = false; btnTime.Enabled = false; btnTime.BackColor = Color.FromArgb(33, 42, 52); P8.Hide(); reportPage(); }