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 +}