private void button2_Click(object sender, EventArgs e) { if (button2.Text == "应急模拟") { pp = true; timer2.Start(); textBox1.AppendText("泄漏发生"); button2.Text = "取消模拟"; } else { pp = false; timer2.Stop(); gateLight1("blue"); gateLight2("blue"); gateLight3("blue"); gateLight4("blue"); gateLight5("blue"); gateLight6("blue"); gateLight7("blue"); gateLight8("blue"); comPort1.WriteData(SerialPortUtil.HexToByte("20")); textBox1.AppendText("取消警报"); button2.Text = "应急模拟"; } }
private void timer1_Tick(object sender, EventArgs e) { windSpeed = Convert.ToInt64(getReal(getSpe()), 16) / 10.00; labelwinSpe.Text = windSpeed.ToString("F1") + "m/s"; windDir = labelwinDir.Text = getStrDir(getReal(getDir())); winDirPic(windDir); labelPot.Text = potency + " ppm"; comPort.WriteData(SerialPortUtil.HexToByte("01")); writeData(); string a = potency + " " + windSpeed.ToString() + " " + windDir; }
private void timer2_Tick(object sender, EventArgs e) { string g = "green"; string r = "red"; string b = "blue"; if (windDir == "北") { gateLight1(g); gateLight2(g); gateLight3(r); gateLight4(r); gateLight5(r); gateLight6(r); gateLight7(r); gateLight8(g); comPort1.WriteData(SerialPortUtil.HexToByte("11")); } else if (windDir == "东北") { gateLight1(g); gateLight2(g); gateLight3(g); gateLight4(r); gateLight5(r); gateLight6(r); gateLight7(r); gateLight8(r); comPort1.WriteData(SerialPortUtil.HexToByte("12")); } else if (windDir == "东") { gateLight1(r); gateLight2(g); gateLight3(g); gateLight4(g); gateLight5(r); gateLight6(r); gateLight7(r); gateLight8(r); comPort1.WriteData(SerialPortUtil.HexToByte("13")); } else if (windDir == "东南") { gateLight1(r); gateLight2(r); gateLight3(g); gateLight4(g); gateLight5(g); gateLight6(r); gateLight7(r); gateLight8(r); comPort1.WriteData(SerialPortUtil.HexToByte("14")); } else if (windDir == "南") { gateLight1(r); gateLight2(r); gateLight3(r); gateLight4(g); gateLight5(g); gateLight6(g); gateLight7(r); gateLight8(r); comPort1.WriteData(SerialPortUtil.HexToByte("15")); } else if (windDir == "西南") { gateLight1(r); gateLight2(r); gateLight3(r); gateLight4(r); gateLight5(g); gateLight6(g); gateLight7(g); gateLight8(r); comPort1.WriteData(SerialPortUtil.HexToByte("16")); } else if (windDir == "西") { gateLight1(r); gateLight2(r); gateLight3(r); gateLight4(r); gateLight5(r); gateLight6(g); gateLight7(g); gateLight8(g); comPort1.WriteData(SerialPortUtil.HexToByte("17")); } else if (windDir == "西北") { gateLight1(g); gateLight2(r); gateLight3(r); gateLight4(r); gateLight5(r); gateLight6(r); gateLight7(g); gateLight8(g); comPort1.WriteData(SerialPortUtil.HexToByte("18")); } else if (windDir == "无风") { gateLight1(g); gateLight2(g); gateLight3(g); gateLight4(g); gateLight5(g); gateLight6(g); gateLight7(g); gateLight8(g); comPort1.WriteData(SerialPortUtil.HexToByte("10")); } else { gateLight1(b); gateLight2(b); gateLight3(b); gateLight4(b); gateLight5(b); gateLight6(b); gateLight7(b); gateLight8(b); comPort1.WriteData(SerialPortUtil.HexToByte("10")); } }