/// <summary>
        /// Throws a FlowFailedException if cylinder is detected as going empty
        /// during the purge.
        /// </summary>
        /// <param name="airEndPoint"></param>
        private void CheckAir(GasEndPoint airEndPoint)
        {
            if (Pump.GetOpenValvePosition() > 0)
            {
                return;
            }

            // For now, we don't bother checking fresh air to be 'empty'.
            // If we did check fresh air, then the port would get marked as 'empty'
            // in the database, and there's currently no way to reset it back to
            // Full except to reboot the docking station.
            //
            // If/when we have mechanism to allow an 'Empty' fresh air port to
            // be 'reset' back to Full, then we should remove this check for IsFreshAir.
            //
            // SEE ALSO: The IsFreshAir check in Pump.CheckFlow's loop.
            //
            // - JMP, 6/30/2011
            if (airEndPoint.Cylinder.IsFreshAir)
            {
                return;
            }

            throw new FlowFailedException(airEndPoint);   // empty
        }
예제 #2
0
        /// <summary>
        /// Monitors the flow rate and adjustes voltage to pump as necessary in
        /// order to maintain desired flowrate.
        /// </summary>
        protected override void Run()
        {
            try
            {
                if (!Pump.IsRunning())
                {
                    return;
                }

                ConsoleState state = Master.ConsoleService.CurrentState;
                if (state == ConsoleState.Diagnosing || state == ConsoleState.InteractiveDiagnostics)
                {
                    return;
                }

                int openedPosition = Pump.GetOpenValvePosition();

                if (openedPosition > 0)
                {
                    DateTime openTime = Pump.GetTimePumpStarted();
                    DateTime now      = DateTime.UtcNow;

                    Log.Debug(string.Format("Opened solenoid {0} at {1}", Pump.GetOpenValvePosition(), Log.DateTimeToString(openTime)));

                    Pump.FlowStatus flowStatus = Pump.CheckFlow();

                    if (flowStatus != Pump.FlowStatus.TooLow)
                    {
                        _flowFailures = 0;
                        if ((openTime != DateTime.MinValue) && ((now - openTime) > _periodAllowedOpen))
                        {
                            Pump.CloseValve(openedPosition);   // Close the valve.
                        }
                    }
                    // Else, assumption is that FlowStatus is TooLow. (empty cylinder?)
                    else if (((now - openTime) > _minOpenPeriod) &&
                             Pump.IsRunning())
                    {
                        _flowFailures++;
                        Log.Debug("Flow failed " + _flowFailures + " times.");

                        if (_flowFailures >= _MIN_FLOW_FAILURES)
                        {
                            _flowFailures = 0;
                            Pump.CloseValve(openedPosition);
                        }
                        else
                        {
                            Pump.OpenValve(Pump.GetOpenValvePosition(), false);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(Name, e);
            }
        }
예제 #3
0
 public virtual int GetOpenValvePosition()
 {
     return(Pump.GetOpenValvePosition());
 }