tangxu
2024-03-26 edd23f115dba31d764fdaf75a6207d888d0419d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
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;
                        }
 
                    }
 
                }));
            }
 
 
        }
 
    }
}