From b45db2b229d8707b0a59d02726603abbfea384d6 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Fri, 15 Dec 2023 17:30:15 +0800 Subject: [PATCH] =?UTF-8?q?ISCS=20ACS=E7=B3=BB=E7=BB=9Fecs=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/iscs_acs.go | 27 +++++++++++++++++++++++++++ entity/iscs_acs.go | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 component/iscs_acs.go create mode 100644 entity/iscs_acs.go diff --git a/component/iscs_acs.go b/component/iscs_acs.go new file mode 100644 index 0000000..e43c6ee --- /dev/null +++ b/component/iscs_acs.go @@ -0,0 +1,27 @@ +package component + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/consts" +) + +// DoorSensor 门磁 +type DoorSensor struct { + State DsState //门磁状态 + Exception consts.DeviceExceptionEnum //具体异常-故障、异常、通信中断 +} + +// DsState 门磁状态 +type DsState = uint8 + +const ( + DsOpen DsState = iota //门打开 + DsNormallyOpen //门常开 + DsForceOpen //门强行打开 + DsClosed //门关闭 + DsNormallyClose //门常闭 +) + +var ( + DoorSensorType = ecs.NewComponentType[DoorSensor]() //门磁 +) diff --git a/entity/iscs_acs.go b/entity/iscs_acs.go new file mode 100644 index 0000000..f582394 --- /dev/null +++ b/entity/iscs_acs.go @@ -0,0 +1,18 @@ +package entity + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" +) + +// NewDoorSensorEntity 创建门磁实体 +func NewDoorSensorEntity(w ecs.World, id string) *ecs.Entry { + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.DoorSensorType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } + return e +}