This commit is contained in:
xzb 2023-10-12 13:55:13 +08:00
commit da8485c036
11 changed files with 318 additions and 106 deletions

View File

@ -4,6 +4,10 @@ import "joylink.club/ecs"
// 按钮标签
var (
// IBP
IBP = ecs.NewTag()
// 未知按钮
UnknowBtn = ecs.NewTag()
// 非自复式按下接通式按钮
NoResetPressBtn = ecs.NewTag()
// 非自复式拉起接通式按钮
@ -12,6 +16,8 @@ var (
ResetPressBtn = ecs.NewTag()
// 自复式拉起接通式按钮
ResetUpBtn = ecs.NewTag()
// 钥匙旋钮
KeyKnobBtn = ecs.NewTag()
)
// 蜂鸣器驱动
@ -23,45 +29,33 @@ type FMQDrive struct {
var FMQDriveType = ecs.NewComponentType[FMQDrive]()
// SPK继电器控制电路
type SpkControlElectronic struct {
type SpkElectronic struct {
// 控制区
SPKSXPLA_BTN *ecs.Entry
SPKSX1J_BTN *ecs.Entry
SPKSX3J_BTN *ecs.Entry
SPKSX1J *ecs.Entry
SPKSX3J *ecs.Entry
SPKSSPLA_BTN *ecs.Entry
SPKSS2J_BTN *ecs.Entry
SPKSS4J_BTN *ecs.Entry
SPKSS2J *ecs.Entry
SPKSS4J *ecs.Entry
}
// SPK继电器元器件组件
var SpkControlElectronicType = ecs.NewComponentType[SpkControlElectronic]()
// SPK标识电路
type SpksStateElectronic struct {
SPKSX1J *ecs.Entry
SPKSX3J *ecs.Entry
SPKSS2J *ecs.Entry
SPKSS4J *ecs.Entry
// 表示区
SPKSX1J *ecs.Entry
SPKSX3J *ecs.Entry
SPKSS2J *ecs.Entry
SPKSS4J *ecs.Entry
SPKSXPLAJ *ecs.Entry
SPKSSPLAJ *ecs.Entry
SPKSX1D *ecs.Entry
SPKSX3D *ecs.Entry
SPKSS2D *ecs.Entry
SPKSS4D *ecs.Entry
SPKSXPLAD *ecs.Entry
SPKSSPLAD *ecs.Entry
SDA *ecs.Entry
SDA *ecs.Entry
}
// SPK继电器元器件组件
var SpksStateElectronicType = ecs.NewComponentType[SpksStateElectronic]()
var SpkElectronicType = ecs.NewComponentType[SpkElectronic]()
// SPK采集电路吸起、落下接通状态
type SpkCollectState struct {
@ -75,39 +69,30 @@ type SpkCollectState struct {
var SpkCollectStateType = ecs.NewComponentType[SpkCollectState]()
// EMP 控制电路
type EmpControlElectronic struct {
// EMP 电路
type EmpElectronic struct {
// 控制区
EMP1_BTN *ecs.Entry
EMP3_BTN *ecs.Entry
EMP5_BTN *ecs.Entry
EMPX_BTN *ecs.Entry
XEMPFA_BTN *ecs.Entry
XEMPJ *ecs.Entry // 继电器
EMP2_BTN *ecs.Entry
EMP4_BTN *ecs.Entry
EMP6_BTN *ecs.Entry
EMPS_BTN *ecs.Entry
SEMPFA_BTN *ecs.Entry
SEMPJ *ecs.Entry // 继电器
}
var EmpControlElectronicType = ecs.NewComponentType[EmpControlElectronic]()
// EMP 标识状态电路
type EmpStateElectronic struct {
// 表示区
XEMPJ *ecs.Entry // 继电器
XEMPD *ecs.Entry
SEMPJ *ecs.Entry // 继电器
SEMPD *ecs.Entry
SDA *ecs.Entry // 按钮
QBA *ecs.Entry // 非自复位按钮
FMQ *ecs.Entry // 蜂鸣器
SDA *ecs.Entry // 按钮
QBA *ecs.Entry // 非自复位按钮
FMQ *ecs.Entry // 蜂鸣器
}
var EmpStateElectronicType = ecs.NewComponentType[EmpStateElectronic]()
var EmpElectronicType = ecs.NewComponentType[EmpElectronic]()
// EMP 采集电路吸起、落下接通状态
type EmpCollectState struct {

View File

@ -39,6 +39,7 @@ type Zdj9OneElectronic struct {
// ZDJ9单机电路元器件组件类型
var Zdj9OneElectronicType = ecs.NewComponentType[Zdj9OneElectronic]()
// ZDJ9双机电路元器件
type Zdj9TwoElectronic struct {
TDC_DCJ *ecs.Entry // 定操继电器
TDC_FCJ *ecs.Entry // 反操继电器
@ -147,8 +148,44 @@ func (te *Zdj9TwoElectronic) HasNilReference() bool {
return len(nils) > 0
}
// ZDJ9双机电路元器件组件类型
var Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
// ZDJ9双机驱动状态组件
type Zdj9TwoDrive struct {
// 定操继电器驱动
DCJ bool
// 反操继电器驱动
FCJ bool
// 允操继电器驱动
YCJ bool
}
// ZDJ9双机采集状态组件
type Zdj9TwoCollect struct {
// 总定表继电器吸起采集
TDC_ZDBJ_XQ bool
// 总反表继电器吸起采集
TDC_ZFBJ_XQ bool
// 允操继电器吸起采集
TDC_YCJ_XQ bool
// 总定表继电器和总反表继电器都落下采集
TDC_ZDBJ_ZFBJ_LX bool
// 1机定表继电器吸起采集
TDFJ1_DBJ_XQ bool
// 1机反表继电器吸起采集
TDFJ1_FBJ_XQ bool
// 2机定表继电器吸起采集
TDFJ2_DBJ_XQ bool
// 2机反表继电器吸起采集
TDFJ2_FBJ_XQ bool
}
var (
// ZDJ9双机电路元器件组件类型
Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
// ZDJ9双机驱动状态组件类型
Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]()
// ZDJ9双机采集状态组件类型
Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]()
)
// 转辙机状态
type ZzjState struct {

113
entity/ibp.go Normal file
View File

@ -0,0 +1,113 @@
package entity
import (
"unsafe"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto"
)
// 创建IBP实体
func NewIBPEntity(w ecs.World, entityMap map[string]*ecs.Entry) {
entry := w.Entry(w.Create(component.IBP))
loadSPKEntity(w, entry, entityMap)
loadEMPEntity(w, entry, entityMap)
}
// 创建按钮实体
func NewButtonEntity(w ecs.World, data *repository.Button, entityMap map[string]*ecs.Entry) *ecs.Entry {
uid := data.Id()
entry, ok := entityMap[uid]
if !ok {
var btnType ecs.IComponentType
switch data.GetBtnType() {
case proto.Button_NO_Reset_Press:
btnType = component.NoResetPressBtn
case proto.Button_NO_Reset_Up:
btnType = component.NoResetUpBtn
case proto.Button_Reset_Press:
btnType = component.ResetPressBtn
case proto.Button_Reset_Up:
btnType = component.ResetUpBtn
case proto.Button_Key_Knob:
btnType = component.KeyKnobBtn
default:
btnType = component.UnknowBtn
}
entry = w.Entry(w.Create(btnType, component.BitStateType))
entityMap[uid] = entry
}
return entry
}
// 创建蜂鸣器实体
func NewFMQEntity(w ecs.World, data *repository.Fmq, entityMap map[string]*ecs.Entry) *ecs.Entry {
uid := data.Id()
entry, ok := entityMap[uid]
if !ok {
entry = w.Entry(w.Create(component.FMQDriveType, component.BitStateType))
entityMap[uid] = entry
}
return entry
}
// 构建人员防护实体
func loadSPKEntity(w ecs.World, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
spk := &component.SpkElectronic{}
// 按钮组
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 = NewRelayEntity(w, nil, entityMap)
spk.SPKSX3J = NewRelayEntity(w, nil, entityMap)
spk.SPKSS2J = NewRelayEntity(w, nil, entityMap)
spk.SPKSS4J = NewRelayEntity(w, nil, entityMap)
spk.SPKSXPLAJ = NewRelayEntity(w, nil, entityMap)
spk.SPKSSPLAJ = NewRelayEntity(w, nil, entityMap)
// 灯组
spk.SPKSX1D = NewLightHEntity(w)
spk.SPKSX3D = NewLightHEntity(w)
spk.SPKSS2D = NewLightHEntity(w)
spk.SPKSS4D = NewLightHEntity(w)
spk.SPKSXPLAD = NewLightHEntity(w)
spk.SPKSSPLAD = NewLightHEntity(w)
entry.AddComponent(component.SpkElectronicType, unsafe.Pointer(spk))
entry.AddComponent(component.SpkCollectStateType, unsafe.Pointer(&component.SpkCollectState{}))
return nil
}
// 构建紧急关闭实体
func loadEMPEntity(w ecs.World, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
emp := &component.EmpElectronic{}
// 按钮组
emp.EMP1_BTN = NewButtonEntity(w, nil, entityMap)
emp.EMP3_BTN = NewButtonEntity(w, nil, entityMap)
emp.EMP5_BTN = NewButtonEntity(w, nil, entityMap)
emp.EMPX_BTN = NewButtonEntity(w, nil, entityMap)
emp.EMP2_BTN = NewButtonEntity(w, nil, entityMap)
emp.EMP4_BTN = NewButtonEntity(w, nil, entityMap)
emp.EMP6_BTN = NewButtonEntity(w, nil, entityMap)
emp.EMPS_BTN = NewButtonEntity(w, nil, entityMap)
emp.XEMPFA_BTN = NewButtonEntity(w, nil, entityMap)
emp.SEMPFA_BTN = NewButtonEntity(w, nil, entityMap)
emp.QBA = NewButtonEntity(w, nil, entityMap)
emp.SDA = NewButtonEntity(w, nil, entityMap)
// 继电器组
emp.XEMPJ = NewRelayEntity(w, nil, entityMap)
emp.SEMPJ = NewRelayEntity(w, nil, entityMap)
// 灯组
emp.XEMPD = NewLightHEntity(w)
emp.SEMPD = NewLightHEntity(w)
// 蜂鸣器
emp.FMQ = NewFMQEntity(w, nil, entityMap)
entry.AddComponent(component.EmpElectronicType, unsafe.Pointer(emp))
entry.AddComponent(component.EmpCollectStateType, unsafe.Pointer(&component.EmpCollectState{}))
return nil
}

View File

@ -133,6 +133,8 @@ func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Ent
} else {
// 给道岔添加电路组件
entry.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(zdj9TwoElectronic))
entry.AddComponent(component.Zdj9TwoCollectType)
entry.AddComponent(component.Zdj9TwoDriveType)
}
} else if size > 0 && size < 3 {
return fmt.Errorf("id=[%s]的道岔是ZDJ9双机牵引,但继电器组合类型少于3个(应为TDC、TDFJ1、TDFJ2三个组合)", turnout.Id())

@ -1 +1 @@
Subproject commit af605020f1bccf1f1b2ab5a4ae4966d1c6c9776c
Subproject commit 74c02116147b7b4e86b56c790c9075e039e6fe82

View File

@ -104,6 +104,8 @@ enum DeviceType {
DeviceType_Relay = 10;
DeviceType_PhaseFailureProtector = 11;
DeviceType_Button = 12;
DeviceType_Light = 13;
DeviceType_FMQ = 14;
}
enum Port {
@ -178,6 +180,7 @@ message Button {
NO_Reset_Up = 2;
Reset_Press = 3;
Reset_Up = 4;
Key_Knob = 5;
}
string id = 1;
ButtonType buttonType = 2;

View File

@ -14,3 +14,7 @@ func NewButton(id string, buttonType proto.Button_ButtonType) *Button {
buttonType: buttonType,
}
}
func (btn *Button) GetBtnType() proto.Button_ButtonType {
return btn.buttonType
}

13
repository/fmq.go Normal file
View File

@ -0,0 +1,13 @@
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},
}
}

View File

@ -36,6 +36,8 @@ const (
DeviceType_DeviceType_Relay DeviceType = 10
DeviceType_DeviceType_PhaseFailureProtector DeviceType = 11
DeviceType_DeviceType_Button DeviceType = 12
DeviceType_DeviceType_Light DeviceType = 13
DeviceType_DeviceType_FMQ DeviceType = 14
)
// Enum value maps for DeviceType.
@ -54,6 +56,8 @@ var (
10: "DeviceType_Relay",
11: "DeviceType_PhaseFailureProtector",
12: "DeviceType_Button",
13: "DeviceType_Light",
14: "DeviceType_FMQ",
}
DeviceType_value = map[string]int32{
"DeviceType_Unknown": 0,
@ -69,6 +73,8 @@ var (
"DeviceType_Relay": 10,
"DeviceType_PhaseFailureProtector": 11,
"DeviceType_Button": 12,
"DeviceType_Light": 13,
"DeviceType_FMQ": 14,
}
)
@ -372,6 +378,7 @@ const (
Button_NO_Reset_Up Button_ButtonType = 2
Button_Reset_Press Button_ButtonType = 3
Button_Reset_Up Button_ButtonType = 4
Button_Key_Knob Button_ButtonType = 5
)
// Enum value maps for Button_ButtonType.
@ -382,6 +389,7 @@ var (
2: "NO_Reset_Up",
3: "Reset_Press",
4: "Reset_Up",
5: "Key_Knob",
}
Button_ButtonType_value = map[string]int32{
"Unknown": 0,
@ -389,6 +397,7 @@ var (
"NO_Reset_Up": 2,
"Reset_Press": 3,
"Reset_Up": 4,
"Key_Knob": 5,
}
)
@ -1685,51 +1694,55 @@ var file_model_proto_rawDesc = []byte{
0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x22,
0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x73, 0x18, 0x02,
0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49,
0x64, 0x73, 0x22, 0xb1, 0x01, 0x0a, 0x06, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x12, 0x0e, 0x0a,
0x64, 0x73, 0x22, 0xbf, 0x01, 0x0a, 0x06, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x38, 0x0a,
0x0a, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0e, 0x32, 0x18, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e,
0x2e, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x62, 0x75, 0x74,
0x74, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0x5d, 0x0a, 0x0a, 0x42, 0x75, 0x74, 0x74, 0x6f,
0x74, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0x6b, 0x0a, 0x0a, 0x42, 0x75, 0x74, 0x74, 0x6f,
0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e,
0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x4e, 0x4f, 0x5f, 0x52, 0x65, 0x73, 0x65, 0x74, 0x5f, 0x50,
0x72, 0x65, 0x73, 0x73, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x4f, 0x5f, 0x52, 0x65, 0x73,
0x65, 0x74, 0x5f, 0x55, 0x70, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x65, 0x74,
0x5f, 0x50, 0x72, 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x65,
0x74, 0x5f, 0x55, 0x70, 0x10, 0x04, 0x2a, 0xe4, 0x02, 0x0a, 0x0a, 0x44, 0x65, 0x76, 0x69, 0x63,
0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54,
0x79, 0x70, 0x65, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x1e, 0x0a,
0x1a, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x68, 0x79, 0x73,
0x69, 0x63, 0x61, 0x6c, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x19, 0x0a,
0x15, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x43, 0x68, 0x65, 0x63,
0x6b, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76, 0x69,
0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x75, 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x10, 0x03,
0x12, 0x15, 0x0a, 0x11, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x53,
0x69, 0x67, 0x6e, 0x61, 0x6c, 0x10, 0x04, 0x12, 0x1a, 0x0a, 0x16, 0x44, 0x65, 0x76, 0x69, 0x63,
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x6e, 0x64, 0x65,
0x72, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70,
0x65, 0x5f, 0x53, 0x6c, 0x6f, 0x70, 0x65, 0x10, 0x06, 0x12, 0x21, 0x0a, 0x1d, 0x44, 0x65, 0x76,
0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61,
0x6c, 0x43, 0x75, 0x72, 0x76, 0x61, 0x74, 0x75, 0x72, 0x65, 0x10, 0x07, 0x12, 0x13, 0x0a, 0x0f,
0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c, 0x69, 0x6e, 0x6b, 0x10,
0x08, 0x12, 0x17, 0x0a, 0x13, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f,
0x4c, 0x69, 0x6e, 0x6b, 0x4e, 0x6f, 0x64, 0x65, 0x10, 0x09, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x65,
0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x10, 0x0a,
0x12, 0x24, 0x0a, 0x20, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x50,
0x68, 0x61, 0x73, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x65,
0x63, 0x74, 0x6f, 0x72, 0x10, 0x0b, 0x12, 0x15, 0x0a, 0x11, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
0x54, 0x79, 0x70, 0x65, 0x5f, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x10, 0x0c, 0x2a, 0x25, 0x0a,
0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12,
0x05, 0x0a, 0x01, 0x41, 0x10, 0x01, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x02, 0x12, 0x05, 0x0a,
0x01, 0x43, 0x10, 0x03, 0x2a, 0x20, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x45, 0x46, 0x54, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x52,
0x49, 0x47, 0x48, 0x54, 0x10, 0x01, 0x2a, 0x43, 0x0a, 0x0e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50,
0x6f, 0x69, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x42, 0x6f, 0x75, 0x6e,
0x64, 0x61, 0x72, 0x79, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x41, 0x78, 0x6c, 0x65, 0x43, 0x6f,
0x75, 0x6e, 0x74, 0x65, 0x72, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x75, 0x6c,
0x61, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x69, 0x6e, 0x74, 0x10, 0x02, 0x42, 0x1a, 0x5a, 0x18, 0x2e,
0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x6d, 0x6f, 0x64, 0x65,
0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x5f, 0x55, 0x70, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x4b, 0x65, 0x79, 0x5f, 0x4b, 0x6e,
0x6f, 0x62, 0x10, 0x05, 0x2a, 0x8e, 0x03, 0x0a, 0x0a, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54,
0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70,
0x65, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, 0x44,
0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63,
0x61, 0x6c, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x19, 0x0a, 0x15, 0x44,
0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50,
0x6f, 0x69, 0x6e, 0x74, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
0x54, 0x79, 0x70, 0x65, 0x5f, 0x54, 0x75, 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x10, 0x03, 0x12, 0x15,
0x0a, 0x11, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x53, 0x69, 0x67,
0x6e, 0x61, 0x6c, 0x10, 0x04, 0x12, 0x1a, 0x0a, 0x16, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54,
0x79, 0x70, 0x65, 0x5f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x6e, 0x64, 0x65, 0x72, 0x10,
0x05, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f,
0x53, 0x6c, 0x6f, 0x70, 0x65, 0x10, 0x06, 0x12, 0x21, 0x0a, 0x1d, 0x44, 0x65, 0x76, 0x69, 0x63,
0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x43,
0x75, 0x72, 0x76, 0x61, 0x74, 0x75, 0x72, 0x65, 0x10, 0x07, 0x12, 0x13, 0x0a, 0x0f, 0x44, 0x65,
0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c, 0x69, 0x6e, 0x6b, 0x10, 0x08, 0x12,
0x17, 0x0a, 0x13, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c, 0x69,
0x6e, 0x6b, 0x4e, 0x6f, 0x64, 0x65, 0x10, 0x09, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x69,
0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x10, 0x0a, 0x12, 0x24,
0x0a, 0x20, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x68, 0x61,
0x73, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x65, 0x63, 0x74,
0x6f, 0x72, 0x10, 0x0b, 0x12, 0x15, 0x0a, 0x11, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79,
0x70, 0x65, 0x5f, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x10, 0x0c, 0x12, 0x14, 0x0a, 0x10, 0x44,
0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x10,
0x0d, 0x12, 0x12, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f,
0x46, 0x4d, 0x51, 0x10, 0x0e, 0x2a, 0x25, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x08, 0x0a,
0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x41, 0x10, 0x01, 0x12, 0x05,
0x0a, 0x01, 0x42, 0x10, 0x02, 0x12, 0x05, 0x0a, 0x01, 0x43, 0x10, 0x03, 0x2a, 0x20, 0x0a, 0x09,
0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x45, 0x46,
0x54, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x49, 0x47, 0x48, 0x54, 0x10, 0x01, 0x2a, 0x43,
0x0a, 0x0e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65,
0x12, 0x0c, 0x0a, 0x08, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x10, 0x00, 0x12, 0x0f,
0x0a, 0x0b, 0x41, 0x78, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x10, 0x01, 0x12,
0x12, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x69, 0x6e,
0x74, 0x10, 0x02, 0x42, 0x1a, 0x5a, 0x18, 0x2e, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x6f, 0x72, 0x79, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -15,8 +15,8 @@ type IBPSys struct {
func NewIBPSys() *IBPSys {
return &IBPSys{
query: ecs.NewQuery(filter.Contains(
component.SpkControlElectronicType, component.SpksStateElectronicType, component.SpkCollectStateType,
component.EmpControlElectronicType, component.EmpStateElectronicType, component.EmpCollectStateType,
component.SpkElectronicType, component.SpkCollectStateType,
component.EmpElectronicType, component.EmpCollectStateType,
)),
}
}
@ -24,18 +24,19 @@ func NewIBPSys() *IBPSys {
// 控制电路更新
func (ibp *IBPSys) Update(w ecs.World) {
ibp.query.Each(w, func(entry *ecs.Entry) {
ibp.spkControl(entry)
ibp.spksState(entry)
ibp.spkCollect(entry)
ibp.empControl(entry)
ibp.empState(entry)
ibp.empCollect(entry)
spkState := component.SpkElectronicType.Get(entry)
ibp.spkControl(entry, spkState)
ibp.spksState(entry, spkState)
ibp.spkCollect(entry, spkState)
empState := component.EmpElectronicType.Get(entry)
ibp.empControl(entry, empState)
ibp.empState(entry, empState)
ibp.empCollect(entry, empState)
})
}
// 人员防护继电器控制电路逻辑
func (ibp *IBPSys) spkControl(entry *ecs.Entry) {
spkState := component.SpkControlElectronicType.Get(entry)
func (ibp *IBPSys) spkControl(entry *ecs.Entry, spkState *component.SpkElectronic) {
spksxplaBtn := getBtnVal(spkState.SPKSXPLA_BTN)
// spksx1j 通电状态
setRelayTdVal(spkState.SPKSX1J, spksxplaBtn || getBtnVal(spkState.SPKSX1J_BTN))
@ -49,8 +50,7 @@ func (ibp *IBPSys) spkControl(entry *ecs.Entry) {
}
// 人员防护表示状态电路逻辑
func (ibp *IBPSys) spksState(entry *ecs.Entry) {
spkState := component.SpksStateElectronicType.Get(entry)
func (ibp *IBPSys) spksState(entry *ecs.Entry, spkState *component.SpkElectronic) {
sda := getBtnVal(spkState.SDA)
// SPKSXPLAJ
spksxplaj := component.RelayDriveType.Get(spkState.SPKSXPLAJ)
@ -73,20 +73,18 @@ func (ibp *IBPSys) spksState(entry *ecs.Entry) {
}
// 人员防护继电器采集电路状态逻辑
func (ibp *IBPSys) spkCollect(entry *ecs.Entry) {
relayState := component.SpksStateElectronicType.Get(entry)
func (ibp *IBPSys) spkCollect(entry *ecs.Entry, spkState *component.SpkElectronic) {
collectState := component.SpkCollectStateType.Get(entry)
collectState.SPKSX1J_XQ = getRelayXqVal(relayState.SPKSX1J)
collectState.SPKSX3J_XQ = getRelayXqVal(relayState.SPKSX3J)
collectState.SPKSS2J_XQ = getRelayXqVal(relayState.SPKSS2J)
collectState.SPKSS4J_XQ = getRelayXqVal(relayState.SPKSS4J)
collectState.SPKSXPLA_XQ = getRelayXqVal(relayState.SPKSXPLAJ)
collectState.SPKSSPLA_XQ = getRelayXqVal(relayState.SPKSSPLAJ)
collectState.SPKSX1J_XQ = getRelayXqVal(spkState.SPKSX1J)
collectState.SPKSX3J_XQ = getRelayXqVal(spkState.SPKSX3J)
collectState.SPKSS2J_XQ = getRelayXqVal(spkState.SPKSS2J)
collectState.SPKSS4J_XQ = getRelayXqVal(spkState.SPKSS4J)
collectState.SPKSXPLA_XQ = getRelayXqVal(spkState.SPKSXPLAJ)
collectState.SPKSSPLA_XQ = getRelayXqVal(spkState.SPKSSPLAJ)
}
// 紧急关闭控制电路
func (ibp *IBPSys) empControl(entry *ecs.Entry) {
s := component.EmpControlElectronicType.Get(entry)
func (ibp *IBPSys) empControl(entry *ecs.Entry, s *component.EmpElectronic) {
xempfab := getBtnVal(s.XEMPFA_BTN)
xempj := component.RelayDriveType.Get(s.XEMPJ)
// xempfab接通或者按钮组接通并且xempj继电器吸起状态
@ -98,8 +96,7 @@ func (ibp *IBPSys) empControl(entry *ecs.Entry) {
}
// 紧急关闭表示电路
func (ibp *IBPSys) empState(entry *ecs.Entry) {
s := component.EmpStateElectronicType.Get(entry)
func (ibp *IBPSys) empState(entry *ecs.Entry, s *component.EmpElectronic) {
sda := getBtnVal(s.SDA)
xempj := component.RelayDriveType.Get(s.XEMPJ)
setLightTdVal(s.XEMPD, sda || !xempj.Xq)
@ -114,11 +111,10 @@ func (ibp *IBPSys) empState(entry *ecs.Entry) {
}
// 紧急关闭继电器采集电路状态逻辑
func (ibp *IBPSys) empCollect(entry *ecs.Entry) {
empState := component.EmpStateElectronicType.Get(entry)
func (ibp *IBPSys) empCollect(entry *ecs.Entry, s *component.EmpElectronic) {
collectState := component.EmpCollectStateType.Get(entry)
collectState.XEMPJ_XQ = getRelayXqVal(empState.XEMPJ)
collectState.SEMPJ_XQ = getRelayXqVal(empState.SEMPJ)
collectState.XEMPJ_XQ = getRelayXqVal(s.XEMPJ)
collectState.SEMPJ_XQ = getRelayXqVal(s.SEMPJ)
}
// 获取按钮状态

View File

@ -16,7 +16,11 @@ type ZDJ9TwoDragSys struct {
func NewZdj9TwoDragSys() *ZDJ9TwoDragSys {
return &ZDJ9TwoDragSys{
query: ecs.NewQuery(filter.Contains(component.Zdj9TwoElectronicType, component.TurnoutZzjType)),
query: ecs.NewQuery(filter.Contains(
component.Zdj9TwoElectronicType,
component.Zdj9TwoDriveType,
component.Zdj9TwoCollectType,
component.TurnoutZzjType)),
}
}
@ -24,6 +28,9 @@ func NewZdj9TwoDragSys() *ZDJ9TwoDragSys {
func (zdj9 *ZDJ9TwoDragSys) Update(w ecs.World) {
zdj9.query.Each(w, func(entry *ecs.Entry) {
elec := component.Zdj9TwoElectronicType.Get(entry)
drive := component.Zdj9TwoDriveType.Get(entry)
collect := component.Zdj9TwoCollectType.Get(entry)
zdj9.exciteDriveElectronic(elec, drive)
// 转辙机一机电路相关动作
// 1DQJ励磁状态控制
zdj9.exciteM1_TDFJ_1DQJ(elec)
@ -58,9 +65,48 @@ func (zdj9 *ZDJ9TwoDragSys) Update(w ecs.World) {
// 总定表/反表继电器
zdj9.exciteZDFBJ(elec)
zdj9.exciteCollectElectronic(elec, collect)
})
}
// 处理采集电路状态
func (zdj9 *ZDJ9TwoDragSys) exciteCollectElectronic(elec *component.Zdj9TwoElectronic, collect *component.Zdj9TwoCollect) {
zdbj := component.BitStateType.Get(elec.TDC_ZDBJ)
zfbj := component.BitStateType.Get(elec.TDC_ZFBJ)
ycj := component.BitStateType.Get(elec.TDC_YCJ)
tdfj1_dbj := component.BitStateType.Get(elec.TDFJ1_DBJ)
tdfj1_fbj := component.BitStateType.Get(elec.TDFJ1_FBJ)
tdfj2_dbj := component.BitStateType.Get(elec.TDFJ2_DBJ)
tdfj2_fbj := component.BitStateType.Get(elec.TDFJ2_FBJ)
collect.TDC_ZDBJ_XQ = zdbj.Val
collect.TDC_ZFBJ_XQ = zfbj.Val
collect.TDC_YCJ_XQ = ycj.Val
collect.TDC_ZDBJ_ZFBJ_LX = !zdbj.Val && !zfbj.Val
collect.TDFJ1_DBJ_XQ = tdfj1_dbj.Val
collect.TDFJ1_FBJ_XQ = tdfj1_fbj.Val
collect.TDFJ2_DBJ_XQ = tdfj2_dbj.Val
collect.TDFJ2_FBJ_XQ = tdfj2_fbj.Val
}
// 处理驱动电路励磁相关继电器
func (zdj9 *ZDJ9TwoDragSys) exciteDriveElectronic(elec *component.Zdj9TwoElectronic, driveElec *component.Zdj9TwoDrive) {
dcj_drive := component.RelayDriveType.Get(elec.TDC_DCJ)
fcj_drive := component.RelayDriveType.Get(elec.TDC_FCJ)
ycj_drive := component.RelayDriveType.Get(elec.TDC_YCJ)
if dcj_drive.Td != driveElec.DCJ {
dcj_drive.Td = driveElec.DCJ
}
if fcj_drive.Td != driveElec.FCJ {
fcj_drive.Td = driveElec.FCJ
}
if ycj_drive.Td != driveElec.YCJ {
ycj_drive.Td = driveElec.YCJ
}
}
// 总定表、反表继电器控制
func (zdj9 *ZDJ9TwoDragSys) exciteZDFBJ(elec *component.Zdj9TwoElectronic) {
tdfj1_dbj := component.BitStateType.Get(elec.TDFJ1_DBJ)