コード例 #1
0
ファイル: WaterController.cs プロジェクト: trexug/trexwater
        public WateringSession TurnOff()
        {
            if (!IsOn)
            {
                throw new InvalidOperationException($"{nameof(WaterController)} is already off.");
            }
            Pin.Write(PIN_OFF);
            IsOn = false;
            Logger.LogTrace("Off written to bcm pin: '{0}'", Pin.BcmPin);
            DateTime now  = TimeProvider.Now;
            TimeSpan span = now - TurnedOnTime;

            Logger.LogTrace("Pin: '{0}' was on for {1:0.00} seconds", Pin.BcmPin, span.TotalSeconds);
            WateringSession session = new WateringSession(TurnedOnTime, now, span.TotalSeconds * LitersPerSecond);

            FlowOff?.Invoke(this, new WaterControllerOffEventArgs(session));
            return(session);
        }
コード例 #2
0
 public WaterControllerOffEventArgs(WateringSession session)
 {
     Session = session;
 }