/// <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++) { WheelSlopes group = _dataQueue.ElementAt(i); this.chart1.Series["WheelLeft"].Points.AddXY(i, group.WheelLeftSlope); this.chart1.Series["WheelRight"].Points.AddXY(i, group.WheelRightSlope); this.chart1.Series["YawAngle"].Points.AddXY(i, group.YawAngle); } }
//更新队列中的值 private void UpdateQueueValue() { if (this._dataQueue.Count > _maxCount) { //先出列 for (int i = 0; i < _num; i++) { this._dataQueue.Dequeue(); } } string sqlString = string.Format("select t.wheel_left_slope, t.wheel_right_slope, t.yaw_plc 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(WheelSlopes.GetInstance(table.Rows[0])); }