public async Task StartPump(PumpType pump, int secondsToRun) { try { semaphore.Wait(); if (status.CanStart(pump)) { if (pump == PumpType.Well) { status.PumpWell.Start(secondsToRun); } if (pump == PumpType.Retention) { status.PumpRetention.Start(secondsToRun); } await mqttProvider.SendIrrigationStatus(status); } await SendStatusToAllClients(); } finally { semaphore.Release(); } }
public static PumpType FindPumpTypeById(int id) { ISession session = ThreadLocalSession.CurrentSession(); PumpType pt = (PumpType)session.Load(typeof(PumpType), id); ThreadLocalSession.CloseCurrentSession(); return(pt); }
public bool CanStart(PumpType pump) // valves belongs to particular pump { if (pump == PumpType.Well) { return(IrrigationValveNW || IrrigationValveNE || IrrigationValveW || IrrigationValveSW || IrrigationValveSE); } if (pump == PumpType.Retention) { return(IrrigationValveN); } return(false); }
public static PumpType FindPumpTypeByName(string pumpType) { ISession session = ThreadLocalSession.CurrentSession(); ICriteria cri_Pt = session.CreateCriteria(typeof(PumpType)); cri_Pt.Add(Expression.Eq("TypeName", pumpType)); IList list = cri_Pt.List(); PumpType ft = (PumpType)list[0]; ThreadLocalSession.CloseCurrentSession(); return(ft); }
public static void DeletePumpType(PumpType pt) { ISession session = ThreadLocalSession.CurrentSession(); ITransaction tx = session.BeginTransaction(); try { session.Delete(pt); tx.Commit(); } catch (HibernateException ex) { tx.Rollback(); } ThreadLocalSession.CloseCurrentSession(); }
public Pump(PumpType type) { Type = type; }