feat(stop uart communication)

This commit is contained in:
kerms 2024-05-22 14:59:40 +08:00
parent 51783612bc
commit a7758ac69a
3 changed files with 24 additions and 25 deletions

View File

@ -403,7 +403,9 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
} }
function addItem(item: Uint8Array, isRX: boolean, doSend: boolean = false, type: number = 0) { function addItem(item: Uint8Array, isRX: boolean, doSend: boolean = false, type: number = 0) {
if (!acceptIncomingData.value && isRX) {
return;
}
const t = new Date(); const t = new Date();
// dataArchive.push({ // dataArchive.push({
@ -425,10 +427,14 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
newArr.set(computedSuffixValue.value, computedPrefixValue.value.length + item.length); newArr.set(computedSuffixValue.value, computedPrefixValue.value.length + item.length);
item = newArr; item = newArr;
} }
if (acceptIncomingData.value) {
if (doSend) { if (doSend) {
/* INFO: hard coded for the moment */ /* INFO: hard coded for the moment */
uart_send_msg(item); uart_send_msg(item);
} }
} else {
type = 1;
}
TxTotalByteCount.value += item.length; TxTotalByteCount.value += item.length;
TxByteCount.value = item.length; TxByteCount.value = item.length;
} }

View File

@ -63,16 +63,11 @@
<script setup lang="ts"> <script setup lang="ts">
import {onMounted, onUnmounted, reactive, type Ref, ref, type UnwrapRef, watch} from "vue"; import {onMounted, onUnmounted, reactive, type Ref, ref, type UnwrapRef, watch} from "vue";
import {breakpointsTailwind, useBreakpoints, useWindowSize} from '@vueuse/core' import {breakpointsTailwind, useBreakpoints} from '@vueuse/core'
import {useDataViewerStore} from '@/stores/dataViewerStore'; import {useDataViewerStore} from '@/stores/dataViewerStore';
import * as api from '@/api'; import * as api from '@/api';
import {ControlEvent} from '@/api';
import * as uart from '@/api/apiUart'; import * as uart from '@/api/apiUart';
import * as bin from '@/api/binDataDef';
import * as data_flow from '@/api/apiDataFlow';
import textDataViewer from "@/views/text-data-viewer/textDataViewer.vue";
import textDataConfig from "@/views/text-data-viewer/textDataConfig.vue"
import {registerModule} from "@/router/msgRouter";
import {type ApiBinaryMsg} from "@/api/binDataDef";
import { import {
type IUartMsgBaud, type IUartMsgBaud,
type IUartMsgConfig, type IUartMsgConfig,
@ -81,12 +76,17 @@ import {
uart_set_baud, uart_set_baud,
uart_set_config, uart_set_config,
WtUartCmd WtUartCmd
} from "@/api/apiUart"; } from '@/api/apiUart';
import {type ApiBinaryMsg} from '@/api/binDataDef';
import {wt_data_flow_attach_cur_to_sender} from '@/api/apiDataFlow';
import textDataViewer from "@/views/text-data-viewer/textDataViewer.vue";
import textDataConfig from "@/views/text-data-viewer/textDataConfig.vue"
import {registerModule} from "@/router/msgRouter";
import {isDevMode} from "@/composables/buildMode"; import {isDevMode} from "@/composables/buildMode";
import {ControlEvent} from "@/api"; import {useWsStore} from "@/stores/websocket";
import {wt_data_flow_attach_cur_to_sender} from "@/api/apiDataFlow";
const store = useDataViewerStore() const store = useDataViewerStore()
const wsStore = useWsStore()
const firstWinResizeRef = ref(document.body); const firstWinResizeRef = ref(document.body);
const thirdWinResizeRef = ref(document.body); const thirdWinResizeRef = ref(document.body);
@ -94,7 +94,6 @@ const win1Ref = ref(document.body);
const win2Ref = ref(document.body); const win2Ref = ref(document.body);
const breakpoints = useBreakpoints(breakpointsTailwind) const breakpoints = useBreakpoints(breakpointsTailwind)
const windowSize = useWindowSize()
const layoutConf = reactive({ const layoutConf = reactive({
isSmall: breakpoints.smaller("sm"), isSmall: breakpoints.smaller("sm"),
@ -112,15 +111,6 @@ const layoutOptions = [{
const layoutMode = ref(layoutOptions[0].value); const layoutMode = ref(layoutOptions[0].value);
const displayOptions = [{
label: '默认显示',
value: 'auto'
}, {
label: '手动显示',
value: 'manual'
}]
const displayMode = ref(displayOptions[0].value);
interface WinProperty { interface WinProperty {
show: boolean; show: boolean;
width: string; width: string;
@ -464,6 +454,7 @@ onMounted(() => {
document.addEventListener("mouseup", stopResize, false); document.addEventListener("mouseup", stopResize, false);
document.addEventListener("touchend", stopResize, false); document.addEventListener("touchend", stopResize, false);
updateUartData(); updateUartData();
store.acceptIncomingData = wsStore.state === ControlEvent.CONNECTED;
}); });
onUnmounted(() => { onUnmounted(() => {

View File

@ -86,7 +86,9 @@
<el-form-item label=" "> <el-form-item label=" ">
<div class="flex"> <div class="flex">
<el-button :type="store.acceptIncomingData ? 'danger': 'success'" <el-button :type="store.acceptIncomingData ? 'danger': 'success'"
:disabled="wsStore.state !== ControlEvent.CONNECTED"> :disabled="wsStore.state !== ControlEvent.CONNECTED"
@click="store.acceptIncomingData = !store.acceptIncomingData"
>
{{ store.acceptIncomingData ? "停止数据收发" : "开始数据收发" }} {{ store.acceptIncomingData ? "停止数据收发" : "开始数据收发" }}
</el-button> </el-button>
</div> </div>