using IStation.Unit;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
namespace IStation.WinFrmUI.Monitor
|
{
|
public partial class WaterLevelAnalysisPage : DocumentPage
|
{
|
public WaterLevelAnalysisPage()
|
{
|
InitializeComponent();
|
this.PageTitle.Caption = "水位分析";
|
this.sceneTreeList1.FocusedChangedEvent += MonitorDataSourcesTreeList1_FocusedChangedEvent;
|
}
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public override void InitialDataSource()
|
{
|
this.timeValueEasyChartView1.InitialDefaultSeries(null);
|
this.sceneTreeList1.SetBindingData();
|
|
}
|
|
private Model.MonitorDataSources _scene = null;
|
private void MonitorDataSourcesTreeList1_FocusedChangedEvent(Model.MonitorDataSources obj)
|
{
|
_scene = obj;
|
}
|
private void barBtnAnalysis_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
Analysis(_scene);
|
}
|
|
private void Analysis(Model.MonitorDataSources scene)
|
{
|
|
this.chartControl1.Series[0].Points.Clear();
|
if (scene == null)
|
return;
|
var point陈行水库水位 = new BLL.MonitorPoint().GetAllExSignalWithSignalType()?.Find(x => x.Name == "陈行水库水位");
|
if (point陈行水库水位 == null)
|
return;
|
|
var bllData = new BLL.MonitorDataSet();
|
|
var packet = bllData.GetSignalRecordPacket(scene.ID, point陈行水库水位.MonitorPointID, point陈行水库水位.SignalID);
|
if (packet == null || packet.RecordList == null)
|
return;
|
var validList = packet.RecordList.Where(x => x.Value != IStation.Error.Default && x.Value != IStation.Error.Abnormal)
|
?.Select(x => new TimeValue(x.Time, x.Value)).ToList();
|
if (validList == null || validList == null)
|
return;
|
|
|
var WaterSums = new WaterLevelAnaly().Get(scene.ID);
|
var waterLevelDeviation = new List<TimeValue>();
|
TimeValue top = null;
|
TimeValue bottom = null;
|
WaterSum waterSum = null;
|
bool asc = false;
|
for (int i = 0; i < validList.Count(); i++)
|
{
|
if (i == 0)
|
{
|
var item = validList[i];
|
var next = validList[i + 1];
|
if (item.Value > next.Value)
|
{
|
asc = false;
|
top = item;
|
}
|
else
|
{
|
asc = true;
|
bottom = item;
|
}
|
continue;
|
}
|
|
if (i + 1 == validList.Count())
|
break;
|
|
|
var positiveLast = validList[i - 1];
|
var positiveItem = validList[i];
|
var positiveNext = validList[i + 1];
|
|
|
if (waterSum == null)
|
{
|
waterSum = WaterSums.Find(x => x.Year == positiveItem.Time.Year && x.Month == positiveItem.Time.Month);
|
}
|
if (waterSum.Year != positiveItem.Time.Year || waterSum.Month != positiveItem.Time.Month)
|
{
|
waterSum = WaterSums.Find(x => x.Year == positiveItem.Time.Year && x.Month == positiveItem.Time.Month);
|
}
|
|
if (positiveLast.Value < positiveItem.Value && positiveItem.Value > positiveNext.Value)
|
{
|
if (bottom == null)
|
{
|
asc = false;
|
}
|
top = positiveItem;
|
}
|
else if (positiveLast.Value > positiveItem.Value && positiveItem.Value < positiveNext.Value)
|
{
|
if (top == null)
|
{
|
asc = true;
|
}
|
bottom = positiveItem;
|
}
|
if (bottom != null && top != null)
|
{
|
bool calcu = false;
|
var topSum = waterSum.Records.Find(x => x.Time == top.Time);
|
var bottomSum = waterSum.Records.Find(x => x.Time == bottom.Time);
|
if (topSum != null && bottomSum != null)
|
{
|
calcu = true;
|
topSum.CalcuWater();
|
bottomSum.CalcuWater();
|
}
|
|
|
var vm = new TimeValue();
|
vm.Time = positiveItem.Time;
|
if (asc)
|
{
|
|
var ascValue = top.Value - bottom.Value;
|
vm.Value = ascValue;
|
|
if (calcu)
|
{
|
var area = Math.Abs((topSum.Water.Value - bottomSum.Water.Value)) / Math.Abs(ascValue);
|
if (area < 10000000)
|
{
|
this.chartControl1.Series[0].Points.Add(new DevExpress.XtraCharts.SeriesPoint(area, positiveItem.Value));
|
}
|
}
|
|
bottom = null;
|
asc = false;
|
}
|
else
|
{
|
var descValue = bottom.Value - top.Value;
|
vm.Value = descValue;
|
|
if (calcu)
|
{
|
var area = Math.Abs((bottomSum.Water.Value - topSum.Water.Value)) / Math.Abs(descValue);
|
if (area < 10000000)
|
{
|
this.chartControl1.Series[0].Points.Add(new DevExpress.XtraCharts.SeriesPoint(area, positiveItem.Value));
|
}
|
}
|
|
top = null;
|
asc = true;
|
|
}
|
waterLevelDeviation.Add(vm);
|
}
|
}
|
|
|
|
|
|
|
|
|
if (int.TryParse(point陈行水库水位.UnitValue, out int unitValue))
|
{
|
var dict = UnitHelper.GetEnUnitDict(point陈行水库水位.UnitType);
|
if (dict != null)
|
this.timeValueEasyChartView1.SetAxisYTitle(dict[unitValue]);
|
}
|
else
|
{
|
this.timeValueEasyChartView1.SetAxisYTitle(point陈行水库水位.UnitValue);
|
}
|
this.timeValueEasyChartView1.InitialDefaultSeries(waterLevelDeviation);
|
|
}
|
|
|
|
/*private BLL.MonitorDataSet bllData = new BLL.MonitorDataSet();
|
private List<Model.SignalRecord> GetSignalRecords(Model.MonitorPointExSignal monitor)
|
{
|
var data = bllData.GetSignalRecordPacket(monitor.MonitorPointID, monitor.SignalID)
|
.RecordList.Where(x => x.Value != IStation.Error.Default && x.Value != IStation.Error.Abnormal)?
|
.ToList();
|
|
return data;
|
}*/
|
|
|
|
}
|
}
|
|
|
/*
|
var ch1_1 = dataCh1.Find(x => x.Time == top.Time);
|
var ch2_1 = dataCh2.Find(x => x.Time == top.Time);
|
var ch3_1 = dataCh3.Find(x => x.Time == top.Time);
|
var ch4_1 = dataCh4.Find(x => x.Time == top.Time);
|
var ch5_1 = dataCh5.Find(x => x.Time == top.Time);
|
|
var jd1_1 = dataJd1.Find(x => x.Time == top.Time);
|
var jd2_1 = dataJd2.Find(x => x.Time == top.Time);
|
var jd3_1 = dataJd3.Find(x => x.Time == top.Time);
|
|
var dn24_1 = dataDn2400.Find(x => x.Time == top.Time);
|
var dn27_1 = dataDn2700.Find(x => x.Time == top.Time);
|
|
var ch1_2 = dataCh1.Find(x => x.Time == bottom.Time);
|
var ch2_2 = dataCh2.Find(x => x.Time == bottom.Time);
|
var ch3_2 = dataCh3.Find(x => x.Time == bottom.Time);
|
var ch4_2 = dataCh4.Find(x => x.Time == bottom.Time);
|
var ch5_2 = dataCh5.Find(x => x.Time == bottom.Time);
|
|
var jd1_2 = dataJd1.Find(x => x.Time == bottom.Time);
|
var jd2_2 = dataJd2.Find(x => x.Time == bottom.Time);
|
var jd3_2 = dataJd3.Find(x => x.Time == bottom.Time);
|
|
var dn24_2 = dataDn2400.Find(x => x.Time == bottom.Time);
|
var dn27_2 = dataDn2700.Find(x => x.Time == bottom.Time);
|
*/
|
/*var ch1累计流量 = new BLL.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongIDAndGroupID(belongType, belongId, 500865961361484)?.Find(x => x.Name == "累积流量");
|
var ch2累计流量 = new BLL.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongIDAndGroupID(belongType, belongId, 500865961361497)?.Find(x => x.Name == "累积流量");
|
var ch3累计流量 = new BLL.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongIDAndGroupID(belongType, belongId, 500865961361510)?.Find(x => x.Name == "累积流量");
|
var ch4累计流量 = new BLL.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongIDAndGroupID(belongType, belongId, 500865961361523)?.Find(x => x.Name == "累积流量");
|
var ch5累计流量 = new BLL.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongIDAndGroupID(belongType, belongId, 500865961365573)?.Find(x => x.Name == "累积流量");
|
|
var point嘉定1线累计流量 = new BLL.MonitorPoint().GetAllExSignalWithSignalType()?.Find(x => x.Name == "嘉定1线累计流量");
|
var point嘉定2线累计流量 = new BLL.MonitorPoint().GetAllExSignalWithSignalType()?.Find(x => x.Name == "嘉定2线累计流量");
|
var point嘉定3线累计流量 = new BLL.MonitorPoint().GetAllExSignalWithSignalType()?.Find(x => x.Name == "嘉定3线累计流量");
|
|
var point2400总管累计流量 = new BLL.MonitorPoint().GetAllExSignalWithSignalType()?.Find(x => x.Name == "2400总管累计流量");
|
var point2700总管累计流量 = new BLL.MonitorPoint().GetAllExSignalWithSignalType()?.Find(x => x.Name == "2700总管累计流量");
|
|
var dataCh1 = GetSignalRecords(ch1累计流量);
|
var dataCh2 = GetSignalRecords(ch2累计流量);
|
var dataCh3 = GetSignalRecords(ch3累计流量);
|
var dataCh4 = GetSignalRecords(ch4累计流量);
|
var dataCh5 = GetSignalRecords(ch5累计流量);
|
|
var dataJd1 = GetSignalRecords(point嘉定1线累计流量);
|
var dataJd2 = GetSignalRecords(point嘉定2线累计流量);
|
var dataJd3 = GetSignalRecords(point嘉定3线累计流量);
|
var dataDn2400 = GetSignalRecords(point2400总管累计流量);
|
var dataDn2700 = GetSignalRecords(point2700总管累计流量);*/
|
|
|
/*
|
for (int i = 0; i < validList.Count(); i++)
|
{
|
if (i == 0)
|
continue;
|
if (i + 1 == validList.Count())
|
break;
|
|
var positiveLast = validList[i - 1];
|
var positiveItem = validList[i];
|
var positiveNext = validList[i + 1];
|
|
if (positiveLast.Value < positiveItem.Value && positiveItem.Value > positiveNext.Value)
|
{
|
if (bottom == null)
|
{
|
asc = false;
|
}
|
top = positiveItem;
|
|
*//* for (int j = i - 1; j > 0; j--)
|
{
|
var negativeLast = validList[j];
|
if (negativeLast.Value > positiveItem.Value)
|
{
|
var a = negativeLast.Value - positiveItem.Value;
|
break;
|
}
|
}
|
_allBindList.Add(new TimeValue(positiveItem.Time, positiveItem.Value));*//*
|
}
|
else if (positiveLast.Value > positiveItem.Value && positiveItem.Value < positiveNext.Value)
|
{
|
if (top == null)
|
{
|
asc = true;
|
}
|
bottom = positiveItem;
|
}
|
if (bottom != null && bottom != null)
|
{
|
if (asc)
|
{
|
var ascValue = top.Value - bottom.Value;
|
bottom = null;
|
}
|
else
|
{
|
var descValue = bottom.Value - top.Value;
|
top = null;
|
}
|
}
|
}*/
|