using Yw.Hydro;
|
|
namespace HStation.WinFrmUI
|
{
|
/// <summary>
|
/// 监测值辅助类
|
/// </summary>
|
public class SimulationMonitorValueHelper
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public SimulationMonitorValueHelper
|
(
|
SimulationVisualListHelper visualListHelper,
|
SimulationMonitorHelper monitorHelper,
|
SimulationCalcuResultHelper calcuResultHelper
|
)
|
{
|
_visualListHelper = visualListHelper;
|
_monitorHelper = monitorHelper;
|
_calcuResultHelper = calcuResultHelper;
|
_calcuResultHelper.InitialEvent += async () => await Update();
|
}
|
|
private readonly SimulationVisualListHelper _visualListHelper = null;//可见列表辅助类
|
private readonly SimulationMonitorHelper _monitorHelper = null;//监测点辅助类
|
private readonly SimulationCalcuResultHelper _calcuResultHelper = null;//计算结果辅助类
|
private List<HydroMonitorValueViewModel> _allList = null;//所有监测值列表
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
public async Task<List<HydroMonitorValueViewModel>> GetAll()
|
{
|
if (_allList == null)
|
{
|
_allList = new List<HydroMonitorValueViewModel>();
|
var allVisualDict = _visualListHelper.GetVisualDict();
|
if (allVisualDict != null && allVisualDict.Count > 0)
|
{
|
var allMonitorList = await _monitorHelper.GetAll();
|
if (allMonitorList != null && allMonitorList.Count > 0)
|
{
|
foreach (var monitor in allMonitorList)
|
{
|
if (allVisualDict.ContainsKey(monitor.Parter))
|
{
|
var visual = allVisualDict[monitor.Parter];
|
double? propValue = null;
|
var calcuVisualResult = _calcuResultHelper.GetVisual(monitor.Parter);
|
if (calcuVisualResult != null)
|
{
|
propValue = calcuVisualResult.GetCalcuValue(monitor.PropName);
|
}
|
var vm = new HydroMonitorValueViewModel(monitor, visual, propValue);
|
_allList.Add(vm);
|
}
|
}
|
}
|
}
|
}
|
return _allList;
|
}
|
|
/// <summary>
|
/// 获取对接列表
|
/// </summary>
|
public async Task<List<HydroMonitorValueViewModel>> GetDockingList()
|
{
|
var all = await GetAll();
|
return all.Where(x => x.Vmo.SourceType == eSourceType.Docking).ToList();
|
}
|
|
/// <summary>
|
/// 获取分析列表
|
/// </summary>
|
public async Task<List<HydroMonitorValueViewModel>> GetAnalyseList()
|
{
|
var all = await GetAll();
|
return all.Where(x => x.Vmo.SourceType == eSourceType.Analyse).ToList();
|
}
|
|
/// <summary>
|
/// 更新
|
/// </summary>
|
public async Task Update()
|
{
|
var all = await GetAll();
|
foreach (var item in all)
|
{
|
if (!item.PropValue.HasValue)
|
{
|
var calcuVisualResult = _calcuResultHelper.GetVisual(item.Vmo.Parter);
|
if (calcuVisualResult != null)
|
{
|
var propValue = calcuVisualResult.GetCalcuValue(item.Vmo.PropName);
|
if (propValue.HasValue)
|
{
|
item.PropValue = item.Vmo.GetPropValue(propValue.Value);
|
}
|
}
|
}
|
}
|
}
|
|
/// <summary>
|
/// 更新
|
/// </summary>
|
public async Task Update(string code, eSourceType sourceType, List<HydroMonitorValueViewModel> valueList)
|
{
|
var all = await GetAll();
|
all.RemoveAll(x => x.Vmo.Parter == code && x.Vmo.SourceType == sourceType);
|
if (valueList != null && valueList.Count > 0)
|
{
|
all.AddRange(valueList);
|
}
|
}
|
|
/// <summary>
|
/// 重置
|
/// </summary>
|
public async Task Reset(List<HydroWorkingMonitorViewModel> allWorkingMonitorList)
|
{
|
var all = await GetAll();
|
all.UpdateMonitorValue(allWorkingMonitorList);
|
}
|
|
/// <summary>
|
/// 重置
|
/// </summary>
|
public async void Reset(string monitorInfo)
|
{
|
var allMonitorValueList = await GetAll();
|
allMonitorValueList.UpdateMonitorValue(monitorInfo);
|
}
|
|
|
}
|
}
|