public string GetEquipColor() { ArdMgr ardMgr = new ArdMgr(_hostEnv, _config, _userManager); ArdRecord ar = ardMgr.GetLast(); PropaneMgr pmgr = new PropaneMgr(_hostEnv, _config, _userManager); PropaneLevel pl = pmgr.GetTUTank(); return(CSSettings.GetColor(CSSettings.GetCSSettings().ActiveEquip, "All", ar, pl, false)); }
public EquipModel(CStat.Models.CStatContext context, IWebHostEnvironment hostEnv, IConfiguration config, UserManager <CStatUser> userManager) { _context = context; _hostEnv = hostEnv; _ardMgr = new ArdMgr(_hostEnv, _config, userManager); _config = config; Settings = CSSettings.GetCSSettings(_config, userManager); PropaneMgr pmgr = new PropaneMgr(_hostEnv, _config, userManager); _ar = _ardMgr.GetLast(); if (_ar == null) { _ar = new ArdRecord(PropMgr.NotSet, PropMgr.NotSet, PropMgr.NotSet, 0, PropMgr.ESTNow); } _pl = pmgr.GetTUTank(); if (_pl == null) { _pl = new PropaneLevel(0, PropMgr.ESTNow, PropMgr.NotSet); } ActiveEqHistory = new List <List <double> >(); int NumActive = Settings.ActiveEquip.Count; if (NumActive > 0) { List <ArdRecord> ardHist = _ardMgr.GetAll(); if (ardHist == null) { ardHist = new List <ArdRecord>(); } List <PropaneLevel> propaneHist = pmgr.GetAll(30); if (propaneHist == null) { propaneHist = new List <PropaneLevel>(); } // Ensure latest is at end of list int ahCount = ardHist.Count; if (ahCount > 0) { if (ardHist[ahCount - 1].TimeStamp != _ar.TimeStamp) { if (ardHist[ahCount - 2].TimeStamp == _ar.TimeStamp) { _ar = _ardMgr.GetLast(); // get latest } else { ardHist.Add(_ar); // set latest if (ahCount >= ArdMgr.MAX_USE_ARS) { ardHist.RemoveAt(0); } } } } int plCount = propaneHist.Count; if (plCount > 0) { if (propaneHist[plCount - 1].ReadingTime != _pl.ReadingTime) { if (propaneHist[plCount - 2].ReadingTime == _pl.ReadingTime) { _pl = pmgr.GetTUTank(); // get latest } else { propaneHist.Add(_pl); // set latest if (plCount >= PropaneMgr.MAX_USE_PLS) { propaneHist.RemoveAt(0); } } } } foreach (var ar in Settings.ActiveEquip) { List <double> dlist; dlist = ar.PropName switch { "freezerTemp" => ardHist.Select(a => a.FreezerTempF).Reverse().ToList(), "frigTemp" => ardHist.Select(a => a.FridgeTempF).Reverse().ToList(), "kitchTemp" => ardHist.Select(a => a.KitchTempF).Reverse().ToList(), "propaneTank" => propaneHist.Select(p => p.LevelPct).Reverse().ToList(), "waterPres" => ardHist.Select(a => a.WaterPress).Reverse().ToList(), _ => new List <double>() }; ActiveEqHistory.Add(dlist); } } }