private void btn_collection_Click(object sender, EventArgs e) { var name = cbb_type.Text; if (string.IsNullOrWhiteSpace(cbb_type.Text)) { MessageBox.Show("警告", "请选择传感器!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return; } double res = 0; bool IsSuccess = false; ListViewItem lvi = new ListViewItem(); if (name == "风速传感器 米/秒") { res = _tcpConnection.GetFSXS(ref IsSuccess); } if (name == "差压传感器 高 帕") { res = _tcpConnection.GetCYXS(ref IsSuccess); } if (name == "温度传感器 ℃") { res = _tcpConnection.GetWDXS(ref IsSuccess); } if (name == "大气压力传感器 KPa") { res = _tcpConnection.GetDQYLXS(ref IsSuccess); } if (name == "位移传感器1 mm") { res = _tcpConnection.GetDisplace1(ref IsSuccess); } if (name == "位移传感器2 mm") { res = _tcpConnection.GetDisplace2(ref IsSuccess); } if (name == "位移传感器3 mm") { res = _tcpConnection.GetDisplace3(ref IsSuccess); } lvi.Text = res.ToString(); lvi.SubItems.Add(DateTime.Now.ToString("HH:mm:ss")); this.lv_cjz.Items.Add(lvi); }
private void DataInit() { //隐藏打开按钮 // tsb_open.Visible = false; if (tcpClient.IsTCPLink) { #region 获取面板显示 var IsSeccess = false; var temperature = _temperature = tcpClient.GetWDXS(ref IsSeccess); if (!IsSeccess) { return; } var temppressure = _temppressure = tcpClient.GetDQYLXS(ref IsSeccess); if (!IsSeccess) { return; } var windSpeed = tcpClient.GetFSXS(ref IsSeccess).ToString(); if (!IsSeccess) { return; } var diffPress = tcpClient.GetCYXS(ref IsSeccess).ToString(); if (!IsSeccess) { return; } lbl_wdcgq.Text = temperature.ToString(); lbl_dqylcgq.Text = temppressure.ToString(); lbl_fscgq.Text = windSpeed.ToString(); lbl_cycgq.Text = diffPress.ToString(); //抗风压 var displace1 = tcpClient.GetDisplace1(ref IsSeccess).ToString(); if (!IsSeccess) { return; } var displace2 = tcpClient.GetDisplace2(ref IsSeccess).ToString(); if (!IsSeccess) { return; } var displace3 = tcpClient.GetDisplace3(ref IsSeccess).ToString(); if (!IsSeccess) { return; } lbl_Displace1.Text = displace1.ToString(); lbl_Displace2.Text = displace2.ToString(); lbl_Displace3.Text = displace3.ToString(); #endregion #region 获取正负压阀状态 GetPRVs(); #endregion } }