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
{
public const UInt32 BASE = 0x0000_0000;
public const UInt32 BASE = 0xB000_0000;
}
public class SevenDigitalTubesCtrl

View File

@ -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 },
);
</script>

View File

@ -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 {
if (enable) {
const matrixKeypadClient =
AuthManager.createAuthenticatedMatrixKeyClient();
if (enable) {
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,6 +302,7 @@ export const useEquipments = defineStore("equipments", () => {
async function sevenSegmentDisplaySetOnOff(enable: boolean) {
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
return;
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
await sevenSegmentDisplayHub.value.start();
if (enable) {
@ -317,6 +315,7 @@ export const useEquipments = defineStore("equipments", () => {
async function sevenSegmentDisplaySetFrequency(frequency: number) {
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
return;
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
await sevenSegmentDisplayHub.value.start();
await sevenSegmentDisplayHubProxy.value.setFrequency(frequency);
@ -325,6 +324,7 @@ export const useEquipments = defineStore("equipments", () => {
async function sevenSegmentDisplayGetStatus() {
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
return;
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);