using MwFramework.Device;

namespace MainShell.Vision
{
    /// <summary>
    /// 相机采图选项。
    /// 该对象仅描述采图动作本身，不负责改变相机触发模式、触发源、抓流状态等硬件工作模式。
    /// 相机工作模式应由上层在采图前完成准备。
    /// </summary>
    public class CameraCaptureOptions
    {
        public static CameraCaptureOptions CreateSoftTrigger(int timeoutMilliseconds = 5000)
        {
            CameraCaptureOptions options = new CameraCaptureOptions();
            options.CaptureMode = CameraCaptureMode.SoftTrigger;
            options.TimeoutMilliseconds = timeoutMilliseconds;
            return options;
        }

        public static CameraCaptureOptions CreateStream(int timeoutMilliseconds = 5000)
        {
            CameraCaptureOptions options = new CameraCaptureOptions();
            options.CaptureMode = CameraCaptureMode.Stream;
            options.TimeoutMilliseconds = timeoutMilliseconds;
            return options;
        }

        public CameraCaptureOptions()
        {
            CaptureMode = CameraCaptureMode.Stream;
            TimeoutMilliseconds = 5000;
            AutoStartGrabbing = false;
            TriggerMode = null;
            TriggerSource = null;
            TriggerDelay = null;
        }

        /// <summary>
        /// 采集方式。
        /// </summary>
        public CameraCaptureMode CaptureMode { get; set; }

        /// <summary>
        /// 超时时间（毫秒）。
        /// </summary>
        public int TimeoutMilliseconds { get; set; }

        /// <summary>
        /// 兼容旧调用保留字段。采图服务不再根据该值自动开启抓流。
        /// </summary>
        public bool AutoStartGrabbing { get; set; }

        /// <summary>
        /// 兼容旧调用保留字段。采图服务不再根据该值自动设置触发模式。
        /// </summary>
        public CameraTriggerMode? TriggerMode { get; set; }

        /// <summary>
        /// 兼容旧调用保留字段。采图服务不再根据该值自动设置触发源。
        /// </summary>
        public CameraTriggerSource? TriggerSource { get; set; }

        /// <summary>
        /// 兼容旧调用保留字段。采图服务不再根据该值自动设置触发延时。
        /// </summary>
        public double? TriggerDelay { get; set; }
    }
}
