fix: 前后端修复七段数码管无法正常工作的问题
This commit is contained in:
parent
0a1e0982c2
commit
9bd3fb29e3
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
const matrixKeypadClient =
|
||||||
|
AuthManager.createAuthenticatedMatrixKeyClient();
|
||||||
if (enable) {
|
if (enable) {
|
||||||
const matrixKeypadClient =
|
|
||||||
AuthManager.createAuthenticatedMatrixKeyClient();
|
|
||||||
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,7 +302,8 @@ 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;
|
||||||
await sevenSegmentDisplayHub.value.start();
|
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
|
||||||
|
await sevenSegmentDisplayHub.value.start();
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
await sevenSegmentDisplayHubProxy.value.startScan();
|
await sevenSegmentDisplayHubProxy.value.startScan();
|
||||||
|
@ -317,7 +315,8 @@ 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;
|
||||||
await sevenSegmentDisplayHub.value.start();
|
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
|
||||||
|
await sevenSegmentDisplayHub.value.start();
|
||||||
|
|
||||||
await sevenSegmentDisplayHubProxy.value.setFrequency(frequency);
|
await sevenSegmentDisplayHubProxy.value.setFrequency(frequency);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +324,8 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
async function sevenSegmentDisplayGetStatus() {
|
async function sevenSegmentDisplayGetStatus() {
|
||||||
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
|
if (!sevenSegmentDisplayHub.value || !sevenSegmentDisplayHubProxy.value)
|
||||||
return;
|
return;
|
||||||
await sevenSegmentDisplayHub.value.start();
|
if (sevenSegmentDisplayHub.value.state === HubConnectionState.Disconnected)
|
||||||
|
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);
|
||||||
|
|
Loading…
Reference in New Issue