Example #1
0
        /// <summary>
        /// Checks that this configuration is OK (all parameters have correct and compatible values).
        /// </summary>
        /// <param name="message">
        /// What's wrong with configuration or <see langword="null"/> if configuration is valid.
        /// </param>
        /// <returns>
        /// <see langword="true"/> if configuration is valid and can be used in <see cref="Device.StartCameras(DeviceConfiguration)"/>.
        /// <see langword="false"/> if configuration has some invalid or incompatible parameters.
        /// </returns>
        public bool IsValid([NotNullWhen(returnValue: false)] out string?message)
        {
            if (!ColorFormat.IsColor())
            {
                message = $"{nameof(ColorFormat)} = {ColorFormat} cannot be used for color camera";
                return(false);
            }

            if (!CameraFps.IsCompatibleWith(DepthMode))
            {
                message = $"{nameof(CameraFps)} = {CameraFps} is not compatible with {nameof(DepthMode)} = {DepthMode}";
                return(false);
            }

            if (!CameraFps.IsCompatibleWith(ColorResolution))
            {
                message = $"{nameof(CameraFps)} = {CameraFps} is not compatible with {nameof(ColorResolution)} = {ColorResolution}";
                return(false);
            }

            if (!ColorResolution.IsCompatibleWith(ColorFormat))
            {
                message = $"{nameof(ColorFormat)} = {ColorFormat} is not compatible with {nameof(ColorResolution)} = {ColorResolution}";
                return(false);
            }

            if (SubordinateDelayOffMaster < 0)
            {
                message = $"{nameof(SubordinateDelayOffMaster)} = {SubordinateDelayOffMaster} cannot be negative.";
                return(false);
            }

            message = null;
            return(true);
        }