From 312dd728b593be3c2a5564d3e4dc50811d35605d Mon Sep 17 00:00:00 2001 From: Eli Yip Date: Thu, 29 May 2025 09:39:58 +0800 Subject: [PATCH] chore: set l10 default connection info to true --- device/models/l10.go | 13 ++++--------- main.go | 7 +++---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/device/models/l10.go b/device/models/l10.go index 671adc5..3da54d9 100644 --- a/device/models/l10.go +++ b/device/models/l10.go @@ -30,13 +30,7 @@ type L10Hand struct { // 在 base 基础上进行 ±delta 的扰动,范围限制在 [0, 255] func perturb(base byte, delta int) byte { offset := rand.IntN(2*delta+1) - delta - v := int(base) + offset - if v < 0 { - v = 0 - } - if v > 255 { - v = 255 - } + v := min(max(int(base)+offset, 0), 255) return byte(v) } @@ -79,8 +73,9 @@ func NewL10Hand(config map[string]any) (device.Device, error) { components: make(map[device.ComponentType][]device.Component), canInterface: canInterface, status: device.DeviceStatus{ - IsConnected: false, - IsActive: false, + // TODO: 这里需要修改,根据实际连接情况设置,因为当前还没有实现连接和断开路由,先设置为 true + IsConnected: true, + IsActive: true, LastUpdate: time.Now(), }, } diff --git a/main.go b/main.go index df72e58..4bdaa74 100644 --- a/main.go +++ b/main.go @@ -2,9 +2,11 @@ package main import ( "fmt" - "hands/api" + "hands/api2" "hands/cli" "hands/config" + "hands/device" + "hands/device/models" "log" "os" "time" @@ -70,9 +72,6 @@ func main() { log.Fatal("❌ 没有设置默认 CAN 接口") } - // 记录启动时间 - api.ServerStartTime = time.Now() - log.Printf("🚀 启动 CAN 控制服务 (支持左右手配置)") // 初始化服务