/// <summary> /// 定时器事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Timer1_Tick(object sender, EventArgs e) { this.UpdateQueueValue(); foreach (var series in this.chart1.Series) { series.Points.Clear(); } for (int i = 0; i < _dataQueue.Count; i++) { BeltDistPowers group = _dataQueue.ElementAt(i); this.chart1.Series["BeltDist"].Points.AddXY(i, group.BeltDist); this.chart1.Series["WheelPowerRaw"].Points.AddXY(i, group.WheelPowerRaw); this.chart1.Series["WheelPowerPolished"].Points.AddXY(i, group.WheelPowerPolished); } }
//更新队列中的值 private void UpdateQueueValue() { if (this._dataQueue.Count > _maxCount) { //先出列 for (int i = 0; i < _num; i++) { this._dataQueue.Dequeue(); } } string sqlString = string.Format("select t.belt_dist, t.wheel_power_raw, t.wheel_power_polished from t_rcms_machineposture_time t where t.machine_name = '{0}'", _machineName); DataTable table = this.provider.Query(sqlString); if (table == null || table.Rows.Count == 0) { return; } this._dataQueue.Enqueue(BeltDistPowers.GetInstance(table.Rows[0])); }