Merge branch 'master' of https://git.code.tencent.com/jl-framework/rtss_simulation
This commit is contained in:
commit
2d64e2b3bb
@ -17,7 +17,7 @@ var (
|
||||
// 自复式拉起接通式按钮
|
||||
ResetUpBtn = ecs.NewTag()
|
||||
// 钥匙旋钮
|
||||
KeyKnobBtn = ecs.NewTag()
|
||||
KeyKnob = ecs.NewTag()
|
||||
)
|
||||
|
||||
// 蜂鸣器驱动
|
||||
@ -32,11 +32,11 @@ var FMQDriveType = ecs.NewComponentType[FMQDrive]()
|
||||
type SpkElectronic struct {
|
||||
// 控制区
|
||||
SPKSXPLA_BTN *ecs.Entry
|
||||
SPKSX1J_BTN *ecs.Entry
|
||||
SPKSX3J_BTN *ecs.Entry
|
||||
SPKSX1J_KEY *ecs.Entry
|
||||
SPKSX3J_KEY *ecs.Entry
|
||||
SPKSSPLA_BTN *ecs.Entry
|
||||
SPKSS2J_BTN *ecs.Entry
|
||||
SPKSS4J_BTN *ecs.Entry
|
||||
SPKSS2J_KEY *ecs.Entry
|
||||
SPKSS4J_KEY *ecs.Entry
|
||||
|
||||
// 表示区
|
||||
SPKSX1J *ecs.Entry
|
||||
|
@ -7,16 +7,17 @@ type LightDrive struct {
|
||||
Td bool
|
||||
}
|
||||
|
||||
// DsTag 灯色标签定义
|
||||
// DsTag 灯显示标签定义
|
||||
type DsTag = ecs.IComponentType
|
||||
|
||||
// 灯色标签
|
||||
// 灯标签
|
||||
var (
|
||||
LdTag DsTag = ecs.NewTag() //绿
|
||||
HdTag = ecs.NewTag() //红
|
||||
UdTag = ecs.NewTag() //黄
|
||||
BdTag = ecs.NewTag() //白
|
||||
AdTag = ecs.NewTag() //蓝
|
||||
FdTag = ecs.NewTag() //封,封灯显示
|
||||
)
|
||||
|
||||
// 组件
|
||||
|
@ -170,12 +170,76 @@ type Signal3XH3Electronic struct {
|
||||
Z3XH3_LXJ *ecs.Entry
|
||||
//引导信号继电器,true-吸合
|
||||
Z3XH3_YXJ *ecs.Entry
|
||||
// 物理黄灯,true-亮
|
||||
Z3XH3_U *ecs.Entry
|
||||
// 物理红灯,true-亮
|
||||
Z3XH3_H *ecs.Entry
|
||||
}
|
||||
|
||||
// Signal3XH3Lsq 联锁驱
|
||||
type Signal3XH3Lsq struct {
|
||||
//true-联锁施加励磁电流驱动继电器DDJ
|
||||
Z3XH3_DDJ_Q bool
|
||||
////true-联锁施加励磁电流驱动继电器LXJ
|
||||
Z3XH3_LXJ_Q bool
|
||||
////true-联锁施加励磁电流驱动继电器LXJ
|
||||
Z3XH3_YXJ_Q bool
|
||||
}
|
||||
|
||||
// Signal3XH3Lsc 联锁采
|
||||
type Signal3XH3Lsc struct {
|
||||
//true-继电器DJ吸起
|
||||
Z3XH3_DJ_Xq bool
|
||||
//true-继电器2DJ吸起
|
||||
Z3XH3_2DJ_Xq bool
|
||||
//true-继电器DDJ落下
|
||||
Z3XH3_DDJ_Lx bool
|
||||
//true-继电器LXJ吸起
|
||||
Z3XH3_LXJ_Xq bool
|
||||
//true-继电器YXJ吸起
|
||||
Z3XH3_YXJ_Xq bool
|
||||
}
|
||||
|
||||
var (
|
||||
Signal3XH3ElectronicType = ecs.NewComponentType[Signal3XH3Electronic]()
|
||||
Signal3XH3LsqType = ecs.NewComponentType[Signal3XH3Lsq]()
|
||||
Signal3XH3LscType = ecs.NewComponentType[Signal3XH3Lsc]()
|
||||
)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Signal3XH4Electronic 电路状态:信号机3XH-4(红-绿-黄) 出站兼道岔防护信号机(三显示不封灯、有单黄显示、无引导)
|
||||
type Signal3XH4Electronic struct {
|
||||
// 点灯继电器,true-吸合,常态落下表示逻辑点灯
|
||||
Z3XH4_DDJ *ecs.Entry
|
||||
//灯丝继电器,true-吸合
|
||||
Z3XH4_DJ *ecs.Entry
|
||||
//列车信号继电器,true-吸合
|
||||
Z3XH4_LXJ *ecs.Entry
|
||||
//开通正线信号继电器,true-吸合
|
||||
Z3XH4_ZXJ *ecs.Entry
|
||||
}
|
||||
|
||||
// Signal3XH4Lsq 联锁驱
|
||||
type Signal3XH4Lsq struct {
|
||||
//true-联锁施加励磁电流驱动继电器DDJ
|
||||
Z3XH4_DDJ_Q bool
|
||||
////true-联锁施加励磁电流驱动继电器LXJ
|
||||
Z3XH4_LXJ_Q bool
|
||||
////true-联锁施加励磁电流驱动继电器ZXJ
|
||||
Z3XH4_ZXJ_Q bool
|
||||
}
|
||||
|
||||
// Signal3XH4Lsc 联锁采
|
||||
type Signal3XH4Lsc struct {
|
||||
//true-继电器DJ吸起
|
||||
Z3XH4_DJ_Xq bool
|
||||
//true-继电器DDJ落下
|
||||
Z3XH4_DDJ_Lx bool
|
||||
//true-继电器LXJ吸起
|
||||
Z3XH4_LXJ_Xq bool
|
||||
//true-继电器ZXJ吸起
|
||||
Z3XH4_ZXJ_Xq bool
|
||||
}
|
||||
|
||||
var (
|
||||
Signal3XH4ElectronicType = ecs.NewComponentType[Signal3XH4Electronic]()
|
||||
Signal3XH4LsqType = ecs.NewComponentType[Signal3XH4Lsq]()
|
||||
Signal3XH4LscType = ecs.NewComponentType[Signal3XH4Lsc]()
|
||||
)
|
||||
|
@ -1,36 +0,0 @@
|
||||
package component
|
||||
|
||||
import "joylink.club/ecs"
|
||||
|
||||
// Signal3XH4Electronic 电路状态:信号机3XH-4(红-绿-黄) 出站兼道岔防护信号机(三显示不封灯、有单黄显示、无引导)
|
||||
type Signal3XH4Electronic struct {
|
||||
// 点灯继电器,true-吸合,常态落下表示逻辑点灯
|
||||
Z3XH4_DDJ *ecs.Entry
|
||||
//灯丝继电器,true-吸合
|
||||
Z3XH4_DJ *ecs.Entry
|
||||
//列车信号继电器,true-吸合
|
||||
Z3XH4_LXJ *ecs.Entry
|
||||
//开通正线信号继电器,true-吸合
|
||||
Z3XH4_ZXJ *ecs.Entry
|
||||
}
|
||||
|
||||
// Signal3XH4Filament 信号机3XH-4 灯丝状态
|
||||
type Signal3XH4Filament struct {
|
||||
// 物理黄灯,true-灯丝正常
|
||||
Uf bool
|
||||
// 物理绿灯,true-灯丝正常
|
||||
Lf bool
|
||||
// 物理红灯,true-灯丝正常
|
||||
Hf bool
|
||||
// 物理黄灯,true-亮
|
||||
U bool
|
||||
// 物理绿灯,true-亮
|
||||
L bool
|
||||
// 物理红灯,true-亮
|
||||
H bool
|
||||
}
|
||||
|
||||
var (
|
||||
Signal3XH4ElectronicType = ecs.NewComponentType[Signal3XH4Electronic]()
|
||||
Signal3XH4FilamentType = ecs.NewComponentType[Signal3XH4Filament]()
|
||||
)
|
@ -32,7 +32,7 @@ func NewButtonEntity(w ecs.World, data *repository.Button, entityMap map[string]
|
||||
case proto.Button_Reset_Up:
|
||||
btnType = component.ResetUpBtn
|
||||
case proto.Button_Key_Knob:
|
||||
btnType = component.KeyKnobBtn
|
||||
btnType = component.KeyKnob
|
||||
default:
|
||||
btnType = component.UnknowBtn
|
||||
}
|
||||
@ -43,8 +43,7 @@ func NewButtonEntity(w ecs.World, data *repository.Button, entityMap map[string]
|
||||
}
|
||||
|
||||
// 创建蜂鸣器实体
|
||||
func NewFMQEntity(w ecs.World, data *repository.Fmq, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||
uid := data.Id()
|
||||
func NewFMQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||
entry, ok := entityMap[uid]
|
||||
if !ok {
|
||||
entry = w.Entry(w.Create(component.FMQDriveType, component.BitStateType))
|
||||
@ -59,11 +58,12 @@ func loadSPKEntity(w ecs.World, entry *ecs.Entry, entityMap map[string]*ecs.Entr
|
||||
// 按钮组
|
||||
spk.SPKSXPLA_BTN = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSSPLA_BTN = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSX1J_BTN = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSX3J_BTN = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSS2J_BTN = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSS4J_BTN = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SDA = NewButtonEntity(w, nil, entityMap)
|
||||
// 钥匙
|
||||
spk.SPKSX1J_KEY = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSX3J_KEY = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSS2J_KEY = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSS4J_KEY = NewButtonEntity(w, nil, entityMap)
|
||||
// 继电器组
|
||||
spk.SPKSX1J = NewRelayEntity(w, nil, entityMap)
|
||||
spk.SPKSX3J = NewRelayEntity(w, nil, entityMap)
|
||||
@ -106,7 +106,7 @@ func loadEMPEntity(w ecs.World, entry *ecs.Entry, entityMap map[string]*ecs.Entr
|
||||
emp.XEMPD = NewLightHEntity(w)
|
||||
emp.SEMPD = NewLightHEntity(w)
|
||||
// 蜂鸣器
|
||||
emp.FMQ = NewFMQEntity(w, nil, entityMap)
|
||||
emp.FMQ = NewFMQEntity(w, "", entityMap)
|
||||
entry.AddComponent(component.EmpElectronicType, unsafe.Pointer(emp))
|
||||
entry.AddComponent(component.EmpCollectStateType, unsafe.Pointer(&component.EmpCollectState{}))
|
||||
return nil
|
||||
|
@ -55,3 +55,12 @@ func NewLights(w ecs.World, lightTags ...component.DsTag) []*ecs.Entry {
|
||||
}
|
||||
return ls
|
||||
}
|
||||
|
||||
// IsLightFd 灯是否被封(如Signal 3xh3 红绿黄三显示封绿灯)
|
||||
func IsLightFd(lightEntry *ecs.Entry) bool {
|
||||
if lightEntry.HasComponent(component.LightDriveType) && lightEntry.HasComponent(component.BitStateType) {
|
||||
return lightEntry.HasComponent(component.FdTag)
|
||||
} else {
|
||||
panic("IsLightFd 参数lightEntry的值非灯实体")
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ func loadSignal3xh3(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
|
||||
if len(elecs) == 5 { //3xh3组合类型包含5个继电器
|
||||
signalEntry.AddComponent(component.Signal3XH3ElectronicType)
|
||||
signalEntry.AddComponent(component.Signal3XH3LsqType)
|
||||
signalEntry.AddComponent(component.Signal3XH3LscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.Signal3XH3Electronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -32,6 +35,11 @@ func loadSignal3xh3(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
}
|
||||
//
|
||||
component.Signal3XH3ElectronicType.Set(signalEntry, elecState)
|
||||
component.Signal3XH3LsqType.Set(signalEntry, &component.Signal3XH3Lsq{})
|
||||
component.Signal3XH3LscType.Set(signalEntry, &component.Signal3XH3Lsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
//封绿灯,即有绿灯但绿被封
|
||||
component.SignalLightsType.Get(signalEntry).GetLightByTag(component.LdTag).AddComponent(component.FdTag)
|
||||
} else {
|
||||
return fmt.Errorf("id=[%s]的信号机3xh3,电子元器件数量须为5", signal.Id())
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ func loadSignal3xh4(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
|
||||
if len(elecs) == 4 { //3xh4组合类型包含4个继电器
|
||||
signalEntry.AddComponent(component.Signal3XH4ElectronicType)
|
||||
signalEntry.AddComponent(component.Signal3XH4FilamentType)
|
||||
signalEntry.AddComponent(component.Signal3XH4LsqType)
|
||||
signalEntry.AddComponent(component.Signal3XH4LscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.Signal3XH4Electronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -31,7 +33,9 @@ func loadSignal3xh4(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
}
|
||||
//
|
||||
component.Signal3XH4ElectronicType.Set(signalEntry, elecState)
|
||||
component.Signal3XH4FilamentType.Set(signalEntry, &component.Signal3XH4Filament{Uf: true, Lf: true, Hf: true, U: false, L: false, H: false})
|
||||
component.Signal3XH4LsqType.Set(signalEntry, &component.Signal3XH4Lsq{})
|
||||
component.Signal3XH4LscType.Set(signalEntry, &component.Signal3XH4Lsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
} else {
|
||||
return fmt.Errorf("id=[%s]的信号机3xh4,电子元器件数量须为4", signal.Id())
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"joylink.club/rtsssimulation/fi"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
"time"
|
||||
@ -32,34 +31,28 @@ func main() {
|
||||
repo := repository.BuildRepositoryForSignalTest(proto)
|
||||
sim := rtss_simulation.NewSimulation(repo)
|
||||
loadEntities(sim, repo)
|
||||
sim.SetSpeed(0.1)
|
||||
sim.SetSpeed(1)
|
||||
sim.AddSystem(sigSys.NewSignalDebugSystem())
|
||||
sim.StartUp()
|
||||
//
|
||||
time.Sleep(1 * time.Second)
|
||||
worldLog(sim, "===>>灭灯 .....")
|
||||
slog.Debug("灭灯 .....")
|
||||
fi.DriveSignal3XH1Dd(sim, IdSignal3XH1, false)
|
||||
//
|
||||
time.Sleep(1 * time.Second)
|
||||
worldLog(sim, "===>>亮灯 .....")
|
||||
slog.Debug("亮灯 .....")
|
||||
fi.DriveSignal3XH1Dd(sim, IdSignal3XH1, true)
|
||||
//
|
||||
time.Sleep(2 * time.Second)
|
||||
worldLog(sim, "===>>开通引导信号 .....")
|
||||
slog.Debug("开通引导信号 .....")
|
||||
fi.DriveSignal3XH1Yx(sim, IdSignal3XH1)
|
||||
time.Sleep(2 * time.Second)
|
||||
worldLog(sim, "===>>开通列车信号 .....")
|
||||
slog.Debug("开通列车信号 .....")
|
||||
fi.DriveSignal3XH1Lx(sim, IdSignal3XH1, false)
|
||||
//
|
||||
time.Sleep(5 * time.Second)
|
||||
sim.Close()
|
||||
}
|
||||
func worldLog(w ecs.World, logInfo string) {
|
||||
ecs.Request(w, func() any {
|
||||
log.Println(logInfo)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
func addProtoSignal3XH1(r *proto.Repository) {
|
||||
//相关继电器
|
||||
r.Relays = append(r.Relays, &proto.Relay{Id: "3xh1-ddj", Code: consts.SIGNAL_DDJ, Model: proto.Relay_JWXC_1700})
|
||||
|
77
fi/ibp.go
Normal file
77
fi/ibp.go
Normal file
@ -0,0 +1,77 @@
|
||||
package fi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
)
|
||||
|
||||
// 按下按钮
|
||||
func PressDownButton(w ecs.World, id string) {
|
||||
w.Execute(func() {
|
||||
wd := entity.GetWorldData(w)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
state := component.BitStateType.Get(entry)
|
||||
if entry.HasComponent(component.NoResetUpBtn) {
|
||||
state.Val = false
|
||||
} else if entry.HasComponent(component.ResetUpBtn) {
|
||||
state.Val = false
|
||||
} else {
|
||||
state.Val = true
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("未找到id=%s的按钮\n", id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 抬起拉起按钮
|
||||
func PressUpButton(w ecs.World, id string) {
|
||||
w.Execute(func() {
|
||||
wd := entity.GetWorldData(w)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
state := component.BitStateType.Get(entry)
|
||||
if entry.HasComponent(component.NoResetUpBtn) {
|
||||
state.Val = true
|
||||
} else if entry.HasComponent(component.ResetUpBtn) {
|
||||
state.Val = true
|
||||
} else {
|
||||
state.Val = false
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("未找到id=%s的按钮\n", id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 修改钥匙旋钮关闭状态
|
||||
func PutKeyOff(w ecs.World, id string) {
|
||||
w.Execute(func() {
|
||||
wd := entity.GetWorldData(w)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
state := component.BitStateType.Get(entry)
|
||||
state.Val = false
|
||||
} else {
|
||||
fmt.Printf("未找到id=%s的钥匙开关\n", id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 修改钥匙旋钮开启状态
|
||||
func PutKeyOn(w ecs.World, id string) {
|
||||
w.Execute(func() {
|
||||
wd := entity.GetWorldData(w)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
state := component.BitStateType.Get(entry)
|
||||
state.Val = true
|
||||
} else {
|
||||
fmt.Printf("未找到id=%s的钥匙开关\n", id)
|
||||
}
|
||||
})
|
||||
}
|
@ -15,11 +15,8 @@ func DriveSignal3XH3Dd(w ecs.World, signalId string, dd bool) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.Signal3XH3ElectronicType.Get(signalEntry)
|
||||
driveDd := component.RelayDriveType.Get(state.Z3XH3_DDJ)
|
||||
//点灯继电器落下时才点灯
|
||||
driveDd.Td = !dd
|
||||
driveDd.Xq = !dd
|
||||
lsq := component.Signal3XH3LsqType.Get(signalEntry)
|
||||
lsq.Z3XH3_DDJ_Q = !dd
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -30,13 +27,9 @@ func DriveSignal3XH3Lx(w ecs.World, signalId string) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.Signal3XH3ElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.Z3XH3_LXJ)
|
||||
driveLx.Td = true
|
||||
driveLx.Xq = true
|
||||
driveYx := component.RelayDriveType.Get(state.Z3XH3_YXJ)
|
||||
driveYx.Td = false
|
||||
driveYx.Xq = false
|
||||
lsq := component.Signal3XH3LsqType.Get(signalEntry)
|
||||
lsq.Z3XH3_LXJ_Q = true
|
||||
lsq.Z3XH3_YXJ_Q = false
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -47,13 +40,9 @@ func DriveSignal3XH3Yx(w ecs.World, signalId string) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.Signal3XH3ElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.Z3XH3_LXJ)
|
||||
driveLx.Td = false
|
||||
driveLx.Xq = false
|
||||
driveYx := component.RelayDriveType.Get(state.Z3XH3_YXJ)
|
||||
driveYx.Td = true
|
||||
driveYx.Xq = true
|
||||
lsq := component.Signal3XH3LsqType.Get(signalEntry)
|
||||
lsq.Z3XH3_LXJ_Q = false
|
||||
lsq.Z3XH3_YXJ_Q = true
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -64,13 +53,9 @@ func DriveSignal3XH3Non(w ecs.World, signalId string) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.Signal3XH3ElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.Z3XH3_LXJ)
|
||||
driveLx.Td = false
|
||||
driveLx.Xq = false
|
||||
driveYx := component.RelayDriveType.Get(state.Z3XH3_YXJ)
|
||||
driveYx.Td = false
|
||||
driveYx.Xq = false
|
||||
lsq := component.Signal3XH3LsqType.Get(signalEntry)
|
||||
lsq.Z3XH3_LXJ_Q = false
|
||||
lsq.Z3XH3_YXJ_Q = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -15,11 +15,8 @@ func DriveSignal3XH4Dd(w ecs.World, signalId string, dd bool) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.Signal3XH4ElectronicType.Get(signalEntry)
|
||||
driveDd := component.RelayDriveType.Get(state.Z3XH4_DDJ)
|
||||
//点灯继电器落下时才点灯
|
||||
driveDd.Td = !dd
|
||||
driveDd.Xq = !dd
|
||||
lsq := component.Signal3XH4LsqType.Get(signalEntry)
|
||||
lsq.Z3XH4_DDJ_Q = !dd
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -31,13 +28,9 @@ func DriveSignal3XH4Lx(w ecs.World, signalId string, zx bool) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.Signal3XH4ElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.Z3XH4_LXJ)
|
||||
driveLx.Td = true
|
||||
driveLx.Xq = true
|
||||
driveZx := component.RelayDriveType.Get(state.Z3XH4_ZXJ)
|
||||
driveZx.Td = zx
|
||||
driveZx.Xq = zx
|
||||
lsq := component.Signal3XH4LsqType.Get(signalEntry)
|
||||
lsq.Z3XH4_LXJ_Q = true
|
||||
lsq.Z3XH4_ZXJ_Q = zx
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -48,13 +41,9 @@ func DriveSignal3XH4Non(w ecs.World, signalId string) {
|
||||
wd := entity.GetWorldData(w)
|
||||
signalEntry, ok := wd.EntityMap[signalId]
|
||||
if ok {
|
||||
state := component.Signal3XH4ElectronicType.Get(signalEntry)
|
||||
driveLx := component.RelayDriveType.Get(state.Z3XH4_LXJ)
|
||||
driveLx.Td = false
|
||||
driveLx.Xq = false
|
||||
driveZx := component.RelayDriveType.Get(state.Z3XH4_ZXJ)
|
||||
driveZx.Td = false
|
||||
driveZx.Xq = false
|
||||
lsq := component.Signal3XH4LsqType.Get(signalEntry)
|
||||
lsq.Z3XH4_LXJ_Q = false
|
||||
lsq.Z3XH4_ZXJ_Q = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ message ElectronicComponentGroup {
|
||||
repeated string componentIds = 2; //组合内电子元件的id
|
||||
}
|
||||
|
||||
// 按钮
|
||||
// 开关、按钮、旋钮
|
||||
message Button {
|
||||
enum ButtonType {
|
||||
Unknown = 0;
|
||||
|
@ -1,13 +0,0 @@
|
||||
package repository
|
||||
|
||||
import "joylink.club/rtsssimulation/repository/model/proto"
|
||||
|
||||
type Fmq struct {
|
||||
Identity
|
||||
}
|
||||
|
||||
func NewFmq(id string) *Fmq {
|
||||
return &Fmq{
|
||||
Identity: identity{id, proto.DeviceType_DeviceType_FMQ},
|
||||
}
|
||||
}
|
@ -39,14 +39,14 @@ func (ibp *IBPSys) Update(w ecs.World) {
|
||||
func (ibp *IBPSys) spkControl(entry *ecs.Entry, spkState *component.SpkElectronic) {
|
||||
spksxplaBtn := getBtnVal(spkState.SPKSXPLA_BTN)
|
||||
// spksx1j 通电状态
|
||||
setRelayTdVal(spkState.SPKSX1J, spksxplaBtn || getBtnVal(spkState.SPKSX1J_BTN))
|
||||
setRelayTdVal(spkState.SPKSX1J, spksxplaBtn || getBtnVal(spkState.SPKSX1J_KEY))
|
||||
// spksx3j 通电状态
|
||||
setRelayTdVal(spkState.SPKSX3J, spksxplaBtn || getBtnVal(spkState.SPKSX3J_BTN))
|
||||
setRelayTdVal(spkState.SPKSX3J, spksxplaBtn || getBtnVal(spkState.SPKSX3J_KEY))
|
||||
spkssplaBtn := getBtnVal(spkState.SPKSSPLA_BTN)
|
||||
// spkss2j 通电状态
|
||||
setRelayTdVal(spkState.SPKSS2J, spkssplaBtn || getBtnVal(spkState.SPKSS2J_BTN))
|
||||
setRelayTdVal(spkState.SPKSS2J, spkssplaBtn || getBtnVal(spkState.SPKSS2J_KEY))
|
||||
// spkss4j 通电状态
|
||||
setRelayTdVal(spkState.SPKSS4J, spkssplaBtn || getBtnVal(spkState.SPKSS4J_BTN))
|
||||
setRelayTdVal(spkState.SPKSS4J, spkssplaBtn || getBtnVal(spkState.SPKSS4J_KEY))
|
||||
}
|
||||
|
||||
// 人员防护表示状态电路逻辑
|
||||
|
@ -11,7 +11,11 @@ type Signal3XH2System struct {
|
||||
}
|
||||
|
||||
func NewSignal3XH2System() *Signal3XH2System {
|
||||
return &Signal3XH2System{query: ecs.NewQuery(filter.Contains(component.Signal3XH2ElectronicType))}
|
||||
return &Signal3XH2System{query: ecs.NewQuery(filter.Contains(
|
||||
component.Signal3XH2ElectronicType,
|
||||
component.Signal3XH2LsqType,
|
||||
component.Signal3XH2LscType,
|
||||
component.SignalLightsType))}
|
||||
}
|
||||
|
||||
// Update world 执行
|
||||
|
@ -11,54 +11,98 @@ type Signal3XH3System struct {
|
||||
}
|
||||
|
||||
func NewSignal3XH3System() *Signal3XH3System {
|
||||
return &Signal3XH3System{query: ecs.NewQuery(filter.Contains(component.Signal3XH3ElectronicType))}
|
||||
return &Signal3XH3System{query: ecs.NewQuery(filter.Contains(
|
||||
component.Signal3XH3ElectronicType,
|
||||
component.Signal3XH3LsqType,
|
||||
component.Signal3XH3LscType,
|
||||
component.SignalLightsType))}
|
||||
}
|
||||
|
||||
// Update world 执行
|
||||
func (s *Signal3XH3System) Update(w ecs.World) {
|
||||
s.query.Each(w, func(e *ecs.Entry) {
|
||||
state := component.Signal3XH3ElectronicType.Get(e)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
state := component.Signal3XH3ElectronicType.Get(entry)
|
||||
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.calculateU(state)
|
||||
s.calculateH(state)
|
||||
s.calculateDJ(state)
|
||||
s.calculate2DJ(state)
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Signal3XH3System) calculateU(state *component.Signal3XH3Electronic) {
|
||||
// 联锁驱
|
||||
func (s *Signal3XH3System) calculateLsq(state *component.Signal3XH3Electronic, lsq *component.Signal3XH3Lsq) {
|
||||
ddj := component.RelayDriveType.Get(state.Z3XH3_DDJ)
|
||||
lxj := component.RelayDriveType.Get(state.Z3XH3_LXJ)
|
||||
yxj := component.RelayDriveType.Get(state.Z3XH3_YXJ)
|
||||
//
|
||||
ddjQ := lsq.Z3XH3_DDJ_Q
|
||||
ddj.Td = ddjQ
|
||||
ddj.Xq = ddjQ
|
||||
//
|
||||
lxjQ := lsq.Z3XH3_LXJ_Q
|
||||
lxj.Td = lxjQ
|
||||
lxj.Xq = lxjQ
|
||||
//
|
||||
yxjQ := lsq.Z3XH3_YXJ_Q
|
||||
yxj.Td = yxjQ
|
||||
yxj.Xq = yxjQ
|
||||
}
|
||||
|
||||
// 联锁采
|
||||
func (s *Signal3XH3System) calculateLsc(state *component.Signal3XH3Electronic, lsc *component.Signal3XH3Lsc) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||
dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
||||
edj := component.BitStateType.Get(state.Z3XH3_2DJ)
|
||||
yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
||||
//
|
||||
lsc.Z3XH3_2DJ_Xq = edj.Val
|
||||
lsc.Z3XH3_DJ_Xq = dj.Val
|
||||
lsc.Z3XH3_DDJ_Lx = !ddj.Val
|
||||
lsc.Z3XH3_LXJ_Xq = lxj.Val
|
||||
lsc.Z3XH3_YXJ_Xq = yxj.Val
|
||||
}
|
||||
func (s *Signal3XH3System) calculateU(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||
dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
||||
yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
||||
isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val || !ddj.Val && lxj.Val
|
||||
driveU := component.LightDriveType.Get(state.Z3XH3_U)
|
||||
driveU := component.LightDriveType.Get(Z3XH3_U)
|
||||
driveU.Td = isU
|
||||
|
||||
}
|
||||
func (s *Signal3XH3System) calculateH(state *component.Signal3XH3Electronic) {
|
||||
func (s *Signal3XH3System) calculateH(state *component.Signal3XH3Electronic, Z3XH3_H *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||
isH := !ddj.Val && !lxj.Val
|
||||
driveH := component.LightDriveType.Get(state.Z3XH3_H)
|
||||
driveH := component.LightDriveType.Get(Z3XH3_H)
|
||||
driveH.Td = isH
|
||||
}
|
||||
func (s *Signal3XH3System) calculateDJ(state *component.Signal3XH3Electronic) {
|
||||
func (s *Signal3XH3System) calculateDJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry, Z3XH3_H *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||
ud := component.BitStateType.Get(state.Z3XH3_U)
|
||||
hd := component.BitStateType.Get(state.Z3XH3_H)
|
||||
ud := component.BitStateType.Get(Z3XH3_U)
|
||||
hd := component.BitStateType.Get(Z3XH3_H)
|
||||
isDJ := ud.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val
|
||||
drive := component.RelayDriveType.Get(state.Z3XH3_DJ)
|
||||
drive.Td = isDJ
|
||||
drive.Xq = isDJ
|
||||
}
|
||||
func (s *Signal3XH3System) calculate2DJ(state *component.Signal3XH3Electronic) {
|
||||
func (s *Signal3XH3System) calculate2DJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||
dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
||||
yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
||||
ud := component.BitStateType.Get(state.Z3XH3_U)
|
||||
ud := component.BitStateType.Get(Z3XH3_U)
|
||||
is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
||||
drive := component.RelayDriveType.Get(state.Z3XH3_2DJ)
|
||||
drive.Td = is2DJ
|
||||
|
@ -11,56 +11,101 @@ type Signal3XH4System struct {
|
||||
}
|
||||
|
||||
func NewSignal3XH4System() *Signal3XH4System {
|
||||
return &Signal3XH4System{query: ecs.NewQuery(filter.Contains(component.Signal3XH4ElectronicType, component.Signal3XH4FilamentType))}
|
||||
return &Signal3XH4System{query: ecs.NewQuery(filter.Contains(
|
||||
component.Signal3XH4ElectronicType,
|
||||
component.Signal3XH4LsqType,
|
||||
component.Signal3XH4LscType,
|
||||
component.SignalLightsType))}
|
||||
}
|
||||
|
||||
// Update world 执行
|
||||
func (s *Signal3XH4System) Update(w ecs.World) {
|
||||
s.query.Each(w, func(e *ecs.Entry) {
|
||||
state := component.Signal3XH4ElectronicType.Get(e)
|
||||
filament := component.Signal3XH4FilamentType.Get(e)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
state := component.Signal3XH4ElectronicType.Get(entry)
|
||||
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.calculateU(state, filament)
|
||||
s.calculateL(state, filament)
|
||||
s.calculateH(w, state, filament)
|
||||
s.calculateDJ(w, e, state, filament)
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Signal3XH4System) calculateU(state *component.Signal3XH4Electronic, filament *component.Signal3XH4Filament) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||
isU := filament.Uf && !ddj.Val && lxj.Val && !zxj.Val
|
||||
filament.U = isU
|
||||
// 联锁驱
|
||||
func (s *Signal3XH4System) calculateLsq(state *component.Signal3XH4Electronic, lsq *component.Signal3XH4Lsq) {
|
||||
ddj := component.RelayDriveType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.RelayDriveType.Get(state.Z3XH4_LXJ)
|
||||
zxj := component.RelayDriveType.Get(state.Z3XH4_ZXJ)
|
||||
//
|
||||
ddjQ := lsq.Z3XH4_DDJ_Q
|
||||
ddj.Td = ddjQ
|
||||
ddj.Xq = ddjQ
|
||||
//
|
||||
lxjQ := lsq.Z3XH4_LXJ_Q
|
||||
lxj.Td = lxjQ
|
||||
lxj.Xq = lxjQ
|
||||
//
|
||||
zxjQ := lsq.Z3XH4_ZXJ_Q
|
||||
zxj.Td = zxjQ
|
||||
zxj.Xq = zxjQ
|
||||
}
|
||||
|
||||
func (s *Signal3XH4System) calculateL(state *component.Signal3XH4Electronic, filament *component.Signal3XH4Filament) {
|
||||
// 联锁采
|
||||
func (s *Signal3XH4System) calculateLsc(state *component.Signal3XH4Electronic, lsc *component.Signal3XH4Lsc) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||
isL := filament.Lf && !ddj.Val && lxj.Val && zxj.Val
|
||||
filament.L = isL
|
||||
}
|
||||
|
||||
func (s *Signal3XH4System) calculateH(w ecs.World, state *component.Signal3XH4Electronic, filament *component.Signal3XH4Filament) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||
isH := filament.Hf && !ddj.Val && !lxj.Val
|
||||
filament.H = isH
|
||||
}
|
||||
|
||||
func (s *Signal3XH4System) calculateDJ(w ecs.World, e *ecs.Entry, state *component.Signal3XH4Electronic, filament *component.Signal3XH4Filament) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
dj := component.BitStateType.Get(state.Z3XH4_DJ)
|
||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||
//
|
||||
lsc.Z3XH4_DJ_Xq = dj.Val
|
||||
lsc.Z3XH4_DDJ_Lx = !ddj.Val
|
||||
lsc.Z3XH4_LXJ_Xq = lxj.Val
|
||||
lsc.Z3XH4_ZXJ_Xq = zxj.Val
|
||||
}
|
||||
func (s *Signal3XH4System) calculateU(state *component.Signal3XH4Electronic, Z3XH4_U *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||
isDJ := filament.Uf && !ddj.Val && lxj.Val && !zxj.Val ||
|
||||
filament.Lf && !ddj.Val && lxj.Val && zxj.Val ||
|
||||
filament.Hf && !ddj.Val && !lxj.Val
|
||||
if isDJ != dj.Val {
|
||||
drive := component.RelayDriveType.Get(state.Z3XH4_DJ)
|
||||
drive.Td = isDJ
|
||||
drive.Xq = isDJ
|
||||
}
|
||||
isU := !ddj.Val && lxj.Val && !zxj.Val
|
||||
driveU := component.LightDriveType.Get(Z3XH4_U)
|
||||
driveU.Td = isU
|
||||
}
|
||||
|
||||
func (s *Signal3XH4System) calculateL(state *component.Signal3XH4Electronic, Z3XH4_L *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||
isL := !ddj.Val && lxj.Val && zxj.Val
|
||||
driveL := component.LightDriveType.Get(Z3XH4_L)
|
||||
driveL.Td = isL
|
||||
}
|
||||
|
||||
func (s *Signal3XH4System) calculateH(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||
isH := !ddj.Val && !lxj.Val
|
||||
driveH := component.LightDriveType.Get(Z3XH4_H)
|
||||
driveH.Td = isH
|
||||
}
|
||||
|
||||
func (s *Signal3XH4System) calculateDJ(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry, Z3XH4_L *ecs.Entry, Z3XH4_U *ecs.Entry) {
|
||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||
hd := component.BitStateType.Get(Z3XH4_H)
|
||||
ld := component.BitStateType.Get(Z3XH4_L)
|
||||
ud := component.BitStateType.Get(Z3XH4_U)
|
||||
isDJ := ud.Val && !ddj.Val && lxj.Val && !zxj.Val ||
|
||||
ld.Val && !ddj.Val && lxj.Val && zxj.Val ||
|
||||
hd.Val && !ddj.Val && !lxj.Val
|
||||
drive := component.RelayDriveType.Get(state.Z3XH4_DJ)
|
||||
drive.Td = isDJ
|
||||
drive.Xq = isDJ
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user