iscs bas 大系统
This commit is contained in:
parent
7deeabe23e
commit
19a231c95b
@ -11,7 +11,7 @@ func NewWireCabinetEntity(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.WireCabinetType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.WireCabinetType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -23,7 +23,7 @@ func NewNetworkSwitchEntity(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.NetworkSwitchType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.NetworkSwitchType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.NetworkSwitchType.Set(e, &component.NetworkSwitch{Normal: true})
|
||||
wd.EntityMap[id] = e
|
||||
@ -36,7 +36,7 @@ func NewAirPavilionEntity(w ecs.World, id string, apType proto.AirPavilion_Type)
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.AirPavilionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.AirPavilionType))
|
||||
//
|
||||
switch apType {
|
||||
case proto.AirPavilion_ExhaustPavilion:
|
||||
@ -57,7 +57,7 @@ func NewValveEntity(w ecs.World, id string, valveType proto.Valve_Type) *ecs.Ent
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.ValveType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.ValveType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.ValveType.Set(e, &component.Valve{OpenRate: 100, Closed: false, Opened: true, Moving: false})
|
||||
//
|
||||
@ -82,7 +82,7 @@ func NewGasMixingChamberEntity(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.GasMixingChamberType))
|
||||
e = w.Entry(w.Create(component.UidType, component.GasMixingChamberType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -97,7 +97,7 @@ func newAirConditioningEntity(w ecs.World, id string, tag *ecs.ComponentType[str
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.AirConditioningType, component.DeviceExceptionType, tag))
|
||||
e = w.Entry(w.Create(component.UidType, component.AirConditioningType, component.DeviceExceptionType, tag))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -109,7 +109,7 @@ func NewPurificationDeviceEntity(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.PurificationDeviceType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.PurificationDeviceType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -121,7 +121,7 @@ func NewAirCurtainEntity(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.AirCurtainType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.AirCurtainType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -133,7 +133,7 @@ func NewGasEnvironmentEntity(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.GasEnvironmentType))
|
||||
e = w.Entry(w.Create(component.UidType, component.GasEnvironmentType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -145,7 +145,7 @@ func NewFanEntity(w ecs.World, id string, fanType proto.Fan_Type) *ecs.Entry {
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.FanDeviceType, component.DeviceExceptionType))
|
||||
e = w.Entry(w.Create(component.UidType, component.FanDeviceType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
component.FanDeviceType.Set(e, &component.FanDevice{Speed: 0, Forward: true, Fs: component.Off})
|
||||
//
|
||||
|
@ -12,7 +12,7 @@ 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))
|
||||
e = w.Entry(w.Create(component.UidType, component.CircuitBreakerType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -24,7 +24,7 @@ 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))
|
||||
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
|
||||
@ -37,7 +37,7 @@ 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))
|
||||
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
|
||||
@ -50,7 +50,7 @@ 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))
|
||||
e = w.Entry(w.Create(component.UidType, component.RectifierType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -62,7 +62,7 @@ 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))
|
||||
e = w.Entry(w.Create(component.UidType, component.DisconnectorType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -74,7 +74,7 @@ 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))
|
||||
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
|
||||
@ -87,7 +87,7 @@ 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))
|
||||
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
|
||||
@ -100,7 +100,7 @@ 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))
|
||||
e = w.Entry(w.Create(component.UidType, component.VoltageTransformerType, component.DeviceExceptionType))
|
||||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||||
wd.EntityMap[id] = e
|
||||
}
|
||||
@ -112,7 +112,7 @@ 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))
|
||||
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
|
||||
@ -125,7 +125,7 @@ func NewPowerSourceEntity(w ecs.World, id string, ac bool, voltage uint32) *ecs.
|
||||
wd := GetWorldData(w)
|
||||
e, ok := wd.EntityMap[id]
|
||||
if !ok {
|
||||
e := w.Entry(w.Create(component.UidType, component.PowerSourceType))
|
||||
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
|
||||
|
@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"joylink.club/rtsssimulation/sys"
|
||||
"time"
|
||||
|
||||
rtss_simulation "joylink.club/rtsssimulation"
|
||||
@ -8,6 +12,35 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
protoRepo := &proto.Repository{}
|
||||
protoRepo.Id = "1"
|
||||
protoRepo.Version = "V1"
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan1", FanType: proto.Fan_CommonFan})
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan2", FanType: proto.Fan_FcBypassFan})
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan3", FanType: proto.Fan_SoftStartFan})
|
||||
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan4", FanType: proto.Fan_HighLowSpeedFan})
|
||||
//
|
||||
repo, _ := repository.BuildRepository(protoRepo)
|
||||
sim, _ := newIscsSimulation(repo)
|
||||
sim.StartUp()
|
||||
sim.SetSpeed(1)
|
||||
time.Sleep(8 * time.Second)
|
||||
sim.Close()
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
func newIscsSimulation(repo *repository.Repository) (ecs.World, error) {
|
||||
w := ecs.NewWorld(100)
|
||||
sys.BindIscsSystem(w)
|
||||
//
|
||||
// 初始化世界数据单例组件
|
||||
entity.LoadWorldData(w, repo)
|
||||
err := entity.LoadIscs(w)
|
||||
return w, err
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
func main1() {
|
||||
sim, _ := rtss_simulation.NewSimulation(&repository.Repository{})
|
||||
sim.StartUp()
|
||||
sim.SetSpeed(2)
|
||||
|
@ -39,6 +39,11 @@ func BuildRepository(source *proto.Repository) (*Repository, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = buildIscsModelRelationship(source, repository)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//
|
||||
repositoryMap[buildRepositoryKey(source.Id, source.Version)] = repository
|
||||
return repository, err
|
||||
}
|
||||
@ -134,9 +139,15 @@ func buildModels(source *proto.Repository, repository *Repository) error {
|
||||
repository.platformMap[m.Id()] = m
|
||||
}
|
||||
err := repository.generateCoordinateInfo(source.MainCoordinateSystem)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, protoData := range source.CentralizedStationRefs {
|
||||
repository.centralizedMap[protoData.StationId] = protoData
|
||||
}
|
||||
//
|
||||
err = buildIscsModels(source, repository)
|
||||
//
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ func BindSystem(w ecs.World) {
|
||||
)
|
||||
}
|
||||
|
||||
// ISCS 系统
|
||||
func bindIscsSystem(w ecs.World) {
|
||||
// BindIscsSystem ISCS 系统
|
||||
func BindIscsSystem(w ecs.World) {
|
||||
w.AddSystem(
|
||||
iscs_sys.NewIscsExceptionSystem(),
|
||||
iscs_sys.NewDevicePlacingSystem(),
|
||||
|
@ -19,8 +19,10 @@ func NewFanSystem() *FanSystem {
|
||||
}
|
||||
func (s *FanSystem) Update(w ecs.World) {
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
//fanId := component.UidType.Get(entry).Id
|
||||
fan := component.FanDeviceType.Get(entry)
|
||||
fan.Forward = fan.Fs.OnForward()
|
||||
//fmt.Printf("==>>风机[%s] forward=%t speed=%f fan-switch=%d\n", fanId, fan.Forward, fan.Speed, fan.Fs)
|
||||
//
|
||||
speed := fan.Speed + s.calculateAc(fan, entry)*float32(w.Tick())
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user