using Application.VaporRecoveryOnlineWatchHubApp;
using Application.VaporRecoveryOnlineWatchHubApp.UnversalApiModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VaporRecoveryOnlineWatchHubApp.Config;
using static Application.VaporRecoveryOnlineWatchHubApp.App;
namespace VaporRecoveryOnlineWatchHubApp.UnversalApiModels
{
///
/// VR Board will watch on each nozzels, and for user side, they care about the nozzles, thus here bring in a logical vr nozzle concept.
///
public class VRBoardNozzle
{
public int SiteLevelNozzleId { get; set; }
//public int SiteLevelDispenserId { get; set; }
///
/// inidcates if this nozzle's vapor recovery facility works good or not.
/// this state is caculated from a period of time.
///
public VRBoardNozzleTrxHealthStateEnum HealthState { get; set; }
//public int PayableTrxes { get; set; }
//public double LastTrxVaporVolume { get; set; }
//public double LastTrxLiquidVolume { get; set; }
//public double LastTrxVaporLiquidRatio { get; set; }
public VRBoardNozzleTrxFlowData LatestTrxFlowData { get; set; }
//public bool StatusOk { get; set; }
public VRBoardNozzleFuelingStateEnum FuelingState { get; set; }
public string PerNozzleVRGroupQualificationDefinitionGroupName { get; set; }
public override string ToString()
{
return GetType().GetProperties().Aggregate(string.Empty,
(result, next) => result + $"{next.Name} : {(next.GetValue(this)?.ToString()) ?? string.Empty} ");
}
}
public enum VRBoardNozzleTrxHealthStateEnum
{
NORMAL,
WARNING,
ALARM,
NOT_SET
}
public enum VRBoardNozzleFuelingStateEnum
{
IDLE,
FUELING
}
//public class Nozzles
//{
// public List data { get; set; } = new List();
// public Nozzles Add(LogicalVRNozzle nozzle)
// {
// data.Add(nozzle);
// return this;
// }
// public static Nozzles Build(NozzleConfigs config)
// {
// var nozzleStatus = new Nozzles();
// config.data.ForEach( i =>
// nozzleStatus.Add(new LogicalVRNozzle
// {
// SiteLevelNozzleId = i.SiteLevelNozzleId,
// SiteLevelDispenserId = i.SiteLevelDispenserId,
// OverallVRState = i.DataCollectorDeviceId == 0 ? NozzleOverallVRStateEnum.NO_VR : NozzleOverallVRStateEnum.DISCONNETED,
// PayableTrxes = 0,
// VaporVolume = 0,
// LiquidVolume = 0,
// VaporLiquidRatio = 0,
// FuelingStatus = FuelingStatus.IDLE
// })
// );
// return nozzleStatus;
// }
// public LogicalVRNozzle GetNozzleById(int nozzleId)
// {
// return data.Where(i => i.SiteLevelNozzleId == nozzleId).FirstOrDefault();
// }
//}
//public static class NozzlesExtension
//{
// public static Nozzles Sort(this Nozzles self)
// {
// self.data = self.data.OrderBy(x => x.SiteLevelNozzleId).ToList();
// return self;
// }
// public static Nozzles Update(this Nozzles nozzles, LogicalVRNozzle nozzle)
// {
// nozzles.data.RemoveAll(i => i.SiteLevelNozzleId == nozzle.SiteLevelNozzleId);
// nozzles.Add(nozzle).Sort();
// return nozzles;
// }
// public static Nozzles UpdateVrState(this Nozzles nozzles, List siteLevelNozzleIdList, NozzleOverallVRStateEnum vRState)
// {
// nozzles.data.ForEach(i => {
// if (siteLevelNozzleIdList.Contains(i.SiteLevelNozzleId))
// {
// i.OverallVRState = vRState;
// }
// });
// return nozzles;
// }
//}
}