信号机3XH-4
This commit is contained in:
parent
32c2fe7aa8
commit
1935ef32b1
@ -1,8 +1,11 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/yohamta/donburi/filter"
|
||||
"joylink.club/ecs"
|
||||
sysEvent "joylink.club/rtsssimulation/system/event"
|
||||
"joylink.club/rtsssimulation/umi"
|
||||
)
|
||||
|
||||
// Signal3XH4State 电路状态:信号机3XH-4(红-绿-黄) 出站兼道岔防护信号机(三显示不封灯、有单黄显示、无引导)
|
||||
@ -63,6 +66,39 @@ func (me *Signal3XH4System) Update(w ecs.World) {
|
||||
me.calculateDJ(w, e, state, filament)
|
||||
})
|
||||
}
|
||||
|
||||
// Signal3XH4RelayActionEventProcessor 继电器动作事件处理
|
||||
var Signal3XH4RelayActionEventProcessor = func(w ecs.World, event sysEvent.RelayActionEvent) {
|
||||
//根据event来更新Signal3XH4State中对应继电器的状态
|
||||
signal3XH4Query.Each(w, func(e *ecs.Entry) {
|
||||
signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
|
||||
roler, ok := signalModel.(umi.IRelayCRole)
|
||||
if ok {
|
||||
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
|
||||
if relayGroup == SIGNAL_3XH4 {
|
||||
state := Signal3XH4StateComponent.Get(e)
|
||||
switch relayName {
|
||||
case SIGNAL_DDJ:
|
||||
state.DDJ = event.Xh
|
||||
case SIGNAL_DJ:
|
||||
state.DJ = event.Xh
|
||||
case SIGNAL_LXJ:
|
||||
state.LXJ = event.Xh
|
||||
case SIGNAL_ZXJ:
|
||||
state.ZXJ = event.Xh
|
||||
default:
|
||||
panic(fmt.Sprintf("Signal3XH4的模型[%s]中继电器功能名称[%s]无法识别", signalModel.GetId(), relayName))
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("Signal3XH4的模型[%s]中继电器组合类型[%s]无法识别", signalModel.GetId(), relayGroup))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
panic("Signal3XH4的模型未实现接口umi.IRelayCRoler")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (me *Signal3XH4System) calculateU(w ecs.World, state *Signal3XH4State, filament *Signal3XH4FilamentState) {
|
||||
isU := filament.Uf && !state.DDJ && state.LXJ && !state.ZXJ
|
||||
state.U = isU
|
||||
@ -83,6 +119,8 @@ func (me *Signal3XH4System) calculateDJ(w ecs.World, e *ecs.Entry, state *Signal
|
||||
filament.Lf && !state.DDJ && state.LXJ && state.ZXJ ||
|
||||
filament.Hf && !state.DDJ && !state.LXJ
|
||||
if isDJ != state.DJ {
|
||||
|
||||
if event, ok := createRelayNeedChangeEvent(w, EntityIdentityComponent.Get(e).Id, SIGNAL_3XH3, SIGNAL_DJ, isDJ); ok {
|
||||
sysEvent.RelayNeedChangeEventBus.Publish(w, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user