[bug]信号机电路系统逻辑没有正确处理驱动状态

This commit is contained in:
thesai 2024-08-01 14:25:45 +08:00
parent 3182e867c1
commit 8d19129ec6
8 changed files with 219 additions and 78 deletions

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal2XH1System struct {
@ -20,21 +21,35 @@ func NewSignal2XH1System() *Signal2XH1System {
// Update world 执行
func (s *Signal2XH1System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.Signal2XH1ElectronicType.Get(entry)
lsq := component.Signal2XH1LsqType.Get(entry)
lsc := component.Signal2XH1LscType.Get(entry)
circuit := component.Signal2XH1ElectronicType.Get(entry)
excite2xh1ByCiDrive(circuit, wd)
//lsq := component.Signal2XH1LsqType.Get(entry)
//lsc := component.Signal2XH1LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z2XH1_L := lights.GetLightByTag(component.LdTag)
Z2XH1_H := lights.GetLightByTag(component.HdTag)
s.calculateLsq(state, lsq)
s.calculateL(state, Z2XH1_L)
s.calculateH(state, Z2XH1_H)
s.calculateDJ(state, Z2XH1_L, Z2XH1_H)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateL(circuit, Z2XH1_L)
s.calculateH(circuit, Z2XH1_H)
s.calculateDJ(circuit, Z2XH1_L, Z2XH1_H)
//s.calculateLsc(circuit, lsc)
})
}
func excite2xh1ByCiDrive(circuit *component.Signal2XH1Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z2XH1_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z2XH1_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z2XH1_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z2XH1_LXJ).Td = bit
}
}
// 联锁驱
func (s *Signal2XH1System) calculateLsq(state *component.Signal2XH1Electronic, lsq *component.Signal2XH1Lsq) {
ddj := component.RelayDriveType.Get(state.Z2XH1_DDJ)

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH1System struct {
@ -20,25 +21,49 @@ func NewSignal3XH1System() *Signal3XH1System {
// Update world 执行
func (s *Signal3XH1System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.Signal3XH1ElectronicType.Get(entry)
lsq := component.Signal3XH1LsqType.Get(entry)
lsc := component.Signal3XH1LscType.Get(entry)
circuit := component.Signal3XH1ElectronicType.Get(entry)
excite3xh1ByCiDrive(circuit, wd)
//lsq := component.Signal3XH1LsqType.Get(entry)
//lsc := component.Signal3XH1LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH1_L := lights.GetLightByTag(component.LdTag)
Z3XH1_H := lights.GetLightByTag(component.HdTag)
Z3XH1_U := lights.GetLightByTag(component.UdTag)
//
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH1_U)
s.calculateL(state, Z3XH1_L)
s.calculateH(state, Z3XH1_H)
s.calculateDJ(state, Z3XH1_H, Z3XH1_L, Z3XH1_U)
s.calculate2DJ(state, Z3XH1_U)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH1_U)
s.calculateL(circuit, Z3XH1_L)
s.calculateH(circuit, Z3XH1_H)
s.calculateDJ(circuit, Z3XH1_H, Z3XH1_L, Z3XH1_U)
s.calculate2DJ(circuit, Z3XH1_U)
//s.calculateLsc(circuit, lsc)
})
}
func excite3xh1ByCiDrive(circuit *component.Signal3XH1Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_ZXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_ZXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH1_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH1_YXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH1System) calculateLsq(state *component.Signal3XH1Electronic, lsq *component.Signal3XH1Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH1_DDJ)

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH2System struct {
@ -20,24 +21,44 @@ func NewSignal3XH2System() *Signal3XH2System {
// Update world 执行
func (s *Signal3XH2System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.Signal3XH2ElectronicType.Get(entry)
lsq := component.Signal3XH2LsqType.Get(entry)
lsc := component.Signal3XH2LscType.Get(entry)
circuit := component.Signal3XH2ElectronicType.Get(entry)
excite3xh2ByCiDrive(circuit, wd)
//lsq := component.Signal3XH2LsqType.Get(entry)
//lsc := component.Signal3XH2LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH2_L := lights.GetLightByTag(component.LdTag)
Z3XH2_H := lights.GetLightByTag(component.HdTag)
Z3XH2_U := lights.GetLightByTag(component.UdTag)
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH2_U)
s.calculateL(state, Z3XH2_L)
s.calculateH(state, Z3XH2_H)
s.calculateDJ(state, Z3XH2_L, Z3XH2_H)
s.calculate2DJ(state, Z3XH2_U)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH2_U)
s.calculateL(circuit, Z3XH2_L)
s.calculateH(circuit, Z3XH2_H)
s.calculateDJ(circuit, Z3XH2_L, Z3XH2_H)
s.calculate2DJ(circuit, Z3XH2_U)
//s.calculateLsc(circuit, lsc)
})
}
// 根据联锁驱动给继电器励磁
func excite3xh2ByCiDrive(circuit *component.Signal3XH2Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH2_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH2_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH2_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH2_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH2_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH2_YXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH2System) calculateLsq(state *component.Signal3XH2Electronic, lsq *component.Signal3XH2Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH2_DDJ)

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH3System struct {
@ -20,23 +21,42 @@ func NewSignal3XH3System() *Signal3XH3System {
// Update world 执行
func (s *Signal3XH3System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.Signal3XH3ElectronicType.Get(entry)
lsq := component.Signal3XH3LsqType.Get(entry)
lsc := component.Signal3XH3LscType.Get(entry)
circuit := component.Signal3XH3ElectronicType.Get(entry)
excite3xh3ByCiDrive(circuit, wd)
//lsq := component.Signal3XH3LsqType.Get(entry)
//lsc := component.Signal3XH3LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH3_H := lights.GetLightByTag(component.HdTag)
Z3XH3_U := lights.GetLightByTag(component.UdTag)
//
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH3_U)
s.calculateH(state, Z3XH3_H)
s.calculateDJ(state, Z3XH3_U, Z3XH3_H)
s.calculate2DJ(state, Z3XH3_U)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH3_U)
s.calculateH(circuit, Z3XH3_H)
s.calculateDJ(circuit, Z3XH3_U, Z3XH3_H)
s.calculate2DJ(circuit, Z3XH3_U)
//s.calculateLsc(circuit, lsc)
})
}
func excite3xh3ByCiDrive(circuit *component.Signal3XH3Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH3_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH3_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH3_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH3_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH3_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH3_YXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH3System) calculateLsq(state *component.Signal3XH3Electronic, lsq *component.Signal3XH3Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH3_DDJ)

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type Signal3XH4System struct {
@ -20,24 +21,43 @@ func NewSignal3XH4System() *Signal3XH4System {
// Update world 执行
func (s *Signal3XH4System) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.Signal3XH4ElectronicType.Get(entry)
lsq := component.Signal3XH4LsqType.Get(entry)
lsc := component.Signal3XH4LscType.Get(entry)
circuit := component.Signal3XH4ElectronicType.Get(entry)
excite3xh4ByCiDrive(circuit, wd)
//lsq := component.Signal3XH4LsqType.Get(entry)
//lsc := component.Signal3XH4LscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
Z3XH4_H := lights.GetLightByTag(component.HdTag)
Z3XH4_L := lights.GetLightByTag(component.LdTag)
Z3XH4_U := lights.GetLightByTag(component.UdTag)
//
s.calculateLsq(state, lsq)
s.calculateU(state, Z3XH4_U)
s.calculateL(state, Z3XH4_L)
s.calculateH(state, Z3XH4_H)
s.calculateDJ(state, Z3XH4_H, Z3XH4_L, Z3XH4_U)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, Z3XH4_U)
s.calculateL(circuit, Z3XH4_L)
s.calculateH(circuit, Z3XH4_H)
s.calculateDJ(circuit, Z3XH4_H, Z3XH4_L, Z3XH4_U)
//s.calculateLsc(circuit, lsc)
})
}
func excite3xh4ByCiDrive(circuit *component.Signal3XH4Electronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.Z3XH4_DDJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH4_DDJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH4_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH4_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.Z3XH4_ZXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.Z3XH4_ZXJ).Td = bit
}
}
// 联锁驱
func (s *Signal3XH4System) calculateLsq(state *component.Signal3XH4Electronic, lsq *component.Signal3XH4Lsq) {
ddj := component.RelayDriveType.Get(state.Z3XH4_DDJ)

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type SignalDCXHSystem struct {
@ -20,23 +21,32 @@ func NewSignalDCXHSystem() *SignalDCXHSystem {
// Update world 执行
func (s *SignalDCXHSystem) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.SignalDCXHElectronicType.Get(entry)
lsq := component.SignalDCXHLsqType.Get(entry)
lsc := component.SignalDCXHLscType.Get(entry)
circuit := component.SignalDCXHElectronicType.Get(entry)
exciteDcxhByCiDrive(circuit, wd)
//lsq := component.SignalDCXHLsqType.Get(entry)
//lsc := component.SignalDCXHLscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
DCXH_A := lights.GetLightByTag(component.AdTag)
DCXH_B := lights.GetLightByTag(component.BdTag)
//
s.calculateLsq(state, lsq)
s.calculateA(state, DCXH_A)
s.calculateB(state, DCXH_B)
s.calculateDJ(state, DCXH_B, DCXH_A)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateA(circuit, DCXH_A)
s.calculateB(circuit, DCXH_B)
s.calculateDJ(circuit, DCXH_B, DCXH_A)
//s.calculateLsc(circuit, lsc)
})
}
func exciteDcxhByCiDrive(circuit *component.SignalDCXHElectronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.DCXH_DXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.DCXH_DXJ).Td = bit
}
}
// 联锁驱
func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) {
dxj := component.RelayDriveType.Get(state.DCXH_DXJ)

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type SignalJCKXHSystem struct {
@ -20,24 +21,38 @@ func NewSignalJCKXHSystem() *SignalJCKXHSystem {
// Update world 执行
func (s *SignalJCKXHSystem) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.SignalJCKXHElectronicType.Get(entry)
lsq := component.SignalJCKXHLsqType.Get(entry)
lsc := component.SignalJCKXHLscType.Get(entry)
circuit := component.SignalJCKXHElectronicType.Get(entry)
exciteJckxhByCiDrive(circuit, wd)
//lsq := component.SignalJCKXHLsqType.Get(entry)
//lsc := component.SignalJCKXHLscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
JCKXH_H := lights.GetLightByTag(component.HdTag)
JCKXH_B := lights.GetLightByTag(component.BdTag)
JCKXH_U := lights.GetLightByTag(component.UdTag)
//
s.calculateLsq(state, lsq)
s.calculateU(state, JCKXH_U)
s.calculateB(state, JCKXH_B)
s.calculateH(state, JCKXH_H)
s.calculateDJ(state, JCKXH_H, JCKXH_B, JCKXH_U)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateU(circuit, JCKXH_U)
s.calculateB(circuit, JCKXH_B)
s.calculateH(circuit, JCKXH_H)
s.calculateDJ(circuit, JCKXH_H, JCKXH_B, JCKXH_U)
//s.calculateLsc(circuit, lsc)
})
}
func exciteJckxhByCiDrive(circuit *component.SignalJCKXHElectronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.JCKXH_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JCKXH_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.JCKXH_DXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JCKXH_DXJ).Td = bit
}
}
// 联锁驱
func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) {
dxj := component.RelayDriveType.Get(state.JCKXH_DXJ)

View File

@ -4,6 +4,7 @@ import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type SignalJDXHSystem struct {
@ -20,25 +21,39 @@ func NewSignalJDXHSystem() *SignalJDXHSystem {
// Update world 执行
func (s *SignalJDXHSystem) Update(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
state := component.SignalJDXHElectronicType.Get(entry)
lsq := component.SignalJDXHLsqType.Get(entry)
lsc := component.SignalJDXHLscType.Get(entry)
circuit := component.SignalJDXHElectronicType.Get(entry)
exciteJdxhByCiDrive(circuit, wd)
//lsq := component.SignalJDXHLsqType.Get(entry)
//lsc := component.SignalJDXHLscType.Get(entry)
lights := component.SignalLightsType.Get(entry)
JDXH_H := lights.GetLightByTag(component.HdTag)
JDXH_L := lights.GetLightByTag(component.LdTag)
JDXH_U := lights.GetLightByTag(component.UdTag)
//
s.calculateLsq(state, lsq)
s.calculateL(state, JDXH_L)
s.calculateU(state, JDXH_U)
s.calculateH(state, JDXH_H)
s.calculateDJ(state, JDXH_L, JDXH_H)
s.calculate2DJ(state, JDXH_U)
s.calculateLsc(state, lsc)
//s.calculateLsq(circuit, lsq)
s.calculateL(circuit, JDXH_L)
s.calculateU(circuit, JDXH_U)
s.calculateH(circuit, JDXH_H)
s.calculateDJ(circuit, JDXH_L, JDXH_H)
s.calculate2DJ(circuit, JDXH_U)
//s.calculateLsc(circuit, lsc)
})
}
func exciteJdxhByCiDrive(circuit *component.SignalJDXHElectronic, wd *component.WorldData) {
bit, err := wd.QueryQdBit(component.UidType.Get(circuit.JDXH_LXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JDXH_LXJ).Td = bit
}
bit, err = wd.QueryQdBit(component.UidType.Get(circuit.JDXH_YXJ).Id)
if err == nil {
component.RelayDriveType.Get(circuit.JDXH_YXJ).Td = bit
}
}
// 联锁驱
func (s *SignalJDXHSystem) calculateLsq(state *component.SignalJDXHElectronic, lsq *component.SignalJDXHLsq) {
lxj := component.RelayDriveType.Get(state.JDXH_LXJ)