namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 监测点拓展
|
/// </summary>
|
public static class HydroMonitorExtensions
|
{
|
/// <summary>
|
/// 匹配
|
/// </summary>
|
public static HydroMonitorVmo Matching(this List<HydroMonitorVmo> allMonitorList, string propName, List<string> flags)
|
{
|
if (allMonitorList == null || allMonitorList.Count < 1)
|
{
|
return default;
|
}
|
var monitorList = allMonitorList.Where(x => x.PropName == propName).ToList();
|
monitorList = monitorList.OrderBy(x => x.Flags.Distinct().Count()).ToList();
|
return monitorList.Find(x => x.Flags.ContainsC(flags));
|
}
|
|
/// <summary>
|
/// 获取属性值
|
/// </summary>
|
public static double GetPropValue(this HydroMonitorVmo monitor, double propValue)
|
{
|
if (monitor == null)
|
{
|
return default;
|
}
|
double pv = 0;
|
switch (monitor.PropName)
|
{
|
case Yw.Hydro.MonitorProp.CalcuQ:
|
{
|
pv = Math.Round(propValue, 1);
|
}
|
break;
|
case Yw.Hydro.MonitorProp.CalcuP:
|
{
|
pv = Math.Round(propValue, 1);
|
}
|
break;
|
case Yw.Hydro.MonitorProp.CalcuE:
|
{
|
pv = Math.Round(propValue, 1);
|
}
|
break;
|
case Yw.Hydro.MonitorProp.CalcuPr:
|
{
|
pv = Math.Round(propValue, 2);
|
}
|
break;
|
case Yw.Hydro.MonitorProp.CalcuO:
|
{
|
pv = Math.Round(propValue, 0);
|
}
|
break;
|
case Yw.Hydro.MonitorProp.CalcuO1:
|
{
|
pv = Math.Round(propValue, 0);
|
}
|
break;
|
case Yw.Hydro.MonitorProp.CalcuO2:
|
{
|
pv = Math.Round(propValue, 0);
|
}
|
break;
|
default: pv = Math.Round(propValue, 2); break;
|
}
|
return pv;
|
}
|
|
/// <summary>
|
/// 获取属性值
|
/// </summary>
|
public static double? GetPropValue(this HydroMonitorVmo monitor, double? propValue)
|
{
|
if (monitor == null)
|
{
|
return default;
|
}
|
if (propValue == null)
|
{
|
return default;
|
}
|
return monitor.GetPropValue(propValue.Value);
|
}
|
|
|
}
|
}
|