ISCS ACS系统ecs定义
This commit is contained in:
parent
ad86410c99
commit
b45db2b229
27
component/iscs_acs.go
Normal file
27
component/iscs_acs.go
Normal 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
18
entity/iscs_acs.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user