feat: 完成基本的Jpeg控制
This commit is contained in:
		@@ -1,77 +1,22 @@
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Microsoft.AspNetCore.Cors;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using Microsoft.AspNetCore.Authorization;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
using Database;
 | 
			
		||||
using DotNext;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 视频流控制器,支持动态配置摄像头连接
 | 
			
		||||
/// </summary>
 | 
			
		||||
[ApiController]
 | 
			
		||||
[Authorize]
 | 
			
		||||
[Route("api/[controller]")]
 | 
			
		||||
public class VideoStreamController : ControllerBase
 | 
			
		||||
{
 | 
			
		||||
    private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
 | 
			
		||||
    private readonly server.Services.HttpVideoStreamService _videoStreamService;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 视频流信息结构体
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class StreamInfoResult
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int FrameRate { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int FrameWidth { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int FrameHeight { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Format { get; set; } = "MJPEG";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string HtmlUrl { get; set; } = "";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string MjpegUrl { get; set; } = "";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string SnapshotUrl { get; set; } = "";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// TODO:
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string UsbCameraUrl { get; set; } = "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 摄像头配置请求模型
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class CameraConfigRequest
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 摄像头地址
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [Required]
 | 
			
		||||
        [RegularExpression(@"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ErrorMessage = "请输入有效的IP地址")]
 | 
			
		||||
        public string Address { get; set; } = "";
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 摄像头端口
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [Required]
 | 
			
		||||
        [Range(1, 65535, ErrorMessage = "端口必须在1-65535范围内")]
 | 
			
		||||
        public int Port { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 分辨率配置请求模型
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -92,6 +37,14 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
        public int Height { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class AvailableResolutionsResponse
 | 
			
		||||
    {
 | 
			
		||||
        public int Width { get; set; }
 | 
			
		||||
        public int Height { get; set; }
 | 
			
		||||
        public string Name { get; set; } = string.Empty;
 | 
			
		||||
        public string Value => $"{Width}x{Height}";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 初始化HTTP视频流控制器
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -102,6 +55,40 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
        _videoStreamService = videoStreamService;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Optional<string> TryGetBoardId()
 | 
			
		||||
    {
 | 
			
		||||
        var userName = User.FindFirstValue(ClaimTypes.Name);
 | 
			
		||||
        if (string.IsNullOrEmpty(userName))
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error("User name not found in claims.");
 | 
			
		||||
            return Optional<string>.None;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var db = new AppDataConnection();
 | 
			
		||||
        if (db == null)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error("Database connection failed.");
 | 
			
		||||
            return Optional<string>.None;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var userRet = db.GetUserByName(userName);
 | 
			
		||||
        if (!userRet.IsSuccessful || !userRet.Value.HasValue)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error("User not found.");
 | 
			
		||||
            return Optional<string>.None;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var user = userRet.Value.Value;
 | 
			
		||||
        var boardId = user.BoardID;
 | 
			
		||||
        if (boardId == Guid.Empty)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error("No board bound to this user.");
 | 
			
		||||
            return Optional<string>.None;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return boardId.ToString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取 HTTP 视频流服务状态
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -114,8 +101,6 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("GetStatus方法被调用,控制器:{Controller},路径:api/VideoStream/Status", this.GetType().Name);
 | 
			
		||||
 | 
			
		||||
            // 使用HttpVideoStreamService提供的状态信息
 | 
			
		||||
            var status = _videoStreamService.GetServiceStatus();
 | 
			
		||||
 | 
			
		||||
@@ -129,101 +114,18 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取 HTTP 视频流信息
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns>流信息</returns>
 | 
			
		||||
    [HttpGet("StreamInfo")]
 | 
			
		||||
    [EnableCors("Users")]
 | 
			
		||||
    [ProducesResponseType(typeof(StreamInfoResult), StatusCodes.Status200OK)]
 | 
			
		||||
    [ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
 | 
			
		||||
    public IResult GetStreamInfo()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("获取 HTTP 视频流信息");
 | 
			
		||||
            var result = new StreamInfoResult
 | 
			
		||||
            {
 | 
			
		||||
                FrameRate = _videoStreamService.FrameRate,
 | 
			
		||||
                FrameWidth = _videoStreamService.FrameWidth,
 | 
			
		||||
                FrameHeight = _videoStreamService.FrameHeight,
 | 
			
		||||
                Format = "MJPEG",
 | 
			
		||||
                HtmlUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/video-feed.html",
 | 
			
		||||
                MjpegUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/video-stream",
 | 
			
		||||
                SnapshotUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/snapshot",
 | 
			
		||||
                UsbCameraUrl = $"http://{Global.localhost}:{_videoStreamService.ServerPort}/usb-camera"
 | 
			
		||||
            };
 | 
			
		||||
            return TypedResults.Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error(ex, "获取 HTTP 视频流信息失败");
 | 
			
		||||
            return TypedResults.InternalServerError(ex.Message);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 配置摄像头连接参数
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="config">摄像头配置</param>
 | 
			
		||||
    /// <returns>配置结果</returns>
 | 
			
		||||
    [HttpPost("ConfigureCamera")]
 | 
			
		||||
    [EnableCors("Users")]
 | 
			
		||||
    [ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
 | 
			
		||||
    [ProducesResponseType(typeof(object), StatusCodes.Status400BadRequest)]
 | 
			
		||||
    [ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
 | 
			
		||||
    public async Task<IResult> ConfigureCamera([FromBody] CameraConfigRequest config)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("配置摄像头连接: {Address}:{Port}", config.Address, config.Port);
 | 
			
		||||
 | 
			
		||||
            var success = await _videoStreamService.ConfigureCameraAsync(config.Address, config.Port);
 | 
			
		||||
 | 
			
		||||
            if (success)
 | 
			
		||||
            {
 | 
			
		||||
                return TypedResults.Ok(new
 | 
			
		||||
                {
 | 
			
		||||
                    success = true,
 | 
			
		||||
                    message = "摄像头配置成功",
 | 
			
		||||
                    cameraAddress = config.Address,
 | 
			
		||||
                    cameraPort = config.Port
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                return TypedResults.BadRequest(new
 | 
			
		||||
                {
 | 
			
		||||
                    success = false,
 | 
			
		||||
                    message = "摄像头配置失败",
 | 
			
		||||
                    cameraAddress = config.Address,
 | 
			
		||||
                    cameraPort = config.Port
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error(ex, "配置摄像头连接失败");
 | 
			
		||||
            return TypedResults.InternalServerError(ex.Message);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取当前摄像头配置
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns>摄像头配置信息</returns>
 | 
			
		||||
    [HttpGet("CameraConfig")]
 | 
			
		||||
    [HttpGet("MyEndpoint")]
 | 
			
		||||
    [EnableCors("Users")]
 | 
			
		||||
    [ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
 | 
			
		||||
    [ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
 | 
			
		||||
    public IResult GetCameraConfig()
 | 
			
		||||
    public IResult MyEndpoint()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("获取摄像头配置");
 | 
			
		||||
            var cameraStatus = _videoStreamService.GetCameraStatus();
 | 
			
		||||
            var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
 | 
			
		||||
            var endpoint = _videoStreamService.GetVideoEndpoint(boardId);
 | 
			
		||||
 | 
			
		||||
            return TypedResults.Ok(cameraStatus);
 | 
			
		||||
            return TypedResults.Ok(endpoint);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
@@ -232,22 +134,6 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 控制 HTTP 视频流服务开关
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="enabled">是否启用服务</param>
 | 
			
		||||
    /// <returns>操作结果</returns>
 | 
			
		||||
    [HttpPost("SetEnabled")]
 | 
			
		||||
    [EnableCors("Users")]
 | 
			
		||||
    [ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
 | 
			
		||||
    [ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
 | 
			
		||||
    public async Task<IResult> SetEnabled([FromQuery] bool enabled)
 | 
			
		||||
    {
 | 
			
		||||
        logger.Info("设置视频流服务开关: {Enabled}", enabled);
 | 
			
		||||
        await _videoStreamService.SetEnable(enabled);
 | 
			
		||||
        return TypedResults.Ok();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 测试 HTTP 视频流连接
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -260,32 +146,23 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("测试 HTTP 视频流连接");
 | 
			
		||||
            var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
 | 
			
		||||
            var endpoint = _videoStreamService.GetVideoEndpoint(boardId);
 | 
			
		||||
 | 
			
		||||
            // 尝试通过HTTP请求检查视频流服务是否可访问
 | 
			
		||||
            bool isConnected = false;
 | 
			
		||||
            using (var httpClient = new HttpClient())
 | 
			
		||||
            {
 | 
			
		||||
                httpClient.Timeout = TimeSpan.FromSeconds(2); // 设置较短的超时时间
 | 
			
		||||
                var response = await httpClient.GetAsync($"http://{Global.localhost}:{_videoStreamService.ServerPort}/");
 | 
			
		||||
                var response = await httpClient.GetAsync(endpoint.MjpegUrl);
 | 
			
		||||
 | 
			
		||||
                // 只要能连接上就认为成功,不管返回状态
 | 
			
		||||
                isConnected = response.IsSuccessStatusCode;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            logger.Info("测试摄像头连接");
 | 
			
		||||
            var ret = await _videoStreamService.TestCameraConnection(boardId);
 | 
			
		||||
 | 
			
		||||
            var (isSuccess, message) = await _videoStreamService.TestCameraConnectionAsync();
 | 
			
		||||
 | 
			
		||||
            return TypedResults.Ok(new
 | 
			
		||||
            {
 | 
			
		||||
                isConnected = isConnected,
 | 
			
		||||
                success = isSuccess,
 | 
			
		||||
                message = message,
 | 
			
		||||
                cameraAddress = _videoStreamService.CameraAddress,
 | 
			
		||||
                cameraPort = _videoStreamService.CameraPort,
 | 
			
		||||
                timestamp = DateTime.Now
 | 
			
		||||
            });
 | 
			
		||||
            return TypedResults.Ok(ret);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
@@ -295,6 +172,23 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [HttpPost("DisableTransmission")]
 | 
			
		||||
    public async Task<IActionResult> DisableHdmiTransmission()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            var boardId = TryGetBoardId().OrThrow(() => new ArgumentException("Board ID is required"));
 | 
			
		||||
 | 
			
		||||
            await _videoStreamService.DisableHdmiTransmissionAsync(boardId.ToString());
 | 
			
		||||
            return Ok($"HDMI transmission for board {boardId} disabled.");
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error(ex, $"Failed to disable HDMI transmission for board");
 | 
			
		||||
            return StatusCode(500, $"Error disabling HDMI transmission: {ex.Message}");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 设置视频流分辨率
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -309,16 +203,16 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info($"设置视频流分辨率为 {request.Width}x{request.Height}");
 | 
			
		||||
            var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
 | 
			
		||||
 | 
			
		||||
            var (isSuccess, message) = await _videoStreamService.SetResolutionAsync(request.Width, request.Height);
 | 
			
		||||
            var ret = await _videoStreamService.SetResolutionAsync(boardId, request.Width, request.Height);
 | 
			
		||||
 | 
			
		||||
            if (isSuccess)
 | 
			
		||||
            if (ret.IsSuccessful && ret.Value)
 | 
			
		||||
            {
 | 
			
		||||
                return TypedResults.Ok(new
 | 
			
		||||
                {
 | 
			
		||||
                    success = true,
 | 
			
		||||
                    message = message,
 | 
			
		||||
                    message = $"成功设置分辨率为 {request.Width}x{request.Height}",
 | 
			
		||||
                    width = request.Width,
 | 
			
		||||
                    height = request.Height,
 | 
			
		||||
                    timestamp = DateTime.Now
 | 
			
		||||
@@ -329,7 +223,7 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
                return TypedResults.BadRequest(new
 | 
			
		||||
                {
 | 
			
		||||
                    success = false,
 | 
			
		||||
                    message = message,
 | 
			
		||||
                    message = ret.Error?.ToString() ?? "未知错误",
 | 
			
		||||
                    timestamp = DateTime.Now
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
@@ -341,37 +235,6 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取当前分辨率
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns>当前分辨率信息</returns>
 | 
			
		||||
    [HttpGet("Resolution")]
 | 
			
		||||
    [EnableCors("Users")]
 | 
			
		||||
    [ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
 | 
			
		||||
    [ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
 | 
			
		||||
    public IResult GetCurrentResolution()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("获取当前视频流分辨率");
 | 
			
		||||
 | 
			
		||||
            var (width, height) = _videoStreamService.GetCurrentResolution();
 | 
			
		||||
 | 
			
		||||
            return TypedResults.Ok(new
 | 
			
		||||
            {
 | 
			
		||||
                width = width,
 | 
			
		||||
                height = height,
 | 
			
		||||
                resolution = $"{width}x{height}",
 | 
			
		||||
                timestamp = DateTime.Now
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error(ex, "获取当前分辨率失败");
 | 
			
		||||
            return TypedResults.InternalServerError($"获取当前分辨率失败: {ex.Message}");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取支持的分辨率列表
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -382,29 +245,19 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
    [ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
 | 
			
		||||
    public IResult GetSupportedResolutions()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        // (640, 480, "640x480 (VGA)"),
 | 
			
		||||
        // (960, 540, "960x540 (qHD)"),
 | 
			
		||||
        // (1280, 720, "1280x720 (HD)"),
 | 
			
		||||
        // (1280, 960, "1280x960 (SXGA)"),
 | 
			
		||||
        // (1920, 1080, "1920x1080 (Full HD)")
 | 
			
		||||
        return TypedResults.Ok(new AvailableResolutionsResponse[]
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("获取支持的分辨率列表");
 | 
			
		||||
 | 
			
		||||
            var resolutions = _videoStreamService.GetSupportedResolutions();
 | 
			
		||||
 | 
			
		||||
            return TypedResults.Ok(new
 | 
			
		||||
            {
 | 
			
		||||
                resolutions = resolutions.Select(r => new
 | 
			
		||||
                {
 | 
			
		||||
                    width = r.Width,
 | 
			
		||||
                    height = r.Height,
 | 
			
		||||
                    name = r.Name,
 | 
			
		||||
                    value = $"{r.Width}x{r.Height}"
 | 
			
		||||
                }),
 | 
			
		||||
                timestamp = DateTime.Now
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error(ex, "获取支持的分辨率列表失败");
 | 
			
		||||
            return TypedResults.InternalServerError($"获取支持的分辨率列表失败: {ex.Message}");
 | 
			
		||||
        }
 | 
			
		||||
            new AvailableResolutionsResponse { Width = 640, Height = 480, Name = "640x480(VGA)" },
 | 
			
		||||
            new AvailableResolutionsResponse { Width = 960, Height = 480, Name = "960x480(qHD)" },
 | 
			
		||||
            new AvailableResolutionsResponse { Width = 1280, Height = 720, Name = "1280x720(HD)" },
 | 
			
		||||
            new AvailableResolutionsResponse { Width = 1280, Height = 960, Name = "1280x960(SXGA)" },
 | 
			
		||||
            new AvailableResolutionsResponse { Width = 1920, Height = 1080, Name = "1920x1080(Full HD)" }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -420,9 +273,9 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("收到初始化自动对焦请求");
 | 
			
		||||
            var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
 | 
			
		||||
 | 
			
		||||
            var result = await _videoStreamService.InitAutoFocusAsync();
 | 
			
		||||
            var result = await _videoStreamService.InitAutoFocusAsync(boardId);
 | 
			
		||||
 | 
			
		||||
            if (result)
 | 
			
		||||
            {
 | 
			
		||||
@@ -465,9 +318,9 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("收到执行自动对焦请求");
 | 
			
		||||
            var boardId = TryGetBoardId().OrThrow(() => new Exception("Board ID not found"));
 | 
			
		||||
 | 
			
		||||
            var result = await _videoStreamService.PerformAutoFocusAsync();
 | 
			
		||||
            var result = await _videoStreamService.PerformAutoFocusAsync(boardId);
 | 
			
		||||
 | 
			
		||||
            if (result)
 | 
			
		||||
            {
 | 
			
		||||
@@ -496,61 +349,4 @@ public class VideoStreamController : ControllerBase
 | 
			
		||||
            return TypedResults.InternalServerError($"执行自动对焦失败: {ex.Message}");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 执行一次自动对焦 (GET方式)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns>对焦结果</returns>
 | 
			
		||||
    [HttpGet("Focus")]
 | 
			
		||||
    [EnableCors("Users")]
 | 
			
		||||
    [ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
 | 
			
		||||
    [ProducesResponseType(typeof(object), StatusCodes.Status400BadRequest)]
 | 
			
		||||
    [ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
 | 
			
		||||
    public async Task<IResult> Focus()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            logger.Info("收到执行一次对焦请求 (GET)");
 | 
			
		||||
 | 
			
		||||
            // 检查摄像头是否已配置
 | 
			
		||||
            if (!_videoStreamService.IsCameraConfigured())
 | 
			
		||||
            {
 | 
			
		||||
                logger.Warn("摄像头未配置,无法执行对焦");
 | 
			
		||||
                return TypedResults.BadRequest(new
 | 
			
		||||
                {
 | 
			
		||||
                    success = false,
 | 
			
		||||
                    message = "摄像头未配置,请先配置摄像头连接",
 | 
			
		||||
                    timestamp = DateTime.Now
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var result = await _videoStreamService.PerformAutoFocusAsync();
 | 
			
		||||
 | 
			
		||||
            if (result)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Info("对焦执行成功");
 | 
			
		||||
                return TypedResults.Ok(new
 | 
			
		||||
                {
 | 
			
		||||
                    success = true,
 | 
			
		||||
                    message = "对焦执行成功",
 | 
			
		||||
                    timestamp = DateTime.Now
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                logger.Warn("对焦执行失败");
 | 
			
		||||
                return TypedResults.BadRequest(new
 | 
			
		||||
                {
 | 
			
		||||
                    success = false,
 | 
			
		||||
                    message = "对焦执行失败",
 | 
			
		||||
                    timestamp = DateTime.Now
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error(ex, "执行对焦时发生异常");
 | 
			
		||||
            return TypedResults.InternalServerError($"执行对焦失败: {ex.Message}");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,5 @@
 | 
			
		||||
using System.Net;
 | 
			
		||||
using DotNext;
 | 
			
		||||
using Peripherals.PowerClient;
 | 
			
		||||
using WebProtocol;
 | 
			
		||||
 | 
			
		||||
namespace Peripherals.CameraClient;
 | 
			
		||||
@@ -16,7 +15,7 @@ static class CameraAddr
 | 
			
		||||
    public const UInt32 CAMERA_POWER = BASE + 0x10; //[0]: rstn, 0 is reset. [8]: power down, 1 is down.
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class Camera
 | 
			
		||||
public class Camera
 | 
			
		||||
{
 | 
			
		||||
    private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
 | 
			
		||||
 | 
			
		||||
@@ -276,7 +275,7 @@ class Camera
 | 
			
		||||
            {
 | 
			
		||||
                var currentAddress = (UInt16)(baseAddress + i - 1);
 | 
			
		||||
                var data = (byte)cmd[i];
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                logger.Debug($"ConfigureRegisters: 写入地址=0x{currentAddress:X4}, 数据=0x{data:X2}");
 | 
			
		||||
 | 
			
		||||
                // 准备I2C数据:16位地址 + 8位数据
 | 
			
		||||
@@ -322,14 +321,14 @@ class Camera
 | 
			
		||||
    public async ValueTask<Result<byte>> ReadRegister(UInt16 register)
 | 
			
		||||
    {
 | 
			
		||||
        var i2c = new Peripherals.I2cClient.I2c(this.address, this.port, this.taskID, this.timeout);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Convert 16-bit register address to byte array
 | 
			
		||||
        var registerBytes = new byte[] { (byte)(register >> 8), (byte)(register & 0xFF) };
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        var ret = await i2c.ReadData(CAM_I2C_ADDR, registerBytes, 1, CAM_PROTO);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
            return new(ret.Error);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return new Result<byte>(ret.Value[0]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -412,25 +411,25 @@ class Camera
 | 
			
		||||
            [0x3801, unchecked((byte)(hStart & 0xFF))],
 | 
			
		||||
            [0x3802, unchecked((byte)((vStart >> 8) & 0xFF))],
 | 
			
		||||
            [0x3803, unchecked((byte)(vStart & 0xFF))],
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            // H_END/V_END
 | 
			
		||||
            [0x3804, unchecked((byte)((hEnd >> 8) & 0xFF))],
 | 
			
		||||
            [0x3805, unchecked((byte)(hEnd & 0xFF))],
 | 
			
		||||
            [0x3806, unchecked((byte)((vEnd >> 8) & 0xFF))],
 | 
			
		||||
            [0x3807, unchecked((byte)(vEnd & 0xFF))],
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            // 输出像素个数
 | 
			
		||||
            [0x3808, unchecked((byte)((dvpHo >> 8) & 0xFF))],
 | 
			
		||||
            [0x3809, unchecked((byte)(dvpHo & 0xFF))],
 | 
			
		||||
            [0x380A, unchecked((byte)((dvpVo >> 8) & 0xFF))],
 | 
			
		||||
            [0x380B, unchecked((byte)(dvpVo & 0xFF))],
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            // 总像素
 | 
			
		||||
            [0x380C, unchecked((byte)((hts >> 8) & 0xFF))],
 | 
			
		||||
            [0x380D, unchecked((byte)(hts & 0xFF))],
 | 
			
		||||
            [0x380E, unchecked((byte)((vts >> 8) & 0xFF))],
 | 
			
		||||
            [0x380F, unchecked((byte)(vts & 0xFF))],
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            // H_OFFSET/V_OFFSET
 | 
			
		||||
            [0x3810, unchecked((byte)((hOffset >> 8) & 0xFF))],
 | 
			
		||||
            [0x3811, unchecked((byte)(hOffset & 0xFF))],
 | 
			
		||||
@@ -521,7 +520,7 @@ class Camera
 | 
			
		||||
            hOffset: 16, vOffset: 4,
 | 
			
		||||
            hWindow: 2624, vWindow: 1456
 | 
			
		||||
        );
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -537,7 +536,7 @@ class Camera
 | 
			
		||||
            hOffset: 16, vOffset: 4,
 | 
			
		||||
            hWindow: 2624, vWindow: 1456
 | 
			
		||||
        );
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -637,7 +636,7 @@ class Camera
 | 
			
		||||
            [0x3008, 0x42] // 休眠命令
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        return await ConfigureRegisters(sleepRegisters,  customDelayMs: 50);
 | 
			
		||||
        return await ConfigureRegisters(sleepRegisters, customDelayMs: 50);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -1305,7 +1304,7 @@ class Camera
 | 
			
		||||
        UInt16 firmwareAddr = 0x8000;
 | 
			
		||||
        var firmwareCommand = new UInt16[1 + OV5640_AF_FIRMWARE.Length];
 | 
			
		||||
        firmwareCommand[0] = firmwareAddr;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // 将固件数据复制到命令数组中
 | 
			
		||||
        for (int i = 0; i < OV5640_AF_FIRMWARE.Length; i++)
 | 
			
		||||
        {
 | 
			
		||||
@@ -1425,7 +1424,7 @@ class Camera
 | 
			
		||||
                logger.Error($"自动对焦超时,状态: 0x{readResult.Value:X2}");
 | 
			
		||||
                return new(new Exception($"自动对焦超时,状态: 0x{readResult.Value:X2}"));
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            await Task.Delay(100);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -55,28 +55,28 @@ class DebuggerCmd
 | 
			
		||||
    public const UInt32 ClearSignal = 0xFFFF_FFFF;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary> 
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 信号捕获模式枚举
 | 
			
		||||
/// </summary>
 | 
			
		||||
public enum CaptureMode : byte
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 无捕获模式
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    None = 0,
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 低电平触发模式
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Logic0 = 1,
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 高电平触发模式
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Logic1 = 2,
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 上升沿触发模式
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Rise = 3,
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 下降沿触发模式
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Fall = 4,
 | 
			
		||||
@@ -170,7 +170,7 @@ public class DebuggerClient
 | 
			
		||||
    /// <returns>操作结果,成功返回状态标志字节,失败返回错误信息</returns>
 | 
			
		||||
    public async ValueTask<Result<byte>> ReadFlag()
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, DebuggerAddr.Signal, this.timeout);
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddrByte(this.ep, this.taskID, DebuggerAddr.Signal, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to read flag: {ret.Error}");
 | 
			
		||||
 
 | 
			
		||||
@@ -8,8 +8,8 @@ static class I2cAddr
 | 
			
		||||
 | 
			
		||||
    const UInt32 Base = 0x6000_0000;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// 0x0000_0000: 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0000:
 | 
			
		||||
    /// [7:0] 本次传输的i2c地址(最高位总为0);
 | 
			
		||||
    /// [8] 1为读,0为写;
 | 
			
		||||
    /// [16] 1为SCCB协议,0为I2C协议;
 | 
			
		||||
@@ -17,45 +17,45 @@ static class I2cAddr
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 BaseConfig = Base + 0x0000_0000;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0001:
 | 
			
		||||
    /// [15:0] 本次传输的数据量(以字节为单位,0为传1个字节);
 | 
			
		||||
    /// [31:16] 若本次传输为读的DUMMY数据量(字节为单位,0为传1个字节)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 TranConfig = Base + 0x0000_0001;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0002: [0] cmd_done; [8] cmd_error;
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 Flag = Base + 0x0000_0002;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0003: FIFO写入口,仅低8位有效,只写
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 Write = Base + 0x0000_0003;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0004: FIFO读出口,仅低8位有效,只读
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 Read = Base + 0x0000_0004;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0005: [0] FIFO写入口清空;[8] FIFO读出口清空;
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 Clear = Base + 0x0000_0005;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary> 
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// [TODO:Enum]
 | 
			
		||||
/// </summary>
 | 
			
		||||
public enum I2cProtocol
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// [TODO:Enum]
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    I2c = 0,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// [TODO:Enum]
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    SCCB = 1
 | 
			
		||||
@@ -296,7 +296,7 @@ public class I2c
 | 
			
		||||
 | 
			
		||||
        // 读取数据
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, I2cAddr.Read);
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddrByte(this.ep, this.taskID, I2cAddr.Read);
 | 
			
		||||
            if (!ret.IsSuccessful)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Failed to read data from I2C FIFO: {ret.Error}");
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										281
									
								
								server/src/Peripherals/JpegClient.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										281
									
								
								server/src/Peripherals/JpegClient.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,281 @@
 | 
			
		||||
using System.Net;
 | 
			
		||||
using DotNext;
 | 
			
		||||
using Common;
 | 
			
		||||
 | 
			
		||||
namespace Peripherals.JpegClient;
 | 
			
		||||
 | 
			
		||||
static class JpegAddr
 | 
			
		||||
{
 | 
			
		||||
    const UInt32 BASE = 0x0000_0000;
 | 
			
		||||
    public const UInt32 ENABLE = BASE + 0x0;
 | 
			
		||||
    public const UInt32 FRAME_NUM = BASE + 0x1;
 | 
			
		||||
    public const UInt32 FRAME_INFO = BASE + 0x2;
 | 
			
		||||
    public const UInt32 FRAME_SAMPLE_RATE = BASE + 0x3;
 | 
			
		||||
    public const UInt32 FRAME_DATA_MAX_POINTER = BASE + 0x4;
 | 
			
		||||
 | 
			
		||||
    public const UInt32 DDR_FRAME_DATA_ADDR = 0x0000_0000;
 | 
			
		||||
    public const UInt32 DDR_FRAME_DATA_MAX_ADDR = 0x8000_0000;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class JpegInfo
 | 
			
		||||
{
 | 
			
		||||
    public UInt32 Width { get; set; }
 | 
			
		||||
    public UInt32 Height { get; set; }
 | 
			
		||||
    public UInt32 Size { get; set; }
 | 
			
		||||
 | 
			
		||||
    public JpegInfo(UInt32 width, UInt32 height, UInt32 size)
 | 
			
		||||
    {
 | 
			
		||||
        Width = width;
 | 
			
		||||
        Height = height;
 | 
			
		||||
        Size = size;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public JpegInfo(byte[] data)
 | 
			
		||||
    {
 | 
			
		||||
        if (data.Length < 8)
 | 
			
		||||
            throw new ArgumentException("Invalid data length", nameof(data));
 | 
			
		||||
 | 
			
		||||
        Width = ((UInt32)(data[5] << 8 + data[6] & 0xF0));
 | 
			
		||||
        Height = ((UInt32)((data[6] & 0x0F) << 4 + data[7]));
 | 
			
		||||
        Size = Number.BytesToUInt32(data, 0, 4).Value;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public enum JpegSampleRate : UInt32
 | 
			
		||||
{
 | 
			
		||||
    RATE_1_1 = 0b1111_1111_1111_1111_1111_1111_1111_1111,
 | 
			
		||||
    RATE_1_2 = 0b1010_1010_1010_1010_1010_1010_1010_1010,
 | 
			
		||||
    RATE_1_4 = 0b1000_1000_1000_1000_1000_1000_1000_1000,
 | 
			
		||||
    RATE_3_4 = 0b1110_1110_1110_1110_1110_1110_1110_1110,
 | 
			
		||||
    RATE_1_8 = 0b1000_0000_1000_0000_1000_0000_1000_0000,
 | 
			
		||||
    RATE_3_8 = 0b1001_0010_0100_1001_1001_0010_0100_1001,
 | 
			
		||||
    RATE_7_8 = 0b1111_1110_1111_1110_1111_1110_1111_1110,
 | 
			
		||||
    RATE_1_16 = 0b1000_0000_0000_0000_1000_0000_0000_0000,
 | 
			
		||||
    RATE_3_16 = 0b1000_0100_0010_0000_1000_0100_0010_0000,
 | 
			
		||||
    RATE_5_16 = 0b1001_0001_0010_0010_0100_0100_1000_1001,
 | 
			
		||||
    RATE_15_16 = 0b1111_1111_1111_1110_1111_1111_1111_1110,
 | 
			
		||||
    RATE_1_32 = 0b1000_0000_0000_0000_0000_0000_0000_0000,
 | 
			
		||||
    RATE_31_32 = 0b1111_1111_1111_1111_1111_1111_1111_1110,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class Jpeg
 | 
			
		||||
{
 | 
			
		||||
    private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
 | 
			
		||||
 | 
			
		||||
    readonly int timeout = 2000;
 | 
			
		||||
    readonly int taskID;
 | 
			
		||||
    readonly int port;
 | 
			
		||||
    readonly string address;
 | 
			
		||||
    private IPEndPoint ep;
 | 
			
		||||
 | 
			
		||||
    public Jpeg(string address, int port, int taskID, int timeout = 2000)
 | 
			
		||||
    {
 | 
			
		||||
        if (timeout < 0)
 | 
			
		||||
            throw new ArgumentException("Timeout couldn't be negative", nameof(timeout));
 | 
			
		||||
        this.address = address;
 | 
			
		||||
        this.taskID = taskID;
 | 
			
		||||
        this.port = port;
 | 
			
		||||
        this.ep = new IPEndPoint(IPAddress.Parse(address), port);
 | 
			
		||||
        this.timeout = timeout;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<bool> SetEnable(bool enable)
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.WriteAddr(
 | 
			
		||||
            this.ep, this.taskID, JpegAddr.ENABLE, Convert.ToUInt32(enable), this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to set JPEG enable: {ret.Error}");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return ret.Value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<bool> SetSampleRate(uint rate)
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.WriteAddr(
 | 
			
		||||
            this.ep, this.taskID, JpegAddr.FRAME_SAMPLE_RATE, rate, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to set JPEG sample rate: {ret.Error}");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return ret.Value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<bool> SetSampleRate(JpegSampleRate rate)
 | 
			
		||||
    {
 | 
			
		||||
        return await SetSampleRate((uint)rate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<uint> GetFrameNumber()
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddrByte(
 | 
			
		||||
            this.ep, this.taskID, JpegAddr.FRAME_NUM, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to get JPEG frame number: {ret.Error}");
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
        return Number.BytesToUInt32(ret.Value.Options.Data ?? Array.Empty<byte>()).Value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<Optional<List<JpegInfo>>> GetFrameInfo(int num)
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, JpegAddr.FRAME_INFO, num, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to get JPEG frame info: {ret.Error}");
 | 
			
		||||
            return new(null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var data = ret.Value.Options.Data;
 | 
			
		||||
        if (data == null || data.Length == 0)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Data is null or empty");
 | 
			
		||||
            return new(null);
 | 
			
		||||
        }
 | 
			
		||||
        if (data.Length != num * 2)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error(
 | 
			
		||||
                $"Data length should be {num * 2} bytes, instead of {data.Length} bytes");
 | 
			
		||||
            return new(null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var infos = new List<JpegInfo>();
 | 
			
		||||
        for (int i = 0; i < num; i++)
 | 
			
		||||
        {
 | 
			
		||||
            infos.Add(new JpegInfo(data[i..(i + 1)]));
 | 
			
		||||
        }
 | 
			
		||||
        return new(infos);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<bool> UpdatePointer(uint cnt)
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.WriteAddr(
 | 
			
		||||
            this.ep, this.taskID, JpegAddr.FRAME_DATA_MAX_POINTER, cnt, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to update pointer: {ret.Error}");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return ret.Value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<Result<byte[]?>> GetFrame(uint offset, uint length)
 | 
			
		||||
    {
 | 
			
		||||
        if (!MsgBus.IsRunning)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error("Message bus is not running");
 | 
			
		||||
            return new(new Exception("Message bus is not running"));
 | 
			
		||||
        }
 | 
			
		||||
        MsgBus.UDPServer.ClearUDPData(this.ep.Address.ToString(), this.ep.Port);
 | 
			
		||||
 | 
			
		||||
        var firstReadLength = (int)(Math.Min(length, JpegAddr.DDR_FRAME_DATA_MAX_ADDR - offset));
 | 
			
		||||
        var secondReadLength = (int)(length - firstReadLength);
 | 
			
		||||
        var dataBytes = new byte[length];
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddr4Bytes(
 | 
			
		||||
                this.ep, this.taskID, JpegAddr.DDR_FRAME_DATA_ADDR + offset, firstReadLength, this.timeout);
 | 
			
		||||
            if (!ret.IsSuccessful)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Failed to get JPEG frame data: {ret.Error}");
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            if (ret.Value.Length != firstReadLength)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Data length should be {firstReadLength} bytes, instead of {ret.Value.Length} bytes");
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            Buffer.BlockCopy(ret.Value, 0, dataBytes, 0, firstReadLength);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (secondReadLength > 0)
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddr4Bytes(
 | 
			
		||||
                this.ep, this.taskID, JpegAddr.DDR_FRAME_DATA_ADDR, secondReadLength, this.timeout);
 | 
			
		||||
            if (!ret.IsSuccessful)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Failed to get JPEG frame data: {ret.Error}");
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            if (ret.Value.Length != secondReadLength)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Data length should be {secondReadLength} bytes, instead of {ret.Value.Length} bytes");
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            Buffer.BlockCopy(ret.Value, 0, dataBytes, firstReadLength, secondReadLength);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return dataBytes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<List<byte[]>> GetMultiFrames(uint offset, uint[] sizes)
 | 
			
		||||
    {
 | 
			
		||||
        var frames = new List<byte[]>();
 | 
			
		||||
        for (int i = 0; i < sizes.Length; i++)
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await GetFrame(offset, sizes[i]);
 | 
			
		||||
            if (!ret.IsSuccessful)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Failed to get JPEG frame {i} data: {ret.Error}");
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            if (ret.Value == null)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Frame {i} data is null");
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            if (ret.Value.Length != sizes[i])
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error(
 | 
			
		||||
                    $"Frame {i} data length should be {sizes[i]} bytes, instead of {ret.Value.Length} bytes");
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            frames.Add(ret.Value);
 | 
			
		||||
            offset += sizes[i];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await UpdatePointer((uint)sizes.Length);
 | 
			
		||||
            if (!ret) logger.Error($"Failed to update pointer");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return frames;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async ValueTask<Result<List<byte[]>?>> GetMultiFrames(uint offset)
 | 
			
		||||
    {
 | 
			
		||||
        if (!MsgBus.IsRunning)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error("Message bus is not running");
 | 
			
		||||
            return new(new Exception("Message bus is not running"));
 | 
			
		||||
        }
 | 
			
		||||
        MsgBus.UDPServer.ClearUDPData(this.ep.Address.ToString(), this.ep.Port);
 | 
			
		||||
 | 
			
		||||
        var frameNum = await GetFrameNumber();
 | 
			
		||||
        if (frameNum == 0) return null;
 | 
			
		||||
 | 
			
		||||
        List<uint>? frameSizes = null;
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await GetFrameInfo((int)frameNum);
 | 
			
		||||
            if (!ret.HasValue || ret.Value.Count == 0)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"Failed to get frame info");
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            frameSizes = ret.Value.Select(x => x.Size).ToList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var frames = await GetMultiFrames(offset, frameSizes.ToArray());
 | 
			
		||||
        if (frames.Count == 0)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to get frames");
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return frames;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -12,7 +12,7 @@ static class AnalyzerAddr
 | 
			
		||||
    const UInt32 DMA1_BASE = 0x7000_0000;
 | 
			
		||||
    const UInt32 DDR_BASE = 0x0000_0000;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0000    R/W [ 0]      capture on:    置1开始等待捕获,0停止捕获。捕获到信号后该位自动清零。  <br/>
 | 
			
		||||
    ///                    [ 8]      capture force: 置1则强制捕获信号,自动置0。 <br/>
 | 
			
		||||
    ///                    [16]      capture busy:  1为逻辑分析仪正在捕获信号。 <br/>
 | 
			
		||||
@@ -21,7 +21,7 @@ static class AnalyzerAddr
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 CAPTURE_MODE = BASE + 0x0000_0000;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0001    R/W [1:0] global trig mode:  00: 全局与  (&) <br/>
 | 
			
		||||
    ///                                             01: 全局或  (|) <br/>
 | 
			
		||||
    ///                                             10: 全局非与(~&) <br/>
 | 
			
		||||
@@ -29,7 +29,7 @@ static class AnalyzerAddr
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 GLOBAL_TRIG_MODE = BASE + 0x0000_0001;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0010 - 0x0000_0017 R/W [5:0] 信号M的触发操作符,共8路 <br/>
 | 
			
		||||
    ///                               [5:3] M's Operator: 000 == <br/>
 | 
			
		||||
    ///                                                   001 != <br/>
 | 
			
		||||
@@ -73,7 +73,7 @@ static class AnalyzerAddr
 | 
			
		||||
    public const UInt32 DMA1_CAPTURE_CTRL_ADDR = DMA1_BASE + 0x0000_0014;
 | 
			
		||||
    public const UInt32 STORE_OFFSET_ADDR = DDR_BASE + 0x0100_0000;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0100_0000 - 0x0100_03FF 只读 32位波形存储,得到的32位数据中低八位最先捕获,高八位最后捕获。<br/>
 | 
			
		||||
    ///                                共1024个地址,每个地址存储4组,深度为4096。<br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -87,53 +87,53 @@ static class AnalyzerAddr
 | 
			
		||||
[Flags]
 | 
			
		||||
public enum CaptureStatus
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 无状态标志
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    None = 0,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 捕获使能位,置1开始等待捕获,0停止捕获。捕获到信号后该位自动清零
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    CaptureOn = 1 << 0,      // [0] 捕获使能
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 强制捕获位,置1则强制捕获信号,自动置0
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    CaptureForce = 1 << 8,   // [8] 强制捕获
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 捕获忙碌位,1为逻辑分析仪正在捕获信号
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    CaptureBusy = 1 << 16,   // [16] 捕获进行中
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 捕获完成位,1为逻辑分析仪内存完整存储了此次捕获的信号
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    CaptureDone = 1 << 24    // [24] 捕获完成
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary> 
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 全局触发模式枚举,定义多路信号触发条件的逻辑组合方式
 | 
			
		||||
/// </summary>
 | 
			
		||||
public enum GlobalCaptureMode
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 全局与模式,所有触发条件都必须满足
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    AND = 0b00,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 全局或模式,任一触发条件满足即可
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    OR = 0b01,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 全局非与模式,不是所有触发条件都满足
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    NAND = 0b10,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 全局非或模式,所有触发条件都不满足
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    NOR = 0b11
 | 
			
		||||
@@ -144,32 +144,32 @@ public enum GlobalCaptureMode
 | 
			
		||||
/// </summary>
 | 
			
		||||
public enum AnalyzerClockDiv
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 1分频
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    DIV1 = 0x0000_0000,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 2分频
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    DIV2 = 0x0000_0001,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 4分频
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    DIV4 = 0x0000_0002,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 8分频
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    DIV8 = 0x0000_0003,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 16分频
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    DIV16 = 0x0000_0004,
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 32分频
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    DIV32 = 0x0000_0005,
 | 
			
		||||
@@ -190,27 +190,27 @@ public enum AnalyzerClockDiv
 | 
			
		||||
/// </summary>
 | 
			
		||||
public enum SignalOperator : byte
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 等于操作符
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Equal = 0b000,        // ==
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 不等于操作符
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    NotEqual = 0b001,     // !=
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 小于操作符
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    LessThan = 0b010,     // <
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 小于等于操作符
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    LessThanOrEqual = 0b011, // <=
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 大于操作符
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    GreaterThan = 0b100,      // >
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 大于等于操作符
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    GreaterThanOrEqual = 0b101 // >=
 | 
			
		||||
@@ -221,35 +221,35 @@ public enum SignalOperator : byte
 | 
			
		||||
/// </summary>
 | 
			
		||||
public enum SignalValue : byte
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 逻辑0电平
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Logic0 = 0b000,        // LOGIC 0
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 逻辑1电平
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Logic1 = 0b001,        // LOGIC 1
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 不关心该信号状态
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    NotCare = 0b010,       // X(not care)
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 上升沿触发
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Rise = 0b011,          // RISE
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 下降沿触发
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    Fall = 0b100,          // FALL
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 上升沿或下降沿触发
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    RiseOrFall = 0b101,    // RISE OR FALL
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 信号无变化
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    NoChange = 0b110,      // NOCHANGE
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 特定数值
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    SomeNumber = 0b111     // SOME NUMBER
 | 
			
		||||
@@ -260,11 +260,11 @@ public enum SignalValue : byte
 | 
			
		||||
/// </summary>
 | 
			
		||||
public enum AnalyzerChannelDiv
 | 
			
		||||
{
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 1路
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    ONE = 0x0000_0000,
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 2路
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    TWO = 0x0000_0001,
 | 
			
		||||
@@ -366,7 +366,7 @@ public class Analyzer
 | 
			
		||||
    /// <returns>操作结果,成功返回寄存器值,否则返回异常信息</returns>
 | 
			
		||||
    public async ValueTask<Result<CaptureStatus>> ReadCaptureStatus()
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, AnalyzerAddr.CAPTURE_MODE, this.timeout);
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddrByte(this.ep, this.taskID, AnalyzerAddr.CAPTURE_MODE, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to read capture status: {ret.Error}");
 | 
			
		||||
 
 | 
			
		||||
@@ -9,57 +9,57 @@ static class OscilloscopeAddr
 | 
			
		||||
{
 | 
			
		||||
    const UInt32 BASE = 0x8000_0000;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0000:R/W[0] wave_run 启动捕获/关闭
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 START_CAPTURE = BASE + 0x0000_0000;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0001: R/W[7:0] trig_level 触发电平
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 TRIG_LEVEL = BASE + 0x0000_0001;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0002:R/W[0] trig_edge 触发边沿,0-下降沿,1-上升沿
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 TRIG_EDGE = BASE + 0x0000_0002;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0003: R/W[9:0] h shift 水平偏移量
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 H_SHIFT = BASE + 0x0000_0003;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0004: R/W[9:0] deci rate 抽样率,0—1023
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 DECI_RATE = BASE + 0x0000_0004;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0005:R/W[0] ram refresh RAM刷新
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 RAM_FRESH = BASE + 0x0000_0005;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000 0006:R[19: 0] ad_freq AD采样频率
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 AD_FREQ = BASE + 0x0000_0006;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Ox0000_0007: R[7:0] ad_vpp AD采样幅度
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 AD_VPP = BASE + 0x0000_0007;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0008: R[7:0] ad max AD采样最大值
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 AD_MAX = BASE + 0x0000_0008;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_0009: R[7:0] ad_min AD采样最小值
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 AD_MIN = BASE + 0x0000_0009;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 0x0000_1000-0x0000_13FF:R[7:0] wave_rd_data 共1024个字节
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 RD_DATA_ADDR = BASE + 0x0000_1000;
 | 
			
		||||
@@ -232,7 +232,7 @@ class Oscilloscope
 | 
			
		||||
    /// <returns>操作结果,成功返回采样频率值,否则返回异常信息</returns>
 | 
			
		||||
    public async ValueTask<Result<UInt32>> GetADFrequency()
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, OscilloscopeAddr.AD_FREQ, this.timeout);
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddrByte(this.ep, this.taskID, OscilloscopeAddr.AD_FREQ, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to read AD frequency: {ret.Error}");
 | 
			
		||||
@@ -255,7 +255,7 @@ class Oscilloscope
 | 
			
		||||
    /// <returns>操作结果,成功返回采样幅度值,否则返回异常信息</returns>
 | 
			
		||||
    public async ValueTask<Result<byte>> GetADVpp()
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, OscilloscopeAddr.AD_VPP, this.timeout);
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddrByte(this.ep, this.taskID, OscilloscopeAddr.AD_VPP, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to read AD VPP: {ret.Error}");
 | 
			
		||||
@@ -275,7 +275,7 @@ class Oscilloscope
 | 
			
		||||
    /// <returns>操作结果,成功返回采样最大值,否则返回异常信息</returns>
 | 
			
		||||
    public async ValueTask<Result<byte>> GetADMax()
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, OscilloscopeAddr.AD_MAX, this.timeout);
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddrByte(this.ep, this.taskID, OscilloscopeAddr.AD_MAX, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to read AD max: {ret.Error}");
 | 
			
		||||
@@ -295,7 +295,7 @@ class Oscilloscope
 | 
			
		||||
    /// <returns>操作结果,成功返回采样最小值,否则返回异常信息</returns>
 | 
			
		||||
    public async ValueTask<Result<byte>> GetADMin()
 | 
			
		||||
    {
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddr(this.ep, this.taskID, OscilloscopeAddr.AD_MIN, this.timeout);
 | 
			
		||||
        var ret = await UDPClientPool.ReadAddrByte(this.ep, this.taskID, OscilloscopeAddr.AD_MIN, this.timeout);
 | 
			
		||||
        if (!ret.IsSuccessful)
 | 
			
		||||
        {
 | 
			
		||||
            logger.Error($"Failed to read AD min: {ret.Error}");
 | 
			
		||||
 
 | 
			
		||||
@@ -7,20 +7,20 @@ static class RemoteUpdaterAddr
 | 
			
		||||
{
 | 
			
		||||
    public const UInt32 Base = 0x20_00_00_00;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X00: 写Flash-读写地址——控制位 <br/>
 | 
			
		||||
    /// [31:16]: wr_sector_num <br/>
 | 
			
		||||
    /// [15: 0]: {flash_wr_en,-,-,-, start_wr_sector} <br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 WriteCtrl = Base + 0x00;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X01: 写Flash-只写地址——FIFO入口 <br/>
 | 
			
		||||
    /// [31:0]:  写比特流数据入口 <br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 WriteFIFO = Base + 0x01;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X02: 写Flash-只读地址——标志位 <br/>
 | 
			
		||||
    /// [31:24]: {-, -, -, -, -, -, -,      wr_fifo_full} <br/>
 | 
			
		||||
    /// [23:16]: {-, -, -, -, -, -, -,     wr_fifo_empty} <br/>
 | 
			
		||||
@@ -29,14 +29,14 @@ static class RemoteUpdaterAddr
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 WriteSign = Base + 0x02;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X03: 读Flash-读写地址——控制位1 <br/>
 | 
			
		||||
    /// [31:16]: rd_sector_num <br/>
 | 
			
		||||
    /// [15: 0]: {flash_rd_en,-,-,-, start_rd_sub_sector} <br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 ReadCtrl1 = Base + 0x03;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X04: 读Flash-读写地址——控制位2 <br/>
 | 
			
		||||
    /// [31:24]: {                                            } <br/>
 | 
			
		||||
    /// [23:16]: {-, -, -, -, -, -,{   bs_crc32_ok           }} <br/>
 | 
			
		||||
@@ -45,19 +45,19 @@ static class RemoteUpdaterAddr
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 ReadCtrl2 = Base + 0x04;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X05: 读Flash-只读地址——FIFO出口 <br/>
 | 
			
		||||
    /// [31:0]: 读比特流数据出口 <br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 ReadFIFO = Base + 0x05;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X06: 读Flash-只读地址——CRC校验值 <br/>
 | 
			
		||||
    /// [31:0]: CRC校验值 bs_readback_crc <br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 ReadCRC = Base + 0x06;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X07: 读Flash-只读地址——标志位 <br/>
 | 
			
		||||
    /// [31:24]: {-, -, -, -, -, -, -,         rd_fifo_afull} <br/>
 | 
			
		||||
    /// [23:16]: {-, -, -, -, -, -, -,         rd_fifo_empty} <br/>
 | 
			
		||||
@@ -66,14 +66,14 @@ static class RemoteUpdaterAddr
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 ReadSign = Base + 0x07;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X08: 热启动开关-读写地址——控制位 <br/>
 | 
			
		||||
    /// [31: 8]: hotreset_addr <br/>
 | 
			
		||||
    /// [ 7: 0]: {-, -, -, -, -, -, -,    hotreset_en} <br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const UInt32 HotResetCtrl = Base + 0x08;
 | 
			
		||||
 | 
			
		||||
    /// <summary> 
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// ADDR: 0X09: 只读地址 版本号 <br/>
 | 
			
		||||
    /// [31: 0]: FPGA_VERSION[31:0] <br/>
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -339,7 +339,7 @@ public class RemoteUpdater
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddr(this.ep, 0, RemoteUpdaterAddr.ReadCRC, this.timeout);
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddrByte(this.ep, 0, RemoteUpdaterAddr.ReadCRC, this.timeout);
 | 
			
		||||
            if (!ret.IsSuccessful) return new(ret.Error);
 | 
			
		||||
 | 
			
		||||
            var bytes = ret.Value.Options.Data;
 | 
			
		||||
@@ -543,7 +543,7 @@ public class RemoteUpdater
 | 
			
		||||
        logger.Trace("Clear udp data finished");
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddr(this.ep, 0, RemoteUpdaterAddr.Version, this.timeout);
 | 
			
		||||
            var ret = await UDPClientPool.ReadAddrByte(this.ep, 0, RemoteUpdaterAddr.Version, this.timeout);
 | 
			
		||||
            if (!ret.IsSuccessful) return new(ret.Error);
 | 
			
		||||
 | 
			
		||||
            var retData = ret.Value.Options.Data;
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ public class HttpHdmiVideoStreamService : BackgroundService
 | 
			
		||||
    public override async Task StartAsync(CancellationToken cancellationToken)
 | 
			
		||||
    {
 | 
			
		||||
        _httpListener = new HttpListener();
 | 
			
		||||
        _httpListener.Prefixes.Add($"http://*:{_serverPort}/");
 | 
			
		||||
        _httpListener.Prefixes.Add($"http://{Global.localhost}:{_serverPort}/");
 | 
			
		||||
        _httpListener.Start();
 | 
			
		||||
        logger.Info($"HDMI Video Stream Service started on port {_serverPort}");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -41,7 +41,7 @@ public class ProgressReporter : ProgressInfo, IProgress<int>
 | 
			
		||||
    private ProgressStatus _status = ProgressStatus.Pending;
 | 
			
		||||
    private string _errorMessage;
 | 
			
		||||
 | 
			
		||||
    public string TaskId { get; set; } = new Guid().ToString();
 | 
			
		||||
    public string TaskId { get; set; } = Guid.NewGuid().ToString();
 | 
			
		||||
    public int ProgressPercent => _progress * 100 / MaxProgress;
 | 
			
		||||
    public ProgressStatus Status => _status;
 | 
			
		||||
    public string ErrorMessage => _errorMessage;
 | 
			
		||||
 
 | 
			
		||||
@@ -223,22 +223,28 @@ public class UDPClientPool
 | 
			
		||||
    /// <param name="endPoint">IP端点(IP地址与端口)</param>
 | 
			
		||||
    /// <param name="taskID">任务ID</param>
 | 
			
		||||
    /// <param name="devAddr">设备地址</param>
 | 
			
		||||
    /// <param name="dataLength">数据长度(0~255)</param>
 | 
			
		||||
    /// <param name="timeout">超时时间(毫秒)</param>
 | 
			
		||||
    /// <returns>读取结果,包含接收到的数据包</returns>
 | 
			
		||||
    public static async ValueTask<Result<RecvDataPackage>> ReadAddr(
 | 
			
		||||
            IPEndPoint endPoint, int taskID, uint devAddr, int timeout = 1000)
 | 
			
		||||
            IPEndPoint endPoint, int taskID, uint devAddr, int dataLength, int timeout = 1000)
 | 
			
		||||
    {
 | 
			
		||||
        if (dataLength <= 0)
 | 
			
		||||
            return new(new ArgumentException("Data length must be greater than 0"));
 | 
			
		||||
 | 
			
		||||
        if (dataLength > 255)
 | 
			
		||||
            return new(new ArgumentException("Data length must be less than or equal to 255"));
 | 
			
		||||
 | 
			
		||||
        var ret = false;
 | 
			
		||||
        var opts = new SendAddrPackOptions()
 | 
			
		||||
        {
 | 
			
		||||
            BurstType = BurstType.FixedBurst,
 | 
			
		||||
            BurstLength = 0,
 | 
			
		||||
            BurstLength = ((byte)(dataLength - 1)),
 | 
			
		||||
            CommandID = Convert.ToByte(taskID),
 | 
			
		||||
            Address = devAddr,
 | 
			
		||||
            IsWrite = false,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // Read Register
 | 
			
		||||
        ret = await UDPClientPool.SendAddrPackAsync(endPoint, new SendAddrPackage(opts));
 | 
			
		||||
        if (!ret) return new(new Exception("Send Address Package Failed!"));
 | 
			
		||||
@@ -260,6 +266,20 @@ public class UDPClientPool
 | 
			
		||||
        return retPack;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 读取设备地址数据
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="endPoint">IP端点(IP地址与端口)</param>
 | 
			
		||||
    /// <param name="taskID">任务ID</param>
 | 
			
		||||
    /// <param name="devAddr">设备地址</param>
 | 
			
		||||
    /// <param name="timeout">超时时间(毫秒)</param>
 | 
			
		||||
    /// <returns>读取结果,包含接收到的数据包</returns>
 | 
			
		||||
    public static async ValueTask<Result<RecvDataPackage>> ReadAddrByte(
 | 
			
		||||
            IPEndPoint endPoint, int taskID, uint devAddr, int timeout = 1000)
 | 
			
		||||
    {
 | 
			
		||||
        return await ReadAddr(endPoint, taskID, devAddr, 0, timeout);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 读取设备地址数据并校验结果
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -271,11 +291,11 @@ public class UDPClientPool
 | 
			
		||||
    /// <param name="timeout">超时时间(毫秒)</param>
 | 
			
		||||
    /// <returns>校验结果,true表示数据匹配期望值</returns>
 | 
			
		||||
    public static async ValueTask<Result<bool>> ReadAddr(
 | 
			
		||||
            IPEndPoint endPoint, int taskID, uint devAddr, UInt32 result, UInt32 resultMask, int timeout = 1000)
 | 
			
		||||
                IPEndPoint endPoint, int taskID, uint devAddr, UInt32 result, UInt32 resultMask, int timeout = 1000)
 | 
			
		||||
    {
 | 
			
		||||
        var address = endPoint.Address.ToString();
 | 
			
		||||
 | 
			
		||||
        var ret = await ReadAddr(endPoint, taskID, devAddr, timeout);
 | 
			
		||||
        var ret = await ReadAddrByte(endPoint, taskID, devAddr, timeout);
 | 
			
		||||
        if (!ret.IsSuccessful) return new(ret.Error);
 | 
			
		||||
        if (!ret.Value.IsSuccessful)
 | 
			
		||||
            return new(new Exception($"Read device {address} address {devAddr} failed"));
 | 
			
		||||
@@ -324,7 +344,7 @@ public class UDPClientPool
 | 
			
		||||
            await Task.Delay(waittime);
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var ret = await ReadAddr(endPoint, taskID, devAddr, Convert.ToInt32(timeleft.TotalMilliseconds));
 | 
			
		||||
                var ret = await ReadAddrByte(endPoint, taskID, devAddr, Convert.ToInt32(timeleft.TotalMilliseconds));
 | 
			
		||||
                if (!ret.IsSuccessful) return new(ret.Error);
 | 
			
		||||
                if (!ret.Value.IsSuccessful)
 | 
			
		||||
                    return new(new Exception($"Read device {address} address {devAddr} failed"));
 | 
			
		||||
@@ -555,7 +575,7 @@ public class UDPClientPool
 | 
			
		||||
        var resultData = new List<byte>();
 | 
			
		||||
        for (int i = 0; i < length; i++)
 | 
			
		||||
        {
 | 
			
		||||
            var ret = await ReadAddr(endPoint, taskID, addr[i], timeout);
 | 
			
		||||
            var ret = await ReadAddrByte(endPoint, taskID, addr[i], timeout);
 | 
			
		||||
            if (!ret.IsSuccessful)
 | 
			
		||||
            {
 | 
			
		||||
                logger.Error($"ReadAddrSeq failed at index {i}: {ret.Error}");
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										520
									
								
								src/APIClient.ts
									
									
									
									
									
								
							
							
						
						
									
										520
									
								
								src/APIClient.ts
									
									
									
									
									
								
							@@ -185,12 +185,8 @@ export class VideoStreamClient {
 | 
			
		||||
        return Promise.resolve<any>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取 HTTP 视频流信息
 | 
			
		||||
     * @return 流信息
 | 
			
		||||
     */
 | 
			
		||||
    getStreamInfo( cancelToken?: CancelToken): Promise<StreamInfoResult> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/StreamInfo";
 | 
			
		||||
    myEndpoint( cancelToken?: CancelToken): Promise<any> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/MyEndpoint";
 | 
			
		||||
        url_ = url_.replace(/[?&]$/, "");
 | 
			
		||||
 | 
			
		||||
        let options_: AxiosRequestConfig = {
 | 
			
		||||
@@ -209,208 +205,11 @@ export class VideoStreamClient {
 | 
			
		||||
                throw _error;
 | 
			
		||||
            }
 | 
			
		||||
        }).then((_response: AxiosResponse) => {
 | 
			
		||||
            return this.processGetStreamInfo(_response);
 | 
			
		||||
            return this.processMyEndpoint(_response);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected processGetStreamInfo(response: AxiosResponse): Promise<StreamInfoResult> {
 | 
			
		||||
        const status = response.status;
 | 
			
		||||
        let _headers: any = {};
 | 
			
		||||
        if (response.headers && typeof response.headers === "object") {
 | 
			
		||||
            for (const k in response.headers) {
 | 
			
		||||
                if (response.headers.hasOwnProperty(k)) {
 | 
			
		||||
                    _headers[k] = response.headers[k];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (status === 200) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result200: any = null;
 | 
			
		||||
            let resultData200  = _responseText;
 | 
			
		||||
            result200 = StreamInfoResult.fromJS(resultData200);
 | 
			
		||||
            return Promise.resolve<StreamInfoResult>(result200);
 | 
			
		||||
 | 
			
		||||
        } else if (status === 500) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result500: any = null;
 | 
			
		||||
            let resultData500  = _responseText;
 | 
			
		||||
            result500 = Exception.fromJS(resultData500);
 | 
			
		||||
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);
 | 
			
		||||
 | 
			
		||||
        } else if (status !== 200 && status !== 204) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
 | 
			
		||||
        }
 | 
			
		||||
        return Promise.resolve<StreamInfoResult>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 配置摄像头连接参数
 | 
			
		||||
     * @param config 摄像头配置
 | 
			
		||||
     * @return 配置结果
 | 
			
		||||
     */
 | 
			
		||||
    configureCamera(config: CameraConfigRequest, cancelToken?: CancelToken): Promise<any> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/ConfigureCamera";
 | 
			
		||||
        url_ = url_.replace(/[?&]$/, "");
 | 
			
		||||
 | 
			
		||||
        const content_ = JSON.stringify(config);
 | 
			
		||||
 | 
			
		||||
        let options_: AxiosRequestConfig = {
 | 
			
		||||
            data: content_,
 | 
			
		||||
            method: "POST",
 | 
			
		||||
            url: url_,
 | 
			
		||||
            headers: {
 | 
			
		||||
                "Content-Type": "application/json",
 | 
			
		||||
                "Accept": "application/json"
 | 
			
		||||
            },
 | 
			
		||||
            cancelToken
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        return this.instance.request(options_).catch((_error: any) => {
 | 
			
		||||
            if (isAxiosError(_error) && _error.response) {
 | 
			
		||||
                return _error.response;
 | 
			
		||||
            } else {
 | 
			
		||||
                throw _error;
 | 
			
		||||
            }
 | 
			
		||||
        }).then((_response: AxiosResponse) => {
 | 
			
		||||
            return this.processConfigureCamera(_response);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected processConfigureCamera(response: AxiosResponse): Promise<any> {
 | 
			
		||||
        const status = response.status;
 | 
			
		||||
        let _headers: any = {};
 | 
			
		||||
        if (response.headers && typeof response.headers === "object") {
 | 
			
		||||
            for (const k in response.headers) {
 | 
			
		||||
                if (response.headers.hasOwnProperty(k)) {
 | 
			
		||||
                    _headers[k] = response.headers[k];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (status === 200) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result200: any = null;
 | 
			
		||||
            let resultData200  = _responseText;
 | 
			
		||||
                result200 = resultData200 !== undefined ? resultData200 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return Promise.resolve<any>(result200);
 | 
			
		||||
 | 
			
		||||
        } else if (status === 400) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result400: any = null;
 | 
			
		||||
            let resultData400  = _responseText;
 | 
			
		||||
                result400 = resultData400 !== undefined ? resultData400 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);
 | 
			
		||||
 | 
			
		||||
        } else if (status === 500) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result500: any = null;
 | 
			
		||||
            let resultData500  = _responseText;
 | 
			
		||||
            result500 = Exception.fromJS(resultData500);
 | 
			
		||||
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);
 | 
			
		||||
 | 
			
		||||
        } else if (status !== 200 && status !== 204) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
 | 
			
		||||
        }
 | 
			
		||||
        return Promise.resolve<any>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取当前摄像头配置
 | 
			
		||||
     * @return 摄像头配置信息
 | 
			
		||||
     */
 | 
			
		||||
    getCameraConfig( cancelToken?: CancelToken): Promise<any> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/CameraConfig";
 | 
			
		||||
        url_ = url_.replace(/[?&]$/, "");
 | 
			
		||||
 | 
			
		||||
        let options_: AxiosRequestConfig = {
 | 
			
		||||
            method: "GET",
 | 
			
		||||
            url: url_,
 | 
			
		||||
            headers: {
 | 
			
		||||
                "Accept": "application/json"
 | 
			
		||||
            },
 | 
			
		||||
            cancelToken
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        return this.instance.request(options_).catch((_error: any) => {
 | 
			
		||||
            if (isAxiosError(_error) && _error.response) {
 | 
			
		||||
                return _error.response;
 | 
			
		||||
            } else {
 | 
			
		||||
                throw _error;
 | 
			
		||||
            }
 | 
			
		||||
        }).then((_response: AxiosResponse) => {
 | 
			
		||||
            return this.processGetCameraConfig(_response);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected processGetCameraConfig(response: AxiosResponse): Promise<any> {
 | 
			
		||||
        const status = response.status;
 | 
			
		||||
        let _headers: any = {};
 | 
			
		||||
        if (response.headers && typeof response.headers === "object") {
 | 
			
		||||
            for (const k in response.headers) {
 | 
			
		||||
                if (response.headers.hasOwnProperty(k)) {
 | 
			
		||||
                    _headers[k] = response.headers[k];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (status === 200) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result200: any = null;
 | 
			
		||||
            let resultData200  = _responseText;
 | 
			
		||||
                result200 = resultData200 !== undefined ? resultData200 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return Promise.resolve<any>(result200);
 | 
			
		||||
 | 
			
		||||
        } else if (status === 500) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result500: any = null;
 | 
			
		||||
            let resultData500  = _responseText;
 | 
			
		||||
            result500 = Exception.fromJS(resultData500);
 | 
			
		||||
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);
 | 
			
		||||
 | 
			
		||||
        } else if (status !== 200 && status !== 204) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
 | 
			
		||||
        }
 | 
			
		||||
        return Promise.resolve<any>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 控制 HTTP 视频流服务开关
 | 
			
		||||
     * @param enabled (optional) 是否启用服务
 | 
			
		||||
     * @return 操作结果
 | 
			
		||||
     */
 | 
			
		||||
    setEnabled(enabled: boolean | undefined, cancelToken?: CancelToken): Promise<any> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/SetEnabled?";
 | 
			
		||||
        if (enabled === null)
 | 
			
		||||
            throw new Error("The parameter 'enabled' cannot be null.");
 | 
			
		||||
        else if (enabled !== undefined)
 | 
			
		||||
            url_ += "enabled=" + encodeURIComponent("" + enabled) + "&";
 | 
			
		||||
        url_ = url_.replace(/[?&]$/, "");
 | 
			
		||||
 | 
			
		||||
        let options_: AxiosRequestConfig = {
 | 
			
		||||
            method: "POST",
 | 
			
		||||
            url: url_,
 | 
			
		||||
            headers: {
 | 
			
		||||
                "Accept": "application/json"
 | 
			
		||||
            },
 | 
			
		||||
            cancelToken
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        return this.instance.request(options_).catch((_error: any) => {
 | 
			
		||||
            if (isAxiosError(_error) && _error.response) {
 | 
			
		||||
                return _error.response;
 | 
			
		||||
            } else {
 | 
			
		||||
                throw _error;
 | 
			
		||||
            }
 | 
			
		||||
        }).then((_response: AxiosResponse) => {
 | 
			
		||||
            return this.processSetEnabled(_response);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected processSetEnabled(response: AxiosResponse): Promise<any> {
 | 
			
		||||
    protected processMyEndpoint(response: AxiosResponse): Promise<any> {
 | 
			
		||||
        const status = response.status;
 | 
			
		||||
        let _headers: any = {};
 | 
			
		||||
        if (response.headers && typeof response.headers === "object") {
 | 
			
		||||
@@ -502,6 +301,59 @@ export class VideoStreamClient {
 | 
			
		||||
        return Promise.resolve<boolean>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    disableHdmiTransmission( cancelToken?: CancelToken): Promise<FileResponse | null> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/DisableTransmission";
 | 
			
		||||
        url_ = url_.replace(/[?&]$/, "");
 | 
			
		||||
 | 
			
		||||
        let options_: AxiosRequestConfig = {
 | 
			
		||||
            responseType: "blob",
 | 
			
		||||
            method: "POST",
 | 
			
		||||
            url: url_,
 | 
			
		||||
            headers: {
 | 
			
		||||
                "Accept": "application/octet-stream"
 | 
			
		||||
            },
 | 
			
		||||
            cancelToken
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        return this.instance.request(options_).catch((_error: any) => {
 | 
			
		||||
            if (isAxiosError(_error) && _error.response) {
 | 
			
		||||
                return _error.response;
 | 
			
		||||
            } else {
 | 
			
		||||
                throw _error;
 | 
			
		||||
            }
 | 
			
		||||
        }).then((_response: AxiosResponse) => {
 | 
			
		||||
            return this.processDisableHdmiTransmission(_response);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected processDisableHdmiTransmission(response: AxiosResponse): Promise<FileResponse | null> {
 | 
			
		||||
        const status = response.status;
 | 
			
		||||
        let _headers: any = {};
 | 
			
		||||
        if (response.headers && typeof response.headers === "object") {
 | 
			
		||||
            for (const k in response.headers) {
 | 
			
		||||
                if (response.headers.hasOwnProperty(k)) {
 | 
			
		||||
                    _headers[k] = response.headers[k];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (status === 200 || status === 206) {
 | 
			
		||||
            const contentDisposition = response.headers ? response.headers["content-disposition"] : undefined;
 | 
			
		||||
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
 | 
			
		||||
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
 | 
			
		||||
            if (fileName) {
 | 
			
		||||
                fileName = decodeURIComponent(fileName);
 | 
			
		||||
            } else {
 | 
			
		||||
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
 | 
			
		||||
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
 | 
			
		||||
            }
 | 
			
		||||
            return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
 | 
			
		||||
        } else if (status !== 200 && status !== 204) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
 | 
			
		||||
        }
 | 
			
		||||
        return Promise.resolve<FileResponse | null>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 设置视频流分辨率
 | 
			
		||||
     * @param request 分辨率配置请求
 | 
			
		||||
@@ -576,67 +428,6 @@ export class VideoStreamClient {
 | 
			
		||||
        return Promise.resolve<any>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取当前分辨率
 | 
			
		||||
     * @return 当前分辨率信息
 | 
			
		||||
     */
 | 
			
		||||
    getCurrentResolution( cancelToken?: CancelToken): Promise<any> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/Resolution";
 | 
			
		||||
        url_ = url_.replace(/[?&]$/, "");
 | 
			
		||||
 | 
			
		||||
        let options_: AxiosRequestConfig = {
 | 
			
		||||
            method: "GET",
 | 
			
		||||
            url: url_,
 | 
			
		||||
            headers: {
 | 
			
		||||
                "Accept": "application/json"
 | 
			
		||||
            },
 | 
			
		||||
            cancelToken
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        return this.instance.request(options_).catch((_error: any) => {
 | 
			
		||||
            if (isAxiosError(_error) && _error.response) {
 | 
			
		||||
                return _error.response;
 | 
			
		||||
            } else {
 | 
			
		||||
                throw _error;
 | 
			
		||||
            }
 | 
			
		||||
        }).then((_response: AxiosResponse) => {
 | 
			
		||||
            return this.processGetCurrentResolution(_response);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected processGetCurrentResolution(response: AxiosResponse): Promise<any> {
 | 
			
		||||
        const status = response.status;
 | 
			
		||||
        let _headers: any = {};
 | 
			
		||||
        if (response.headers && typeof response.headers === "object") {
 | 
			
		||||
            for (const k in response.headers) {
 | 
			
		||||
                if (response.headers.hasOwnProperty(k)) {
 | 
			
		||||
                    _headers[k] = response.headers[k];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (status === 200) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result200: any = null;
 | 
			
		||||
            let resultData200  = _responseText;
 | 
			
		||||
                result200 = resultData200 !== undefined ? resultData200 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return Promise.resolve<any>(result200);
 | 
			
		||||
 | 
			
		||||
        } else if (status === 500) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result500: any = null;
 | 
			
		||||
            let resultData500  = _responseText;
 | 
			
		||||
                result500 = resultData500 !== undefined ? resultData500 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);
 | 
			
		||||
 | 
			
		||||
        } else if (status !== 200 && status !== 204) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
 | 
			
		||||
        }
 | 
			
		||||
        return Promise.resolve<any>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取支持的分辨率列表
 | 
			
		||||
     * @return 支持的分辨率列表
 | 
			
		||||
@@ -835,75 +626,6 @@ export class VideoStreamClient {
 | 
			
		||||
        }
 | 
			
		||||
        return Promise.resolve<any>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 执行一次自动对焦 (GET方式)
 | 
			
		||||
     * @return 对焦结果
 | 
			
		||||
     */
 | 
			
		||||
    focus( cancelToken?: CancelToken): Promise<any> {
 | 
			
		||||
        let url_ = this.baseUrl + "/api/VideoStream/Focus";
 | 
			
		||||
        url_ = url_.replace(/[?&]$/, "");
 | 
			
		||||
 | 
			
		||||
        let options_: AxiosRequestConfig = {
 | 
			
		||||
            method: "GET",
 | 
			
		||||
            url: url_,
 | 
			
		||||
            headers: {
 | 
			
		||||
                "Accept": "application/json"
 | 
			
		||||
            },
 | 
			
		||||
            cancelToken
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        return this.instance.request(options_).catch((_error: any) => {
 | 
			
		||||
            if (isAxiosError(_error) && _error.response) {
 | 
			
		||||
                return _error.response;
 | 
			
		||||
            } else {
 | 
			
		||||
                throw _error;
 | 
			
		||||
            }
 | 
			
		||||
        }).then((_response: AxiosResponse) => {
 | 
			
		||||
            return this.processFocus(_response);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected processFocus(response: AxiosResponse): Promise<any> {
 | 
			
		||||
        const status = response.status;
 | 
			
		||||
        let _headers: any = {};
 | 
			
		||||
        if (response.headers && typeof response.headers === "object") {
 | 
			
		||||
            for (const k in response.headers) {
 | 
			
		||||
                if (response.headers.hasOwnProperty(k)) {
 | 
			
		||||
                    _headers[k] = response.headers[k];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (status === 200) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result200: any = null;
 | 
			
		||||
            let resultData200  = _responseText;
 | 
			
		||||
                result200 = resultData200 !== undefined ? resultData200 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return Promise.resolve<any>(result200);
 | 
			
		||||
 | 
			
		||||
        } else if (status === 400) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result400: any = null;
 | 
			
		||||
            let resultData400  = _responseText;
 | 
			
		||||
                result400 = resultData400 !== undefined ? resultData400 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);
 | 
			
		||||
 | 
			
		||||
        } else if (status === 500) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            let result500: any = null;
 | 
			
		||||
            let resultData500  = _responseText;
 | 
			
		||||
                result500 = resultData500 !== undefined ? resultData500 : <any>null;
 | 
			
		||||
    
 | 
			
		||||
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);
 | 
			
		||||
 | 
			
		||||
        } else if (status !== 200 && status !== 204) {
 | 
			
		||||
            const _responseText = response.data;
 | 
			
		||||
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
 | 
			
		||||
        }
 | 
			
		||||
        return Promise.resolve<any>(null as any);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class BsdlParserClient {
 | 
			
		||||
@@ -7253,134 +6975,6 @@ export interface IException {
 | 
			
		||||
    stackTrace?: string | undefined;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 视频流信息结构体 */
 | 
			
		||||
export class StreamInfoResult implements IStreamInfoResult {
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    frameRate!: number;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    frameWidth!: number;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    frameHeight!: number;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    format!: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    htmlUrl!: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    mjpegUrl!: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    snapshotUrl!: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    usbCameraUrl!: string;
 | 
			
		||||
 | 
			
		||||
    constructor(data?: IStreamInfoResult) {
 | 
			
		||||
        if (data) {
 | 
			
		||||
            for (var property in data) {
 | 
			
		||||
                if (data.hasOwnProperty(property))
 | 
			
		||||
                    (<any>this)[property] = (<any>data)[property];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    init(_data?: any) {
 | 
			
		||||
        if (_data) {
 | 
			
		||||
            this.frameRate = _data["frameRate"];
 | 
			
		||||
            this.frameWidth = _data["frameWidth"];
 | 
			
		||||
            this.frameHeight = _data["frameHeight"];
 | 
			
		||||
            this.format = _data["format"];
 | 
			
		||||
            this.htmlUrl = _data["htmlUrl"];
 | 
			
		||||
            this.mjpegUrl = _data["mjpegUrl"];
 | 
			
		||||
            this.snapshotUrl = _data["snapshotUrl"];
 | 
			
		||||
            this.usbCameraUrl = _data["usbCameraUrl"];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static fromJS(data: any): StreamInfoResult {
 | 
			
		||||
        data = typeof data === 'object' ? data : {};
 | 
			
		||||
        let result = new StreamInfoResult();
 | 
			
		||||
        result.init(data);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    toJSON(data?: any) {
 | 
			
		||||
        data = typeof data === 'object' ? data : {};
 | 
			
		||||
        data["frameRate"] = this.frameRate;
 | 
			
		||||
        data["frameWidth"] = this.frameWidth;
 | 
			
		||||
        data["frameHeight"] = this.frameHeight;
 | 
			
		||||
        data["format"] = this.format;
 | 
			
		||||
        data["htmlUrl"] = this.htmlUrl;
 | 
			
		||||
        data["mjpegUrl"] = this.mjpegUrl;
 | 
			
		||||
        data["snapshotUrl"] = this.snapshotUrl;
 | 
			
		||||
        data["usbCameraUrl"] = this.usbCameraUrl;
 | 
			
		||||
        return data;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 视频流信息结构体 */
 | 
			
		||||
export interface IStreamInfoResult {
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    frameRate: number;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    frameWidth: number;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    frameHeight: number;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    format: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    htmlUrl: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    mjpegUrl: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    snapshotUrl: string;
 | 
			
		||||
    /** TODO: */
 | 
			
		||||
    usbCameraUrl: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 摄像头配置请求模型 */
 | 
			
		||||
export class CameraConfigRequest implements ICameraConfigRequest {
 | 
			
		||||
    /** 摄像头地址 */
 | 
			
		||||
    address!: string;
 | 
			
		||||
    /** 摄像头端口 */
 | 
			
		||||
    port!: number;
 | 
			
		||||
 | 
			
		||||
    constructor(data?: ICameraConfigRequest) {
 | 
			
		||||
        if (data) {
 | 
			
		||||
            for (var property in data) {
 | 
			
		||||
                if (data.hasOwnProperty(property))
 | 
			
		||||
                    (<any>this)[property] = (<any>data)[property];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    init(_data?: any) {
 | 
			
		||||
        if (_data) {
 | 
			
		||||
            this.address = _data["address"];
 | 
			
		||||
            this.port = _data["port"];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static fromJS(data: any): CameraConfigRequest {
 | 
			
		||||
        data = typeof data === 'object' ? data : {};
 | 
			
		||||
        let result = new CameraConfigRequest();
 | 
			
		||||
        result.init(data);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    toJSON(data?: any) {
 | 
			
		||||
        data = typeof data === 'object' ? data : {};
 | 
			
		||||
        data["address"] = this.address;
 | 
			
		||||
        data["port"] = this.port;
 | 
			
		||||
        return data;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 摄像头配置请求模型 */
 | 
			
		||||
export interface ICameraConfigRequest {
 | 
			
		||||
    /** 摄像头地址 */
 | 
			
		||||
    address: string;
 | 
			
		||||
    /** 摄像头端口 */
 | 
			
		||||
    port: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 分辨率配置请求模型 */
 | 
			
		||||
export class ResolutionConfigRequest implements IResolutionConfigRequest {
 | 
			
		||||
    /** 宽度 */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							@@ -1,10 +0,0 @@
 | 
			
		||||
import './assets/main.css'
 | 
			
		||||
 | 
			
		||||
import { createApp } from 'vue'
 | 
			
		||||
import { createPinia } from 'pinia'
 | 
			
		||||
 | 
			
		||||
import App from '@/App.vue'
 | 
			
		||||
import router from './router'
 | 
			
		||||
 | 
			
		||||
const app = createApp(App).use(router).use(createPinia()).mount('#app')
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user