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

36 lines
1.0 KiB
Go
Raw Normal View History

package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/repository"
)
type DisconnectorSystem struct {
query *ecs.Query
}
func NewDisconnectorSystem() *DisconnectorSystem {
return &DisconnectorSystem{
query: ecs.NewQuery(filter.Contains(component.UidType, component.DisconnectorType, component.DeviceExceptionType)),
}
}
func (s *DisconnectorSystem) Update(w ecs.World) {
s.disconnectorTransPower(w)
}
// 隔离开关传递电能
func (s *DisconnectorSystem) disconnectorTransPower(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
breakerId := component.UidType.Get(entry).Id
closed := component.DisconnectorType.Get(entry).Closed
breakerModel := (wd.Repo.FindById(breakerId)).(*repository.Disconnector)
breakerPortA := breakerModel.PortA
breakerPortB := breakerModel.PortB
towPipePortsTransPower(wd, closed, breakerPortA, breakerPortB)
})
}