using DevExpress.XtraEditors;
|
using IStation.Unit;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
namespace IStation.WinFrmUI.Monitor
|
{
|
public partial class DataScreeningPage : DocumentPage
|
{
|
public DataScreeningPage()
|
{
|
InitializeComponent();
|
PageTitle.Caption = "数据筛选";
|
monitorDataSourcesTreeList.FocusedChangedEvent += MonitorDataSourcesTreeList1_FocusedChangedEvent;
|
monitorPointTreeList1.FocusedChangedEvent += MonitorPointTreeList1_FocusedChangedEvent;
|
timeValueEasyChartView1.BoxSelCompleteEvent += TimeValueEasyChartView1_BoxSelCompleteEvent;
|
}
|
|
|
private Model.MonitorDataSources _dataSource = null;
|
private Model.MonitorPointExSignalWithSignalType _model = null;
|
private BLL.MonitorDataSet _bll = new BLL.MonitorDataSet();
|
private List<TimeValue> _allBindList = null;
|
private const string delete = "delete";
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public override void InitialDataSource()
|
{
|
_allBindList = new List<TimeValue>();
|
timeValueEasyChartView1.InitialDefaultSeries(_allBindList);
|
timeValueEasyChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute);
|
monitorDataSourcesTreeList.SetBindingData();
|
monitorPointTreeList1.SetBindingData();
|
}
|
|
private void MonitorDataSourcesTreeList1_FocusedChangedEvent(Model.MonitorDataSources obj)
|
{
|
SetBindingData(obj, _model);
|
}
|
|
private void MonitorPointTreeList1_FocusedChangedEvent(Model.MonitorPointExSignalWithSignalType obj)
|
{
|
SetBindingData(_dataSource, obj);
|
}
|
|
private void SetBindingData(Model.MonitorDataSources scene, Model.MonitorPointExSignalWithSignalType obj)
|
{
|
_dataSource = scene;
|
_model = obj;
|
_allBindList = new List<TimeValue>();
|
if (_dataSource == null || _model == null)
|
{
|
timeValueEasyChartView1.SetAxisYTitle("?");
|
timeValueEasyChartView1.InitialDefaultSeries(null);
|
}
|
else
|
{
|
|
if (int.TryParse(_model.UnitValue, out int unitValue))
|
{
|
var dict = UnitHelper.GetEnUnitDict(_model.UnitType);
|
if (dict != null)
|
timeValueEasyChartView1.SetAxisYTitle(dict[unitValue]);
|
}
|
else
|
{
|
timeValueEasyChartView1.SetAxisYTitle(_model.UnitValue);
|
}
|
var packet = _bll.GetSignalRecordPacket(_dataSource.ID, _model.MonitorPointID, _model.SignalID);
|
if (packet != null && packet.RecordList != null)
|
{
|
var validList = packet.RecordList.Where(x => x.Value != IStation.Error.Default && x.Value != IStation.Error.Abnormal);
|
if (validList != null && validList.Any())
|
{
|
_allBindList = validList.Select(x => new TimeValue(x.Time, x.Value)).ToList();
|
}
|
}
|
}
|
|
timeValueEasyChartView1.InitialDefaultSeries(_allBindList);
|
}
|
|
private void TimeValueEasyChartView1_BoxSelCompleteEvent(string tag, List<TimeValue> timeValues)
|
{
|
if (timeValues == null || timeValues.Count < 1)
|
return;
|
var times = timeValues.Select(x => x.Time);
|
switch (tag)
|
{
|
case delete:
|
{
|
Delete(times);
|
}
|
break;
|
default:
|
break;
|
}
|
}
|
|
|
|
//删除
|
private void Delete(IEnumerable<DateTime> times)
|
{
|
if (_dataSource == null)
|
return;
|
WaitFrmHelper.ShowWaitForm("正在删除...");
|
if (times == null || times.Count() < 1)
|
{
|
XtraMessageBox.Show("无数据!");
|
return;
|
}
|
var bol = new BLL.MonitorDataSet().SetAbnormal(_dataSource.ID, _model.MonitorPointID, _model.SignalID, times, IStation.Error.Default);
|
if (!bol)
|
{
|
XtraMessageBox.Show("删除失败!");
|
return;
|
}
|
for (int i = 0; i < _allBindList.Count; i++)
|
{
|
var point = _allBindList[i];
|
if (times.Contains(point.Time))
|
{
|
_allBindList.RemoveAt(i);
|
i--;
|
}
|
}
|
timeValueEasyChartView1.InitialDefaultSeries(_allBindList);
|
WaitFrmHelper.HideWaitForm();
|
XtraMessageBox.Show("删除成功!");
|
}
|
|
|
//框选删除
|
public void Delete()
|
{
|
timeValueEasyChartView1.StartBoxSel(delete);
|
}
|
|
//区间删除
|
public void RangeDelete()
|
{
|
var dlg = new SetRangeDlg();
|
if (dlg.ShowDialog() != DialogResult.OK)
|
return;
|
var times = _allBindList?.Where(x => x.Value >= dlg.MinValue && x.Value <= dlg.MaxValue).Select(x => x.Time).ToList();
|
if (times == null || times.Count < 1)
|
{
|
XtraMessageBox.Show("未检索到区间值!");
|
return;
|
}
|
Delete(times);
|
}
|
|
//清除负值
|
public void ClearNegativeValues()
|
{
|
if (XtraMessageBox.Show("确认清除所有负值吗?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
return;
|
var times = _allBindList?.Where(x => x.Value < 0).Select(x => x.Time).ToList();
|
if (times == null || times.Count < 1)
|
{
|
XtraMessageBox.Show("未检索到负值!");
|
return;
|
}
|
Delete(times);
|
}
|
|
//清除零值
|
public void ClearZer0()
|
{
|
if (XtraMessageBox.Show("确认清除所有负值吗?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
return;
|
var times = _allBindList?.Where(x => x.Value == 0).Select(x => x.Time).ToList();
|
if (times == null || times.Count < 1)
|
{
|
XtraMessageBox.Show("未检索到零值!");
|
return;
|
}
|
Delete(times);
|
}
|
|
// 刷新数据
|
private void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var t = _allBindList?.OrderBy(x => x.Value).LastOrDefault();
|
if (t != null)
|
{
|
XtraMessageBox.Show($"{t.Time}:{t.Value:N3}米");
|
return;
|
}
|
InitialDataSource();
|
}
|
|
|
|
//修正运行状态
|
private void barBtnCorrectRunStatus_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_model == null)
|
{
|
return;
|
}
|
if (_model.SignalType != IStation.SignalType.运行状态)
|
{
|
XtraMessageBox.Show("请选择运行状态测点!");
|
return;
|
}
|
|
var monitor_points = new BLL.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongIDAndGroupID
|
(_model.BelongType, _model.BelongID, _model.GroupID);
|
var rpm_mp = monitor_points?.Find(x => x.SignalType == IStation.SignalType.转速);
|
if (rpm_mp == null)
|
{
|
XtraMessageBox.Show("不存在转速测点!");
|
return;
|
}
|
|
var rpm_packet_list = _bll.GetMonitorDataSet(_dataSource.ID, rpm_mp.MonitorPointID);
|
if (rpm_packet_list == null || !rpm_packet_list.Any())
|
{
|
XtraMessageBox.Show("不存在转速数据!");
|
return;
|
}
|
var bol = _bll.Clear(_dataSource.ID, _model.MonitorPointID, _model.SignalID);
|
if (!bol)
|
{
|
XtraMessageBox.Show("运行状态数据清空失败!");
|
return;
|
}
|
foreach (var rpm_packet in rpm_packet_list)
|
{
|
var rpm_record_list = rpm_packet.PacketList
|
.SelectMany(x => x.RecordList).ToList();
|
var rpm_run_status_record_list = rpm_record_list.Select(x => new Model.SignalRecord(x.Time, x.Value > 10 ? 1 : 0))
|
.ToList();
|
_bll.Save(_dataSource.ID, _model.MonitorPointID, _model.SignalID, rpm_run_status_record_list, rpm_packet.Year, rpm_packet.Month);
|
}
|
|
|
}
|
|
private void barBtnQueryMinAndMaxRpmFlow_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (_model == null)
|
{
|
return;
|
}
|
|
if (_model.SignalType != IStation.SignalType.转速)
|
{
|
XtraMessageBox.Show("请选择转速测点!");
|
return;
|
}
|
var rpm_packet_list = _bll.GetMonitorDataSet(_dataSource.ID, _model.MonitorPointID);
|
if (rpm_packet_list == null || !rpm_packet_list.Any())
|
{
|
XtraMessageBox.Show("不存在转速数据!");
|
return;
|
}
|
|
var monitor_points = new BLL.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongIDAndGroupID
|
(_model.BelongType, _model.BelongID, _model.GroupID);
|
var pressure_mp = monitor_points?.Find(x => x.SignalType == IStation.SignalType.出口压力);
|
if (pressure_mp == null)
|
{
|
XtraMessageBox.Show("不存在压力测点!");
|
return;
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
}
|