不带电路的信号机
This commit is contained in:
parent
ec53a8e204
commit
41a7f7a585
@ -5,6 +5,7 @@ import (
|
|||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/consts"
|
"joylink.club/rtsssimulation/consts"
|
||||||
|
"joylink.club/rtsssimulation/repository"
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
)
|
)
|
||||||
@ -15,7 +16,7 @@ func LoadSignals(w ecs.World) error {
|
|||||||
signals := data.Repo.SignalList()
|
signals := data.Repo.SignalList()
|
||||||
for _, signal := range signals {
|
for _, signal := range signals {
|
||||||
groups := signal.RelayGroups()
|
groups := signal.RelayGroups()
|
||||||
signalEntry := newSignalEntity(w, signal.Id(), data)
|
signalEntry := newSignalEntity(w, signal, data)
|
||||||
if len(groups) == 1 { //带电路的信号机,有且只有一个组合类型,组合类型与电路有关
|
if len(groups) == 1 { //带电路的信号机,有且只有一个组合类型,组合类型与电路有关
|
||||||
group := groups[0]
|
group := groups[0]
|
||||||
elecs := group.Components()
|
elecs := group.Components()
|
||||||
@ -56,20 +57,21 @@ func LoadSignals(w ecs.World) error {
|
|||||||
default:
|
default:
|
||||||
slog.Warn(fmt.Sprintf("id=[%s]的信号机,无效组合类型[%s]", signal.Id(), group.Code()))
|
slog.Warn(fmt.Sprintf("id=[%s]的信号机,无效组合类型[%s]", signal.Id(), group.Code()))
|
||||||
}
|
}
|
||||||
} else { //不带电路的信号机
|
} else {
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
slog.Debug(fmt.Sprintf("id=[%s]的信号机,没有组合类型或组合类型个数不为1", signal.Id()))
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLightsByModel(w, signal.Model()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新建信号机实体
|
// 新建信号机实体
|
||||||
func newSignalEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
func newSignalEntity(w ecs.World, signal *repository.Signal, worldData *component.WorldData) *ecs.Entry {
|
||||||
|
uid := signal.Id()
|
||||||
entry, ok := worldData.EntityMap[uid]
|
entry, ok := worldData.EntityMap[uid]
|
||||||
if !ok {
|
if !ok {
|
||||||
entry = w.Entry(w.Create(component.UidType, component.SignalTag))
|
entry = w.Entry(w.Create(component.UidType, component.SignalTag, component.SignalLightsType))
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
|
component.SignalLightsType.Set(entry, newSignalLightsByModel(w, signal.Model()))
|
||||||
worldData.EntityMap[uid] = entry
|
worldData.EntityMap[uid] = entry
|
||||||
}
|
}
|
||||||
return entry
|
return entry
|
||||||
|
@ -14,7 +14,6 @@ func loadSignal2xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
signalEntry.AddComponent(component.Signal2XH1ElectronicType)
|
signalEntry.AddComponent(component.Signal2XH1ElectronicType)
|
||||||
signalEntry.AddComponent(component.Signal2XH1LsqType)
|
signalEntry.AddComponent(component.Signal2XH1LsqType)
|
||||||
signalEntry.AddComponent(component.Signal2XH1LscType)
|
signalEntry.AddComponent(component.Signal2XH1LscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.Signal2XH1Electronic{}
|
elecState := &component.Signal2XH1Electronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -33,7 +32,6 @@ func loadSignal2xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
component.Signal2XH1ElectronicType.Set(signalEntry, elecState)
|
component.Signal2XH1ElectronicType.Set(signalEntry, elecState)
|
||||||
component.Signal2XH1LsqType.Set(signalEntry, &component.Signal2XH1Lsq{})
|
component.Signal2XH1LsqType.Set(signalEntry, &component.Signal2XH1Lsq{})
|
||||||
component.Signal2XH1LscType.Set(signalEntry, &component.Signal2XH1Lsc{})
|
component.Signal2XH1LscType.Set(signalEntry, &component.Signal2XH1Lsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.Z2XH1_DDJ == nil {
|
if elecState.Z2XH1_DDJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机2xh1,缺少元件DDJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机2xh1,缺少元件DDJ", signal.Id())
|
||||||
|
@ -14,7 +14,6 @@ func loadSignal3xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
signalEntry.AddComponent(component.Signal3XH1ElectronicType)
|
signalEntry.AddComponent(component.Signal3XH1ElectronicType)
|
||||||
signalEntry.AddComponent(component.Signal3XH1LsqType)
|
signalEntry.AddComponent(component.Signal3XH1LsqType)
|
||||||
signalEntry.AddComponent(component.Signal3XH1LscType)
|
signalEntry.AddComponent(component.Signal3XH1LscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.Signal3XH1Electronic{}
|
elecState := &component.Signal3XH1Electronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -39,7 +38,6 @@ func loadSignal3xh1(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
component.Signal3XH1ElectronicType.Set(signalEntry, elecState)
|
component.Signal3XH1ElectronicType.Set(signalEntry, elecState)
|
||||||
component.Signal3XH1LsqType.Set(signalEntry, &component.Signal3XH1Lsq{})
|
component.Signal3XH1LsqType.Set(signalEntry, &component.Signal3XH1Lsq{})
|
||||||
component.Signal3XH1LscType.Set(signalEntry, &component.Signal3XH1Lsc{})
|
component.Signal3XH1LscType.Set(signalEntry, &component.Signal3XH1Lsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.Z3XH1_DDJ == nil {
|
if elecState.Z3XH1_DDJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机3xh1,缺少元件DDJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机3xh1,缺少元件DDJ", signal.Id())
|
||||||
|
@ -14,7 +14,6 @@ func loadSignal3xh2(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
signalEntry.AddComponent(component.Signal3XH2ElectronicType)
|
signalEntry.AddComponent(component.Signal3XH2ElectronicType)
|
||||||
signalEntry.AddComponent(component.Signal3XH2LsqType)
|
signalEntry.AddComponent(component.Signal3XH2LsqType)
|
||||||
signalEntry.AddComponent(component.Signal3XH2LscType)
|
signalEntry.AddComponent(component.Signal3XH2LscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.Signal3XH2Electronic{}
|
elecState := &component.Signal3XH2Electronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -37,7 +36,6 @@ func loadSignal3xh2(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
component.Signal3XH2ElectronicType.Set(signalEntry, elecState)
|
component.Signal3XH2ElectronicType.Set(signalEntry, elecState)
|
||||||
component.Signal3XH2LsqType.Set(signalEntry, &component.Signal3XH2Lsq{})
|
component.Signal3XH2LsqType.Set(signalEntry, &component.Signal3XH2Lsq{})
|
||||||
component.Signal3XH2LscType.Set(signalEntry, &component.Signal3XH2Lsc{})
|
component.Signal3XH2LscType.Set(signalEntry, &component.Signal3XH2Lsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.Z3XH2_DDJ == nil {
|
if elecState.Z3XH2_DDJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机3xh2,缺少元件DDJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机3xh2,缺少元件DDJ", signal.Id())
|
||||||
|
@ -14,7 +14,6 @@ func loadSignal3xh3(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
signalEntry.AddComponent(component.Signal3XH3ElectronicType)
|
signalEntry.AddComponent(component.Signal3XH3ElectronicType)
|
||||||
signalEntry.AddComponent(component.Signal3XH3LsqType)
|
signalEntry.AddComponent(component.Signal3XH3LsqType)
|
||||||
signalEntry.AddComponent(component.Signal3XH3LscType)
|
signalEntry.AddComponent(component.Signal3XH3LscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.Signal3XH3Electronic{}
|
elecState := &component.Signal3XH3Electronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -37,7 +36,6 @@ func loadSignal3xh3(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
component.Signal3XH3ElectronicType.Set(signalEntry, elecState)
|
component.Signal3XH3ElectronicType.Set(signalEntry, elecState)
|
||||||
component.Signal3XH3LsqType.Set(signalEntry, &component.Signal3XH3Lsq{})
|
component.Signal3XH3LsqType.Set(signalEntry, &component.Signal3XH3Lsq{})
|
||||||
component.Signal3XH3LscType.Set(signalEntry, &component.Signal3XH3Lsc{})
|
component.Signal3XH3LscType.Set(signalEntry, &component.Signal3XH3Lsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.Z3XH3_DDJ == nil {
|
if elecState.Z3XH3_DDJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机3xh3,缺少元件DDJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机3xh3,缺少元件DDJ", signal.Id())
|
||||||
|
@ -14,7 +14,6 @@ func loadSignal3xh4(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
signalEntry.AddComponent(component.Signal3XH4ElectronicType)
|
signalEntry.AddComponent(component.Signal3XH4ElectronicType)
|
||||||
signalEntry.AddComponent(component.Signal3XH4LsqType)
|
signalEntry.AddComponent(component.Signal3XH4LsqType)
|
||||||
signalEntry.AddComponent(component.Signal3XH4LscType)
|
signalEntry.AddComponent(component.Signal3XH4LscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.Signal3XH4Electronic{}
|
elecState := &component.Signal3XH4Electronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -35,7 +34,6 @@ func loadSignal3xh4(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
component.Signal3XH4ElectronicType.Set(signalEntry, elecState)
|
component.Signal3XH4ElectronicType.Set(signalEntry, elecState)
|
||||||
component.Signal3XH4LsqType.Set(signalEntry, &component.Signal3XH4Lsq{})
|
component.Signal3XH4LsqType.Set(signalEntry, &component.Signal3XH4Lsq{})
|
||||||
component.Signal3XH4LscType.Set(signalEntry, &component.Signal3XH4Lsc{})
|
component.Signal3XH4LscType.Set(signalEntry, &component.Signal3XH4Lsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.Z3XH4_DDJ == nil {
|
if elecState.Z3XH4_DDJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机3xh4,缺少元件DDJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机3xh4,缺少元件DDJ", signal.Id())
|
||||||
|
@ -14,7 +14,6 @@ func loadSignalDcxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
signalEntry.AddComponent(component.SignalDCXHElectronicType)
|
signalEntry.AddComponent(component.SignalDCXHElectronicType)
|
||||||
signalEntry.AddComponent(component.SignalDCXHLsqType)
|
signalEntry.AddComponent(component.SignalDCXHLsqType)
|
||||||
signalEntry.AddComponent(component.SignalDCXHLscType)
|
signalEntry.AddComponent(component.SignalDCXHLscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.SignalDCXHElectronic{}
|
elecState := &component.SignalDCXHElectronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -31,7 +30,6 @@ func loadSignalDcxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
component.SignalDCXHElectronicType.Set(signalEntry, elecState)
|
component.SignalDCXHElectronicType.Set(signalEntry, elecState)
|
||||||
component.SignalDCXHLsqType.Set(signalEntry, &component.SignalDCXHLsq{})
|
component.SignalDCXHLsqType.Set(signalEntry, &component.SignalDCXHLsq{})
|
||||||
component.SignalDCXHLscType.Set(signalEntry, &component.SignalDCXHLsc{})
|
component.SignalDCXHLscType.Set(signalEntry, &component.SignalDCXHLsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.AdTag, component.BdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.DCXH_DJ == nil {
|
if elecState.DCXH_DJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机DCXH,缺少元件DJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机DCXH,缺少元件DJ", signal.Id())
|
||||||
|
@ -14,7 +14,6 @@ func loadSignalJckxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.En
|
|||||||
signalEntry.AddComponent(component.SignalJCKXHElectronicType)
|
signalEntry.AddComponent(component.SignalJCKXHElectronicType)
|
||||||
signalEntry.AddComponent(component.SignalJCKXHLsqType)
|
signalEntry.AddComponent(component.SignalJCKXHLsqType)
|
||||||
signalEntry.AddComponent(component.SignalJCKXHLscType)
|
signalEntry.AddComponent(component.SignalJCKXHLscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.SignalJCKXHElectronic{}
|
elecState := &component.SignalJCKXHElectronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -33,7 +32,6 @@ func loadSignalJckxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.En
|
|||||||
component.SignalJCKXHElectronicType.Set(signalEntry, elecState)
|
component.SignalJCKXHElectronicType.Set(signalEntry, elecState)
|
||||||
component.SignalJCKXHLsqType.Set(signalEntry, &component.SignalJCKXHLsq{})
|
component.SignalJCKXHLsqType.Set(signalEntry, &component.SignalJCKXHLsq{})
|
||||||
component.SignalJCKXHLscType.Set(signalEntry, &component.SignalJCKXHLsc{})
|
component.SignalJCKXHLscType.Set(signalEntry, &component.SignalJCKXHLsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.BdTag, component.UdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.JCKXH_DJ == nil {
|
if elecState.JCKXH_DJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机JCKXH,缺少元件DJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机JCKXH,缺少元件DJ", signal.Id())
|
||||||
|
@ -14,7 +14,6 @@ func loadSignalJdxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
signalEntry.AddComponent(component.SignalJDXHElectronicType)
|
signalEntry.AddComponent(component.SignalJDXHElectronicType)
|
||||||
signalEntry.AddComponent(component.SignalJDXHLsqType)
|
signalEntry.AddComponent(component.SignalJDXHLsqType)
|
||||||
signalEntry.AddComponent(component.SignalJDXHLscType)
|
signalEntry.AddComponent(component.SignalJDXHLscType)
|
||||||
signalEntry.AddComponent(component.SignalLightsType)
|
|
||||||
//
|
//
|
||||||
elecState := &component.SignalJDXHElectronic{}
|
elecState := &component.SignalJDXHElectronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -35,7 +34,6 @@ func loadSignalJdxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
|||||||
component.SignalJDXHElectronicType.Set(signalEntry, elecState)
|
component.SignalJDXHElectronicType.Set(signalEntry, elecState)
|
||||||
component.SignalJDXHLsqType.Set(signalEntry, &component.SignalJDXHLsq{})
|
component.SignalJDXHLsqType.Set(signalEntry, &component.SignalJDXHLsq{})
|
||||||
component.SignalJDXHLscType.Set(signalEntry, &component.SignalJDXHLsc{})
|
component.SignalJDXHLscType.Set(signalEntry, &component.SignalJDXHLsc{})
|
||||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
|
||||||
//校验
|
//校验
|
||||||
if elecState.JDXH_DJ == nil {
|
if elecState.JDXH_DJ == nil {
|
||||||
return fmt.Errorf("id=[%s]的信号机JDXH,缺少元件DJ", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机JDXH,缺少元件DJ", signal.Id())
|
||||||
|
Loading…
Reference in New Issue
Block a user