|
@@ -57,6 +57,8 @@ namespace SCADA_DAQ.Customer
|
|
|
|
|
|
private PoweMeterReuslt poweMeterReuslt { get; set; }
|
|
|
|
|
|
+ private System.Timers.Timer _timer = new System.Timers.Timer();
|
|
|
+
|
|
|
public DateTime StartTime { get; set; }
|
|
|
|
|
|
private bool PumpIsRun = false;
|
|
@@ -67,12 +69,17 @@ namespace SCADA_DAQ.Customer
|
|
|
|
|
|
private double CurrentFlow { get; set; }
|
|
|
|
|
|
+ public int SpeedIndex = 0;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// /
|
|
|
/// </summary>
|
|
|
public UctFrmMain()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ //_timer.Interval = 1000;
|
|
|
+
|
|
|
+ //_timer.Elapsed += _timer_Elapsed;
|
|
|
ToolBar.Visibility = Visibility.Collapsed;
|
|
|
DataToExcel.Columns.Add("Time", typeof(DateTime));
|
|
|
DataToExcel.Columns.Add("Index");
|
|
@@ -91,8 +98,9 @@ namespace SCADA_DAQ.Customer
|
|
|
DataToExcel.Columns.Add("Pressure3");
|
|
|
DataToExcel.Columns.Add("Power");
|
|
|
DataToExcel.Columns.Add("FlowRate");
|
|
|
- DataToExcel.Columns.Add("RPM");
|
|
|
+ DataToExcel.Columns.Add("FlowSpeed");
|
|
|
DataToExcel.Columns.Add("Pump");
|
|
|
+
|
|
|
CustomerEnv.DaqSettingValue.PropertyChanged += DaqSettingValue_PropertyChanged;
|
|
|
DaqInfo.StartCtrl = new Action(() =>
|
|
|
{
|
|
@@ -101,27 +109,28 @@ namespace SCADA_DAQ.Customer
|
|
|
MsChart1.ClearDatas();
|
|
|
MsChart2.ClearDatas();
|
|
|
ClearFlowToPlc();
|
|
|
+ _timer.Start();
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
Check.IsEnabled = false;
|
|
|
|
|
|
});
|
|
|
//MsChart.mainChart.ChartAreas[0].AxisX.po
|
|
|
- StartFlag = true;
|
|
|
+ StartFlag = true;
|
|
|
var startTime = DateTime.Now;
|
|
|
double index = 0d;
|
|
|
while (StartFlag)
|
|
|
{
|
|
|
if ((DateTime.Now - startTime).TotalSeconds >= CustomerEnv.DaqSettingValue.TimeOut)
|
|
|
{
|
|
|
- StartFlag = false;
|
|
|
- ExportToExcel();
|
|
|
- DataToExcel.Rows.Clear();
|
|
|
+
|
|
|
+ Stop();
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
DaqInfo.StopBtn.IsEnabled = false;
|
|
|
DaqInfo.StartBtn.IsEnabled = true;
|
|
|
});
|
|
|
+
|
|
|
MessageBox.Show("采样时间已超出设定的超时时间,采样已结束!");
|
|
|
}
|
|
|
else
|
|
@@ -136,19 +145,42 @@ namespace SCADA_DAQ.Customer
|
|
|
|
|
|
DaqInfo.EndCtrl = new Action(() =>
|
|
|
{
|
|
|
-
|
|
|
+ Stop();
|
|
|
+ });
|
|
|
+ plc3.BaseDevice.RegReadValueChanged += BaseDevice_RegReadValueChanged;
|
|
|
+ //Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Stop()
|
|
|
+ {
|
|
|
+ //_timer.Stop();
|
|
|
+ SpeedIndex = 0;
|
|
|
+ StartFlag = false;
|
|
|
+ ExportToExcel();
|
|
|
+ DataToExcel.Rows.Clear();
|
|
|
+ CurrentFlow = 0;
|
|
|
+ FlowRate = 0;
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ Check.IsEnabled = true;
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
|
|
+ {
|
|
|
+ if (StartFlag == true && Check.TypeChecks2[3] == true)
|
|
|
+ {
|
|
|
+ var value = plc3.GetListenReg("D20").ScaleValue.Value;
|
|
|
+ FlowRate = value - CurrentFlow;
|
|
|
+ SpeedIndex++;
|
|
|
+ CurrentFlow = value;
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
- Check.IsEnabled = true;
|
|
|
-
|
|
|
+ MsChart2.mainChart.Series[4].Points.AddXY(SpeedIndex, FlowRate);
|
|
|
+ DataToExcel.Rows[DataToExcel.Rows.Count - 1][17] = FlowRate;
|
|
|
});
|
|
|
- StartFlag = false;
|
|
|
- FlowRate = 0;
|
|
|
- ExportToExcel();
|
|
|
- DataToExcel.Rows.Clear();
|
|
|
- });
|
|
|
- plc3.BaseDevice.RegReadValueChanged += BaseDevice_RegReadValueChanged;
|
|
|
- Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
|
|
@@ -159,7 +191,13 @@ namespace SCADA_DAQ.Customer
|
|
|
{
|
|
|
var value = plc3.GetListenReg("D20").ScaleValue.Value;
|
|
|
FlowRate = value - CurrentFlow;
|
|
|
+ SpeedIndex++;
|
|
|
CurrentFlow = value;
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ MsChart2.mainChart.Series[4].Points.AddXY(SpeedIndex, FlowRate);
|
|
|
+ DataToExcel.Rows[DataToExcel.Rows.Count - 1][17] = FlowRate;
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -251,7 +289,6 @@ namespace SCADA_DAQ.Customer
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- var a = DateTime.Now - starttime;
|
|
|
|
|
|
for (int i = 0; i < MsChart2.mainChart.Series.Count - 2; i++)
|
|
|
{
|
|
@@ -279,14 +316,28 @@ namespace SCADA_DAQ.Customer
|
|
|
|
|
|
rowValue[i + 2 + MsChart1.mainChart.Series.Count] = value;
|
|
|
}
|
|
|
+ var speedIndex =Math.Round( index,0) % 1.0d;
|
|
|
+
|
|
|
if (Check.TypeChecks2[3] == true)
|
|
|
{
|
|
|
var value = Math.Round(plc3.GetListenReg("D20").ScaleValue.Value, 1);
|
|
|
rowValue[16] = value;
|
|
|
+ rowValue[17] = 0;
|
|
|
+
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
MsChart2.mainChart.Series[3].Points.AddXY(Math.Round(index, 1), value);
|
|
|
- MsChart2.mainChart.Series[4].Points.AddXY(Math.Round(index, 1), FlowRate);
|
|
|
+ if (speedIndex == 0 && index != 0)
|
|
|
+ {
|
|
|
+ var Plcvalue = plc3.GetListenReg("D20").ScaleValue.Value;
|
|
|
+ FlowRate = Plcvalue - CurrentFlow;
|
|
|
+ SpeedIndex++;
|
|
|
+ CurrentFlow = Plcvalue;
|
|
|
+ MsChart2.mainChart.Series[4].Points.AddXY(index, FlowRate);
|
|
|
+
|
|
|
+ DataToExcel.Rows[DataToExcel.Rows.Count - 1][17] = FlowRate;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
});
|
|
|
}
|
|
@@ -312,7 +363,6 @@ namespace SCADA_DAQ.Customer
|
|
|
MsChart2.mainChart.ChartAreas[0].AxisX.ScaleView.Position = 0;
|
|
|
}
|
|
|
});
|
|
|
- rowValue[16] = 0;
|
|
|
rowValue[0] = DateTime.Now.Format();
|
|
|
rowValue[1] = index;
|
|
|
|
|
@@ -447,7 +497,11 @@ namespace SCADA_DAQ.Customer
|
|
|
protected override void CloseThis()
|
|
|
{
|
|
|
base.CloseThis();
|
|
|
+ //_timer.Stop();
|
|
|
+ //_timer.Dispose();
|
|
|
+ Env.Schedual.DateTimeChanged -= Schedual_DateTimeChanged;
|
|
|
StartFlag = false;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|