ISCS ACS系统ecs定义

This commit is contained in:
xzb 2023-12-15 17:30:15 +08:00
parent ad86410c99
commit b45db2b229
2 changed files with 45 additions and 0 deletions

27
component/iscs_acs.go Normal file
View File

@ -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]() //门磁
)

18
entity/iscs_acs.go Normal file
View File

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