rts-sim-module/sys/iscs_sys/iscs_pscada_three_position_switch.go

37 lines
1.1 KiB
Go

package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/repository"
)
type ThreePositionSwitchSystem struct {
query *ecs.Query
}
func NewThreePositionSwitchSystem() *ThreePositionSwitchSystem {
return &ThreePositionSwitchSystem{
query: ecs.NewQuery(filter.Contains(component.UidType, component.ThreePositionSwitchType)),
}
}
func (s *ThreePositionSwitchSystem) Update(w ecs.World) {
s.threePositionSwitchTransPower(w)
}
// 三工位隔离开关传递电能
func (s *ThreePositionSwitchSystem) threePositionSwitchTransPower(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
breakerId := component.UidType.Get(entry).Id
closed := component.ThreePositionSwitchType.Get(entry).Position == component.StpClosedWorking
breakerModel := (wd.Repo.FindById(breakerId)).(*repository.ThreePositionSwitch)
breakerPortA := breakerModel.PortA
breakerPortB := breakerModel.PortB
towPipePortsTransPower(wd, closed, breakerPortA, breakerPortB)
})
}