init commit

This commit is contained in:
叶志超
2023-10-13 16:43:53 +08:00
parent c1fc36b44c
commit d184776cb3
275 changed files with 8305 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<template>
<n-card title="卫星时间" class="h-full">
<n-space vertical justify="space-around" class="h-full">
<n-descriptions label-placement="left">
<n-descriptions-item label="  日   期  ">
{{ date }}
</n-descriptions-item>
</n-descriptions>
<n-descriptions label-placement="left">
<n-descriptions-item label="  时   间  ">
{{ time }}
</n-descriptions-item>
</n-descriptions>
</n-space>
</n-card>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { NCard, NSpace, NDescriptions, NDescriptionsItem } from 'naive-ui'
import { useSerialPortStore, SerialPortEventType } from '@/stores/serialPort'
import { LineBreakParser } from '@/utils/parser'
const date = ref()
const time = ref()
const handle = (data: string) => {
const startMarkIndex = data.indexOf('@')
const checksumMarkIndex = data.indexOf('*')
if (startMarkIndex < 0 || checksumMarkIndex < startMarkIndex) return
// 校验和验证
const info = data.substring(startMarkIndex + 1, checksumMarkIndex)
const cs = parseInt(data.substring(checksumMarkIndex + 1))
if (cs != info.length + 2) return
const infoArr = info.split(',')
if (infoArr.length != 3 || infoArr[0] != 'TIME') return
date.value = infoArr[1]
time.value = infoArr[2]
}
const decoder = new TextDecoder()
const parser = new LineBreakParser()
const onSerialPortData = (data: Uint8Array) => {
const lineArr = parser.parse(decoder.decode(data))
lineArr.forEach(line => handle(line))
}
const serialPort = useSerialPortStore()
serialPort.addEventListener(SerialPortEventType.data, onSerialPortData)
</script>
<style scoped lang="less">
:deep(.n-card-header) {
font-size: 4vh;
}
:deep(.n-descriptions) {
font-size: 3vh;
}
</style>