【获取继电器吸起、落下电路状态】
This commit is contained in:
parent
2a57111870
commit
b93fd9ad2a
35
fi/circuit.go
Normal file
35
fi/circuit.go
Normal file
@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user