Merge branch 'master' of https://git.code.tencent.com/jl-framework/rtss_simulation into HEAD
# Conflicts: # repository/model/proto/model.pb.go
This commit is contained in:
commit
b9e687d26a
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: component/common.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: component/turnout.proto
|
||||
|
||||
|
@ -322,22 +322,8 @@ type SignalJDXHElectronic struct {
|
||||
JDXH_LXJ *ecs.Entry
|
||||
//引导信号继电器,true-吸合
|
||||
JDXH_YXJ *ecs.Entry
|
||||
}
|
||||
|
||||
// SignalJDXHFilament 信号机JDXH 灯丝状态
|
||||
type SignalJDXHFilament struct {
|
||||
// 物理黄灯,true-灯丝正常
|
||||
Uf bool
|
||||
// 物理绿灯,true-灯丝正常
|
||||
Lf bool
|
||||
// 物理红灯,true-灯丝正常
|
||||
Hf bool
|
||||
// 物理黄灯,true-亮
|
||||
U bool
|
||||
// 物理绿灯,true-亮
|
||||
L bool
|
||||
// 物理红灯,true-亮
|
||||
H bool
|
||||
//引导转换继电器,true-吸合
|
||||
JDXH_YZHJ *ecs.Entry
|
||||
}
|
||||
|
||||
// SignalJDXHLsq 联锁驱
|
||||
@ -362,5 +348,6 @@ type SignalJDXHLsc struct {
|
||||
|
||||
var (
|
||||
SignalJDXHElectronicType = ecs.NewComponentType[SignalJDXHElectronic]()
|
||||
SignalJDXHFilamentType = ecs.NewComponentType[SignalJDXHFilament]()
|
||||
SignalJDXHLsqType = ecs.NewComponentType[SignalJDXHLsq]()
|
||||
SignalJDXHLscType = ecs.NewComponentType[SignalJDXHLsc]()
|
||||
)
|
||||
|
@ -12,7 +12,9 @@ func loadSignalJdxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
|
||||
if len(elecs) == 4 { //jdxh组合类型包含3个继电器
|
||||
signalEntry.AddComponent(component.SignalJDXHElectronicType)
|
||||
signalEntry.AddComponent(component.SignalJDXHFilamentType)
|
||||
signalEntry.AddComponent(component.SignalJDXHLsqType)
|
||||
signalEntry.AddComponent(component.SignalJDXHLscType)
|
||||
signalEntry.AddComponent(component.SignalLightsType)
|
||||
//
|
||||
elecState := &component.SignalJDXHElectronic{}
|
||||
for _, elec := range elecs {
|
||||
@ -31,7 +33,9 @@ func loadSignalJdxh(w ecs.World, signal *repository.Signal, signalEntry *ecs.Ent
|
||||
}
|
||||
//
|
||||
component.SignalJDXHElectronicType.Set(signalEntry, elecState)
|
||||
component.SignalJDXHFilamentType.Set(signalEntry, &component.SignalJDXHFilament{Uf: true, Lf: true, Hf: true, U: false, L: false, H: false})
|
||||
component.SignalJDXHLsqType.Set(signalEntry, &component.SignalJDXHLsq{})
|
||||
component.SignalJDXHLscType.Set(signalEntry, &component.SignalJDXHLsc{})
|
||||
component.SignalLightsType.Set(signalEntry, newSignalLights(w, component.HdTag, component.LdTag, component.UdTag))
|
||||
} else {
|
||||
return fmt.Errorf("id=[%s]的信号机jdxh,电子元器件数量须为4", signal.Id())
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ message Repository {
|
||||
repeated PhaseFailureProtector phaseFailureProtectors = 12;
|
||||
repeated Button buttons = 13;
|
||||
repeated Psd psds = 14;
|
||||
repeated Light lights = 15;
|
||||
repeated Alarm alarms = 16;
|
||||
repeated Station stations = 17;
|
||||
}
|
||||
|
||||
//物理区段
|
||||
@ -115,6 +118,7 @@ enum DeviceType {
|
||||
DeviceType_Light = 13;
|
||||
DeviceType_Alarm = 14;
|
||||
DeviceType_Psd = 15;
|
||||
DeviceType_Station = 16;
|
||||
}
|
||||
|
||||
enum Port {
|
||||
@ -194,4 +198,32 @@ message Button {
|
||||
string id = 1;
|
||||
string code = 2;
|
||||
ButtonType buttonType = 3;
|
||||
}
|
||||
}
|
||||
|
||||
// 灯
|
||||
message Light {
|
||||
enum LightAspect {
|
||||
L = 0; //绿灯
|
||||
H = 1; //红灯
|
||||
U = 2; //黄灯
|
||||
HU= 3; //红黄灯
|
||||
B=4; //白灯
|
||||
A=5; //蓝灯
|
||||
}
|
||||
string id = 1;
|
||||
string code = 2;
|
||||
LightAspect aspect = 3;
|
||||
}
|
||||
|
||||
// 报警器
|
||||
message Alarm {
|
||||
string id = 1;
|
||||
string code = 2;
|
||||
}
|
||||
|
||||
// 车站
|
||||
message Station {
|
||||
string id = 1;
|
||||
string code = 2;
|
||||
repeated ElectronicComponentGroup electronicComponentGroups = 3; // 关联电子元件组合
|
||||
}
|
||||
|
@ -11,62 +11,100 @@ type SignalJDXHSystem struct {
|
||||
}
|
||||
|
||||
func NewSignalJDXHSystem() *SignalJDXHSystem {
|
||||
return &SignalJDXHSystem{query: ecs.NewQuery(filter.Contains(component.SignalJDXHElectronicType, component.SignalJDXHFilamentType))}
|
||||
return &SignalJDXHSystem{query: ecs.NewQuery(filter.Contains(
|
||||
component.SignalJDXHElectronicType,
|
||||
component.SignalJDXHLsqType,
|
||||
component.SignalJDXHLscType,
|
||||
component.SignalLightsType))}
|
||||
}
|
||||
|
||||
// Update world 执行
|
||||
func (s *SignalJDXHSystem) Update(w ecs.World) {
|
||||
s.query.Each(w, func(e *ecs.Entry) {
|
||||
state := component.SignalJDXHElectronicType.Get(e)
|
||||
filament := component.SignalJDXHFilamentType.Get(e)
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
state := component.SignalJDXHElectronicType.Get(entry)
|
||||
lsq := component.SignalJDXHLsqType.Get(entry)
|
||||
lsc := component.SignalJDXHLscType.Get(entry)
|
||||
lights := component.SignalLightsType.Get(entry)
|
||||
JDXH_H := lights.GetLightByTag(component.HdTag)
|
||||
JDXH_L := lights.GetLightByTag(component.LdTag)
|
||||
JDXH_U := lights.GetLightByTag(component.UdTag)
|
||||
//
|
||||
s.calculateL(state, filament)
|
||||
s.calculateU(state, filament)
|
||||
s.calculateH(state, filament)
|
||||
s.calculateDJ(state, filament)
|
||||
s.calculate2DJ(state, filament)
|
||||
s.calculateLsq(state, lsq)
|
||||
s.calculateL(state, JDXH_L)
|
||||
s.calculateU(state, JDXH_U)
|
||||
s.calculateH(state, JDXH_H)
|
||||
s.calculateDJ(state, JDXH_L, JDXH_H)
|
||||
s.calculate2DJ(state, JDXH_U)
|
||||
s.calculateLsc(state, lsc)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SignalJDXHSystem) calculateU(state *component.SignalJDXHElectronic, filament *component.SignalJDXHFilament) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||
yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
||||
isU := filament.Uf && !lxj.Val && dj.Val && yxj.Val
|
||||
filament.U = isU
|
||||
// 联锁驱
|
||||
func (s *SignalJDXHSystem) calculateLsq(state *component.SignalJDXHElectronic, lsq *component.SignalJDXHLsq) {
|
||||
lxj := component.RelayDriveType.Get(state.JDXH_LXJ)
|
||||
yzhj := component.RelayDriveType.Get(state.JDXH_YZHJ)
|
||||
//
|
||||
lxjQ := lsq.JDXH_LXJ_Q
|
||||
lxj.Td = lxjQ
|
||||
lxj.Xq = lxjQ
|
||||
//
|
||||
yzhjQ := lsq.JDXH_YZHJ_Q
|
||||
yzhj.Td = yzhjQ
|
||||
yzhj.Xq = yzhjQ
|
||||
}
|
||||
|
||||
func (s *SignalJDXHSystem) calculateL(state *component.SignalJDXHElectronic, filament *component.SignalJDXHFilament) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
isL := filament.Lf && lxj.Val
|
||||
filament.L = isL
|
||||
}
|
||||
|
||||
func (s *SignalJDXHSystem) calculateH(state *component.SignalJDXHElectronic, filament *component.SignalJDXHFilament) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
isH := filament.Hf && !lxj.Val
|
||||
filament.H = isH
|
||||
}
|
||||
|
||||
func (s *SignalJDXHSystem) calculateDJ(state *component.SignalJDXHElectronic, filament *component.SignalJDXHFilament) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||
isDJ := filament.Lf && lxj.Val || filament.Hf && !lxj.Val
|
||||
if isDJ != dj.Val {
|
||||
drive := component.RelayDriveType.Get(state.JDXH_DJ)
|
||||
drive.Td = isDJ
|
||||
drive.Xq = isDJ
|
||||
}
|
||||
}
|
||||
func (s *SignalJDXHSystem) calculate2DJ(state *component.SignalJDXHElectronic, filament *component.SignalJDXHFilament) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||
// 联锁采
|
||||
func (s *SignalJDXHSystem) calculateLsc(state *component.SignalJDXHElectronic, lsc *component.SignalJDXHLsc) {
|
||||
edj := component.BitStateType.Get(state.JDXH_2DJ)
|
||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
||||
is2DJ := filament.Uf && !lxj.Val && dj.Val && yxj.Val
|
||||
if is2DJ != edj.Val {
|
||||
drive := component.RelayDriveType.Get(state.JDXH_2DJ)
|
||||
drive.Td = is2DJ
|
||||
drive.Xq = is2DJ
|
||||
}
|
||||
yzhj := component.BitStateType.Get(state.JDXH_YZHJ)
|
||||
//
|
||||
lsc.JDXH_2DJ_Xq = edj.Val
|
||||
lsc.JDXH_DJ_Xq = dj.Val
|
||||
lsc.JDXH_LXJ_Xq = lxj.Val
|
||||
lsc.JDXH_YZHJ_YXJ_Xq = yxj.Val && yzhj.Val
|
||||
}
|
||||
func (s *SignalJDXHSystem) calculateU(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||
yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
||||
isU := !lxj.Val && dj.Val && yxj.Val
|
||||
driveU := component.LightDriveType.Get(JDXH_U)
|
||||
driveU.Td = isU
|
||||
}
|
||||
|
||||
func (s *SignalJDXHSystem) calculateL(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
isL := lxj.Val
|
||||
driveL := component.LightDriveType.Get(JDXH_L)
|
||||
driveL.Td = isL
|
||||
}
|
||||
|
||||
func (s *SignalJDXHSystem) calculateH(state *component.SignalJDXHElectronic, JDXH_H *ecs.Entry) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
isH := !lxj.Val
|
||||
driveH := component.LightDriveType.Get(JDXH_H)
|
||||
driveH.Td = isH
|
||||
}
|
||||
|
||||
func (s *SignalJDXHSystem) calculateDJ(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry, JDXH_H *ecs.Entry) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
hd := component.BitStateType.Get(JDXH_H)
|
||||
ld := component.BitStateType.Get(JDXH_L)
|
||||
isDJ := ld.Val && lxj.Val || hd.Val && !lxj.Val
|
||||
drive := component.RelayDriveType.Get(state.JDXH_DJ)
|
||||
drive.Td = isDJ
|
||||
drive.Xq = isDJ
|
||||
}
|
||||
func (s *SignalJDXHSystem) calculate2DJ(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) {
|
||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||
yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
||||
ud := component.BitStateType.Get(JDXH_U)
|
||||
is2DJ := ud.Val && !lxj.Val && dj.Val && yxj.Val
|
||||
drive := component.RelayDriveType.Get(state.JDXH_2DJ)
|
||||
drive.Td = is2DJ
|
||||
drive.Xq = is2DJ
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user