From 83f49b80c98ffa18a8b933d60b81cc352cc0f02c Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 7 Dec 2023 10:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A4=84=E7=90=86IBP=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E6=8C=89=E9=92=AE=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message_server/ibp_ms.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/message_server/ibp_ms.go b/message_server/ibp_ms.go index 6e1e02b..1a85856 100644 --- a/message_server/ibp_ms.go +++ b/message_server/ibp_ms.go @@ -2,6 +2,7 @@ package message_server import ( "fmt" + "log/slog" "time" "google.golang.org/protobuf/proto" @@ -96,7 +97,8 @@ func (ms *IbpMs) collectIBPButtonState(stationUid string, uidsMap *memory.IBPUid uid := stationUid + "_" + uidsMap.IbpButtonIds[data.Common.Id].Uid entry, ok := entity.GetEntityByUid(ms.vs.World, uid) if !ok { - return nil, fmt.Errorf("ibp按钮实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + slog.Warn("ibp按钮实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + continue } if entry.HasComponent(component.ButtonTag) { states = append(states, getIBPButtonState(data.Common.Id, entry)) @@ -125,7 +127,8 @@ func (ms *IbpMs) collectIBPAlarmState(stationUid string, uidsMap *memory.IBPUidS uid := stationUid + "_" + uidsMap.IbpAlarmIds[data.Common.Id].Uid entry, ok := entity.GetEntityByUid(ms.vs.World, uid) if !ok { - return nil, fmt.Errorf("ibp报警器实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + slog.Warn("ibp报警器实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + continue } if entry.HasComponent(component.AlarmTag) { states = append(states, &state.AlarmState{Id: data.Common.Id, Active: component.BitStateType.Get(entry).Val}) @@ -141,7 +144,8 @@ func (ms *IbpMs) collectIBPLightState(stationUid string, uidsMap *memory.IBPUidS uid := stationUid + "_" + uidsMap.IbpLightIds[data.Common.Id].Uid entry, ok := entity.GetEntityByUid(ms.vs.World, uid) if !ok { - return nil, fmt.Errorf("ibp指示灯实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + slog.Warn("ibp指示灯实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + continue } if entry.HasComponent(component.LightTag) { states = append(states, &state.LightState{Id: data.Common.Id, Active: component.BitStateType.Get(entry).Val}) @@ -157,7 +161,8 @@ func (ms *IbpMs) collectIBPKeyState(stationUid string, uidsMap *memory.IBPUidStr uid := stationUid + "_" + uidsMap.IbpKeyIds[data.Common.Id].Uid entry, ok := entity.GetEntityByUid(ms.vs.World, uid) if !ok { - return nil, fmt.Errorf("ibp钥匙实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + slog.Warn("ibp钥匙实体不存在: World id=%d, uid=%s", ms.vs.World.Id(), uid) + continue } if entry.HasComponent(component.KeyTag) { states = append(states, &state.KeyState{Id: data.Common.Id, Gear: component.GearStateType.Get(entry).Val})