盘表1设置 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace TransmissionLine.UserControls { public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } public void SetText(string text) { this.valueLabel.Text = text; } public void SetRange(double minValue, double maxValue) { if (minValue < maxValue) { this.gaugeContainer.CircularGauges[0].Scales[0].Minimum = minValue; this.gaugeContainer.CircularGauges[0].Scales[0].Maximum = maxValue; } } public void SetFormat(string formatString) { this.GbWmNumGauge.NumericIndicators[0].FormatString = this.GbCtmNumGauge.NumericIndicators[0].FormatString = formatString; } public void SetValue(double currentValue, double gb_wm_value, double ieee_wm_value, double gb_ctm_value, double ieee_ctm_value) { this.gaugeContainer.CircularGauges[0].Pointers["Load"].Value = currentValue; this.gaugeContainer.CircularGauges[0].Pointers["GB-WM"].Value = this.GbWmNumGauge.NumericIndicators[0].Value = gb_wm_value; this.gaugeContainer.CircularGauges[0].Pointers["GB-CTM"].Value = this.GbCtmNumGauge.NumericIndicators[0].Value = gb_ctm_value; if (Double.IsNaN(gb_wm_value) || Double.IsNaN(ieee_wm_value) || Double.IsNaN(gb_ctm_value) || Double.IsNaN(ieee_ctm_value)) { this.gaugeContainer.CircularGauges[0].Ranges[0].StartValue = Double.NaN; this.gaugeContainer.CircularGauges[0].Ranges[0].EndValue = Double.NaN; return; } else { this.gaugeContainer.CircularGauges[0].Ranges[0].StartValue = Math.Max(gb_wm_value, gb_ctm_value); this.gaugeContainer.CircularGauges[0].Ranges[0].EndValue = Math.Min(gb_wm_value, gb_ctm_value); } } } } 温度设置 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace TransmissionLine.UserControls { public partial class Thermometer : UserControl { public Thermometer() { InitializeComponent(); } public void SetRange(double minValue, double maxValue) { if (minValue < maxValue) { this.gaugeContainer.LinearGauges[0].Scales[0].Minimum = minValue; this.gaugeContainer.LinearGauges[0].Scales[0].Maximum = maxValue; } } public void SetFormat(string formatString) { this.numGauge.NumericIndicators[0].FormatString = formatString; } public void SetChildValue(double strainValue) { this.gaugeContainer.LinearGauges[0].Pointers[0].Value = this.numGauge.NumericIndicators[0].Value = strainValue; } } } 盘表2 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace TransmissionLine.UserControls { public partial class InstantView : UserControl { public InstantView() { InitializeComponent(); } public void SetRange(double minValue, double maxValue) { if (minValue < maxValue) { this.gaugeContainer.CircularGauges[0].Scales[0].Minimum = minValue; this.gaugeContainer.CircularGauges[0].Scales[0].Maximum = maxValue; } } public void SetFormat(string formatString) { this.loadNumGauge.NumericIndicators[0].FormatString = formatString; this.capacityNumGauge.NumericIndicators[0].FormatString = formatString; this.differenceNumContainer.NumericIndicators[0].FormatString = formatString; } public void SetValue(double load, double capacity) { this.loadNumGauge.NumericIndicators[0].Value = load; this.capacityNumGauge.NumericIndicators[0].Value = capacity; this.gaugeContainer.CircularGauges[0].Pointers["Load"].Value = load; this.gaugeContainer.CircularGauges[0].Pointers["Capacity"].Value = capacity; if (Double.IsNaN(load) || Double.IsNaN(capacity)) { this.gaugeContainer.CircularGauges[0].Ranges[0].StartValue = Double.NaN; this.gaugeContainer.CircularGauges[0].Ranges[0].EndValue = Double.NaN; this.gaugeContainer.StateIndicators[0].Value = -1; this.differenceNumContainer.NumericIndicators[0].Value = Double.NaN; return; } double quotient = capacity / load; this.gaugeContainer.StateIndicators[0].Value = quotient; if (quotient > 1.2) { this.gaugeContainer.CircularGauges[0].Ranges[0].StartValue = load; this.gaugeContainer.CircularGauges[0].Ranges[0].EndValue = capacity; this.gaugeContainer.CircularGauges[0].Ranges[0].FillColor = Color.FromArgb(100, Color.Blue); this.differenceNumContainer.NumericIndicators[0].Value = capacity - load; } else if (quotient > 1) { this.gaugeContainer.CircularGauges[0].Ranges[0].StartValue = load; this.gaugeContainer.CircularGauges[0].Ranges[0].EndValue = capacity; this.gaugeContainer.CircularGauges[0].Ranges[0].FillColor = Color.FromArgb(100, Color.Blue); this.differenceNumContainer.NumericIndicators[0].Value = capacity - load; } else { this.gaugeContainer.CircularGauges[0].Ranges[0].StartValue = capacity; this.gaugeContainer.CircularGauges[0].Ranges[0].EndValue = load; this.gaugeContainer.CircularGauges[0].Ranges[0].FillColor = Color.FromArgb(100, Color.Red); this.differenceNumContainer.NumericIndicators[0].Value = double.NaN; } } } } 表3 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace TransmissionLine.UserControls { public partial class SingleGauge : UserControl { public SingleGauge() { InitializeComponent(); } public void SetRange(double minValue, double maxValue) { if (minValue < maxValue) { this.gaugeContainer.CircularGauges[0].Scales[0].Minimum = minValue; this.gaugeContainer.CircularGauges[0].Scales[0].Maximum = maxValue; } } public void SetFormat(string formatString) { this.numContainer.NumericIndicators[0].FormatString = formatString; } public void SetValue(double value) { this.gaugeContainer.CircularGauges[0].Pointers[0].Value = value; this.numContainer.NumericIndicators[0].Value = value; } public void SetText(string text, string unit) { this.valueLabel.Text = text; this.gaugeContainer.Labels[0].Text = text; this.unitLabel.Text = unit; } } } 调用类 /// <summary> /// 构造函数 /// </summary> /// <param name="dpmain"></param> public TMidRealtimedata(dpMain dpmain) { this.dpmain = dpmain;//还是在容器中显示避免新增页面 //构造方法 InitializeComponent(); this.PropertyTable = new DataTable(); this.PropertyTable.Columns.Add("UpdataTimeString", typeof(string)); this.PropertyTable.Columns.Add("LineTitle", typeof(string)); this.PropertyTable.Columns.Add("StrainTitle", typeof(string)); this.PropertyTable.Rows.Add("未更新", "线路表计监控", "耐张段表计监控"); this.updateTimeLabel.DataBindings.Add("Text", this.PropertyTable, "UpdataTimeString", false, DataSourceUpdateMode.OnPropertyChanged); this.lineGroupBox.DataBindings.Add("Text", this.PropertyTable, "LineTitle", false, DataSourceUpdateMode.OnPropertyChanged); this.strainGroupBox.DataBindings.Add("Text", this.PropertyTable, "StrainTitle", false, DataSourceUpdateMode.OnPropertyChanged); this.singleGauge1.SetText("耐张段张力", "(N)"); this.singleGauge2.SetText("耐张段弧垂", "(m)"); } /// <summary> /// 线路名绑定下拉框 /// </summary> public void InitLineGroup() { DataTable dt = new LINE_PARA_TSM_DLRBLL().SelectDataTable();//查询线路信息表 this.lineComboBox.DataSource = dt; this.lineComboBox.DisplayMember = "LINENAME"; if (this.lineComboBox.Items.Count > 0) this.lineComboBox.SelectedIndex = 0; string ss = this.lineComboBox.Text; ResetStrainGroupBox(ss); //设置各表计的最大最小值 double maxCapacity = 3000; double minCapacity = 0; //温度 double maxTempreture = 60; double minTempreture = -40; //耐张段张力 double maxTension = 3000; double minTension = 0; //耐张段代表档距弧垂小值大值 double maxSag = 2000; double minSag = 0; this.instantView1.SetRange(minCapacity, maxCapacity);//设置instantView1盘表值 this.userControl12.SetRange(minCapacity, maxCapacity);//设置userControl12盘表值 this.thermometer1.SetRange(minTempreture, maxTempreture);//设置温度 this.singleGauge1.SetRange(minTension, maxTension);//耐张段张力 this.singleGauge2.SetRange(minSag, maxSag);//耐张段代表档距弧垂 this.instantView1.SetFormat("0000.0"); this.userControl12.SetFormat("0000.0"); this.thermometer1.SetFormat("0000.0"); } /// <summary> /// 耐张段 /// </summary> private void InitStrainGrop() { //double max } /// <summary> /// 耐张段名绑定下拉框 /// </summary> /// <param name="LineName"></param> public void ResetStrainGroupBox(string LineName) {//绑定耐张段信息表 DataTable dt = new STRAIN_PARABLL().SelectLineStrain(" where LINENAME = '" + LineName + "'"); this.strainComboBox.DataSource = dt; this.strainComboBox.DisplayMember = "STRAINNAME"; if (this.strainComboBox.Items.Count > 0) this.strainComboBox.SelectedIndex = 0; } private void TMidRealtimedata_Activated(object sender, EventArgs e) {//每当页面激活时 dpmain.isdiposes(); } private void lineComboBox_SelectedIndexChanged(object sender, EventArgs e) {//下拉框更改时发生 ResetStrainGroupBox(this.lineComboBox.Text); ResetLineValues(); } private void strainComboBox_SelectedIndexChanged(object sender, EventArgs e) {//下拉框更改时发生 ResetStrainValues(); } /// <summary> /// 线路容量实时数据表 /// </summary> void ResetLineValues() { CAPACITY_INSTANT model = new CAPACITY_INSTANTBLL().GetObjectByCondition(" where linename='" + lineComboBox.Text + "'"); try { //设置盘表值 this.instantView1.SetValue(decimal.ToDouble(model.LINELOAD.Value), decimal.ToDouble(model.LINECAPACITY.Value)); } catch (Exception) { this.instantView1.SetValue(double.NaN, double.NaN); } try { this.thermometer1.SetChildValue(decimal.ToDouble(model.LINETEMPERATURE.Value)); } catch (Exception) { this.thermometer1.SetChildValue(double.NaN); } } /// <summary> /// 耐张段实时数据表 /// </summary> void ResetStrainValues() { STRAIN_INSTANT model = new STRAIN_INSTANTBLL().GetObjectByCondition(" where Linename='" + lineComboBox.Text + "' and StrainName='" + strainComboBox.Text + "'"); try { //耐张段张力没值的时候显示空,有值的时候显示耐张段线路负荷 this.userControl12.SetValue(Convert.ToDouble(model.STRAINLOAD) == 0 ? Double.NaN : Convert.ToDouble(model.STRAINLINELOAD), Convert.ToDouble(model.CAPACITY_WM_GB), Convert.ToDouble(model.CAPACITY_WM_IEEE), Convert.ToDouble(model.CAPACITY_CTM_GB), Convert.ToDouble(model.CAPACITY_CTM_IEEE)); } catch { this.userControl12.SetValue(Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN); } try { //耐张段张力 this.singleGauge1.SetValue(Convert.ToDouble(model.STRAINLOAD)); } catch { this.singleGauge1.SetValue(Double.NaN); } try { //耐张段代表档距弧垂 this.singleGauge2.SetValue(Convert.ToDouble(model.STRAINCONDUCTSAG)); } catch (Exception) { this.singleGauge2.SetValue(Double.NaN); } } }