using DevExpress.XtraEditors;
|
using DevExpress.XtraEditors.Repository;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace IStation.WinFrmUI.CalcErQu
|
{
|
public partial class AnimationTipInfoDlg : XtraForm
|
{
|
System.Data.DataTable dataTableLookUp;
|
public AnimationTipInfoDlg()
|
{
|
InitializeComponent();
|
|
InitLookUpDataTable();
|
|
|
|
}
|
#region Grid Table
|
|
void AddRecordToLookUpDataTable(string tag, string fName, string fUnit)
|
{
|
DataRow row = this.dataTableLookUp.NewRow();
|
row["clnTag"] = tag;
|
row["clnName"] = fName;
|
row["clnValue"] = "";
|
row["clnUnit"] = fUnit;
|
|
this.dataTableLookUp.Rows.Add(row);
|
}
|
void InitLookUpDataTable()
|
{
|
this.dataTableLookUp = new System.Data.DataTable();
|
|
this.gridControl1.DataSource = this.dataTableLookUp;
|
gridView1.OptionsMenu.ShowAutoFilterRowItem = false;
|
|
System.Data.DataColumn dataColumn1 = new System.Data.DataColumn();
|
dataColumn1.Caption = "Tag";
|
dataColumn1.ColumnName = "clnTag";
|
|
System.Data.DataColumn dataColumn2 = new System.Data.DataColumn();
|
dataColumn2.Caption = "Name";
|
dataColumn2.ColumnName = "clnName";
|
|
System.Data.DataColumn dataColumn3 = new System.Data.DataColumn();
|
dataColumn3.Caption = "Value";
|
dataColumn3.ColumnName = "clnValue";
|
|
System.Data.DataColumn dataColumn4 = new System.Data.DataColumn();
|
dataColumn4.Caption = "Unit";
|
dataColumn4.ColumnName = "clnUnit";
|
this.dataTableLookUp.Columns.AddRange(new System.Data.DataColumn[] {
|
dataColumn1,
|
dataColumn2,
|
dataColumn3,dataColumn4});
|
this.dataTableLookUp.TableName = "TableLookUp";
|
|
AddRecordToLookUpDataTable("Time", "时间", "");
|
AddRecordToLookUpDataTable("Flow", "瞬时流量", "m³/h");
|
AddRecordToLookUpDataTable("OpenPumpCount", "开机数", "");
|
AddRecordToLookUpDataTable("OpenPumpName", "开机泵名", "");
|
AddRecordToLookUpDataTable("WaterLevelC", "长江水位", "m");
|
AddRecordToLookUpDataTable("WaterLevelQ", "前池水位", "m");
|
AddRecordToLookUpDataTable("Head", "扬程", "m");
|
AddRecordToLookUpDataTable("Power", "功率", "kW");
|
|
AddRecordToLookUpDataTable("TotalFlow", "今日累计供水", "m³");
|
AddRecordToLookUpDataTable("TotalEle", "今日累计用电", " ");
|
AddRecordToLookUpDataTable("TotalMoney", "今日累计电费", "元");
|
|
this.gridControl1.DataSource = dataTableLookUp;
|
|
this.gridControl1.ForceInitialize();
|
}
|
|
|
|
#endregion
|
|
private List<IStation.CalcModel.PumpInfo> _allPumpInfo = null;
|
public void SetPumpInfo(List<IStation.CalcModel.PumpInfo> allPumpInfo)
|
{
|
this._allPumpInfo = allPumpInfo;
|
|
chartPumpCurveParalCtrl1.SetPumpInfo(allPumpInfo);
|
|
}
|
|
|
protected int _calcSpaceMinute = 2;
|
public int CalcSpaceMinute { get { return _calcSpaceMinute; } set { _calcSpaceMinute = value; } }
|
IStation.CalcModel.AnaPrj _anaPrj = null;
|
DateTime _startTime, _endTime;
|
public void SetBindingData(IStation.CalcModel.AnaPrj anaPrj)
|
{
|
if (anaPrj == null)
|
return;
|
|
|
this.CalcSpaceMinute = IStation.WinFrmUI.CalcErQu.Properties.Settings.Default.CalcSpaceMinute;
|
|
this._startTime = anaPrj.StartTime;
|
this._endTime = anaPrj.EndTime;
|
this._anaPrj = anaPrj;
|
|
_animationMovePtIndx = 0;
|
_animationTime = this._startTime;
|
_animationSpaceMinute = _calcSpaceMinute / 2.0;
|
}
|
|
private void AnimationTipInfoDlg_Load(object sender, EventArgs e)
|
{
|
|
}
|
|
public void UpdateData(
|
DateTime animationTime,
|
IStation.ViewModel.RealTimeData rtd)
|
{
|
this.dataTableLookUp.Rows[0]["clnValue"] = animationTime.ToString("HH:mm");
|
this.dataTableLookUp.Rows[1]["clnValue"] = rtd.Flow.ToString();
|
this.dataTableLookUp.Rows[2]["clnValue"] = rtd.OpenPumpCount.ToString();
|
this.dataTableLookUp.Rows[3]["clnValue"] = "";
|
this.dataTableLookUp.Rows[4]["clnValue"] = Math.Round(rtd.WaterLevelC, 2).ToString();//长江水位
|
this.dataTableLookUp.Rows[5]["clnValue"] = Math.Round(rtd.WaterLevelQ, 2).ToString();
|
this.dataTableLookUp.Rows[6]["clnValue"] = Math.Round(rtd.Head, 1).ToString();
|
this.dataTableLookUp.Rows[7]["clnValue"] = Math.Round(rtd.Power, 1).ToString();
|
|
this.dataTableLookUp.Rows[8]["clnValue"] = Math.Round(rtd.TotalFlow, 1).ToString();
|
this.dataTableLookUp.Rows[9]["clnValue"] = Math.Round(rtd.TotalEle, 1).ToString();
|
this.dataTableLookUp.Rows[10]["clnValue"] = Math.Round(rtd.TotalMoney, 1).ToString();
|
|
gaugeContent长江水位.SetValue(Math.Round(rtd.WaterLevelC, 1), Convert.ToSingle(rtd.WaterLevelC * 100 / 5));
|
// gaugeContent供水量.SetValue(Math.Round(rtd.TotalFlow/10000,1), Convert.ToSingle(rtd.TotalFlow * 100 / this._targeFlow));
|
|
|
chartPumpCurveParalCtrl1.SetPumpRun(rtd);
|
|
}
|
|
System.Timers.Timer _timerAnimation;
|
DateTime _animationTime;
|
int _animationMovePtIndx = 0;
|
double _animationSpaceMinute = 2;
|
private void btnStart_Click(object sender, EventArgs e)
|
{
|
if (_timerAnimation != null)
|
{
|
_timerAnimation.Start();
|
return;
|
}
|
|
_timerAnimation = new System.Timers.Timer();
|
_timerAnimation.Enabled = true;
|
// 1-10
|
_timerAnimation.Interval = GetInterval();//执行间隔时间,单位为毫秒
|
|
OnStartAnimation.Invoke();
|
|
_timerAnimation.Elapsed += new System.Timers.ElapsedEventHandler(AnimationTimer_Elapsed);
|
|
_timerAnimation.Start();
|
}
|
private int GetInterval()
|
{ //200
|
return 550 - (trackBarControl1.Value * 50);
|
}
|
|
|
private void btnPause_Click(object sender, EventArgs e)
|
{
|
_timerAnimation.Stop();
|
}
|
|
private void btnStop_Click(object sender, EventArgs e)
|
{
|
_timerAnimation.Stop();
|
_timerAnimation.Dispose();
|
_timerAnimation = null;
|
|
OnStopAnimation.Invoke();
|
}
|
private void AnimationTipInfoDlg_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
e.Cancel = true;
|
|
if (_timerAnimation != null)
|
{
|
_timerAnimation.Stop();
|
_timerAnimation.Dispose();
|
_timerAnimation = null;
|
|
OnStopAnimation.Invoke();
|
}
|
|
|
|
|
OnHide.Invoke();
|
|
//this.Hide();
|
|
}
|
|
public Action<DateTime, IStation.ViewModel.RealTimeData> OnRefreshAnimation = null;
|
public Action OnStopAnimation = null;
|
public Action OnStartAnimation = null;
|
|
List<IStation.ViewModel.RealTimeData> realTimeDataList;
|
public void SetRealTimeDataList(List<IStation.ViewModel.RealTimeData> list)
|
{
|
this.realTimeDataList = list;
|
}
|
|
private void trackBarControl1_EditValueChanged(object sender, EventArgs e)
|
{
|
if (_timerAnimation == null)
|
return;
|
_timerAnimation.Stop();
|
_timerAnimation.Interval = GetInterval();//执行间隔时间,单位为毫秒
|
_timerAnimation.Start();
|
}
|
public Action OnHide = null;
|
private void simpleButton关闭_Click(object sender, EventArgs e)
|
{
|
if (_timerAnimation != null)
|
_timerAnimation.Stop();
|
OnHide.Invoke();
|
}
|
public void StopAnimation()
|
{
|
if (_timerAnimation != null)
|
_timerAnimation.Stop();
|
}
|
private void AnimationTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
{
|
this._animationTime = this._animationTime.AddMinutes(_animationSpaceMinute);
|
|
if (this._animationTime >= this._endTime)
|
{
|
_timerAnimation.Stop();
|
_timerAnimation.Dispose();
|
_timerAnimation = null;
|
return;
|
}
|
if (this.IsHandleCreated)
|
{
|
this.Invoke(new Action(() =>
|
{
|
if (_timerAnimation == null)
|
return;
|
for (int i = this._animationMovePtIndx; i < this.realTimeDataList.Count; i++)
|
{
|
if (this.realTimeDataList[i].Time >= this._animationTime)
|
{
|
this._animationMovePtIndx = i;
|
var lastMovePt = realTimeDataList[_animationMovePtIndx];
|
|
this.OnRefreshAnimation(this._animationTime, lastMovePt);
|
UpdateData(this._animationTime, lastMovePt);
|
return;
|
}
|
|
}
|
|
}));
|
}
|
|
|
}
|
|
}
|
}
|