信号机电路
This commit is contained in:
parent
a82f2d3d65
commit
0a5df829a2
@ -9,6 +9,24 @@ import (
|
||||
"joylink.club/rtsssimulation/umi"
|
||||
)
|
||||
|
||||
// 信号机电路继电器组合类型和功能名称常量
|
||||
// 其他信号机的一并定义于此
|
||||
const (
|
||||
//继电器组合类型
|
||||
SIGNAL_3XH1 = "3XH-1"
|
||||
SIGNAL_3XH2 = "3XH-2"
|
||||
SIGNAL_3XH3 = "3XH-3"
|
||||
SIGNAL_3XH4 = "3XH-4"
|
||||
SIGNAL_2XH1 = "2XH-1"
|
||||
//继电器功能名称
|
||||
SIGNAL_DDJ = "DDJ"
|
||||
SIGNAL_DJ = "DJ"
|
||||
SIGNAL_2DJ = "2DJ"
|
||||
SIGNAL_LXJ = "LXJ"
|
||||
SIGNAL_YXJ = "YXJ"
|
||||
SIGNAL_ZXJ = "ZXJ"
|
||||
)
|
||||
|
||||
// 电路状态:信号机3XH-1(红-绿-黄) 道岔防护信号机(三显示不封灯,有单黄显示、带引导)
|
||||
type Signal3XH1State struct {
|
||||
// 物理黄灯,true-亮
|
||||
@ -64,23 +82,27 @@ var Signal3XH1RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay
|
||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||
roler, ok := signalModel.(umi.IRelayCRole)
|
||||
if ok {
|
||||
if _, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||
state := Signal3XH1StateComponent.Get(e)
|
||||
switch relayName {
|
||||
case "DDJ":
|
||||
state.DDJ = event.Xh
|
||||
case "DJ":
|
||||
state.DJ = event.Xh
|
||||
case "2DJ":
|
||||
state.EDJ = event.Xh
|
||||
case "LXJ":
|
||||
state.LXJ = event.Xh
|
||||
case "YXJ":
|
||||
state.YXJ = event.Xh
|
||||
case "ZXJ":
|
||||
state.ZXJ = event.Xh
|
||||
default:
|
||||
panic(fmt.Sprintf("Signal3XH1的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||
if relayGroup == SIGNAL_3XH1 {
|
||||
state := Signal3XH1StateComponent.Get(e)
|
||||
switch relayName {
|
||||
case SIGNAL_DDJ:
|
||||
state.DDJ = event.Xh
|
||||
case SIGNAL_DJ:
|
||||
state.DJ = event.Xh
|
||||
case SIGNAL_2DJ:
|
||||
state.EDJ = event.Xh
|
||||
case SIGNAL_LXJ:
|
||||
state.LXJ = event.Xh
|
||||
case SIGNAL_YXJ:
|
||||
state.YXJ = event.Xh
|
||||
case SIGNAL_ZXJ:
|
||||
state.ZXJ = event.Xh
|
||||
default:
|
||||
panic(fmt.Sprintf("Signal3XH1的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("Signal3XH1的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -150,7 +172,7 @@ func (me *Signal3XH1System) calculateDJ(w ecs.World, e *ecs.Entry, state *Signal
|
||||
if _DJ != isDj {
|
||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||
relayRole, _ := signalModel.(umi.IRelayCRole)
|
||||
relayModel := relayRole.FindRelayModelByCRole("3XH-1", "DJ")
|
||||
relayModel := relayRole.FindRelayModelByCRole(SIGNAL_3XH1, SIGNAL_DJ)
|
||||
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.GetId(), Xh: isDj})
|
||||
}
|
||||
}
|
||||
@ -164,7 +186,7 @@ func (me *Signal3XH1System) calculate2DJ(w ecs.World, e *ecs.Entry, state *Signa
|
||||
if _2DJ != is2DJ {
|
||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||
relayRole, _ := signalModel.(umi.IRelayCRole)
|
||||
relayModel := relayRole.FindRelayModelByCRole("3XH-1", "2DJ")
|
||||
relayModel := relayRole.FindRelayModelByCRole(SIGNAL_3XH1, SIGNAL_2DJ)
|
||||
sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.GetId(), Xh: is2DJ})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user