diff --git a/server/src/Peripherals/SevenDigitalTubesClient.cs b/server/src/Peripherals/SevenDigitalTubesClient.cs index 733e8a6..7028c00 100644 --- a/server/src/Peripherals/SevenDigitalTubesClient.cs +++ b/server/src/Peripherals/SevenDigitalTubesClient.cs @@ -6,7 +6,7 @@ namespace Peripherals.SevenDigitalTubesClient; static class SevenDigitalTubesAddr { - public const UInt32 BASE = 0x0000_0000; + public const UInt32 BASE = 0xB000_0000; } public class SevenDigitalTubesCtrl diff --git a/src/components/equipments/SevenSegmentDisplayUltimate.vue b/src/components/equipments/SevenSegmentDisplayUltimate.vue index 681dba4..98b4343 100644 --- a/src/components/equipments/SevenSegmentDisplayUltimate.vue +++ b/src/components/equipments/SevenSegmentDisplayUltimate.vue @@ -174,17 +174,18 @@ function isSegmentActive(segmentId: keyof typeof SEGMENT_BITS): boolean { // SignalR数字孪生集成 // ============================================================================ -const { - sevenSegmentDisplaySetOnOff, - sevenSegmentDisplayData, - sevenSegmentDisplaySetFrequency, -} = useEquipments(); +const eqps = useEquipments(); async function initDigitalTwin() { - if (!props.enableDigitalTwin || !props.digitalTwinNum) return; + if ( + !props.enableDigitalTwin || + props.digitalTwinNum < 0 || + props.digitalTwinNum > 31 + ) + return; try { - sevenSegmentDisplaySetOnOff(props.enableDigitalTwin); + eqps.sevenSegmentDisplaySetOnOff(props.enableDigitalTwin); console.log( `Digital twin initialized for address: ${props.digitalTwinNum}`, @@ -195,16 +196,16 @@ async function initDigitalTwin() { } watch( - () => [sevenSegmentDisplayData], + () => [eqps.sevenSegmentDisplayData], () => { if ( - !sevenSegmentDisplayData || + !eqps.sevenSegmentDisplayData || props.digitalTwinNum < 0 || props.digitalTwinNum > 31 ) return; - handleDigitalTwinData(sevenSegmentDisplayData[props.digitalTwinNum]); + handleDigitalTwinData(eqps.sevenSegmentDisplayData[props.digitalTwinNum]); }, ); @@ -253,7 +254,7 @@ function startAfterglow(byte: number) { } function cleanupDigitalTwin() { - sevenSegmentDisplaySetOnOff(false); + eqps.sevenSegmentDisplaySetOnOff(false); } // ============================================================================ @@ -349,7 +350,7 @@ onUnmounted(() => { // 监听模式切换 watch( - () => [props.enableDigitalTwin, props.digitalTwinNum], + () => [props.enableDigitalTwin], async () => { // 清理旧模式 cleanupDigitalTwin(); @@ -366,7 +367,6 @@ watch( updateConstraintStates(); } }, - { immediate: false }, ); diff --git a/src/stores/equipments.ts b/src/stores/equipments.ts index ae95632..09ad5d3 100644 --- a/src/stores/equipments.ts +++ b/src/stores/equipments.ts @@ -12,7 +12,7 @@ import { toFileParameterOrUndefined, } from "@/utils/Common"; import { AuthManager } from "@/utils/AuthManager"; -import { HubConnection } from "@microsoft/signalr"; +import { HubConnection, HubConnectionState } from "@microsoft/signalr"; import { getHubProxyFactory, getReceiverRegister, @@ -220,7 +220,6 @@ export const useEquipments = defineStore("equipments", () => { async function matrixKeypadSetKeyStates(keyStates: boolean[]) { const release = await matrixKeypadClientMutex.acquire(); - console.log("set Key !!!!!!!!!!!!"); try { const matrixKeypadClient = AuthManager.createAuthenticatedMatrixKeyClient(); @@ -241,9 +240,9 @@ export const useEquipments = defineStore("equipments", () => { async function matrixKeypadEnable(enable: boolean) { const release = await matrixKeypadClientMutex.acquire(); try { + const matrixKeypadClient = + AuthManager.createAuthenticatedMatrixKeyClient(); if (enable) { - const matrixKeypadClient = - AuthManager.createAuthenticatedMatrixKeyClient(); const resp = await matrixKeypadClient.enabelMatrixKey( boardAddr.value, boardPort.value, @@ -251,8 +250,6 @@ export const useEquipments = defineStore("equipments", () => { enableMatrixKey.value = resp; return resp; } else { - const matrixKeypadClient = - AuthManager.createAuthenticatedMatrixKeyClient(); const resp = await matrixKeypadClient.disableMatrixKey( boardAddr.value, boardPort.value, @@ -305,7 +302,8 @@ export const useEquipments = defineStore("equipments", () => { async function sevenSegmentDisplaySetOnOff(enable: boolean) { if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value) return; - await sevenSegmentDisplayHub.value.start(); + if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected) + await sevenSegmentDisplayHub.value.start(); if (enable) { await sevenSegmentDisplayHubProxy.value.startScan(); @@ -317,7 +315,8 @@ export const useEquipments = defineStore("equipments", () => { async function sevenSegmentDisplaySetFrequency(frequency: number) { if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value) return; - await sevenSegmentDisplayHub.value.start(); + if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected) + await sevenSegmentDisplayHub.value.start(); await sevenSegmentDisplayHubProxy.value.setFrequency(frequency); } @@ -325,7 +324,8 @@ export const useEquipments = defineStore("equipments", () => { async function sevenSegmentDisplayGetStatus() { if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value) return; - await sevenSegmentDisplayHub.value.start(); + if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected) + await sevenSegmentDisplayHub.value.start(); return await sevenSegmentDisplayHubProxy.value.getStatus(); } @@ -338,7 +338,7 @@ export const useEquipments = defineStore("equipments", () => { onMounted(async () => { // 每次挂载都重新创建连接 sevenSegmentDisplayHub.value = - AuthManager.createAuthenticatedJtagHubConnection(); + AuthManager.createAuthenticatedDigitalTubesHubConnection(); sevenSegmentDisplayHubProxy.value = getHubProxyFactory( "IDigitalTubesHub", ).createHubProxy(sevenSegmentDisplayHub.value);