Пример #1
0
        /// <summary>
        /// When bad pump tubing is detected, dock uploads it as a docking station error to iNet
        /// and sends BadPumpTubingDetectedAction.
        /// </summary>
        /// <returns></returns>
        public DockingStationAction ReportBadCradleTubingError()
        {
            string message = string.Format("Bad pump tubing was detected on docking station {0}.", Configuration.DockingStation.SerialNumber);

            Log.Debug(string.Format(message));

            //Report kinked tubing error to iNet
            DockingStationError error = new DockingStationError(message, DockingStationErrorLevel.Error, Configuration.DockingStation.SerialNumber, "KINKED_TUBING_DETECTED");

            ReportError(error);

            //Return action to show error on dock's LCD
            DockingStationAction dsAction = new BadPumpTubingDetectedAction(Configuration.DockingStation.SerialNumber);

            return(dsAction);
        }
Пример #2
0
        /// <summary>
        /// Queues a docking station error to list.  The list is
        /// uploaded along with the next uploaded event.
        /// </summary>
        /// <param name="error">
        /// Error that is to be added to the list.
        /// </param>
        public void ReportError(DockingStationError error)
        {
            lock ( _errorsQueue )
            {
                // Check to see if its already been reported.
                // Don't report it if so.
                foreach (DockingStationError err in _errorsQueue)
                {
                    if (err.Description == error.Description)
                    {
                        return;
                    }
                }

                Log.Debug(string.Format("Queuing error for upload to server: \"{0}\"", error.Description));

                _errorsQueue.Enqueue(error);
            }
        }
Пример #3
0
        private void ReportQueuedErrors(InetUploader inetUploader)
        {
            lock ( _errorsQueue )
            {
                while (_errorsQueue.Count > 0)
                {
                    Log.Debug("ReportQueuedErrors: uploading error");

                    DockingStationError dsError = _errorsQueue.Peek();

                    Log.Debug(dsError.ToString());

                    inetUploader.UploadError(dsError, Configuration.DockingStation.TimeZoneInfo);

                    _errorsQueue.Dequeue();
                }
                _errorsQueue.TrimExcess();
            }
        }
Пример #4
0
        /// <summary>
        /// For certain 'actions' that the VDS decides to do, iNet needs to be
        /// notified of.  e.g. failed Leak check, Unavailable Gas, etc.
        /// </summary>
        /// <param name="dsAction"></param>
        /// <param name="inetUploader">May be null.
        /// If null is passed, the method will instantiate an Inet object to use.</param>
        private void ProcessNotificationAction(DockingStationAction dsAction, InetUploader inetUploader)
        {
            // _lastNotificationError is the last CONSECUTIVE NotificationAction.
            // This the passed-in action is not a NotificationAction, then that
            // breaks the current series of consecutive NotificationActions.
            // So, we set it to null to denote that.
            if (!(dsAction is INotificationAction))
            {
                _lastNotificationError = null;
                return;
            }

            const string funcMsg = "ProcessNotificationAction: ";

            StringBuilder errMsg = new StringBuilder(dsAction.Name);

            foreach (string m in dsAction.Messages)
            {
                errMsg.AppendFormat("\r\n{0}", m);
            }

            if (dsAction is UnsupportedCylinderAction)
            {
                errMsg.AppendFormat("\r\non Port {0}", ((UnsupportedCylinderAction)dsAction).GasEndPoint.Position);
            }

            // If it's an UnavailableAction, then the content of the error should
            // be the Exception's error (if there is an Exception).
            if ((dsAction is UnavailableAction) && (((UnavailableAction)dsAction).Exception != null))
            {
                errMsg.AppendFormat("\r\n{0}", ((UnavailableAction)dsAction).Exception.ToString());
            }

            DockingStationError dsError;

            //Suresh 02-Feb-2012 INS-2392
            if (Master.SwitchService.Instrument == null)
            {
                dsError = new DockingStationError(errMsg.ToString());
            }
            else
            {
                dsError = new DockingStationError(errMsg.ToString(), Master.SwitchService.Instrument.SerialNumber);
            }

            // If this NotificationError's detail is the exact same as the last NotificationError's
            // detail, then we assume it's a duplicate.  We don't want to upload duplicates.
            if (_lastNotificationError != null && _lastNotificationError.Description == dsError.Description)
            {
                Log.Debug(string.Format("{0}Ignoring duplicate: {1}", funcMsg, dsAction.ToString()));
                return;
            }

            _lastNotificationError = dsError;

            // We upload the error immediately (don't just queue it to our "Errors" List).
            if (inetUploader != null)
            {
                Log.Debug(string.Format("{0}Uploading ", funcMsg, dsAction.Name));
                inetUploader.UploadError(dsError, Configuration.DockingStation.TimeZoneInfo);
            }
            else
            {
                // if an uploader wasn't passed in to us to be re-used, then we need to create our own local one.
                using (InetUploader localUploader = new InetUploader())
                {
                    Log.Debug(string.Format("{0}Uploading {1}", funcMsg, dsAction.Name));
                    localUploader.UploadError(dsError, Configuration.DockingStation.TimeZoneInfo);
                }
            }
        }