fix: 修改camera寄存器地址,同时修改前端逻辑

This commit is contained in:
SikongJueluo 2025-07-11 13:22:42 +08:00
parent d83bc250bd
commit bdffba7576
No known key found for this signature in database
3 changed files with 36 additions and 14 deletions

View File

@ -162,13 +162,7 @@ public class VideoStreamController : ControllerBase
logger.Info("获取摄像头配置"); logger.Info("获取摄像头配置");
var cameraStatus = _videoStreamService.GetCameraStatus(); var cameraStatus = _videoStreamService.GetCameraStatus();
return TypedResults.Ok(new return TypedResults.Ok(cameraStatus);
{
address = _videoStreamService.CameraAddress,
port = _videoStreamService.CameraPort,
isConfigured = cameraStatus.GetType().GetProperty("IsConfigured")?.GetValue(cameraStatus),
connectionString = $"{_videoStreamService.CameraAddress}:{_videoStreamService.CameraPort}"
});
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -7,9 +7,9 @@ static class CameraAddr
{ {
public const UInt32 BASE = 0x7000_0000; public const UInt32 BASE = 0x7000_0000;
public const UInt32 STORE_ADDR = BASE + 12; public const UInt32 STORE_ADDR = BASE + 0x12;
public const UInt32 STORE_NUM = BASE + 13; public const UInt32 STORE_NUM = BASE + 0x13;
public const UInt32 CAPTURE_ON = BASE + 14; public const UInt32 CAPTURE_ON = BASE + 0x14;
} }
class Camera class Camera

View File

@ -90,6 +90,15 @@
<!-- 操作按钮 --> <!-- 操作按钮 -->
<div class="card-actions justify-end mt-4"> <div class="card-actions justify-end mt-4">
<button
class="btn btn-outline btn-primary"
@click="configCamera"
:dsiabled="configing"
>
<RefreshCw v-if="configing" class="animate-spin h-4 w-4 mr-2" />
<RefreshCw v-else class="h-4 w-4 mr-2" />
{{ configing ? "配置中..." : "配置摄像头" }}
</button>
<button <button
class="btn btn-outline btn-primary" class="btn btn-outline btn-primary"
@click="refreshStatus" @click="refreshStatus"
@ -307,6 +316,7 @@ const eqps = useEquipments();
// //
const loading = ref(false); const loading = ref(false);
const configing = ref(false);
const testing = ref(false); const testing = ref(false);
const isPlaying = ref(false); const isPlaying = ref(false);
const hasVideoError = ref(false); const hasVideoError = ref(false);
@ -425,9 +435,8 @@ const takeSnapshot = async () => {
} }
}; };
// async function configCamera() {
const refreshStatus = async () => { configing.value = true;
loading.value = true;
try { try {
// addLog("info", "..."); // addLog("info", "...");
// const boardconfig = new CameraConfigRequest({ // const boardconfig = new CameraConfigRequest({
@ -436,6 +445,24 @@ const refreshStatus = async () => {
// }); // });
// await videoClient.configureCamera(boardconfig); // await videoClient.configureCamera(boardconfig);
const status = await videoClient.getCameraConfig();
if (status.isConfigured) {
addLog("success", "摄像头已配置并初始化");
} else {
addLog("error", "摄像头配置失败,请检查地址和端口");
}
} catch (error) {
addLog("error", `摄像头配置失败: ${error}`);
console.error("摄像头配置失败:", error);
} finally {
configing.value = false;
}
}
//
const refreshStatus = async () => {
loading.value = true;
try {
addLog("info", "正在获取服务状态..."); addLog("info", "正在获取服务状态...");
// 使API // 使API
@ -559,7 +586,8 @@ onUnmounted(() => {
/* 自定义样式 */ /* 自定义样式 */
.stats { .stats {
background-color: var(--b1); background-color: var(--b1);
color: var(--bc); /* 添加适配文本颜色 */ color: var(--bc);
/* 添加适配文本颜色 */
} }
code { code {