Compare commits

..
10 Commits
14 changed files with 887 additions and 39 deletions
+33
View File
@@ -777,3 +777,36 @@ async def power_control(power_data: dict):
except Exception as e:
print(f"电源控制时发生错误: {e}")
raise HTTPException(status_code=500, detail=str(e))
# 扫描控制API - 控制Scanner的启动与停止
@app.post("/api/scanctrl")
async def scan_control(scan_data: dict):
"""
控制Scanner的启动与停止
参数:
- action: 操作,可选值: 'start' (启动) 或 'stop' (停止)
"""
try:
action = scan_data.get("action")
# 验证操作类型
if action not in ['start', 'stop']:
raise HTTPException(status_code=400, detail="action 必须是 'start' 或 'stop'")
try:
path = "/home/admin/.config/cpy/config.json"
with open(path, "r") as f:
config = json.load(f)
sn = config.get('sn', "")
if sn == "":
raise HTTPException(status_code=400, detail="配置文件中缺少 sn 字段")
except FileNotFoundError:
raise HTTPException(status_code=400, detail="配置文件不存在")
mqtt_client.publish(f"v1/cpy/{sn}/control", json.dumps({"method": "scan_control", "action": action}))
return {"action": action, "status": "success"}
except HTTPException:
raise
except Exception as e:
print(f"扫描控制时发生错误: {e}")
raise HTTPException(status_code=500, detail=str(e))
-1
View File
@@ -27,5 +27,4 @@ coverage
*.sln
*.sw?
*.json
*.ts
*.tsbuildinfo
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+31 -12
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { ref, onMounted, onUnmounted, computed } from 'vue'
import axios from 'axios'
import { useRoute } from 'vue-router'
import {
@@ -7,7 +7,7 @@ import {
Connection,
List,
Setting,
Zap,
SwitchButton,
ArrowLeft,
ArrowRight
} from '@element-plus/icons-vue'
@@ -15,8 +15,18 @@ import {
const systemInfo = ref(null)
const networkInfo = ref(null)
const isSidebarCollapsed = ref(false)
const isMobile = ref(false)
const route = useRoute()
// 检测是否为移动设备
const checkMobile = () => {
isMobile.value = window.innerWidth <= 768
// 移动设备上默认折叠侧边栏
if (isMobile.value) {
isSidebarCollapsed.value = true
}
}
const currentRoute = computed(() => route.path)
const activeMenu = computed(() => route.path)
@@ -50,6 +60,8 @@ const toggleSidebar = () => {
// 页面加载时获取信息
onMounted(() => {
checkMobile()
window.addEventListener('resize', checkMobile)
fetchSystemInfo()
fetchNetworkInfo()
// 每30秒更新一次系统信息
@@ -57,6 +69,10 @@ onMounted(() => {
// 每60秒更新一次网络信息
setInterval(fetchNetworkInfo, 60000)
})
onUnmounted(() => {
window.removeEventListener('resize', checkMobile)
})
</script>
<template>
@@ -64,7 +80,7 @@ onMounted(() => {
<el-container>
<el-aside :width="isSidebarCollapsed ? '64px' : '200px'">
<div class="logo">
<span v-if="!isSidebarCollapsed">树莓派设备管理系统</span>
<span v-if="!isSidebarCollapsed">设备管理系统</span>
</div>
<el-menu
:default-active="activeMenu"
@@ -93,7 +109,7 @@ onMounted(() => {
<template #title>服务管理</template>
</el-menu-item>
<el-menu-item index="/power-control">
<el-icon><Zap /></el-icon>
<el-icon><SwitchButton /></el-icon>
<template #title>电源控制</template>
</el-menu-item>
</el-menu>
@@ -101,9 +117,6 @@ onMounted(() => {
<!-- 主内容区 -->
<div class="main-container" :class="{ 'sidebar-collapsed': isSidebarCollapsed }">
<header class="header">
<h1>测偏仪管理后台</h1>
</header>
<main class="main-content">
<div class="content-wrapper">
<router-view></router-view>
@@ -223,27 +236,33 @@ onMounted(() => {
position: fixed;
height: 100vh;
z-index: 1000;
width: 64px !important;
}
.main-container {
margin-left: 0;
margin-left: 64px !important;
}
.main-container.sidebar-collapsed {
margin-left: 0;
margin-left: 64px !important;
}
.header {
left: 0;
left: 64px !important;
}
.sidebar-collapsed + .header {
left: 0;
left: 64px !important;
}
.content-wrapper {
max-width: 100%;
padding: 0 1rem;
padding: 0 0.5rem;
}
.logo {
padding: 0;
justify-content: center;
}
}
</style>
+19
View File
@@ -0,0 +1,19 @@
import './assets/main.css'
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router/index.ts'
import axios from 'axios'
// 配置 axios 默认值
// axios.defaults.baseURL = window.location.origin + ':8000/api'
// axios.defaults.baseURL = '/api'
axios.defaults.baseURL = `${window.location.protocol}//${window.location.hostname}/api`;
const app = createApp(App)
app.use(ElementPlus)
app.use(router)
app.mount('#app')
+45
View File
@@ -0,0 +1,45 @@
import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import DeviceManagement from '../views/DeviceManagement.vue'
import DeviceTypeManagement from '../views/DeviceTypeManagement.vue'
import ServiceManagement from '../views/ServiceManagement.vue'
import InterfaceManagement from '../views/InterfaceManagement.vue'
import PowerControl from '../views/PowerControl.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/devices',
name: 'devices',
component: DeviceManagement
},
{
path: '/device-types',
name: 'device-types',
component: DeviceTypeManagement
},
{
path: '/services',
name: 'services',
component: ServiceManagement
},
{
path: '/interfaces',
name: 'interfaces',
component: InterfaceManagement
},
{
path: '/power-control',
name: 'power-control',
component: PowerControl
}
]
})
export default router
+34
View File
@@ -0,0 +1,34 @@
export interface DeviceTypeItem {
id: number
name: string
code: string
address_range_start: number
address_range_end: number
chip_model: string
description?: string
created_at: string
}
export interface InterfaceItem {
id: number
name: string
type: 'CAN' | 'Powerbus'
description?: string
port?: string
baud_rate?: number
can_channel?: number
can_baud_rate?: number
created_at: string
}
export interface DeviceItem {
id: number
name: string
device_address: number
device_type_id?: number
interface_id: number
status: string
created_at: string
device_type?: DeviceTypeItem
interface?: InterfaceItem
}
+50
View File
@@ -0,0 +1,50 @@
export interface DeviceStatus {
light?: boolean;
flow_rate?: number;
water_temp?: number;
[key: string]: any;
}
export interface DeviceItem {
id: number;
name: string;
code: string;
device_address: number;
device_type_id: number | null;
interface_id: number;
status?: DeviceStatus;
last_update?: string;
created_at: string;
updated_at: string;
device_type?: {
id: number;
name: string;
code: string;
};
interface?: {
id: number;
name: string;
};
}
export interface DeviceTypeItem {
id: number;
name: string;
code: string;
address_range_start: number;
address_range_end: number;
chip_model: string;
description?: string;
created_at: string;
}
export interface InterfaceItem {
id: number;
name: string;
type: 'CAN' | 'Powerbus';
can_channel?: number;
can_baud_rate?: number;
port?: string;
baud_rate?: number;
created_at: string;
}
+45 -19
View File
@@ -11,12 +11,18 @@
<div v-for="device in devices" :key="device.id" class="device-card">
<div class="device-header">
<h3>{{ device.name }}</h3>
<div class="device-header-right">
<div class="device-status-container">
<div class="device-enabled" :class="device.enabled ? 'enabled' : 'disabled'">
<span class="device-enabled" :class="device.enabled ? 'enabled' : 'disabled'">
{{ device.enabled ? '已启用' : '已禁用' }}
</div>
<div class="device-status" :class="typeof device.status === 'object' && device.status.online ? 'online' : 'offline'">
</span>
<span class="device-status" :class="typeof device.status === 'object' && device.status.online ? 'online' : 'offline'">
{{ typeof device.status === 'object' && device.status.online ? '在线' : '离线' }}
</span>
</div>
<div class="device-header-actions">
<el-button type="text" @click="editDevice(device)">编辑</el-button>
<el-button type="text" @click="deleteDevice(device)">删除</el-button>
</div>
</div>
</div>
@@ -104,8 +110,6 @@
@click="controlDevice2(device, 'emergency_stop', 0)"
>急停</el-button>
</template>
<el-button type="primary" @click="editDevice(device)">编辑</el-button>
<el-button type="danger" @click="deleteDevice(device)">删除</el-button>
</div>
</div>
</div>
@@ -749,41 +753,63 @@ onMounted(() => {
margin-bottom: 15px;
}
.device-header-right {
display: flex;
align-items: center;
gap: 16px;
}
.device-status-container {
display: flex;
gap: 8px;
}
.device-enabled {
padding: 4px 8px;
border-radius: 4px;
font-size: 0.9rem;
padding: 2px 6px;
border-radius: 2px;
font-size: 0.75rem;
font-weight: 500;
}
.device-enabled.enabled {
background-color: #67C23A;
color: white;
background-color: #E8F5E9;
color: #2E7D32;
border: 1px solid #C8E6C9;
}
.device-enabled.disabled {
background-color: #909399;
color: white;
background-color: #F5F5F5;
color: #757575;
border: 1px solid #E0E0E0;
}
.device-status {
padding: 4px 8px;
border-radius: 4px;
font-size: 0.9rem;
padding: 2px 6px;
border-radius: 2px;
font-size: 0.75rem;
font-weight: 500;
}
.device-status.online {
background-color: #67C23A;
color: white;
background-color: #E3F2FD;
color: #1565C0;
border: 1px solid #BBDEFB;
}
.device-status.offline {
background-color: #F56C6C;
color: white;
background-color: #FFEBEE;
color: #C62828;
border: 1px solid #FFCDD2;
}
.device-header-actions {
display: flex;
gap: 8px;
}
.device-header-actions .el-button--text {
padding: 4px 8px;
font-size: 0.85rem;
}
.device-info {
+498
View File
@@ -0,0 +1,498 @@
<template>
<div class="power-control-page">
<h2>电源与扫描控制</h2>
<!-- 电源状态概览 -->
<el-card class="status-card">
<template #header>
<div class="card-header">
<span>电源状态概览</span>
</div>
</template>
<div class="status-grid">
<div class="status-item">
<div class="status-icon" :class="hvsPowerStatus">
<span class="icon-circle"></span>
</div>
<div class="status-info">
<h3>HVS 供电</h3>
<el-tag :type="hvsPowerStatus === 'on' ? 'success' : hvsPowerStatus === 'off' ? 'danger' : 'warning'">
{{ hvsPowerStatus === 'on' ? '已开启' : hvsPowerStatus === 'off' ? '已关闭' : '未知' }}
</el-tag>
</div>
</div>
<div class="status-item">
<div class="status-icon" :class="scannerPowerStatus">
<span class="icon-circle"></span>
</div>
<div class="status-info">
<h3>Scanner 供电</h3>
<el-tag :type="scannerPowerStatus === 'on' ? 'success' : scannerPowerStatus === 'off' ? 'danger' : 'warning'">
{{ scannerPowerStatus === 'on' ? '已开启' : scannerPowerStatus === 'off' ? '已关闭' : '未知' }}
</el-tag>
</div>
</div>
</div>
</el-card>
<!-- HVS电源控制 -->
<el-card class="control-card">
<template #header>
<div class="card-header">
<span>HVS 电源控制</span>
</div>
</template>
<div class="control-content">
<div class="control-description">
<p>HVS(高压电源)用于为测偏仪的高压部件提供电力。</p>
<p>GPIO 引脚: <strong>GPIO26</strong></p>
</div>
<div class="control-actions">
<el-button
type="primary"
:loading="hvsLoading"
@click="controlPower('hvs', 'on')"
>
<span class="btn-icon">▸</span> 打开供电
</el-button>
<el-button
type="danger"
:loading="hvsLoading"
@click="controlPower('hvs', 'off')"
>
<span class="btn-icon">■</span> 关闭供电
</el-button>
</div>
</div>
</el-card>
<!-- Scanner电源控制 -->
<el-card class="control-card">
<template #header>
<div class="card-header">
<span>Scanner 电源控制</span>
</div>
</template>
<div class="control-content">
<div class="control-description">
<p>Scanner(扫描器)用于获取测量数据。</p>
<p>GPIO 引脚: <strong>GPIO17</strong></p>
</div>
<div class="control-actions">
<el-button
type="primary"
:loading="scannerLoading"
@click="controlPower('scanner', 'on')"
>
<span class="btn-icon">▸</span> 打开供电
</el-button>
<el-button
type="danger"
:loading="scannerLoading"
@click="controlPower('scanner', 'off')"
>
<span class="btn-icon">■</span> 关闭供电
</el-button>
</div>
</div>
</el-card>
<!-- 扫描控制 -->
<el-card class="control-card scan-card">
<template #header>
<div class="card-header">
<span>扫描控制</span>
</div>
</template>
<div class="control-content">
<div class="control-description">
<p>控制扫描过程的启动与停止。</p>
</div>
<div class="control-actions">
<el-button
type="success"
:loading="scanLoading"
@click="controlScan('start')"
>
<span class="btn-icon">▶</span> 启动扫描
</el-button>
<el-button
type="warning"
:loading="scanLoading"
@click="controlScan('stop')"
>
<span class="btn-icon">■</span> 停止扫描
</el-button>
</div>
</div>
</el-card>
<!-- 操作日志 -->
<el-card class="log-card">
<template #header>
<div class="card-header">
<span>操作日志</span>
</div>
</template>
<div class="log-container">
<div
v-for="(log, index) in operationLogs"
:key="index"
class="log-item"
:class="log.type"
>
<span class="log-time">{{ log.time }}</span>
<span class="log-content">{{ log.message }}</span>
</div>
<div v-if="operationLogs.length === 0" class="empty-log">
暂无操作记录
</div>
</div>
</el-card>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import axios from 'axios'
import { ElMessage } from 'element-plus'
// 电源状态
const hvsPowerStatus = ref('unknown')
const scannerPowerStatus = ref('unknown')
const hvsLoading = ref(false)
const scannerLoading = ref(false)
// 扫描状态
const scanLoading = ref(false)
// 操作日志
const operationLogs = ref<Array<{ time: string; message: string; type: string }>>([
{ time: new Date().toLocaleTimeString(), message: '系统已启动', type: 'info' }
])
// 获取电源状态
const fetchPowerStatus = async () => {
try {
// 获取HVS电源状态
const hvsResponse = await axios.post('/powerctrl', {
device: 'hvs',
action: 'status'
})
hvsPowerStatus.value = hvsResponse.data.status
// 获取Scanner电源状态
const scannerResponse = await axios.post('/powerctrl', {
device: 'scanner',
action: 'status'
})
scannerPowerStatus.value = scannerResponse.data.status
} catch (error) {
console.error('获取电源状态失败:', error)
hvsPowerStatus.value = 'unknown'
scannerPowerStatus.value = 'unknown'
addLog('error', '获取电源状态失败')
}
}
// 控制电源
const controlPower = async (device: string, action: string) => {
const deviceName = device === 'hvs' ? 'HVS' : 'Scanner'
const actionText = action === 'on' ? '打开' : '关闭'
// 设置加载状态
if (device === 'hvs') {
hvsLoading.value = true
} else {
scannerLoading.value = true
}
addLog('info', `正在${actionText}${deviceName}电源...`)
try {
const response = await axios.post('/powerctrl', {
device: device,
action: action
})
if (response.data.status === 'success') {
ElMessage.success(`${deviceName}电源${actionText}成功`)
addLog('success', `${deviceName}电源${actionText}成功`)
// 控制成功后立即刷新状态
setTimeout(fetchPowerStatus, 500)
} else {
ElMessage.error('操作失败')
addLog('error', `${deviceName}电源${actionText}失败`)
}
} catch (error) {
console.error('控制电源失败:', error)
ElMessage.error('控制电源失败')
addLog('error', `${deviceName}电源${actionText}失败: ${error}`)
} finally {
// 清除加载状态
if (device === 'hvs') {
hvsLoading.value = false
} else {
scannerLoading.value = false
}
}
}
// 控制扫描
const controlScan = async (action: 'start' | 'stop') => {
const actionText = action === 'start' ? '启动' : '停止'
scanLoading.value = true
addLog('info', `正在${actionText}扫描...`)
try {
const response = await axios.post('/scanctrl', {
action: action
})
if (response.data.status === 'success') {
ElMessage.success(`扫描${actionText}成功`)
addLog('success', `扫描${actionText}成功`)
} else {
ElMessage.error('操作失败')
addLog('error', `扫描${actionText}失败`)
}
} catch (error) {
console.error('扫描控制失败:', error)
ElMessage.error(`扫描${actionText}失败`)
addLog('error', `扫描${actionText}失败: ${error}`)
} finally {
scanLoading.value = false
}
}
// 添加日志
const addLog = (type: string, message: string) => {
operationLogs.value.unshift({
time: new Date().toLocaleTimeString(),
message: message,
type: type
})
// 保留最近50条日志
if (operationLogs.value.length > 50) {
operationLogs.value.pop()
}
}
// 页面加载时获取状态
onMounted(() => {
fetchPowerStatus()
})
</script>
<style scoped>
.power-control-page {
padding: 20px;
max-width: 800px;
margin: 0 auto;
min-height: calc(100vh - 84px);
background-color: #f5f7fa;
}
h2 {
margin-bottom: 24px;
color: #1f2f3d;
font-weight: 500;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 20px;
border-bottom: 1px solid #ebeef5;
}
.status-card {
margin-bottom: 20px;
background: white;
border-radius: 8px;
}
.status-grid {
display: flex;
gap: 20px;
padding: 20px;
}
.status-item {
flex: 1;
display: flex;
align-items: center;
gap: 16px;
padding: 20px;
background: #f8f9fa;
border-radius: 8px;
}
.status-icon {
width: 48px;
height: 48px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
}
.status-icon.on {
background: #f0f9eb;
}
.status-icon.off {
background: #fff2f0;
}
.status-icon.unknown {
background: #fffbe6;
}
.icon-circle {
width: 24px;
height: 24px;
border-radius: 50%;
}
.status-icon.on .icon-circle {
background: #67c23a;
box-shadow: 0 0 12px rgba(103, 194, 58, 0.5);
}
.status-icon.off .icon-circle {
background: #f56c6c;
box-shadow: 0 0 12px rgba(245, 108, 108, 0.5);
}
.status-icon.unknown .icon-circle {
background: #e6a23c;
box-shadow: 0 0 12px rgba(230, 162, 60, 0.5);
}
.status-info h3 {
margin-bottom: 8px;
color: #303133;
font-size: 16px;
}
.control-card {
margin-bottom: 20px;
background: white;
border-radius: 8px;
}
.scan-card {
border-left: 4px solid #409eff;
}
.control-content {
padding: 20px;
}
.control-description {
margin-bottom: 20px;
}
.control-description p {
margin-bottom: 8px;
color: #606266;
line-height: 1.6;
}
.control-description strong {
color: #409eff;
}
.control-actions {
display: flex;
gap: 12px;
}
.btn-icon {
margin-right: 6px;
}
.log-card {
background: white;
border-radius: 8px;
}
.log-container {
padding: 20px;
max-height: 300px;
overflow-y: auto;
}
.log-item {
padding: 10px 12px;
margin-bottom: 8px;
border-radius: 4px;
font-size: 14px;
}
.log-item:last-child {
margin-bottom: 0;
}
.log-item.info {
background: #f0f5ff;
color: #409eff;
}
.log-item.success {
background: #f0f9eb;
color: #67c23a;
}
.log-item.error {
background: #fff2f0;
color: #f56c6c;
}
.log-time {
margin-right: 12px;
font-weight: 500;
}
.empty-log {
text-align: center;
color: #909399;
padding: 20px;
}
:deep(.el-card__header) {
padding: 0;
}
:deep(.el-card__body) {
padding: 0;
}
:deep(.el-tag) {
font-weight: 500;
}
@media (max-width: 768px) {
.status-grid {
flex-direction: column;
}
.control-actions {
flex-direction: column;
}
}
</style>
+39
View File
@@ -0,0 +1,39 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
build:{
chunkSizeWarningLimit: 1500,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return 'vendor';
}
}
}
}
},
plugins: [vue()
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
host : '192.168.8.118',
port: 8001,
proxy: {
'/api': {
target: 'http://192.168.8.118:8000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
},
// cors: true
},
base: '/'
})
+6
View File
@@ -1,11 +1,17 @@
import time
import os
from config import *
from tcp_io_module import TcpIoModule
from hvs import HvService
from mqtt_client import mqtt_client
# pinctrl set 26 op pn dl
def main():
#通过pinctrl打开电源
os.system("pinctrl set 26 op pn dl")
io_module = TcpIoModule(host='192.168.8.211', port=502)
io_module.start()
+75 -2
View File
@@ -1,3 +1,4 @@
import math
import time
import json
import logging
@@ -166,6 +167,75 @@ class SensorService:
logger.info(f"成功发布服务状态到 {SERVICE_STATUS_TOPIC}: {service_message}")
self.last_service_status_time = current_time
# float get_temperature(float Rt)
# {
# const float Rp = 50000.0; ///< 10K NTC
# const float T2 = (273.15+25.0); ///< 10K NTC
# const float Bx = 3950.0; ///< 10K NTC
# const float Ka = 273.15; ///< 10K NTC
# float Temp = 0.0f;
# Temp = Rt / Rp;
# Temp = log(Temp);
# Temp /=Bx;
# Temp += (1 / T2);
# Temp = 1 / Temp;
# Temp -= Ka;
# return Temp;
# }
def wsu_get_temperature(self, Rt):
"""计算WSU温度"""
Rp = 50000.0
T2 = (273.15+25.0)
Bx = 3950.0
Ka = 273.15
Temp = 0.0
Temp = Rt / Rp
Temp = math.log10(Temp)
Temp /=Bx
Temp += (1 / T2)
Temp = 1 / Temp
Temp -= Ka
return Temp
def wsu_get_flow_rate_g1(self, freq):
"""计算WSU流量"""
if freq == 0:
return 0.0
return 50 * 1000.0 * 60 * 10 / 660 / freq
def wsu_get_flow_rate_g2(self, freq, factor):
"""计算WSU流量"""
if freq == 0:
return 0.0
return freq * 60 / factor
def handle_wsu_data(self, device, regs):
"""处理WSU数据"""
if not regs or len(regs) < 2:
return 0, 0
generation = device.get("generation", "0")
flow_rate = regs[0]
water_temp = regs[1]
if generation == "0" and regs[1] < 500:
flow_rate = flow_rate / 1000.0
water_temp = water_temp / 10.0
elif generation == "1" and regs[1] >= 500:
flow_rate = self.wsu_get_flow_rate_g1(flow_rate)
water_temp = self.wsu_get_temperature(water_temp * 2)
elif generation == "2":
factor = device.get("factor", 6000)
flow_rate = self.wsu_get_flow_rate_g2(flow_rate, factor)
water_temp = self.wsu_get_temperature(water_temp * 2)
return flow_rate, water_temp
def read_and_publish_devices_data(self):
"""读取并发布所有设备数据"""
# 确保Modbus连接正常
@@ -190,11 +260,14 @@ class SensorService:
device["error_count"] = device.get("error_count", 10) + 1
else:
device["error_count"] = 0
flow_rate, water_temp = self.handle_wsu_data(device, regs)
device.update({
"status" : {
"online": device.get("error_count", 10) < 3,
"flow_rate": regs[0] / 1000.0 if regs and len(regs) > 0 else None,
"water_temp": regs[1] / 10.0 if regs and len(regs) > 1 else None,
"flow_rate": flow_rate,
"water_temp": water_temp
}
})
elif device.get('type', '') == 'OSU':
@@ -34,6 +34,7 @@ class Scanner:
self.last_update_time = 0
self.location = 0
self.velocity = 0
self.motor_power = 'on'
self.daq_info = {}
@@ -207,6 +208,11 @@ class MotorManager(QObject):
self.scanner(index).daq_info['temp'] = data['daq_temp']
if 'daq_online' in data:
self.scanner(index).daq_info['online'] = data['daq_online']
if 'daq_power' in data:
self.scanner(index).daq_info['power'] = data['daq_power']
if 'motor_power' in data:
self.scanner(index).motor_power = data['motor_power']
if self.scanner(index).state in [ScannerState.MOVING_UP, ScannerState.MOVING_DOWN]:
self.scanner(index).last_moving_time = time.time()