//**************************************************** private void Emboard_Load(object sender,EventArgs e) { Database db = new Database(); comPort.pic = pictureBox1; db.setAllFalse(); txtmac.Hide(); pnShow.Hide(); btexit.Enabled = true; comPort.txtShowData = tbShow; comPort.TimerInit(); comPort.Time_control = db.getTimeActor(); comPort.Time_alarm = db.getTimeAlarm(); db.setFalseBC(); db.setValOff(); db.setAllFalse(); #if ACTOR_BAOCHAY cbMalenh.Items.Clear(); cbMalenh.Items.Add("Lay nhiet do, do am"); for (int i = 1; i < 6; i++) { cbMalenh.Items.Add("Gui canh bao muc "+i); } #else cbMalenh.Items.Clear(); cbMalenh.Items.Add("Lay nhiet do, do am"); for (int i = 1; i < 7; i++) { cbMalenh.Items.Add("Bat van so "+i); } cbMalenh.Items.Add("Bat tat ca cac van"); for (int i = 1; i < 7; i++) { cbMalenh.Items.Add("Tat van so " + i); } cbMalenh.Items.Add("Tat tat ca cac van"); #endif try { drawImage.pictureBox = pictureBox1; drawImage.reload(drawImage.pictureBox); } catch { MessageBox.Show("Khong the load ban do"); } }
private void btApply_Click(object sender, EventArgs e) { try { if(cbMode.SelectedIndex == 0) { comPort.DisplayData("("+DateTime.Now+")Sensor chuyen sang che do thuc ngu!", tbShow); comPort.WriteData(confixcmd); MessageBox.Show("Sent successful!", "Infomations"); } if(cbMode.SelectedIndex == 1) { if (cbPeriod.SelectedIndex != -1) { comPort.DisplayData("(" + DateTime.Now + ")Dieu chinh thoi gian gui du lieu dinh ky!", tbShow); comPort.WriteData(confixcmd); MessageBox.Show("Sent successful!", "Infomations"); } else { MessageBox.Show("Not enough imformation","Error"); } } if (cbMode.SelectedIndex == 2) { if (cbtimecontrol.SelectedIndex != -1) { Database myDatabase = new Database(); int value = cbtimecontrol.SelectedIndex + 1; int a = myDatabase.setTimeActor(value); if(a == 1) MessageBox.Show("Save successful!", "Infomations"); comPort.Time_control = myDatabase.getTimeActor(); } else { MessageBox.Show("Not enough imformation", "Error"); } } if (cbMode.SelectedIndex == 3) { if (cbSmokeThresh.SelectedIndex != -1) { comPort.WriteData(confixcmd); comPort.DisplayData("(" + DateTime.Now + ")Thiet lap nong do nguong khoi", tbShow); MessageBox.Show("Sent successful", "Imformation"); } else { MessageBox.Show("Not enough imformation", "Error"); } } if (cbMode.SelectedIndex == 4) { if (cbalarm.SelectedIndex != -1) { Database myDatabase = new Database(); int value = (cbalarm.SelectedIndex + 1)*5; int a = myDatabase.setTimeAlarm(value); if (a == 1) MessageBox.Show("Save successful!", "Infomations"); comPort.Time_alarm = myDatabase.getTimeAlarm(); } else { MessageBox.Show("Not enough imformation", "Error"); } } } catch { } }
//**************************************************** private void Emboard_Load(object sender,EventArgs e) { Database db = new Database(); comPort.pic = pictureBox1; db.setAllFalse(); txtmac.Hide(); pnShow.Hide(); btexit.Enabled = true; comPort.txtShowData = tbShow; comPort.PicboxImage = picboxImage; comPort.TimerInit(); comPort.Time_control = db.getTimeActor(); comPort.Time_alarm = db.getTimeAlarm(); db.setFalseBC(); db.setValOff(); db.setAllFalse(); #region tabpicture begin cbnodeImg.Items.Clear(); Database my_Database = new Database(); //Hien thi danh sach sensor khu vuon lan XmlNodeList nodeSensor = ((XmlElement)my_Database.sensor).GetElementsByTagName("node"); foreach (XmlNode node in nodeSensor) { if (node.Attributes["status"].Value == "true" || node.Attributes["status"].Value == "True") { string str = "Sensor " + node.Attributes["mac"].Value; cbnodeImg.Items.Add(str); } } XmlNodeList nodeSensor_BC = ((XmlElement)my_Database.sensor_bc).GetElementsByTagName("node"); foreach (XmlNode node_BC in nodeSensor_BC) { if (node_BC.Attributes["status"].Value == "true" || node_BC.Attributes["status"].Value == "True") { string str = "Sensor " + node_BC.Attributes["mac"].Value; cbnodeImg.Items.Add(str); } } #endregion #if ACTOR_BAOCHAY cbMalenh.Items.Clear(); cbMalenh.Items.Add("Lay nhiet do, do am"); for (int i = 1; i < 6; i++) { cbMalenh.Items.Add("Gui canh bao muc "+i); } #else cbMalenh.Items.Clear(); cbMalenh.Items.Add("Lay nhiet do, do am"); for (int i = 1; i < 7; i++) { cbMalenh.Items.Add("Bat van so "+i); } cbMalenh.Items.Add("Bat tat ca cac van"); for (int i = 1; i < 7; i++) { cbMalenh.Items.Add("Tat van so " + i); } cbMalenh.Items.Add("Tat tat ca cac van"); #endif try { drawImage.pictureBox = pictureBox1; drawImage.reload(drawImage.pictureBox); } catch { MessageBox.Show("Khong the load ban do"); } }
private void cbMode_SelectedIndexChanged(object sender, System.EventArgs e) { try { Database myDatabase = new Database(); btApply.Enabled = true; btCancel.Enabled = true; if (cbMode.SelectedIndex == 0) { lbsmoke.Hide(); cbSmokeThresh.Hide(); lbtimecontrol.Hide(); cbtimecontrol.Hide(); lbperiod.Hide(); cbPeriod.Hide(); lbalarm.Hide(); cbalarm.Hide(); confixcmd[2] = 1; } if (cbMode.SelectedIndex == 1) { lbsmoke.Hide(); cbSmokeThresh.Hide(); lbtimecontrol.Hide(); cbtimecontrol.Hide(); cbPeriod.Show(); lbperiod.Show(); lbalarm.Hide(); cbalarm.Hide(); for (int i = 1; i < 17; i++) { cbPeriod.Items.Add(i * 5 + " minutes"); } } if (cbMode.SelectedIndex == 2) { lbsmoke.Hide(); cbSmokeThresh.Hide(); lbtimecontrol.Show(); cbtimecontrol.Show(); lbperiod.Hide(); cbPeriod.Hide(); lbalarm.Hide(); cbalarm.Hide(); lbtimecontrol.Location = new Point(7, 91); cbtimecontrol.Location = new Point(108, 91); for (int i = 1; i < 31; i++) { cbtimecontrol.Items.Add(i+" minutes"); } cbtimecontrol.SelectedIndex = myDatabase.getTimeActor() - 1; } if (cbMode.SelectedIndex == 3) { lbsmoke.Show(); cbSmokeThresh.Show(); lbtimecontrol.Hide(); cbtimecontrol.Hide(); lbperiod.Hide(); cbPeriod.Hide(); lbalarm.Hide(); cbalarm.Hide(); lbsmoke.Location = new Point(7,91); cbSmokeThresh.Location =new Point (108, 91); } if (cbMode.SelectedIndex == 4) { lbsmoke.Hide(); cbSmokeThresh.Hide(); lbtimecontrol.Hide(); cbtimecontrol.Hide(); lbperiod.Hide(); cbPeriod.Hide(); lbalarm.Show(); cbalarm.Show(); lbalarm.Location = new Point(7, 91); cbalarm.Location = new Point(108, 91); for (int i = 1; i < 25; i++) { cbalarm.Items.Add(5*i+" minutes"); } cbalarm.SelectedIndex = myDatabase.getTimeAlarm()/5 -1; } } catch { } }
//**************************************************** private void Emboard_Load(object sender,EventArgs e) { Database myDatabase = new Database(); send = new Thread(new ThreadStart(comPort.SendRS)); send.Start(); comPort.TimerInt(); #if ACTOR_COOR myDatabase.setAllFalse(); cbMalenh.Items.Clear(); cbMalenh.Items.Add("Lay nhiet do, do am"); cbMalenh.Items.Add("Bat van so 1"); cbMalenh.Items.Add("Bat van so 2"); cbMalenh.Items.Add("Bat van so 3"); cbMalenh.Items.Add("Bat van so 4"); cbMalenh.Items.Add("Bat van so 5"); cbMalenh.Items.Add("Bat van so 6"); cbMalenh.Items.Add("Bat tat ca cac van"); cbMalenh.Items.Add("Tat van so 1"); cbMalenh.Items.Add("Tat van so 2"); cbMalenh.Items.Add("Tat van so 3"); cbMalenh.Items.Add("Tat van so 4"); cbMalenh.Items.Add("Tat van so 5"); cbMalenh.Items.Add("Tat van so 6"); cbMalenh.Items.Add("Tat tat ca cac van"); #endif #if BC_COOR myDatabase.setFalseActor(); myDatabase.setNetworkIpActor("B1","0000"); cbMalenh.Items.Clear(); cbMalenh.Items.Add("Lay nhiet do, do am"); cbMalenh.Items.Add("Bat canh bao muc 1"); cbMalenh.Items.Add("Bat canh bao muc 2"); cbMalenh.Items.Add("Bat canh bao muc 3"); cbMalenh.Items.Add("Bat canh bao muc 4"); cbMalenh.Items.Add("Bat canh bao muc 5"); #endif myDatabase.setFalseBC(); myDatabase.setValOff(); myDatabase.setTimeVan(1, 0); myDatabase.setTimeVan(2, 0); myDatabase.setTimeVan(3, 0); myDatabase.setTimeVan(4,0); myDatabase.setTimeVan(5, 0); comPort.Time_alarm = myDatabase.getTimeAlarm(); comPort.Time_control = myDatabase.getTimeActor(); comPort.mypanel = pnShow; comPort.mytext = txtshow; comPort.tb = tbShow; txtmac.Hide(); pnShow.Hide(); btexit.Enabled = true; try { comPort.pictureBox = pictureBox1; comPort.reload(comPort.pictureBox); } catch { MessageBox.Show("Khong the load ban do"); } }