package entity import ( "joylink.club/ecs" "joylink.club/rtsssimulation/component" ) // // NewCircuitBreakerEntity 创建断路器 func NewCircuitBreakerEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.CircuitBreakerType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) wd.EntityMap[id] = e } return e } // NewThreePositionSwitchEntity 创建三工位隔离开关实体 func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: component.StpOpened}) wd.EntityMap[id] = e } return e } // NewHandcartSwitchEntity 创建手车实体 func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.HandcartSwitchType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: component.HpOpened}) wd.EntityMap[id] = e } return e } // NewRectifierEntity 创建整流器实体 func NewRectifierEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.RectifierType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) wd.EntityMap[id] = e } return e } // NewDisconnectorEntity 创建隔离开关实体 func NewDisconnectorEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.DisconnectorType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) wd.EntityMap[id] = e } return e } // NewLightningArresterEntity 创建避雷器实体 func NewLightningArresterEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.LightningArresterType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.LightningArresterType.Set(e, &component.LightningArrester{Normal: true}) wd.EntityMap[id] = e } return e } // NewEarthingDeviceEntity 创建接地装置实体 func NewEarthingDeviceEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.EarthingDeviceType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.EarthingDeviceType.Set(e, &component.EarthingDevice{Voltage: 0}) wd.EntityMap[id] = e } return e } // NewVoltageTransformerEntity 创建变压器实体 func NewVoltageTransformerEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.VoltageTransformerType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) wd.EntityMap[id] = e } return e } // NewPowerPipeEntity 创建PSCADA电力母线实体 func NewPowerPipeEntity(w ecs.World, id string) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.PowerPipeType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.PowerPipeType.Set(e, &component.PowerPipe{Sources: make(map[string]*component.ElePower)}) wd.EntityMap[id] = e } return e } // NewPowerSourceEntity 创建PSCADA电源实体 func NewPowerSourceEntity(w ecs.World, id string, ac bool, voltage uint32) *ecs.Entry { wd := GetWorldData(w) e, ok := wd.EntityMap[id] if !ok { e = w.Entry(w.Create(component.UidType, component.PowerSourceType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.PowerSourceType.Set(e, &component.PowerSource{Ac: ac, Voltage: voltage}) wd.EntityMap[id] = e } return e }