signal jckxh 驱采
This commit is contained in:
parent
d2e31012db
commit
7864f04cba
@ -273,3 +273,39 @@ var (
|
||||
SignalDCXHLsqType = ecs.NewComponentType[SignalDCXHLsq]()
|
||||
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个继电器
|
||||
signalEntry.AddComponent(component.SignalJCKXHElectronicType)
|
||||
signalEntry.AddComponent(component.SignalJCKXHFilamentType)
|
||||
signalEntry.AddComponent(component.SignalJCKXHLsqType)
|
||||
signalEntry.AddComponent(component.SignalJCKXHLscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.SignalJCKXHElectronic{}
|
||||
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.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 {
|
||||
return fmt.Errorf("id=[%s]的信号机jckxh,电子元器件数量须为3", signal.Id())
|
||||
}
|
||||
|
@ -14,13 +14,9 @@ func DriveSignalJCKXHLx(w ecs.World, signalId string) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.SignalJCKXHElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
||||
driveLx.Td = true
|
||||
driveLx.Xq = true
|
||||
driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
||||
driveDx.Td = false
|
||||
driveDx.Xq = false
|
||||
lsq := component.SignalJCKXHLsqType.Get(signalEntry)
|
||||
lsq.JCKXH_LXJ_Q = true
|
||||
lsq.JCKXH_DXJ_Q = false
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -31,13 +27,9 @@ func DriveSignalJCKXHDx(w ecs.World, signalId string) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.SignalJCKXHElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
||||
driveLx.Td = false
|
||||
driveLx.Xq = false
|
||||
driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
||||
driveDx.Td = true
|
||||
driveDx.Xq = true
|
||||
lsq := component.SignalJCKXHLsqType.Get(signalEntry)
|
||||
lsq.JCKXH_LXJ_Q = false
|
||||
lsq.JCKXH_DXJ_Q = true
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -48,13 +40,9 @@ func DriveSignalJCKXHNon(w ecs.World, signalId string) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.SignalJCKXHElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
||||
driveLx.Td = false
|
||||
driveLx.Xq = false
|
||||
driveDx := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
||||
driveDx.Td = false
|
||||
driveDx.Xq = false
|
||||
lsq := component.SignalJCKXHLsqType.Get(signalEntry)
|
||||
lsq.JCKXH_LXJ_Q = false
|
||||
lsq.JCKXH_DXJ_Q = 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) {
|
||||
dxj := component.RelayDriveType.Get(state.DCXH_DXJ)
|
||||
//
|
||||
ddjQ := lsq.DCXH_DXJ_Q
|
||||
dxj.Td = ddjQ
|
||||
dxj.Xq = ddjQ
|
||||
dxjQ := lsq.DCXH_DXJ_Q
|
||||
dxj.Td = dxjQ
|
||||
dxj.Xq = dxjQ
|
||||
}
|
||||
|
||||
// 联锁采
|
||||
|
@ -11,50 +11,88 @@ type SignalJCKXHSystem struct {
|
||||
}
|
||||
|
||||
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 执行
|
||||
func (s *SignalJCKXHSystem) Update(w ecs.World) {
|
||||
s.query.Each(w, func(e *ecs.Entry) {
|
||||
state := component.SignalJCKXHElectronicType.Get(e)
|
||||
filament := component.SignalJCKXHFilamentType.Get(e)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
state := component.SignalJCKXHElectronicType.Get(entry)
|
||||
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.calculateB(state, filament)
|
||||
s.calculateH(state, filament)
|
||||
s.calculateDJ(state, filament)
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SignalJCKXHSystem) calculateU(state *component.SignalJCKXHElectronic, filament *component.SignalJCKXHFilament) {
|
||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||
isU := filament.Uf && lxj.Val
|
||||
filament.U = isU
|
||||
// 联锁驱
|
||||
func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) {
|
||||
dxj := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
||||
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)
|
||||
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)
|
||||
// 联锁采
|
||||
func (s *SignalJCKXHSystem) calculateLsc(state *component.SignalJCKXHElectronic, lsc *component.SignalJCKXHLsc) {
|
||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||
dj := component.BitStateType.Get(state.JCKXH_DJ)
|
||||
isDJ := filament.Uf && lxj.Val || filament.Bf && !lxj.Val && dxj.Val || filament.Bf && !lxj.Val && dxj.Val
|
||||
if isDJ != dj.Val {
|
||||
drive := component.RelayDriveType.Get(state.JCKXH_DJ)
|
||||
drive.Td = isDJ
|
||||
drive.Xq = isDJ
|
||||
}
|
||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||
//
|
||||
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.Td = isDJ
|
||||
drive.Xq = isDJ
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user