feat 数据流模拟

This commit is contained in:
Ironsp
2026-09-17 16:33:54 +08:00
parent faf4ea1155
commit 65fc29f777
8 changed files with 144 additions and 44 deletions

View File

@@ -1,22 +1,18 @@
<script setup lang="ts">
// RTK 轨迹实时监测 - 状态头部组件
import { useRtkLive } from '@/composables/useRtkLive'
interface Props {
deviceName?: string
speed?: number
frequency?: number
amplitude?: number
rtkFixed?: boolean
}
withDefaults(defineProps<Props>(), {
deviceName: '徐工XS65H #01',
speed: 4.2,
frequency: 28.5,
amplitude: 1.86,
rtkFixed: true,
})
const { speedTextSpaced, frequencyText, amplitudeText } = useRtkLive()
function handleToggle() {
uni.switchTab({
url: '/pages/work/index',
@@ -54,7 +50,7 @@ function handleToggle() {
车速
</text>
<text class="data-value">
{{ speed }} km/h
{{ speedTextSpaced }}
</text>
</view>
<view class="data-item">
@@ -62,7 +58,7 @@ function handleToggle() {
振动频率
</text>
<text class="data-value">
{{ frequency }} HZ
{{ frequencyText }}
</text>
</view>
<view class="data-item">
@@ -70,7 +66,7 @@ function handleToggle() {
振幅
</text>
<text class="data-value">
{{ amplitude }} mm
{{ amplitudeText }}
</text>
</view>
<view class="rtk-status">

View File

@@ -8,6 +8,7 @@ import type { HeatmapLayerKey } from './heatUtils'
*/
import type { MockRtkPoint } from '@/mock/rtkTrack'
import { getCurrentInstance, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { publishRtkPoint } from '@/composables/useRtkLive'
import { createMockRtkStream } from '@/mock/rtkTrack'
import { colorByScore, layerScore } from './heatUtils'
@@ -123,6 +124,7 @@ function startStream() {
stream.start((point) => {
appendPoint(point)
publishRtkPoint(point)
})
}

View File

@@ -1,7 +1,9 @@
<script setup lang="ts">
import { useCurrentProject } from '@/composables/useCurrentProject'
import { useRtkLive } from '@/composables/useRtkLive'
const { hasCurrentProject } = useCurrentProject()
const { speedText, tempText } = useRtkLive()
function goToWork() {
uni.switchTab({
@@ -37,28 +39,12 @@ function goToWork() {
</view>
</view>
<view class="status-params">
<!-- <view class="param">
<text class="param-label">
振动频率
</text>
<text class="param-value">
8939HZ
</text>
</view>
<view class="param">
<text class="param-label">
振幅
</text>
<text class="param-value">
8939mm
</text>
</view> -->
<view class="param">
<text class="param-label">
行驶速度
</text>
<text class="param-value">
3km/h
{{ speedText }}
</text>
</view>
<view class="param">
@@ -66,7 +52,7 @@ function goToWork() {
钢轮温度
</text>
<text class="param-value">
8939°C
{{ tempText }}
</text>
</view>
</view>

View File

@@ -1,24 +1,39 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useCurrentProject } from '@/composables/useCurrentProject'
import { useRtkLive } from '@/composables/useRtkLive'
const { hasCurrentProject } = useCurrentProject()
const {
compactionValue: liveCompaction,
speed,
compactionText: liveCompactionText,
frequencyText: liveFrequencyText,
} = useRtkLive()
// 压实度 (假数据,后续替换)
const compactionValue = computed(() => (hasCurrentProject.value ? 25 : 0))
const compactionText = computed(() => (hasCurrentProject.value ? `${compactionValue.value}%` : '--'))
const compactionValue = computed(() => {
if (!hasCurrentProject.value || liveCompaction.value == null)
return 0
return Math.round(liveCompaction.value)
})
const compactionText = computed(() => (hasCurrentProject.value ? liveCompactionText.value : '--'))
// 车速 (假数据,范围 0-12,中间值 6)
const speedValue = computed(() => (hasCurrentProject.value ? 4.2 : 0))
const speedText = computed(() => (hasCurrentProject.value ? `${speedValue.value}KM/H` : '--'))
const speedValue = computed(() => {
if (!hasCurrentProject.value || speed.value == null)
return 0
return speed.value
})
const speedText = computed(() => {
if (!hasCurrentProject.value || speed.value == null)
return '--'
return `${speed.value}KM/H`
})
const speedMax = 12
// 指针旋转角度:0km/h → 225°(左下),12km/h → -45°(右下),中间90°(正上)
const needleRotation = computed(() => 225 - (speedValue.value / speedMax) * 270)
const frequencyText = computed(() => (hasCurrentProject.value ? '8939HZ' : '--'))
const frequencyText = computed(() => (hasCurrentProject.value ? liveFrequencyText.value : '--'))
// 今日作业概览数据
const overviewData = computed(() => {
if (!hasCurrentProject.value) {
return [

View File

@@ -5,6 +5,7 @@
import type { MockRtkPoint } from '@/mock/rtkTrack'
import { getCurrentInstance, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { useCurrentProject } from '@/composables/useCurrentProject'
import { publishRtkPoint } from '@/composables/useRtkLive'
import { createMockRtkStream } from '@/mock/rtkTrack'
const props = withDefaults(defineProps<{
@@ -236,6 +237,7 @@ function startStream() {
stream.start((point, index) => {
trail.push(point)
publishRtkPoint(point)
finished = index >= stream.points.length - 1
updateHeightFromTrail()
nextTick(() => draw())

View File

@@ -1,27 +1,23 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useCurrentProject } from '@/composables/useCurrentProject'
import { useRtkLive } from '@/composables/useRtkLive'
interface Props {
deviceName?: string
speed?: number
frequency?: number
amplitude?: number
rtkFixed?: boolean
}
const props = withDefaults(defineProps<Props>(), {
deviceName: '徐工XS65H #01',
speed: 4.2,
frequency: 28.5,
amplitude: 1.86,
rtkFixed: true,
})
const { hasCurrentProject } = useCurrentProject()
const { speedTextSpaced } = useRtkLive()
const displayDeviceName = computed(() => (hasCurrentProject.value ? props.deviceName : '--'))
const displaySpeed = computed(() => (hasCurrentProject.value ? `${props.speed} km/h` : '--'))
const displaySpeed = computed(() => (hasCurrentProject.value ? speedTextSpaced.value : '--'))
const displayStatusText = computed(() => (hasCurrentProject.value ? '实时监测中' : '--'))
const displayRtkText = computed(() => (hasCurrentProject.value ? 'RTK固定' : '--'))