public void CanConvertToString()
        {
            var    error    = new HardwareError(HardwareErrorSeverity.Critical, HardwareErrorClass.Device, 1, "1");
            string asString = error.ToString();

            Assert.IsTrue(!String.IsNullOrWhiteSpace(asString) && asString != typeof(HardwareError).FullName);
        }
        public void HasBasicRetrySupport()
        {
            var notRetriable = new HardwareError(HardwareErrorSeverity.Critical, HardwareErrorClass.Device, 1, "1");
            var retriable    = new HardwareError(HardwareErrorSeverity.Error, HardwareErrorClass.Communication, 1, "1");

            Assert.AreEqual(false, notRetriable.IsRetryable());
            Assert.AreEqual(true, retriable.IsRetryable());
        }
        public void ExceptionMessageIsFirstErrorMessage()
        {
            var error1    = new HardwareError(HardwareErrorSeverity.Critical, HardwareErrorClass.Device, 1, "1");
            var error2    = new HardwareError(HardwareErrorSeverity.Critical, HardwareErrorClass.Device, 2, "2");
            var exception = new HardwareException(new HardwareError[] { error1, error2 });

            Assert.AreEqual(error1.Message, exception.Message);
        }
        /// <summary>
        ///
        ///  |Advise Mask        |Description                                        |int value(lParam)|
        ///  |:-----------------:|:-------------------------------------------------:|:---------------:|
        ///  |DisplaySetting     | Display settings have changed                     |  1              |
        ///  |ExternalStart      | Acquisition has been started externall            |  1048608        |
        ///  |CalibrationChange  | A calibration parameter has changed               |  4              |
        ///  |AcquireStart       | Acquisition has been started                      |  134217728      |
        ///  |AcquireDone        | Acquisition has been stopped                      | -2147483648     |
        ///  |DataChange         | Data has been changes (occurs after AcquireClear) |  67108864       |
        ///  |HardwareError      | Hardware error                                    |  2097152        |
        ///  |HardwareChange     | Hardware setting has changed                      |  268435456      |
        ///  |HardwareAttention  | Hardware is requesting attention                  |  16777216       |
        ///  |DeviceUpdate       | Device settings have been updated                 |  8388608        |
        ///  |SampleChangerSet   | Sample changer set                                |  1073741824     |
        ///  |SampleChangeAdvance| Sample changer advanced                           |  4194304        |

        /// </summary>
        /// <param name="message">DeviceMessages type from CanberraDeviceAccessLib</param>
        /// <param name="wParam">The first parameter of information associated with the message.</param>
        /// <param name="lParam">The second parameter of information associated with the message</param>
        private void DeviceMessagesHandler(int message, int wParam, int lParam)
        {
            string response     = "";
            bool   isForCalling = true;

            try
            {
                if ((int)AdviseMessageMasks.amAcquireDone == lParam && !IsPaused)
                {
                    //if (Math.Abs(Counts - ElapsedRealTime) >= 10) return;
                    if (ElapsedRealTime < 10)
                    {
                        return;
                    }

                    Report.Notify(new DetectorMessage(Codes.INFO_DET_ACQ_DONE)); //$"Has got message AcquireDone."));
                    response = "Acquire has done";
                    Status   = DetectorStatus.ready;
                    if (AcquisitionStartDateTime.HasValue)
                    {
                        CurrentMeasurement.DateTimeStart  = AcquisitionStartDateTime;
                        CurrentMeasurement.DateTimeFinish = AcquisitionStartDateTime.Value.AddSeconds(ElapsedRealTime);
                    }
                    AcquireDone?.Invoke(this);
                }

                if ((int)AdviseMessageMasks.amAcquireStart == lParam)
                {
                    Report.Notify(new DetectorMessage(Codes.INFO_DET_ACQ_START)); //$"Has got message amAcquireStart."));
                    response = "Acquire has start";
                    Status   = DetectorStatus.busy;
                    AcquireStart?.Invoke(this);
                }

                if ((int)AdviseMessageMasks.amHardwareError == lParam)
                {
                    Status       = DetectorStatus.error;
                    ErrorMessage = $"{_device.Message((MessageCodes)lParam)}";
                    response     = ErrorMessage;
                    Report.Notify(new DetectorMessage(Codes.ERR_DET_ACQ_HRDW)
                    {
                        DetailedText = ErrorMessage
                    });
                    HardwareError?.Invoke(this);
                }
                if ((int)AdviseMessageMasks.amAcquisitionParamChange == lParam)
                {
                    response     = "Device ready to use!";
                    isForCalling = false;
                    ParamChange?.Invoke(this);
                }

                if (isForCalling)
                {
                    AcquiringStatusChanged?.Invoke(this, new DetectorEventsArgs {
                        Message = response, AcquireMessageParam = lParam, Name = this.Name, Status = this.Status
                    });
                }
            }
            catch (Exception ex)
            {
                Report.Notify(new DetectorMessage(Codes.ERR_DET_MSG_UNREG)
                {
                    DetailedText = ex.ToString()
                });
            }
        }