signal jckxh 驱采
This commit is contained in:
parent
d2e31012db
commit
7864f04cba
@ -273,3 +273,39 @@ var (
|
|||||||
SignalDCXHLsqType = ecs.NewComponentType[SignalDCXHLsq]()
|
SignalDCXHLsqType = ecs.NewComponentType[SignalDCXHLsq]()
|
||||||
SignalDCXHLscType = ecs.NewComponentType[SignalDCXHLsc]()
|
SignalDCXHLscType = ecs.NewComponentType[SignalDCXHLsc]()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// SignalJCKXHElectronic 电路状态:信号机JCKXH(红-白-黄) 进/出库列车兼调车信号机(三显示不封灯、有单黄显示、无引导)
|
||||||
|
type SignalJCKXHElectronic struct {
|
||||||
|
//灯丝继电器,true-吸合
|
||||||
|
JCKXH_DJ *ecs.Entry
|
||||||
|
//调车信号继电器,true-吸合
|
||||||
|
JCKXH_DXJ *ecs.Entry
|
||||||
|
//列车信号继电器,true-吸合
|
||||||
|
JCKXH_LXJ *ecs.Entry
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignalJCKXHLsq 联锁驱
|
||||||
|
type SignalJCKXHLsq struct {
|
||||||
|
//true-联锁施加励磁电流驱动继电器DXJ
|
||||||
|
JCKXH_DXJ_Q bool
|
||||||
|
////true-联锁施加励磁电流驱动继电器LXJ
|
||||||
|
JCKXH_LXJ_Q bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignalJCKXHLsc 联锁采
|
||||||
|
type SignalJCKXHLsc struct {
|
||||||
|
//true-继电器DJ吸起
|
||||||
|
JCKXH_DJ_Xq bool
|
||||||
|
//true-继电器DXJ吸起
|
||||||
|
JCKXH_DXJ_Xq bool
|
||||||
|
//true-继电器LXJ吸起
|
||||||
|
JCKXH_LXJ_Xq bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
SignalJCKXHElectronicType = ecs.NewComponentType[SignalJCKXHElectronic]()
|
||||||
|
SignalJCKXHLsqType = ecs.NewComponentType[SignalJCKXHLsq]()
|
||||||
|
SignalJCKXHLscType = ecs.NewComponentType[SignalJCKXHLsc]()
|
||||||
|
)
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package component
|
|
||||||
|
|
||||||
import "joylink.club/ecs"
|
|
||||||
|
|
||||||
// SignalJCKXHElectronic 电路状态:信号机JCKXH(红-白-黄) 进/出库列车兼调车信号机(三显示不封灯、有单黄显示、无引导)
|
|
||||||
type SignalJCKXHElectronic struct {
|
|
||||||
//灯丝继电器,true-吸合
|
|
||||||
JCKXH_DJ *ecs.Entry
|
|
||||||
//调车信号继电器,true-吸合
|
|
||||||
JCKXH_DXJ *ecs.Entry
|
|
||||||
//列车信号继电器,true-吸合
|
|
||||||
JCKXH_LXJ *ecs.Entry
|
|
||||||
}
|
|
||||||
|
|
||||||
// SignalJCKXHFilament 信号机JCKXH 灯丝状态
|
|
||||||
type SignalJCKXHFilament struct {
|
|
||||||
// 物理黄灯,true-灯丝正常
|
|
||||||
Uf bool
|
|
||||||
// 物理白灯,true-灯丝正常
|
|
||||||
Bf bool
|
|
||||||
// 物理红灯,true-灯丝正常
|
|
||||||
Hf bool
|
|
||||||
// 物理黄灯,true-亮
|
|
||||||
U bool
|
|
||||||
// 物理白灯,true-亮
|
|
||||||
B bool
|
|
||||||
// 物理红灯,true-亮
|
|
||||||
H bool
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
SignalJCKXHElectronicType = ecs.NewComponentType[SignalJCKXHElectronic]()
|
|
||||||
SignalJCKXHFilamentType = ecs.NewComponentType[SignalJCKXHFilament]()
|
|
||||||
)
|
|
@ -12,7 +12,9 @@ func loadSignalJckxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.En
|
|||||||
|
|
||||||
if len(elecs) == 3 { //jckxh组合类型包含3个继电器
|
if len(elecs) == 3 { //jckxh组合类型包含3个继电器
|
||||||
signalEntry.AddComponent(component.SignalJCKXHElectronicType)
|
signalEntry.AddComponent(component.SignalJCKXHElectronicType)
|
||||||
signalEntry.AddComponent(component.SignalJCKXHFilamentType)
|
signalEntry.AddComponent(component.SignalJCKXHLsqType)
|
||||||
|
signalEntry.AddComponent(component.SignalJCKXHLscType)
|
||||||
|
signalEntry.AddComponent(component.SignalLightsType)
|
||||||
//
|
//
|
||||||
elecState := &component.SignalJCKXHElectronic{}
|
elecState := &component.SignalJCKXHElectronic{}
|
||||||
for _, elec := range elecs {
|
for _, elec := range elecs {
|
||||||
@ -29,7 +31,9 @@ func loadSignalJckxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.En
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
component.SignalJCKXHElectronicType.Set(signalEntry, elecState)
|
component.SignalJCKXHElectronicType.Set(signalEntry, elecState)
|
||||||
component.SignalJCKXHFilamentType.Set(signalEntry, &component.SignalJCKXHFilament{Uf: true, Bf: true, Hf: true, U: false, B: false, H: false})
|
component.SignalJCKXHLsqType.Set(signalEntry, &component.SignalJCKXHLsq{})
|
||||||
|
component.SignalJCKXHLscType.Set(signalEntry, &component.SignalJCKXHLsc{})
|
||||||
|
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.BdTag, component.UdTag))
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("id=[%s]的信号机jckxh,电子元器件数量须为3", signal.Id())
|
return fmt.Errorf("id=[%s]的信号机jckxh,电子元器件数量须为3", signal.Id())
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,9 @@ func DriveSignalJCKXHLx(w ecs.World, signalId string) {
|
|||||||
wd := entity.GetWorldData(w)
|
wd := entity.GetWorldData(w)
|
||||||
signalEntry, ok := wd.EntityMap[signalId]
|
signalEntry, ok := wd.EntityMap[signalId]
|
||||||
if ok {
|
if ok {
|
||||||
state := component.SignalJCKXHElectronicType.Get(signalEntry)
|
lsq := component.SignalJCKXHLsqType.Get(signalEntry)
|
||||||
driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
lsq.JCKXH_LXJ_Q = true
|
||||||
driveLx.Td = true
|
lsq.JCKXH_DXJ_Q = false
|
||||||
driveLx.Xq = true
|
|
||||||
driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
|
||||||
driveDx.Td = false
|
|
||||||
driveDx.Xq = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -31,13 +27,9 @@ func DriveSignalJCKXHDx(w ecs.World, signalId string) {
|
|||||||
wd := entity.GetWorldData(w)
|
wd := entity.GetWorldData(w)
|
||||||
signalEntry, ok := wd.EntityMap[signalId]
|
signalEntry, ok := wd.EntityMap[signalId]
|
||||||
if ok {
|
if ok {
|
||||||
state := component.SignalJCKXHElectronicType.Get(signalEntry)
|
lsq := component.SignalJCKXHLsqType.Get(signalEntry)
|
||||||
driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
lsq.JCKXH_LXJ_Q = false
|
||||||
driveLx.Td = false
|
lsq.JCKXH_DXJ_Q = true
|
||||||
driveLx.Xq = false
|
|
||||||
driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
|
||||||
driveDx.Td = true
|
|
||||||
driveDx.Xq = true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -48,13 +40,9 @@ func DriveSignalJCKXHNon(w ecs.World, signalId string) {
|
|||||||
wd := entity.GetWorldData(w)
|
wd := entity.GetWorldData(w)
|
||||||
signalEntry, ok := wd.EntityMap[signalId]
|
signalEntry, ok := wd.EntityMap[signalId]
|
||||||
if ok {
|
if ok {
|
||||||
state := component.SignalJCKXHElectronicType.Get(signalEntry)
|
lsq := component.SignalJCKXHLsqType.Get(signalEntry)
|
||||||
driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
lsq.JCKXH_LXJ_Q = false
|
||||||
driveLx.Td = false
|
lsq.JCKXH_DXJ_Q = false
|
||||||
driveLx.Xq = false
|
|
||||||
driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
|
||||||
driveDx.Td = false
|
|
||||||
driveDx.Xq = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 37e06d2aaf64828da677131dfb790bd0de7cef56
|
Subproject commit 1c6eed67ea95b41e7b3cae7375f0f740202fd22b
|
@ -41,9 +41,9 @@ func (s *SignalDCXHSystem) Update(w ecs.World) {
|
|||||||
func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) {
|
func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) {
|
||||||
dxj := component.RelayDriveType.Get(state.DCXH_DXJ)
|
dxj := component.RelayDriveType.Get(state.DCXH_DXJ)
|
||||||
//
|
//
|
||||||
ddjQ := lsq.DCXH_DXJ_Q
|
dxjQ := lsq.DCXH_DXJ_Q
|
||||||
dxj.Td = ddjQ
|
dxj.Td = dxjQ
|
||||||
dxj.Xq = ddjQ
|
dxj.Xq = dxjQ
|
||||||
}
|
}
|
||||||
|
|
||||||
// 联锁采
|
// 联锁采
|
||||||
|
@ -11,50 +11,88 @@ type SignalJCKXHSystem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewSignalJCKXHSystem() *SignalJCKXHSystem {
|
func NewSignalJCKXHSystem() *SignalJCKXHSystem {
|
||||||
return &SignalJCKXHSystem{query: ecs.NewQuery(filter.Contains(component.SignalJCKXHElectronicType, component.SignalJCKXHFilamentType))}
|
return &SignalJCKXHSystem{query: ecs.NewQuery(filter.Contains(
|
||||||
|
component.SignalJCKXHElectronicType,
|
||||||
|
component.SignalJCKXHLsqType,
|
||||||
|
component.SignalJCKXHLscType,
|
||||||
|
component.SignalLightsType))}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update world 执行
|
// Update world 执行
|
||||||
func (s *SignalJCKXHSystem) Update(w ecs.World) {
|
func (s *SignalJCKXHSystem) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(e *ecs.Entry) {
|
s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.SignalJCKXHElectronicType.Get(e)
|
state := component.SignalJCKXHElectronicType.Get(entry)
|
||||||
filament := component.SignalJCKXHFilamentType.Get(e)
|
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.calculateU(state, filament)
|
s.calculateLsq(state, lsq)
|
||||||
s.calculateB(state, filament)
|
s.calculateU(state, JCKXH_U)
|
||||||
s.calculateH(state, filament)
|
s.calculateB(state, JCKXH_B)
|
||||||
s.calculateDJ(state, filament)
|
s.calculateH(state, JCKXH_H)
|
||||||
|
s.calculateDJ(state, JCKXH_H, JCKXH_B, JCKXH_U)
|
||||||
|
s.calculateLsc(state, lsc)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalJCKXHSystem) calculateU(state *component.SignalJCKXHElectronic, filament *component.SignalJCKXHFilament) {
|
// 联锁驱
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) {
|
||||||
isU := filament.Uf && lxj.Val
|
dxj := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
||||||
filament.U = isU
|
lxj := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
||||||
|
//
|
||||||
|
dxjQ := lsq.JCKXH_DXJ_Q
|
||||||
|
dxj.Td = dxjQ
|
||||||
|
dxj.Xq = dxjQ
|
||||||
|
//
|
||||||
|
lxjQ := lsq.JCKXH_LXJ_Q
|
||||||
|
lxj.Td = lxjQ
|
||||||
|
lxj.Xq = lxjQ
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalJCKXHSystem) calculateB(state *component.SignalJCKXHElectronic, filament *component.SignalJCKXHFilament) {
|
// 联锁采
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
func (s *SignalJCKXHSystem) calculateLsc(state *component.SignalJCKXHElectronic, lsc *component.SignalJCKXHLsc) {
|
||||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
|
||||||
isB := filament.Bf && !lxj.Val && dxj.Val
|
|
||||||
filament.B = isB
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SignalJCKXHSystem) calculateH(state *component.SignalJCKXHElectronic, filament *component.SignalJCKXHFilament) {
|
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
|
||||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
|
||||||
isH := filament.Bf && !lxj.Val && dxj.Val
|
|
||||||
filament.H = isH
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SignalJCKXHSystem) calculateDJ(state *component.SignalJCKXHElectronic, filament *component.SignalJCKXHFilament) {
|
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
|
||||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
dj := component.BitStateType.Get(state.JCKXH_DJ)
|
dj := component.BitStateType.Get(state.JCKXH_DJ)
|
||||||
isDJ := filament.Uf && lxj.Val || filament.Bf && !lxj.Val && dxj.Val || filament.Bf && !lxj.Val && dxj.Val
|
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
if isDJ != dj.Val {
|
//
|
||||||
|
lsc.JCKXH_DJ_Xq = dj.Val
|
||||||
|
lsc.JCKXH_LXJ_Xq = lxj.Val
|
||||||
|
lsc.JCKXH_DXJ_Xq = dxj.Val
|
||||||
|
}
|
||||||
|
func (s *SignalJCKXHSystem) calculateU(state *component.SignalJCKXHElectronic, JCKXH_U *ecs.Entry) {
|
||||||
|
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
|
isU := lxj.Val
|
||||||
|
driveU := component.LightDriveType.Get(JCKXH_U)
|
||||||
|
driveU.Td = isU
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SignalJCKXHSystem) calculateB(state *component.SignalJCKXHElectronic, JCKXH_B *ecs.Entry) {
|
||||||
|
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
|
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
|
isB := !lxj.Val && dxj.Val
|
||||||
|
driveB := component.LightDriveType.Get(JCKXH_B)
|
||||||
|
driveB.Td = isB
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SignalJCKXHSystem) calculateH(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry) {
|
||||||
|
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
|
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
|
isH := !lxj.Val && dxj.Val
|
||||||
|
driveH := component.LightDriveType.Get(JCKXH_H)
|
||||||
|
driveH.Td = isH
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SignalJCKXHSystem) calculateDJ(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry, JCKXH_B *ecs.Entry, JCKXH_U *ecs.Entry) {
|
||||||
|
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
|
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
|
hd := component.BitStateType.Get(JCKXH_H)
|
||||||
|
bd := component.BitStateType.Get(JCKXH_B)
|
||||||
|
ud := component.BitStateType.Get(JCKXH_U)
|
||||||
|
isDJ := ud.Val && lxj.Val || bd.Val && !lxj.Val && dxj.Val || hd.Val && !lxj.Val && dxj.Val
|
||||||
drive := component.RelayDriveType.Get(state.JCKXH_DJ)
|
drive := component.RelayDriveType.Get(state.JCKXH_DJ)
|
||||||
drive.Td = isDJ
|
drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
drive.Xq = isDJ
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user