【修改】车库门继电器状态丢失的故障由应用层实现;不再影响继电器的实际状态;也不再导致门故障继电器接通;

This commit is contained in:
thesai 2024-03-29 16:46:30 +08:00
parent 6d5457f706
commit cf783364fe
3 changed files with 9 additions and 52 deletions

View File

@ -5,10 +5,9 @@ import (
) )
var ( var (
CkmTag = ecs.NewTag() CkmTag = ecs.NewTag()
CkmStateLossTag = ecs.NewTag() //状态丢失故障tag CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
CkmCircuitType = ecs.NewComponentType[CkmCircuit]() CkmPslType = ecs.NewComponentType[CkmPsl]()
CkmPslType = ecs.NewComponentType[CkmPsl]()
) )
type CkmCircuit struct { type CkmCircuit struct {
@ -23,6 +22,10 @@ type CkmCircuit struct {
GMJ *ecs.Entry //关门继电器 GMJ *ecs.Entry //关门继电器
} }
func (c *CkmCircuit) RelayList() []*ecs.Entry {
return []*ecs.Entry{c.MKJ, c.MGJ, c.MGZJ, c.MPLJ, c.MMSJ, c.KMJ, c.GMJ}
}
type CkmPsl struct { type CkmPsl struct {
KMA *ecs.Entry //开门按钮 KMA *ecs.Entry //开门按钮
GMA *ecs.Entry //关门按钮 GMA *ecs.Entry //关门按钮

View File

@ -1,42 +0,0 @@
package fi
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// 采集继电器吸起电路状态
func CollectXQCircuitState(w ecs.World, id string) bool {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
state := component.BitStateType.Get(entry)
return state.Val
} else {
fmt.Printf("未找到id=%s的继电器\n", id)
}
return false
}
// 采集继电器落下电路状态
func CollectLXCircuitState(w ecs.World, id string) bool {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
state := component.BitStateType.Get(entry)
return !state.Val
} else {
fmt.Printf("未找到id=%s的继电器\n", id)
}
return false
}
// 驱动电路状态修改
// x,y:二维数组的索引
// state : 32位的bool数组
func DriveCircuitStateChange(w ecs.World, x, y int, state bool) {
}

View File

@ -22,10 +22,6 @@ func NewCkmSys() *CkmSys {
func (p *CkmSys) Update(world ecs.World) { func (p *CkmSys) Update(world ecs.World) {
worldData := entity.GetWorldData(world) worldData := entity.GetWorldData(world)
p.query.Each(world, func(entry *ecs.Entry) { p.query.Each(world, func(entry *ecs.Entry) {
//车库门故障(状态丢失)
if entry.HasComponent(component.CkmStateLossTag) {
return
}
posCom := component.FixedPositionTransformType.Get(entry) posCom := component.FixedPositionTransformType.Get(entry)
circuit := component.CkmCircuitType.Get(entry) //目前不考虑没有车库门电路的情况 circuit := component.CkmCircuitType.Get(entry) //目前不考虑没有车库门电路的情况
//车库门PSL //车库门PSL
@ -42,8 +38,8 @@ func (p *CkmSys) Update(world ecs.World) {
component.RelayDriveType.Get(circuit.MGJ).Td = false component.RelayDriveType.Get(circuit.MGJ).Td = false
component.RelayDriveType.Get(circuit.MKJ).Td = true component.RelayDriveType.Get(circuit.MKJ).Td = true
} }
//门故障继电器及状态 ////门故障继电器及状态
component.RelayDriveType.Get(circuit.MGZJ).Td = entry.HasComponent(component.CkmStateLossTag) //component.RelayDriveType.Get(circuit.MGZJ).Td =
//开/关门继电器驱动状态 //开/关门继电器驱动状态
if component.BitStateType.Get(circuit.MMSJ).Val { if component.BitStateType.Get(circuit.MMSJ).Val {
ckmPsl := component.CkmPslType.Get(entry) ckmPsl := component.CkmPslType.Get(entry)