public DockingStationEvent Execute()
        {
            string funcMsg = Name + ".Execute";

            Log.Debug(funcMsg);

            // We copy the PostUpdate and SettingsRefId from the action to the event so they can
            // be passed on to the followup SettingsRead.  See the EventProcessor.GetFollowupAction method.
            CylinderPressureResetEvent dsEvent = new CylinderPressureResetEvent(this);

            dsEvent.PostUpdate    = this.PostUpdate;
            dsEvent.SettingsRefId = this.SettingsRefId;

            List <GasEndPoint> emptyManGasEndPoints = new List <GasEndPoint>();
            List <GasEndPoint> manGasEndPoints
                = new GasEndPointDataAccess().FindAll().FindAll(m => m.InstallationType == GasEndPoint.Type.Manifold ||
                                                                m.InstallationType == GasEndPoint.Type.Manual);

            // We want to reset low/empty non-iGas cylinders to full.
            for (int position = 1; position <= Configuration.DockingStation.NumGasPorts; position++)
            {
                // We don't want to process (manual) fresh air cylinders on port 1.
                GasEndPoint man = manGasEndPoints.Find(m => m.Position == position && !(m.Position == 1 && m.Cylinder.IsFreshAir));
                if (man != null)
                {
                    Log.Debug(string.Format("{0}Position {1} {2} found (\"{3}\", \"{4}\") with {5} pressure.", LOG_LABEL, position,
                                            man.InstallationType == GasEndPoint.Type.Manifold ? "Manifold" : "Manual Cylinder",
                                            man.Cylinder.FactoryId, man.Cylinder.PartNumber, man.Cylinder.Pressure));

                    if (man.Cylinder.Pressure != PressureLevel.Full)
                    {
                        man.GasChangeType     = GasEndPoint.ChangeType.PressureChanged;
                        man.Cylinder.Pressure = PressureLevel.Full;
                        emptyManGasEndPoints.Add(man);
                    }
                }
            }

            if (emptyManGasEndPoints.Count > 0)
            {
                // Save the modified cylinders in the local database.  The followup SettingsRead with
                // ChangedSmartCards set to null will take care of updating the cylinders in memory.
                using (DataAccessTransaction trx = new DataAccessTransaction())
                {
                    new GasEndPointDataAccess().SaveChangedCylinders(emptyManGasEndPoints, trx);
                    trx.Commit();

                    Log.Debug(string.Format("{0}{1} non-iGas cylinders were reset to full.", LOG_LABEL, emptyManGasEndPoints.Count));
                }
            }
            else
            {
                Log.Debug(string.Format("{0}No manifold or manual cylinders were found that needed reset to full.", LOG_LABEL));
            }

            return(dsEvent);
        }
        /// <summary>
        /// Return the information from all smart cards, manifolds and manual cylinders that are present at start-up.
        /// </summary>
        /// <param name="installedCylinders">Information about the cylinders is placed into this passed-in list.</param>
        static private void ReadInstalledCylinders(List <GasEndPoint> gasEndPoints, PortRestrictions port1Restrictions)
        {
            const string funcName = "ReadInstalledCylinders: ";

            // Get all currently attached manifolds and manually-assigned cylinders.
            List <GasEndPoint> manGasEndPoints
                = new GasEndPointDataAccess().FindAll().FindAll(m => m.InstallationType == GasEndPoint.Type.Manifold ||
                                                                m.InstallationType == GasEndPoint.Type.Manual);

            for (int position = 1; position <= Configuration.DockingStation.NumGasPorts; position++)
            {
                Log.Debug(funcName + "POSITION " + position);

                // iGas cylinders take precendence
                if (!SmartCardManager.IsCardPresent(position))
                {
                    Log.Debug(string.Format("{0}Position {1}, No iGas card detected.", funcName, position));

                    // Does the port have a manifold or manual cylinder attached?  Then make sure we include
                    // that cylinder in the returned list. If no cylinder exists on port 1, then create a
                    // virtual fresh air cylinder.
                    GasEndPoint man = manGasEndPoints.Find(m => m.Position == position);
                    if (man != null)
                    {
                        Log.Debug(string.Format("{0}Position {1} {2} found (\"{3}\", \"{4}\", Pressure {5}).", funcName, position,
                                                man.InstallationType == GasEndPoint.Type.Manifold ? "Manifold" : "Manual Cylinder",
                                                man.Cylinder.FactoryId, man.Cylinder.PartNumber, man.Cylinder.Pressure));
                        gasEndPoints.Add(man);
                    }
                    else if (position == Controller.FRESH_AIR_GAS_PORT)
                    {
                        Log.Debug(string.Format("{0}Position {1} is assumed to be Fresh Air.", funcName, position));
                        GasEndPoint freshAirEndPoint = GasEndPoint.CreateFreshAir(position);
                        freshAirEndPoint.GasChangeType = GasEndPoint.ChangeType.Installed;
                        gasEndPoints.Add(freshAirEndPoint);
                    }
                    continue;
                }

                // IF WE MAKE IT TO HERE, THEN WE KNOW WE HAVE AN INSERTED SMART CARD WHICH MEANS iGas IS ATTACHED.

                Cylinder cylinder = SmartCardManager.ReadCard(position);
                if (cylinder == null)   // Check for a valid cylinder.
                {
                    Log.Debug(string.Format("{0}Position {1}, ReadCard returned null. SKIPPING cylinder.", funcName, position));
                    continue;
                }

                // Dates read from card will be in 'local' time, but everything we deal with is in UTC.
                cylinder.ExpirationDate = Configuration.ToUniversalTime(cylinder.ExpirationDate);
                cylinder.RefillDate     = Configuration.ToUniversalTime(cylinder.RefillDate);

                Thread.Sleep(1000);

                if (SmartCardManager.IsPressureSwitchPresent(position))
                {
                    if (SmartCardManager.CheckPressureSwitch(position))
                    {
                        cylinder.Pressure = PressureLevel.Full;
                    }
                    else
                    {
                        cylinder.Pressure = PressureLevel.Low;
                    }

                    Log.Debug(string.Format("{0}Position {1} Pressure Switch reports {2}.", funcName, position, cylinder.Pressure));
                }
                else
                {
                    Log.Debug(string.Format("{0}Position {1} Pressure Switch not detected.", funcName, position));
                }

                GasEndPoint gasEndPoint = new GasEndPoint(cylinder, position, GasEndPoint.Type.iGas);

                // Add the installed cylinder to the DockingStation (IDS).
                gasEndPoints.Add(gasEndPoint);
            }

            return;
        }