using Yw;
|
using Yw.WinFrmUI;
|
|
namespace IBox.WinFrmUI
|
{
|
public partial class IBoxFormOverview : DocumentPage
|
{
|
|
//private string startCode = "[&start&]";
|
//private string endCode = "[&end&]";
|
//private string paramCode = "[¶m&]";
|
//private string getbaseCode = "getbase";
|
//private string getrealrecordCode = "getrealrecord";
|
//private string gethistoryrecordCode = "gethistoryrecord";
|
//private string getalarmbydayCode = "getalarmbyday";
|
//private string getbysignalidofdayrangeCode = "getbysignalidofdayrange";
|
|
//Stopwatch sw = new Stopwatch();
|
//string swstr=string.Empty;
|
private List<MonitorValueAlarmRecord> monitorValueAlarmRecords = new List<MonitorValueAlarmRecord>();
|
|
private List<DataGridMonitorViewModel> dataGridMonitorViewModels = new List<DataGridMonitorViewModel>();
|
private List<PumpRunStatusViewModel> pumpRunStatusModels = new List<PumpRunStatusViewModel>();
|
private List<PumpEnergyViewModel> pumpEnergyViewModels = new List<PumpEnergyViewModel>();
|
|
public IBoxFormOverview()
|
{
|
this.PageTitle.Caption = "泵组总览";
|
InitializeComponent();
|
|
}
|
|
|
private void EboxForm_Load(object sender, EventArgs e)
|
{
|
Thread.Sleep(500);
|
SendText(IBoxHelper.startCode + IBoxHelper.getbaseCode + IBoxHelper.paramCode + IBoxHelper.endCode);
|
|
}
|
|
private List<DataGridMonitorViewModel> dataList = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
/// <param name="list"></param>
|
/// <param name="isBlue"></param>
|
/// <returns></returns>
|
public async Task<int> BindGrid(List<StationMonitorListGroupMobileDto> list, bool isBlue = true)
|
{
|
dataList = new List<DataGridMonitorViewModel>();
|
foreach (var item in list)
|
{
|
foreach (var ml in item.MonitorList)
|
{
|
dataList.Add(new DataGridMonitorViewModel()
|
{
|
DataTime = !ml.DataTime.HasValue ? "-" : ml.DataTime?.ToString("yyyy-MM-dd HH:mm:ss"),
|
DataValue = string.IsNullOrEmpty(ml.DataValue) ? "-" : ml.DataValue,
|
GroupID = item.ID,
|
GroupName = item.Name,
|
MonitorName = ml.Name,
|
SignalID = ml.SignalID,
|
UnitName = ml.UnitName,
|
DataStatus = ml.DataStatus,
|
});
|
}
|
}
|
|
if (isBlue)
|
{
|
this.Invoke(new Action(() =>
|
{
|
dataGridMonitorViewModels = dataList;
|
this.bindingSource1.DataSource = dataGridMonitorViewModels;
|
}));
|
}
|
else
|
{
|
dataGridMonitorViewModels = dataList;
|
this.bindingSource1.DataSource = dataGridMonitorViewModels;
|
}
|
|
return 0;
|
}
|
|
|
private void gridView3_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
|
{
|
var b = gridView3.GetRow(e.RowHandle) as PumpRunStatusViewModel;
|
|
if (e.Column.FieldName.Equals("ContinutRunTime"))
|
{
|
e.DisplayText = ConvertToText(b.ContinutRunTime);
|
}
|
if (e.Column.FieldName.Equals("TotalRunTime"))
|
{
|
e.DisplayText = ConvertToText(b.TotalRunTime);
|
}
|
if (e.Column.FieldName.Equals("RunStatus"))
|
{
|
var s = "关机";
|
e.Appearance.ForeColor = Color.LightSlateGray;
|
switch (b.RunStatus)
|
{
|
case 1:
|
s = "开机";
|
e.Appearance.ForeColor = Color.Green;
|
break;
|
}
|
e.DisplayText = s;
|
}
|
}
|
|
private string ConvertToText(long? minite)
|
{
|
if (!minite.HasValue)
|
return "";
|
long minites = minite.Value;
|
long days = minites / 60 / 24;
|
long hours = 0;
|
if (days > 0)
|
hours = (minites - (days * 1440)) / 60;
|
else hours = minites / 60;
|
long minitesLeft = minites % 60;
|
if (days > 0)
|
return $"{days}天{hours}小时{minitesLeft}分钟";
|
else return $"{hours}小时{minitesLeft}分钟";
|
}
|
|
public event EventHandler<string> SendData;
|
private void SendText(string content)
|
{
|
//BluetoothHelper.GetInstance().SendData(content);
|
SendData?.Invoke(null, content);
|
}
|
}
|
}
|