/// <summary> /// 绑定GridView /// </summary> private void BindGridView() { try { if (this.dataGridView1.DataSource == null) { //if (GlobalVariables.UnitNumber == 1) //{ // GlobalVariables.dtTagsSet.DefaultView.RowFilter = "([id]<2000 or [id]>3000) and datasourcesNo=1"; // dt = GlobalVariables.dtTagsSet.DefaultView.ToTable(); // GlobalVariables.dtTagsSet.DefaultView.RowFilter = ""; //} //else if (GlobalVariables.UnitNumber == 2) //{ // GlobalVariables.dtTagsSet.DefaultView.RowFilter = "[id]>2000 and datasourcesNo=1"; // dt = GlobalVariables.dtTagsSet.DefaultView.ToTable(); // GlobalVariables.dtTagsSet.DefaultView.RowFilter = ""; //} GlobalVariables.dtTagsSetFive.DefaultView.RowFilter = "datasourcesNo=1"; dt = GlobalVariables.dtTagsSetFive.DefaultView.ToTable(); this.dataGridView1.DataSource = dt; } else { string tagValue = ""; for (int i = 0; i < dt.Rows.Count; i++) { tagValue = TagValue.GetShowValueFive(int.Parse(dt.Rows[i]["id"].ToString()), "", dt.Rows[i]["adjustValue"].ToString()); //CalTree.GetShowValueNoUnit(int.Parse(dt.Rows[i]["id"].ToString()), dt.Rows[i]["Unit"].ToString(), dt.Rows[i]["adjustValue"].ToString()); dataGridView1.Rows[i].Cells["TagValue"].Value = tagValue; //CalTree.GetShowValueNoUnit(int.Parse(dt.Rows[i]["id"].ToString()), dt.Rows[i]["Unit"].ToString(), dt.Rows[i]["adjustValue"].ToString()); if (string.IsNullOrEmpty(tagValue) || tagValue == "--" || tagValue == GlobalVariables.BadValue.ToString()) //实时值 { this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.OrangeRed; continue; } else { this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.White; } } } Application.DoEvents(); } catch (Exception ex) { WriteLog.WriteLogs(ex.ToString()); } }
/// <summary> /// 设定绑定标签的Text(测点值+测点单位)。 /// </summary> void SetBindingLabelsText() { try { int i; LabelTag labelTag; Control control, parent = panel1; foreach (DataRowView row in viewTagLabelBinding) { try { //由父控件找到本Label control = parent.Controls.Find(row["LabelName"].ToString(), false)[0]; labelTag = (LabelTag)control.Tag; try { if (labelTag.IsSetToolTipText == false) { toolTip1.SetToolTip(control, row["TagDesc"].ToString()); labelTag.IsSetToolTipText = true; labelTag.TagID = int.Parse(row["TagID"].ToString()); labelTag.TagDesc = row["TagDesc"].ToString(); labelTag.TagUnit = row["unit"].ToString(); } } catch { control.Tag = new LabelTag(true, int.Parse(row["TagID"].ToString()), row["TagDesc"].ToString(), row["unit"].ToString()); toolTip1.SetToolTip(control, row["TagDesc"].ToString()); } //这里是否需要根据机组区分 ZZH control.Text = TagValue.GetShowValueFive(labelTag.TagID, labelTag.TagUnit, row["adjustValue"].ToString()); control.Refresh(); } catch { } } lblRunOptimizePromptText.Text = RunOptimizePrompt.GetPromptText(); lblRunOptimizePromptText.ForeColor = RunOptimizePrompt.GetPromptTextForeColor(); lblTemp.Text = "环境温度:" + TagValue.GetShowValueSix(3208, "℃", "");// GlobalVariables.dtOneRowData.Rows[0]["F3208"].ToString(); } catch (Exception ex) { WriteLog.WriteLogs(ex.ToString()); } }
/// <summary> /// 折线图表 绑定 /// </summary> private void Chart1Bind() { //if (GlobalVariables.dtChartDatas == null || GlobalVariables.dtChartDatas.Rows.Count < 1) // return; double pointX = 550; double pointY = 25; string dygpqll = ""; //低压缸排气流量1324/2324 double dqy = 0.1; //大气压 //string dygjqyl = "--"; //低压缸进汽压力 //int rowCount = GlobalVariables.dtChartDatas.Rows.Count - 1; //if (GlobalVariables.UnitNumber == 1) //{ // try // { // //这里添加#1机组的XY坐标 // pointX = double.Parse(GlobalVariables.dtChartDatas.Rows[rowCount]["F1169"].ToString()); // //pointY = double.Parse(CalDataTable.Rows[0]["F3126"].ToString()) * 1000; // dygpqll = GlobalVariables.dtChartDatas.Rows[rowCount]["F1324"].ToString(); // dygjqyl = CalTree.GetShowValue(1111, "MPa", "F3004"); // } // catch { } //} //else //{ // try // { // //这里添加#2机组的XY坐标 // pointX = double.Parse(GlobalVariables.dtChartDatas.Rows[rowCount]["F2169"].ToString()); // //pointY = double.Parse(CalDataTable.Rows[0]["F3126"].ToString()) * 1000; // dygpqll = GlobalVariables.dtChartDatas.Rows[rowCount]["F2324"].ToString(); // dygjqyl = CalTree.GetShowValue(2111, "MPa", "F3004"); // } // catch { } //} //try //{ // pointY = double.Parse(GlobalVariables.dtChartDatas.Rows[rowCount]["F3126"].ToString()) * 1000; // dqy = double.Parse(GlobalVariables.dtChartDatas.Rows[rowCount]["F3004"].ToString()) * 1000; //} //catch { } if (this.UnitNO == 5) { try { //这里添加#1机组的XY坐标 // X坐标修改成低压缸排汽流量 ZZH 20160830 pointX = TagValue.GetFinishedTagValueFive("F1324");// double.Parse(CalDataTable.Rows[0]["F1169"].ToString()); if (pointX == GlobalVariables.BadValue) { pointX = TagValue.GetSetValueFive("1324", "SetValue"); } dygpqll = TagValue.GetShowValueFive(1324, "t/h", ""); // CalDataTable.Rows[0]["F1324"].ToString(); //dygjqyl = TagValue.GetShowValueFive(1111, "MPa", ""); //这里,如果不配置公共,需要修改 ZZH 2016-9-17 pointY = TagValue.GetFinishedTagValueFive("F3126") * 1000; //double.Parse(CalDataTable.Rows[0]["F3126"].ToString()) * 1000; dqy = TagValue.GetFinishedTagValueFive("F3004") * 1000; //double.Parse(CalDataTable.Rows[0]["F3004"].ToString()) * 1000; if (pointY == GlobalVariables.BadValue * 1000) { pointY = TagValue.GetSetValueFive("3126", "SetValue") * 1000; } if (dqy == GlobalVariables.BadValue * 1000) { dqy = TagValue.GetSetValueFive("3004", "SetValue") * 1000; } } catch { } } else if (this.UnitNO == 6) { try { //这里添加#2机组的XY坐标 pointX = TagValue.GetFinishedTagValueSix("F2324");//double.Parse(CalDataTable.Rows[0]["F2169"].ToString()); if (pointX == GlobalVariables.BadValue) { pointX = TagValue.GetSetValueSix("2324", "SetValue"); } dygpqll = TagValue.GetShowValueSix(2324, "t/h", ""); //CalDataTable.Rows[0]["F2324"].ToString(); //dygjqyl = TagValue.GetShowValueSix(2111, "MPa", ""); //这里,如果不配置公共,需要修改 ZZH 2016-9-17 pointY = TagValue.GetFinishedTagValueSix("F4126") * 1000; //double.Parse(CalDataTable.Rows[0]["F3126"].ToString()) * 1000; dqy = TagValue.GetFinishedTagValueSix("F4004") * 1000; //double.Parse(CalDataTable.Rows[0]["F3004"].ToString()) * 1000; if (pointY == GlobalVariables.BadValue * 1000) { pointY = TagValue.GetSetValueSix("4126", "SetValue") * 1000; } if (dqy == GlobalVariables.BadValue * 1000) { dqy = TagValue.GetSetValueSix("4004", "SetValue") * 1000; } } catch { } } //绑定低压缸排气流量和相对容积流量 this.label27.Text = dygpqll; this.label28.Text = pointY + " KPa"; //this.label1.Text = dygjqyl; //低压缸进气压力 //真空 F3004*1000 - F3126*1000 this.label43.Text = Math.Round(dqy - pointY, 2) + " KPa"; try { //Y2轴 真空绑定 double max = dqy - 0; double min = dqy - 70; this.chart1.ChartAreas[0].AxisY2.Minimum = min; this.chart1.ChartAreas[0].AxisY2.Maximum = max; } catch { } //闪点绑定 this.chart1.Series["chart3Series"].Points.Clear(); this.chart1.Series["chart3Series"].Points.AddXY(pointX, pointY); this.chart1.Series["chart3Series"].Label = "低压缸排气流量:" + dygpqll + "\r\n真 空:" + (dqy - pointY) + "KPa"; //this.chart1.Series["chart3Series"].Label = "低压缸排气流量:" + dygpqll + "\r\n低压缸进汽压力:" + dygjqyl + "\r\n真 空:" + (dqy - pointY) + "KPa"; }