fix: 前后端修复七段数码管无法正常工作的问题

This commit is contained in:
SikongJueluo 2025-08-16 13:05:01 +08:00
parent 0a1e0982c2
commit 9bd3fb29e3
No known key found for this signature in database
3 changed files with 24 additions and 24 deletions

View File

@ -6,7 +6,7 @@ namespace Peripherals.SevenDigitalTubesClient;
static class SevenDigitalTubesAddr static class SevenDigitalTubesAddr
{ {
public const UInt32 BASE = 0x0000_0000; public const UInt32 BASE = 0xB000_0000;
} }
public class SevenDigitalTubesCtrl public class SevenDigitalTubesCtrl

View File

@ -174,17 +174,18 @@ function isSegmentActive(segmentId: keyof typeof SEGMENT_BITS): boolean {
// SignalR // SignalR
// ============================================================================ // ============================================================================
const { const eqps = useEquipments();
sevenSegmentDisplaySetOnOff,
sevenSegmentDisplayData,
sevenSegmentDisplaySetFrequency,
} = useEquipments();
async function initDigitalTwin() { async function initDigitalTwin() {
if (!props.enableDigitalTwin || !props.digitalTwinNum) return; if (
!props.enableDigitalTwin ||
props.digitalTwinNum < 0 ||
props.digitalTwinNum > 31
)
return;
try { try {
sevenSegmentDisplaySetOnOff(props.enableDigitalTwin); eqps.sevenSegmentDisplaySetOnOff(props.enableDigitalTwin);
console.log( console.log(
`Digital twin initialized for address: ${props.digitalTwinNum}`, `Digital twin initialized for address: ${props.digitalTwinNum}`,
@ -195,16 +196,16 @@ async function initDigitalTwin() {
} }
watch( watch(
() => [sevenSegmentDisplayData], () => [eqps.sevenSegmentDisplayData],
() => { () => {
if ( if (
!sevenSegmentDisplayData || !eqps.sevenSegmentDisplayData ||
props.digitalTwinNum < 0 || props.digitalTwinNum < 0 ||
props.digitalTwinNum > 31 props.digitalTwinNum > 31
) )
return; return;
handleDigitalTwinData(sevenSegmentDisplayData[props.digitalTwinNum]); handleDigitalTwinData(eqps.sevenSegmentDisplayData[props.digitalTwinNum]);
}, },
); );
@ -253,7 +254,7 @@ function startAfterglow(byte: number) {
} }
function cleanupDigitalTwin() { function cleanupDigitalTwin() {
sevenSegmentDisplaySetOnOff(false); eqps.sevenSegmentDisplaySetOnOff(false);
} }
// ============================================================================ // ============================================================================
@ -349,7 +350,7 @@ onUnmounted(() => {
// //
watch( watch(
() => [props.enableDigitalTwin, props.digitalTwinNum], () => [props.enableDigitalTwin],
async () => { async () => {
// //
cleanupDigitalTwin(); cleanupDigitalTwin();
@ -366,7 +367,6 @@ watch(
updateConstraintStates(); updateConstraintStates();
} }
}, },
{ immediate: false },
); );
</script> </script>

View File

@ -12,7 +12,7 @@ import {
toFileParameterOrUndefined, toFileParameterOrUndefined,
} from "@/utils/Common"; } from "@/utils/Common";
import { AuthManager } from "@/utils/AuthManager"; import { AuthManager } from "@/utils/AuthManager";
import { HubConnection } from "@microsoft/signalr"; import { HubConnection, HubConnectionState } from "@microsoft/signalr";
import { import {
getHubProxyFactory, getHubProxyFactory,
getReceiverRegister, getReceiverRegister,
@ -220,7 +220,6 @@ export const useEquipments = defineStore("equipments", () => {
async function matrixKeypadSetKeyStates(keyStates: boolean[]) { async function matrixKeypadSetKeyStates(keyStates: boolean[]) {
const release = await matrixKeypadClientMutex.acquire(); const release = await matrixKeypadClientMutex.acquire();
console.log("set Key !!!!!!!!!!!!");
try { try {
const matrixKeypadClient = const matrixKeypadClient =
AuthManager.createAuthenticatedMatrixKeyClient(); AuthManager.createAuthenticatedMatrixKeyClient();
@ -241,9 +240,9 @@ export const useEquipments = defineStore("equipments", () => {
async function matrixKeypadEnable(enable: boolean) { async function matrixKeypadEnable(enable: boolean) {
const release = await matrixKeypadClientMutex.acquire(); const release = await matrixKeypadClientMutex.acquire();
try { try {
if (enable) {
const matrixKeypadClient = const matrixKeypadClient =
AuthManager.createAuthenticatedMatrixKeyClient(); AuthManager.createAuthenticatedMatrixKeyClient();
if (enable) {
const resp = await matrixKeypadClient.enabelMatrixKey( const resp = await matrixKeypadClient.enabelMatrixKey(
boardAddr.value, boardAddr.value,
boardPort.value, boardPort.value,
@ -251,8 +250,6 @@ export const useEquipments = defineStore("equipments", () => {
enableMatrixKey.value = resp; enableMatrixKey.value = resp;
return resp; return resp;
} else { } else {
const matrixKeypadClient =
AuthManager.createAuthenticatedMatrixKeyClient();
const resp = await matrixKeypadClient.disableMatrixKey( const resp = await matrixKeypadClient.disableMatrixKey(
boardAddr.value, boardAddr.value,
boardPort.value, boardPort.value,
@ -305,6 +302,7 @@ export const useEquipments = defineStore("equipments", () => {
async function sevenSegmentDisplaySetOnOff(enable: boolean) { async function sevenSegmentDisplaySetOnOff(enable: boolean) {
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value) if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
return; return;
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
await sevenSegmentDisplayHub.value.start(); await sevenSegmentDisplayHub.value.start();
if (enable) { if (enable) {
@ -317,6 +315,7 @@ export const useEquipments = defineStore("equipments", () => {
async function sevenSegmentDisplaySetFrequency(frequency: number) { async function sevenSegmentDisplaySetFrequency(frequency: number) {
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value) if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
return; return;
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
await sevenSegmentDisplayHub.value.start(); await sevenSegmentDisplayHub.value.start();
await sevenSegmentDisplayHubProxy.value.setFrequency(frequency); await sevenSegmentDisplayHubProxy.value.setFrequency(frequency);
@ -325,6 +324,7 @@ export const useEquipments = defineStore("equipments", () => {
async function sevenSegmentDisplayGetStatus() { async function sevenSegmentDisplayGetStatus() {
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value) if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
return; return;
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
await sevenSegmentDisplayHub.value.start(); await sevenSegmentDisplayHub.value.start();
return await sevenSegmentDisplayHubProxy.value.getStatus(); return await sevenSegmentDisplayHubProxy.value.getStatus();
@ -338,7 +338,7 @@ export const useEquipments = defineStore("equipments", () => {
onMounted(async () => { onMounted(async () => {
// 每次挂载都重新创建连接 // 每次挂载都重新创建连接
sevenSegmentDisplayHub.value = sevenSegmentDisplayHub.value =
AuthManager.createAuthenticatedJtagHubConnection(); AuthManager.createAuthenticatedDigitalTubesHubConnection();
sevenSegmentDisplayHubProxy.value = getHubProxyFactory( sevenSegmentDisplayHubProxy.value = getHubProxyFactory(
"IDigitalTubesHub", "IDigitalTubesHub",
).createHubProxy(sevenSegmentDisplayHub.value); ).createHubProxy(sevenSegmentDisplayHub.value);