2023-12-22 13:20:06 +08:00
|
|
|
package iscs_sys
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/ecs/filter"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
"joylink.club/rtsssimulation/entity"
|
|
|
|
"joylink.club/rtsssimulation/repository"
|
|
|
|
)
|
|
|
|
|
2024-01-05 15:21:29 +08:00
|
|
|
// 接地
|
2023-12-22 13:20:06 +08:00
|
|
|
type EarthingDeviceSystem struct {
|
|
|
|
query *ecs.Query
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewEarthingDeviceSystem() *EarthingDeviceSystem {
|
|
|
|
return &EarthingDeviceSystem{
|
|
|
|
query: ecs.NewQuery(filter.Contains(component.UidType, component.EarthingDeviceType)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update 接地装置传递异常电能
|
|
|
|
func (s *EarthingDeviceSystem) Update(w ecs.World) {
|
|
|
|
wd := entity.GetWorldData(w)
|
|
|
|
s.query.Each(w, func(entry *ecs.Entry) {
|
|
|
|
edId := component.UidType.Get(entry).Id
|
|
|
|
ed := component.EarthingDeviceType.Get(entry)
|
|
|
|
//
|
|
|
|
edModel := (wd.Repo.FindById(edId)).(*repository.EarthingDevice)
|
|
|
|
if edModel.PortA != nil {
|
|
|
|
edPipeEntry := wd.EntityMap[edModel.PortA.Device().Id()]
|
2024-01-05 15:21:29 +08:00
|
|
|
edPipe := perfectPipeElectricity(edPipeEntry)
|
2024-01-05 11:30:39 +08:00
|
|
|
ed.Voltage = edPipe.U
|
2023-12-22 13:20:06 +08:00
|
|
|
} else {
|
2024-01-05 11:30:39 +08:00
|
|
|
ed.Voltage = 0 //零电压
|
2023-12-22 13:20:06 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|