对齐时间戳的同时,也对齐SecMark

This commit is contained in:
洛洛希雅 2024-05-10 17:44:36 +08:00
parent 01d3c4362a
commit f89412a467

View File

@ -32,6 +32,7 @@ const publish = reactive({
count: 1, count: 1,
startTime: 0, startTime: 0,
startTimestamp: 0, startTimestamp: 0,
startSecMark: 0,
lastTime: 0, lastTime: 0,
lastTimestamp: 0, lastTimestamp: 0,
lastRawTimestamp: 0, lastRawTimestamp: 0,
@ -43,6 +44,7 @@ const publish = reactive({
pause: false, pause: false,
rawTime: true, rawTime: true,
forceRawTime: false, forceRawTime: false,
normalizedTime: false,
range: { range: {
start: 0, start: 0,
end: 0 end: 0
@ -148,22 +150,39 @@ async function doPublish() {
let list = item[0].content let list = item[0].content
// //
publish.lastRawTimestamp = item[0].content[0].timeStamp publish.lastRawTimestamp = item[0].content[0].timeStamp
if (publish.startTimestamp === 0) {
publish.startTimestamp = publish.lastRawTimestamp
publish.startSecMark = item[0].content[0].secMark
}
if (!publish.rawTime || publish.normalizedTime) {
//
item = JSON.parse(JSON.stringify(item))
list = item[0].content
}
// * 100 ms
if (publish.normalizedTime) {
for (const it of list) {
it.timeStamp = publish.startTimestamp + publish.index * 100
it.secMark = (publish.startSecMark + publish.index * 100) % 60000
}
}
// //
if (!publish.rawTime) { if (!publish.rawTime) {
if (publish.timeTicking < 0) publish.timeOffset += 200 if (publish.timeTicking < 0) publish.timeOffset += 200
else if (publish.pause) publish.timeOffset += 100 else if (publish.pause) publish.timeOffset += 100
const offset = publish.timeOffset const offset = publish.timeOffset
publish.lastTimestamp = publish.lastRawTimestamp + publish.timeOffset publish.lastTimestamp = publish.lastRawTimestamp + publish.timeOffset
// for (const it of list) {
item = JSON.parse(JSON.stringify(item)) it.timeStamp = it.timeStamp + offset
list = item[0].content it.secMark = (it.secMark + offset) % 60000
for (const it of list) it.timeStamp = it.timeStamp + offset }
} else { } else {
publish.lastTimestamp = publish.lastRawTimestamp publish.lastTimestamp = publish.lastRawTimestamp
} }
if (publish.startTimestamp === 0) {
publish.startTimestamp = publish.lastTimestamp
}
publish.cars = list.map((it) => ({ publish.cars = list.map((it) => ({
name: it.global_track_id, name: it.global_track_id,
x: it.x / 1.6, x: it.x / 1.6,
@ -257,21 +276,28 @@ watch(
<el-input v-model="password" /> <el-input v-model="password" />
</el-form-item> </el-form-item>
<el-form-item label="控制柄"> <el-form-item label="控制柄">
<div>
<el-row>
<el-button v-if="!publish.status" type="primary" @click="connect">连接</el-button> <el-button v-if="!publish.status" type="primary" @click="connect">连接</el-button>
<el-button v-else type="danger" @click="disconnect">断开</el-button> <el-button v-else type="danger" @click="disconnect">断开</el-button>
<el-button v-if="!jobCancel" type="primary" :disabled="!publish.status" @click="doPublish">发送</el-button> <el-button v-if="!jobCancel" type="primary" :disabled="!publish.status" @click="doPublish">
发送
</el-button>
<template v-else> <template v-else>
<el-button type="danger" :disabled="!publish.status" @click="() => jobCancel?.()">停止</el-button> <el-button type="danger" :disabled="!publish.status" @click="() => jobCancel?.()">停止</el-button>
</template> </template>
<div class="publish-controller-bar" :class="{ disabled: !jobCancel }"> <el-button v-if="!publish.pause" :disabled="!jobCancel" type="warning" @click="pause">暂停</el-button>
<el-button v-if="!publish.pause" type="warning" @click="pause">暂停</el-button> <el-button v-else :disabled="!jobCancel" type="success" @click="publish.pause = false">继续</el-button>
<el-button v-else type="success" @click="publish.pause = false">继续</el-button>
</div>
<el-button v-if="publish.forceRawTime" ml="12px" type="primary" @click="publish.forceRawTime = false"> <el-button v-if="publish.forceRawTime" ml="12px" type="primary" @click="publish.forceRawTime = false">
原始时间模式: 原始时间模式:
</el-button> </el-button>
<el-button v-else ml="12px" type="info" @click="publish.forceRawTime = true">原始时间模式:</el-button> <el-button v-else ml="12px" type="info" @click="publish.forceRawTime = true">原始时间模式:</el-button>
<div class="publish-controller-bar" :class="{ disabled: !jobCancel }"> <el-button v-if="publish.normalizedTime" ml="12px" type="primary" @click="publish.normalizedTime = false">
时间归一化:
</el-button>
<el-button v-else ml="12px" type="info" @click="publish.normalizedTime = true">时间归一化:</el-button>
</el-row>
<el-row class="publish-controller-bar" :class="{ disabled: !jobCancel }">
<el-button type="info" @mousedown="reverse" @mouseup="publish.timeTicking = 1">倒带</el-button> <el-button type="info" @mousedown="reverse" @mouseup="publish.timeTicking = 1">倒带</el-button>
<el-button-group type="info"> <el-button-group type="info">
<el-button @click="move(-100)">后退10秒</el-button> <el-button @click="move(-100)">后退10秒</el-button>
@ -281,14 +307,18 @@ watch(
<el-button @click="move(10)">前进1秒</el-button> <el-button @click="move(10)">前进1秒</el-button>
<el-button @click="move(100)">前进10秒</el-button> <el-button @click="move(100)">前进10秒</el-button>
</el-button-group> </el-button-group>
</el-row>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="提示"> <el-form-item label="提示">
<div v-if="!publish.forceRawTime" style="font-size: 1.2em" text-red> <div style="font-size: 1.2em">
<div v-if="!publish.forceRawTime" text-red>
原始时间模式已关闭这可能导致需要绝对时间的功能出现异常例如红绿灯与车流可能不再同步 原始时间模式已关闭这可能导致需要绝对时间的功能出现异常例如红绿灯与车流可能不再同步
</div> </div>
<div v-else style="font-size: 1.2em" text-red> <div v-else text-red>原始时间模式已开启这可能导致修改进度时画面出现闪烁暂停时画面不显示车辆的问题</div>
原始时间模式已开启这可能导致修改进度时画面出现闪烁暂停时画面不显示车辆的问题 <div v-if="publish.normalizedTime">
时间归一化已开启可以修复原始数据可能存在的时间戳不一致问题减少V2X系统内时间跳跃问题发生的概率
</div>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item v-if="jobCancel" label="状态"> <el-form-item v-if="jobCancel" label="状态">
@ -301,8 +331,9 @@ watch(
{{ (publish.lastRawTimestamp - publish.startTimestamp) / 1000 }} {{ (publish.lastRawTimestamp - publish.startTimestamp) / 1000 }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="原始时间"> <el-descriptions-item label="原始时间">
<template v-if="publish.rawTime">正常</template> <template v-if="!publish.rawTime">已禁用</template>
<template v-else>已禁用</template> <template v-else-if="publish.normalizedTime">归一化</template>
<template v-else>正常</template>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="数据起始时间戳"> <el-descriptions-item label="数据起始时间戳">
{{ publish.startTimestamp }} {{ publish.startTimestamp }}
@ -416,7 +447,7 @@ watch(
.config-form { .config-form {
.publish-controller-bar { .publish-controller-bar {
margin-left: 12px; margin-top: 16px;
&.disabled { &.disabled {
> * { > * {
pointer-events: none; pointer-events: none;