修复北斗授时的bug以及为字体设计新增显示到LED屏的功能

master
qubiaobiao 2023-10-16 13:55:56 +08:00
parent a292e1aca6
commit 5120201397
11 changed files with 183 additions and 51 deletions

1
fontLibrary.json Normal file
View File

@ -0,0 +1 @@
{"font35":{"0":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"1":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"2":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"3":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"4":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"5":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"6":[false,true,true,false,false,true,true,true,false,false,true,false,false,false,true],"7":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"8":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"9":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],":":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],".":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"-":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]},"font47":{"0":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"1":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"2":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"3":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"4":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"5":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"6":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"7":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"8":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"9":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],":":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],".":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"-":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}}

View File

@ -20,7 +20,7 @@
"echarts": "^5.4.0", "echarts": "^5.4.0",
"events": "^3.3.0", "events": "^3.3.0",
"naive-ui": "^2.34.3", "naive-ui": "^2.34.3",
"nmea": "git+https://e.coding.net/hwasmart/beidou-satellite-data-monitor/node-nmea.git", "nmea": "http://git.hwasmart.com/bd_group/node-nmea.git",
"node-wifi": "^2.0.16", "node-wifi": "^2.0.16",
"pinia": "^2.0.27", "pinia": "^2.0.27",
"systeminformation": "^5.17.12", "systeminformation": "^5.17.12",

View File

@ -10,14 +10,23 @@
</n-tab-pane> </n-tab-pane>
</Tabs> </Tabs>
</Layout> </Layout>
<SerialPortManagementDrawer ref="serialportmanagementdrawer" />
</Application> </Application>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue'
import { NTabPane } from 'naive-ui' import { NTabPane } from 'naive-ui'
import { Application } from '@/components/Application' import { Application } from '@/components/Application'
import { Layout } from '@/layout/default' import { Layout } from '@/layout/default'
import { SerialPortManagementDrawer } from '@/components/SerialPortManagementDrawer'
import { Tabs } from '@/components/Tabs' import { Tabs } from '@/components/Tabs'
import { EditFontView } from '@/views/FontDesign/EditFontView' import { EditFontView } from '@/views/FontDesign/EditFontView'
import { DotMatrixScreenDisplayView } from '@/views/FontDesign/DotMatrixScreenDisplayView' import { DotMatrixScreenDisplayView } from '@/views/FontDesign/DotMatrixScreenDisplayView'
const serialportmanagementdrawer = ref()
onMounted(()=>{
serialportmanagementdrawer.value.appname('fontDesign')
})
</script> </script>

View File

@ -220,8 +220,12 @@ const option = reactive({
}) })
let date let date
const update = (dateTime: Date) => { const update = (handleDate: Date) => {
if (!dateTime) return
if (!handleDate) return
let dateTime = new Date(handleDate)
const seconds = dateTime.getSeconds() const seconds = dateTime.getSeconds()
const minutes = dateTime.getMinutes() const minutes = dateTime.getMinutes()
const hours = dateTime.getHours() const hours = dateTime.getHours()

View File

@ -1,5 +1,5 @@
<template> <template>
<n-button circle type="primary" size="large" class="drawer-control-button" @click="show = true"> <n-button circle type="primary" size="large" :class=cvalue @click="show = true">
<template #icon> <template #icon>
<n-icon> <n-icon>
<Cable /> <Cable />
@ -21,6 +21,15 @@ import { CableFilled as Cable } from '@vicons/material'
import { SerialPortManagementView } from '@/components/SerialPort' import { SerialPortManagementView } from '@/components/SerialPort'
const show = ref(false) const show = ref(false)
const cvalue = ref('drawer-control-button')
const appname = (name) => {
if(name == 'fontDesign'){
cvalue.value = 'tobottom'
}
}
defineExpose( { appname })
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@ -29,5 +38,11 @@ const show = ref(false)
right: 60px; right: 60px;
top: 120px; top: 120px;
} }
.tobottom {
position: fixed;
right: 49%;
bottom: 0.5%;
}
</style> </style>

View File

@ -36,6 +36,8 @@ export const useSerialPortStore = defineStore('serialPort', {
}, },
async open(options) { async open(options) {
eventListeners[SerialPortEventType.beforeOpen]?.forEach((cb: Function) => cb(this))
if ( !options ) throw new Error('缺少串口配置参数') if ( !options ) throw new Error('缺少串口配置参数')
if ( !this.instance ) throw new Error('未选择串口设备') if ( !this.instance ) throw new Error('未选择串口设备')
@ -87,7 +89,11 @@ export const useSerialPortStore = defineStore('serialPort', {
} }
} }
eventListeners[SerialPortEventType.beforeClose]?.forEach((cb: Function) => cb(this))
await this.instance.close() await this.instance.close()
eventListeners[SerialPortEventType.afterClose]?.forEach((cb: Function) => cb(this))
}, },
async close() { async close() {

View File

@ -27,15 +27,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, watch, onMounted } from 'vue' import { ref, watch, onMounted } from 'vue'
import { NGi, NGrid, NDatePicker, NButton } from 'naive-ui' import { NGi, NGrid, NDatePicker, NButton, useMessage } from 'naive-ui'
import { Clock } from '@/components/Charts' import { Clock } from '@/components/Charts'
import { useSerialPortStore, SerialPortEventType } from '@/stores/serialPort' import { useSerialPortStore, SerialPortEventType } from '@/stores/serialPort'
import { useNMEAStore, NMEADataSource } from '@/stores/nmea' import { useNMEAStore, NMEADataSource } from '@/stores/nmea'
import { actions } from './data' import { actions } from './data'
import { LineBreakParser } from '@/utils/parser' import { LineBreakParser } from '@/utils/parser'
const serialPort = useSerialPortStore()
const nmea = useNMEAStore() const nmea = useNMEAStore()
const message = useMessage()
const dataSource = new NMEADataSource() const dataSource = new NMEADataSource()
nmea.bindDataSource(dataSource) nmea.bindDataSource(dataSource)
const decoder = new TextDecoder() const decoder = new TextDecoder()
@ -46,44 +47,90 @@ const onSerialPortData = (data: Uint8Array) => {
} }
const disabled = ref(true) const disabled = ref(true)
const clearset = ref(false)
const mark = ref(false)
const BJ_clock = ref(null) const BJ_clock = ref(null)
watch(() => nmea.handled, (value) => {
if (!value) return
const BJDateTime = nmea.dateTime
if (BJDateTime === undefined) {
disabled.value = true
} else {
disabled.value = false
BJ_clock.value.update(BJDateTime)
}
})
const system_clock = ref(null) const system_clock = ref(null)
let currentTimeStamp = (new Date()).valueOf()
onMounted(() => {
setInterval(() => { let firstintv
let currentTimeStamp = (new Date()).valueOf()+1000
onMounted(() => {
console.log(currentTimeStamp)
firstintv =setInterval(() => {
currentTimeStamp += 1000 currentTimeStamp += 1000
system_clock.value.update(new Date(currentTimeStamp)) system_clock.value.update(currentTimeStamp)
}, 1000) }, 1000)
}) })
watch(() => nmea.handled, (value) => {
if (!value) return
const BJDateTime = nmea.dateTime
console.log(BJDateTime)
if (BJDateTime === undefined) {
disabled.value = true
}else {
disabled.value = false
BJ_clock.value.update(BJDateTime)
if(clearset.value){
system_clock.value.update(BJDateTime)
currentTimeStamp = BJDateTime
}else{
if(mark.value){
system_clock.value.update(BJDateTime)
mark.value = false
clearInterval(firstintv)
currentTimeStamp = new Date(currentTimeStamp).getTime()+1000
firstintv = firstintv =setInterval(() => {
currentTimeStamp += 1000
system_clock.value.update(currentTimeStamp)
}, 1000)
}
}
}
})
const onBDTimingBtnClick = () => { const onBDTimingBtnClick = () => {
const date = BJ_clock.value.getDate() clearInterval(firstintv)
clearset.value = true
currentTimeStamp = date.valueOf() mark.value = true
} }
const dateTime = ref(null) // const dateTime = ref(null) //
const onDatePickerTimingBtnClick = () => { const onDatePickerTimingBtnClick = () => {
currentTimeStamp = dateTime.value clearInterval(firstintv)
clearset.value = false
currentTimeStamp = dateTime.value-1000
firstintv = firstintv =setInterval(() => {
currentTimeStamp += 1000
system_clock.value.update(currentTimeStamp)
}, 1000)
}
const resettime = () => {
if(serialPort.isOpen){
console.log('now open')
}else{
console.log('not open')
if(clearset.value){
clearInterval(firstintv)
currentTimeStamp = new Date(currentTimeStamp).getTime()
clearset.value = false
disabled.value = true
firstintv = firstintv =setInterval(() => {
currentTimeStamp += 1000
system_clock.value.update(currentTimeStamp)
}, 1000)
}
}
} }
const serialPort = useSerialPortStore()
serialPort.addEventListener(SerialPortEventType.data, onSerialPortData) serialPort.addEventListener(SerialPortEventType.data, onSerialPortData)
// serialPort.addEventListener(SerialPortEventType.beforeOpen, resettime)
serialPort.addEventListener(SerialPortEventType.afterOpen, resettime)
// serialPort.addEventListener(SerialPortEventType.beforeClose, resettime)
serialPort.addEventListener(SerialPortEventType.afterClose, resettime)
</script> </script>
<style scoped lang="less"> <style scoped lang="less">

View File

@ -8,54 +8,95 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import { NGrid, NGi } from 'naive-ui' import { NGrid, NGi, useMessage } from 'naive-ui'
import convert from 'color-convert'
import LED from './components/LED.vue' import LED from './components/LED.vue'
import { useSerialPortStore } from '@/stores/serialPort'
import { ROWS, COLS } from './data' import { ROWS, COLS } from './data'
const message = useMessage()
const ledRefs = ref() const ledRefs = ref()
const serialPort = useSerialPortStore()
const showChar = (index, data, color) => { const showChar = (index, data, color) => {
if (!data) return if (!data) return
if (!serialPort.isOpen) {
message.error('请连接并打开串口设备')
return
}
clearArea(index) clearArea(index)
if (data.length === 15) { if (!color) return
for (let i = 0; i < data.length; i++) {
if (data[i]) {
const x = Math.floor(i / 3)
const y = i % 3 + index * 4
ledRefs.value[x * COLS + y].$el.children[0].style.backgroundColor = color if (data.length === 15) {
} data = [data[0],data[1],data[2],false,
} data[3],data[4],data[5],false,
data[6],data[7],data[8],false,
data[9],data[10],data[11],false,
data[12],data[13],data[14],false,
false,false,false,false,
false,false,false,false]
} }
if (data.length === 28) { if (data.length === 28) {
let ledx = {
0:[0,0,0,0,0,0,0,0],
1:[0,0,0,0,0,0,0,0],
2:[0,0,0,0,0,0,0,0],
3:[0,0,0,0,0,0,0,0]
}
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (data[i]) { if(data[i]){
const x = Math.floor(i / 4) const x = i % 4 + index * 4
const y = i % 4 + index * 4 const y = Math.floor(i / 4)
const ledIndex = y * COLS + x
ledRefs.value[x * COLS + y].$el.children[0].style.backgroundColor = color ledRefs.value[ledIndex].$el.children[0].style.backgroundColor = color
const rx = ledIndex % COLS
const ry = Math.floor(ledIndex / COLS)
ledx[rx-4*index][ry] = 1
} }
} }
const origin = 4 * index
const rgb = convert.hex.rgb(color)
const I = parseInt(ledx[0].toString().replace(/,/gi,''),2)
const II = parseInt(ledx[1].toString().replace(/,/gi,''),2)
const III = parseInt(ledx[2].toString().replace(/,/gi,''),2)
const IV = parseInt(ledx[3].toString().replace(/,/gi,''),2)
let cmd = `$LEDAREA,${origin},0,${I},${II},${III},${IV},${rgb[0]},${rgb[1]},${rgb[2]}*`
cmd += cmd.length
cmd += '\r\n'
serialPort.write(cmd)
} }
} }
const clearArea = (areaIndex) => { const clearArea = (areaIndex) => {
for (let i = 0; i < 7; i++) { for(let i = 0; i < 8; i++){
for (let j = 0; j < 4; j++) { for (let j = 0; j < 4; j++){
const ledIndex = i * COLS + areaIndex * 4 + j const ledIndex = i * COLS + areaIndex * 4 + j
ledRefs.value[ledIndex].$el.children[0].style.backgroundColor = 'black' ledRefs.value[ledIndex].$el.children[0].style.backgroundColor = 'black'
} }
} }
const origin = 4 * areaIndex
let cmd = `$LEDAREA,${origin},0,0,0,0,0,0,0,0*`
cmd += cmd.length
cmd += '\r\n'
serialPort.write(cmd)
} }
const clearAll = () => { const clearAll = () => {
if (!serialPort.isOpen) {
message.error('请连接并打开串口设备')
return
}
ledRefs.value.forEach(ledRef => { ledRefs.value.forEach(ledRef => {
ledRef.$el.children[0].style.backgroundColor = 'black' ledRef.$el.children[0].style.backgroundColor = 'black'
}); })
serialPort.write('$LEDCL,0*9\r\n')
} }
defineExpose( { showChar, clearArea, clearAll }) defineExpose( { showChar, clearArea, clearAll })

View File

@ -20,7 +20,7 @@
<n-space vertical> <n-space vertical>
<div> <div>
<n-text v-if="!hasFont"></n-text> <n-text v-if="!hasFont">{{ fontmsg }}</n-text>
<n-radio-group v-else v-model:value="fontLibrarySelected" name="radiogroup"> <n-radio-group v-else v-model:value="fontLibrarySelected" name="radiogroup">
<n-space> <n-space>
@ -39,23 +39,31 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch, onMounted } from 'vue' import { ref, watch, onMounted } from 'vue'
import { NSpace, NGrid, NGi, NInput, NRadioGroup, NRadio, NText, NButton } from 'naive-ui' import { NSpace, NGrid, NGi, NInput, NRadioGroup, NRadio, NText, NButton, useMessage } from 'naive-ui'
import { LEDPanelView } from './LEDPanelView' import { LEDPanelView } from './LEDPanelView'
import { hasIpcRenderer } from '@/utils' import { hasIpcRenderer } from '@/utils'
const itemStyle = { textAlign: 'center', flex: '1 1 50%'} const message = useMessage()
const itemStyle = { textAlign: 'center', flex: '1 1 50%' }
const count = 8 const count = 8
const hasFont = ref(false) const hasFont = ref(false)
const fontmsg = ref('字库未创建,请先创建字库后重启软件')
const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '.', '-'] const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '.', '-']
const onlyAllow = (value: string) => !value || chars.indexOf(value) >= 0 const onlyAllow = (value: string) => !value || chars.indexOf(value) >= 0
const ledPanelViewRef = ref() const ledPanelViewRef = ref()
const inputValues = ref(new Array(count).fill(null)) const inputValues = ref(new Array(count).fill(null))
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
watch( watch(
() => inputValues.value[i], () => inputValues.value[i],
value => { value => {
const { data } = window.ipcRenderer.sendSync('LOAD_FONT_LIBRARY')
if (!data) return
fontLibrary = JSON.parse(data)
hasFont.value = true
if (!value) { if (!value) {
ledPanelViewRef.value.clearArea(i) ledPanelViewRef.value.clearArea(i)
} else { } else {
@ -86,6 +94,7 @@ onMounted(() => {
const onClearBtnClick = () => { const onClearBtnClick = () => {
inputValues.value.fill(null) inputValues.value.fill(null)
ledPanelViewRef.value.clearAll()
} }
</script> </script>

View File

@ -38,7 +38,7 @@ const onClick = () => {
dialog.success({ dialog.success({
title: '系统消息', title: '系统消息',
content: '保存字库成功,重启软件后生效', content: '保存字库成功',
positiveText: '确定', positiveText: '确定',
closable: false, closable: false,
maskClosable: false, maskClosable: false,

View File

@ -3400,9 +3400,9 @@ needle@^3.1.0:
iconv-lite "^0.6.3" iconv-lite "^0.6.3"
sax "^1.2.4" sax "^1.2.4"
"nmea@git+https://e.coding.net/hwasmart/beidou-satellite-data-monitor/node-nmea.git": "nmea@http://git.hwasmart.com/bd_group/node-nmea.git":
version "0.1.2" version "0.1.2"
resolved "git+https://e.coding.net/hwasmart/beidou-satellite-data-monitor/node-nmea.git#7dbd7671aefebb73f820c51d76322ee96bdfe574" resolved "http://git.hwasmart.com/bd_group/node-nmea.git#94f58cd552a9b122816996c21047e34687f7157c"
dependencies: dependencies:
JSONStream "0.7" JSONStream "0.7"
through ">=2.2.7 <3" through ">=2.2.7 <3"