This commit is contained in:
walker 2023-10-20 15:06:51 +08:00
commit 7fb253612e
16 changed files with 375 additions and 151 deletions

View File

@ -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

View File

@ -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/psd.proto

View File

@ -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/signal.proto

View File

@ -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

View File

@ -24,6 +24,8 @@ var (
AlarmTag = ecs.NewTag()
// 灯标签
LightTag = ecs.NewTag()
// 钥匙标签
KeyTag = ecs.NewTag()
)
// 带单灯设备
@ -41,6 +43,13 @@ type AlarmDrive struct {
// 蜂鸣器驱动组件
var AlarmDriveType = ecs.NewComponentType[AlarmDrive]()
// 挡位组件
type GearState struct {
Val int32
}
var GearStateType = ecs.NewComponentType[GearState]()
// SPK继电器控制电路
type SpkElectronic struct {
// 控制区

View File

@ -43,6 +43,16 @@ func (sl *SignalLights) GetLightByColor(light component_proto.Light_Color) *ecs.
return nil
}
// HaveLightsByColor 判断信号机是否有这几个色灯
func (sl *SignalLights) HaveLightsByColor(lights ...component_proto.Light_Color) bool {
for _, light := range lights {
if sl.GetLightByColor(light) == nil {
return false
}
}
return true
}
//////////////////////////////////////////////////////////////////
var (

View File

@ -63,6 +63,17 @@ func NewIBPLightEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry)
return entry
}
// 创建IBP钥匙实体
func NewIBPKeyEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
entry, ok := entityMap[uid]
if !ok {
entry = w.Entry(w.Create(component.KeyTag, component.UidType, component.GearStateType))
component.UidType.SetValue(entry, component.Uid{Id: uid})
entityMap[uid] = entry
}
return entry
}
// 构建人员防护实体
func LoadSPKEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap, worldData *component.WorldData) error {
entityMap := worldData.EntityMap
@ -75,6 +86,14 @@ func LoadSPKEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap,
spk.SPKSXPLA_BTN = e
case "SPKSSPLA":
spk.SPKSSPLA_BTN = e
case "人员防护试灯":
spk.SDA = e
}
}
// 钥匙组
for _, key := range spkData.Keys() {
e := NewIBPKeyEntity(w, key.Id(), entityMap)
switch key.Code() {
case "SPKS1":
spk.SPKSX1J_KEY = e
case "SPKS3":
@ -83,8 +102,6 @@ func LoadSPKEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap,
spk.SPKSS2J_KEY = e
case "SPKS4":
spk.SPKSS4J_KEY = e
case "人员防护试灯":
spk.SDA = e
}
}
// 继电器组
@ -129,10 +146,19 @@ func LoadSPKEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap,
// 人员防护设置默认值
func setSpkDefault(spk *component.SpkElectronic) {
setBtnVal(spk.SPKSX1J_KEY, true)
setBtnVal(spk.SPKSX3J_KEY, true)
setBtnVal(spk.SPKSS2J_KEY, true)
setBtnVal(spk.SPKSS4J_KEY, true)
setIbpKeyGearVal(spk.SPKSX1J_KEY, 1)
setIbpKeyGearVal(spk.SPKSX3J_KEY, 1)
setIbpKeyGearVal(spk.SPKSS2J_KEY, 1)
setIbpKeyGearVal(spk.SPKSS4J_KEY, 1)
}
// 设置IBP钥匙状态
func setIbpKeyGearVal(entry *ecs.Entry, val int32) {
if entry == nil {
return
}
btn := component.GearStateType.Get(entry)
btn.Val = val
}
// 构建紧急关闭实体
@ -183,9 +209,9 @@ func LoadEMPEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap,
for _, light := range spkData.Lights() {
e := NewIBPLightEntity(w, light.Id(), entityMap)
switch light.Code() {
case "XEMPD":
case "X紧急关闭":
emp.XEMPJ = e
case "SEMPD":
case "S紧急关闭":
emp.SEMPJ = e
}
}
@ -205,18 +231,18 @@ func LoadEMPEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap,
// 紧急关闭设置默认值
func setEmpDefault(emp *component.EmpElectronic) {
setBtnVal(emp.EMP1_BTN, true)
setBtnVal(emp.EMP3_BTN, true)
setBtnVal(emp.EMP5_BTN, true)
setBtnVal(emp.EMPX_BTN, true)
setBtnVal(emp.EMP2_BTN, true)
setBtnVal(emp.EMP4_BTN, true)
setBtnVal(emp.EMP6_BTN, true)
setBtnVal(emp.EMPS_BTN, true)
setIbpBtnVal(emp.EMP1_BTN, true)
setIbpBtnVal(emp.EMP3_BTN, true)
setIbpBtnVal(emp.EMP5_BTN, true)
setIbpBtnVal(emp.EMPX_BTN, true)
setIbpBtnVal(emp.EMP2_BTN, true)
setIbpBtnVal(emp.EMP4_BTN, true)
setIbpBtnVal(emp.EMP6_BTN, true)
setIbpBtnVal(emp.EMPS_BTN, true)
}
// 获取按钮状态
func setBtnVal(entry *ecs.Entry, val bool) {
func setIbpBtnVal(entry *ecs.Entry, val bool) {
if entry == nil {
return
}

View File

@ -48,28 +48,14 @@ func PressUpButton(w ecs.World, id string) {
})
}
// 修改钥匙旋钮关闭状态
func PutKeyOff(w ecs.World, id string) {
// 修改钥匙挡位
func SwitchKeyGear(w ecs.World, id string, gear int32) {
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
state := component.GearStateType.Get(entry)
state.Val = gear
} else {
fmt.Printf("未找到id=%s的钥匙开关\n", id)
}

View File

@ -43,3 +43,36 @@ func UpdateSignalLightFault(w ecs.World, signalId string, light component_proto.
})
return r.Err
}
// SignalLightDrive 当没有电路时,直接驱动信号机灯位上的灯
// ldLights : 需要亮的灯;当为空时则信号机所有色灯灭灯
func SignalLightDrive(w ecs.World, signalId string, ldLights ...component_proto.Light_Color) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if !ok {
return ecs.NewErrResult(fmt.Errorf("信号机[%s]不存实体", signalId))
}
//
lights := component.SignalLightsType.Get(signalEntry)
//ldLights色灯亮
if len(ldLights) > 0 { //色灯亮
if !lights.HaveLightsByColor(ldLights...) {
return ecs.NewErrResult(fmt.Errorf("要点亮的这几个色灯不在信号机[%s]的灯位中", signalId))
}
for _, mdLightEntry := range lights.Lights {
component.LightDriveType.Get(mdLightEntry).Td = false
}
for _, ldLight := range ldLights {
ldLightEntry := lights.GetLightByColor(ldLight)
component.LightDriveType.Get(ldLightEntry).Td = true
}
} else { //信号机所有色灯灭灯
for _, mdLightEntry := range lights.Lights {
component.LightDriveType.Get(mdLightEntry).Td = false
}
}
return ecs.NewOkEmptyResult()
})
return r.Err
}

View File

@ -25,6 +25,8 @@ message Repository {
repeated Mkx mkxs = 18;
repeated Platform platforms = 19;
string mainCoordinateSystem = 20;
repeated Key Keys = 21;
}
//
@ -134,6 +136,7 @@ enum DeviceType {
DeviceType_Psd = 15;
DeviceType_Station = 16;
DeviceType_Mkx = 17;
DeviceType_Key = 18;
}
enum Port {
@ -270,4 +273,12 @@ message Platform {
string code = 2;
string stationId = 3;
string physicalSectionId = 4;
}
}
//
message Key {
string id = 1;
string code = 2;
int32 gear = 3; //
}

View File

@ -133,3 +133,22 @@ func NewLight(id string, code string) *Light {
code: code,
}
}
// 钥匙
type Key struct {
Identity
code string
gear int32
}
func (a *Key) Code() string {
return a.code
}
func NewKey(id string, code string, gear int32) *Key {
return &Key{
Identity: identity{id, proto.DeviceType_DeviceType_Key},
code: code,
gear: gear,
}
}

View File

@ -7,18 +7,8 @@ type IBP struct {
func NewIBP() *IBP {
return &IBP{
Spk: &IBPRefMap{
buttonMap: make(map[string]*Button),
relayMap: make(map[string]*Relay),
alarmMap: make(map[string]*Alarm),
lightMap: make(map[string]*Light),
},
Emp: &IBPRefMap{
buttonMap: make(map[string]*Button),
relayMap: make(map[string]*Relay),
alarmMap: make(map[string]*Alarm),
lightMap: make(map[string]*Light),
},
Spk: newIBPRefMap(),
Emp: newIBPRefMap(),
}
}
@ -27,6 +17,17 @@ type IBPRefMap struct {
relayMap map[string]*Relay
alarmMap map[string]*Alarm
lightMap map[string]*Light
keyMap map[string]*Key
}
func newIBPRefMap() *IBPRefMap {
return &IBPRefMap{
buttonMap: make(map[string]*Button),
relayMap: make(map[string]*Relay),
alarmMap: make(map[string]*Alarm),
lightMap: make(map[string]*Light),
keyMap: make(map[string]*Key),
}
}
func (ibp *IBPRefMap) AddButton(btn *Button) {
@ -45,6 +46,10 @@ func (ibp *IBPRefMap) AddAlarm(fmq *Alarm) {
ibp.alarmMap[fmq.Id()] = fmq
}
func (ibp *IBPRefMap) AddKey(key *Key) {
ibp.keyMap[key.Id()] = key
}
func (ibp *IBPRefMap) Buttons() []*Button {
var buttons []*Button
for _, b := range ibp.buttonMap {
@ -76,3 +81,11 @@ func (ibp *IBPRefMap) Lights() []*Light {
}
return lights
}
func (ibp *IBPRefMap) Keys() []*Key {
var keys []*Key
for _, b := range ibp.keyMap {
keys = append(keys, b)
}
return keys
}

View File

@ -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: model.proto
@ -41,6 +41,7 @@ const (
DeviceType_DeviceType_Psd DeviceType = 15
DeviceType_DeviceType_Station DeviceType = 16
DeviceType_DeviceType_Mkx DeviceType = 17
DeviceType_DeviceType_Key DeviceType = 18
)
// Enum value maps for DeviceType.
@ -64,6 +65,7 @@ var (
15: "DeviceType_Psd",
16: "DeviceType_Station",
17: "DeviceType_Mkx",
18: "DeviceType_Key",
}
DeviceType_value = map[string]int32{
"DeviceType_Unknown": 0,
@ -84,6 +86,7 @@ var (
"DeviceType_Psd": 15,
"DeviceType_Station": 16,
"DeviceType_Mkx": 17,
"DeviceType_Key": 18,
}
)
@ -580,6 +583,7 @@ type Repository struct {
Mkxs []*Mkx `protobuf:"bytes,18,rep,name=mkxs,proto3" json:"mkxs,omitempty"`
Platforms []*Platform `protobuf:"bytes,19,rep,name=platforms,proto3" json:"platforms,omitempty"`
MainCoordinateSystem string `protobuf:"bytes,20,opt,name=mainCoordinateSystem,proto3" json:"mainCoordinateSystem,omitempty"`
Keys []*Key `protobuf:"bytes,21,rep,name=Keys,proto3" json:"Keys,omitempty"`
}
func (x *Repository) Reset() {
@ -754,6 +758,13 @@ func (x *Repository) GetMainCoordinateSystem() string {
return ""
}
func (x *Repository) GetKeys() []*Key {
if x != nil {
return x.Keys
}
return nil
}
// 物理区段
type PhysicalSection struct {
state protoimpl.MessageState
@ -2249,11 +2260,75 @@ func (x *Platform) GetPhysicalSectionId() string {
return ""
}
// 报警器
type Key struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
Gear int32 `protobuf:"varint,3,opt,name=gear,proto3" json:"gear,omitempty"` // 挡位数量
}
func (x *Key) Reset() {
*x = Key{}
if protoimpl.UnsafeEnabled {
mi := &file_model_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Key) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Key) ProtoMessage() {}
func (x *Key) ProtoReflect() protoreflect.Message {
mi := &file_model_proto_msgTypes[23]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Key.ProtoReflect.Descriptor instead.
func (*Key) Descriptor() ([]byte, []int) {
return file_model_proto_rawDescGZIP(), []int{23}
}
func (x *Key) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Key) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
func (x *Key) GetGear() int32 {
if x != nil {
return x.Gear
}
return 0
}
var File_model_proto protoreflect.FileDescriptor
var file_model_proto_rawDesc = []byte{
0x0a, 0x0b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6d,
0x6f, 0x64, 0x65, 0x6c, 0x22, 0xb6, 0x07, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x6f, 0x64, 0x65, 0x6c, 0x22, 0xd6, 0x07, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x6f, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a,
@ -2312,7 +2387,9 @@ var file_model_proto_rawDesc = []byte{
0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x6d, 0x61, 0x69,
0x6e, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65,
0x6d, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x6d, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6f,
0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x22, 0xab, 0x01,
0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x1e, 0x0a,
0x04, 0x4b, 0x65, 0x79, 0x73, 0x18, 0x15, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6d, 0x6f,
0x64, 0x65, 0x6c, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x04, 0x4b, 0x65, 0x79, 0x73, 0x22, 0xab, 0x01,
0x0a, 0x0f, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x75, 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x49, 0x64, 0x73, 0x18,
@ -2533,47 +2610,52 @@ var file_model_proto_rawDesc = []byte{
0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x11, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c,
0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x11, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x49, 0x64, 0x2a, 0xd0, 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,
0x14, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x41, 0x6c,
0x61, 0x72, 0x6d, 0x10, 0x0e, 0x12, 0x12, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54,
0x79, 0x70, 0x65, 0x5f, 0x50, 0x73, 0x64, 0x10, 0x0f, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76,
0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x10,
0x10, 0x12, 0x12, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f,
0x4d, 0x6b, 0x78, 0x10, 0x11, 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,
0x49, 0x64, 0x22, 0x3d, 0x0a, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x67, 0x65, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x67, 0x65, 0x61,
0x72, 0x2a, 0xe4, 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, 0x14,
0x0a, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x41, 0x6c, 0x61,
0x72, 0x6d, 0x10, 0x0e, 0x12, 0x12, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79,
0x70, 0x65, 0x5f, 0x50, 0x73, 0x64, 0x10, 0x0f, 0x12, 0x16, 0x0a, 0x12, 0x44, 0x65, 0x76, 0x69,
0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x10,
0x12, 0x12, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x5f, 0x4d,
0x6b, 0x78, 0x10, 0x11, 0x12, 0x12, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79,
0x70, 0x65, 0x5f, 0x4b, 0x65, 0x79, 0x10, 0x12, 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 (
@ -2589,7 +2671,7 @@ func file_model_proto_rawDescGZIP() []byte {
}
var file_model_proto_enumTypes = make([]protoimpl.EnumInfo, 9)
var file_model_proto_msgTypes = make([]protoimpl.MessageInfo, 23)
var file_model_proto_msgTypes = make([]protoimpl.MessageInfo, 24)
var file_model_proto_goTypes = []interface{}{
(DeviceType)(0), // 0: model.DeviceType
(Port)(0), // 1: model.Port
@ -2623,6 +2705,7 @@ var file_model_proto_goTypes = []interface{}{
(*ElectronicComponent)(nil), // 29: model.ElectronicComponent
(*Mkx)(nil), // 30: model.Mkx
(*Platform)(nil), // 31: model.Platform
(*Key)(nil), // 32: model.Key
}
var file_model_proto_depIdxs = []int32{
10, // 0: model.Repository.physicalSections:type_name -> model.PhysicalSection
@ -2642,43 +2725,44 @@ var file_model_proto_depIdxs = []int32{
27, // 14: model.Repository.stations:type_name -> model.Station
30, // 15: model.Repository.mkxs:type_name -> model.Mkx
31, // 16: model.Repository.platforms:type_name -> model.Platform
18, // 17: model.PhysicalSection.aDevicePort:type_name -> model.DevicePort
18, // 18: model.PhysicalSection.bDevicePort:type_name -> model.DevicePort
19, // 19: model.CheckPoint.km:type_name -> model.Kilometer
3, // 20: model.CheckPoint.type:type_name -> model.CheckPointType
18, // 21: model.CheckPoint.devicePorts:type_name -> model.DevicePort
19, // 22: model.Turnout.km:type_name -> model.Kilometer
18, // 23: model.Turnout.aDevicePort:type_name -> model.DevicePort
18, // 24: model.Turnout.bDevicePort:type_name -> model.DevicePort
18, // 25: model.Turnout.cDevicePort:type_name -> model.DevicePort
4, // 26: model.Turnout.switchMachineType:type_name -> model.Turnout.SwitchMachineType
23, // 27: model.Turnout.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
19, // 28: model.Signal.km:type_name -> model.Kilometer
18, // 29: model.Signal.turnoutPort:type_name -> model.DevicePort
23, // 30: model.Signal.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
5, // 31: model.Signal.model:type_name -> model.Signal.Model
23, // 32: model.Psd.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
19, // 33: model.Transponder.km:type_name -> model.Kilometer
18, // 34: model.Transponder.turnoutPort:type_name -> model.DevicePort
19, // 35: model.Slope.kms:type_name -> model.Kilometer
19, // 36: model.SectionalCurvature.kms:type_name -> model.Kilometer
0, // 37: model.DevicePort.deviceType:type_name -> model.DeviceType
1, // 38: model.DevicePort.port:type_name -> model.Port
2, // 39: model.Kilometer.direction:type_name -> model.Direction
19, // 40: model.KilometerConvert.kmA:type_name -> model.Kilometer
19, // 41: model.KilometerConvert.kmB:type_name -> model.Kilometer
6, // 42: model.Relay.model:type_name -> model.Relay.Model
7, // 43: model.Button.buttonType:type_name -> model.Button.ButtonType
8, // 44: model.Light.aspect:type_name -> model.Light.LightAspect
28, // 45: model.Station.electronicGroup:type_name -> model.ElectronicGroup
29, // 46: model.ElectronicGroup.components:type_name -> model.ElectronicComponent
0, // 47: model.ElectronicComponent.deviceType:type_name -> model.DeviceType
23, // 48: model.Mkx.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
49, // [49:49] is the sub-list for method output_type
49, // [49:49] is the sub-list for method input_type
49, // [49:49] is the sub-list for extension type_name
49, // [49:49] is the sub-list for extension extendee
0, // [0:49] is the sub-list for field type_name
32, // 17: model.Repository.Keys:type_name -> model.Key
18, // 18: model.PhysicalSection.aDevicePort:type_name -> model.DevicePort
18, // 19: model.PhysicalSection.bDevicePort:type_name -> model.DevicePort
19, // 20: model.CheckPoint.km:type_name -> model.Kilometer
3, // 21: model.CheckPoint.type:type_name -> model.CheckPointType
18, // 22: model.CheckPoint.devicePorts:type_name -> model.DevicePort
19, // 23: model.Turnout.km:type_name -> model.Kilometer
18, // 24: model.Turnout.aDevicePort:type_name -> model.DevicePort
18, // 25: model.Turnout.bDevicePort:type_name -> model.DevicePort
18, // 26: model.Turnout.cDevicePort:type_name -> model.DevicePort
4, // 27: model.Turnout.switchMachineType:type_name -> model.Turnout.SwitchMachineType
23, // 28: model.Turnout.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
19, // 29: model.Signal.km:type_name -> model.Kilometer
18, // 30: model.Signal.turnoutPort:type_name -> model.DevicePort
23, // 31: model.Signal.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
5, // 32: model.Signal.model:type_name -> model.Signal.Model
23, // 33: model.Psd.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
19, // 34: model.Transponder.km:type_name -> model.Kilometer
18, // 35: model.Transponder.turnoutPort:type_name -> model.DevicePort
19, // 36: model.Slope.kms:type_name -> model.Kilometer
19, // 37: model.SectionalCurvature.kms:type_name -> model.Kilometer
0, // 38: model.DevicePort.deviceType:type_name -> model.DeviceType
1, // 39: model.DevicePort.port:type_name -> model.Port
2, // 40: model.Kilometer.direction:type_name -> model.Direction
19, // 41: model.KilometerConvert.kmA:type_name -> model.Kilometer
19, // 42: model.KilometerConvert.kmB:type_name -> model.Kilometer
6, // 43: model.Relay.model:type_name -> model.Relay.Model
7, // 44: model.Button.buttonType:type_name -> model.Button.ButtonType
8, // 45: model.Light.aspect:type_name -> model.Light.LightAspect
28, // 46: model.Station.electronicGroup:type_name -> model.ElectronicGroup
29, // 47: model.ElectronicGroup.components:type_name -> model.ElectronicComponent
0, // 48: model.ElectronicComponent.deviceType:type_name -> model.DeviceType
23, // 49: model.Mkx.electronicComponentGroups:type_name -> model.ElectronicComponentGroup
50, // [50:50] is the sub-list for method output_type
50, // [50:50] is the sub-list for method input_type
50, // [50:50] is the sub-list for extension type_name
50, // [50:50] is the sub-list for extension extendee
0, // [0:50] is the sub-list for field type_name
}
func init() { file_model_proto_init() }
@ -2963,6 +3047,18 @@ func file_model_proto_init() {
return nil
}
}
file_model_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Key); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -2970,7 +3066,7 @@ func file_model_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_model_proto_rawDesc,
NumEnums: 9,
NumMessages: 23,
NumMessages: 24,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -27,8 +27,8 @@ type Repository struct {
alarmMap map[string]*Alarm
stationMap map[string]*Station
mkxMap map[string]*Mkx
linkMap map[string]*Link
keyMap map[string]*Key
linkMap map[string]*Link
}
func newRepository(id string, version string) *Repository {
@ -52,6 +52,7 @@ func newRepository(id string, version string) *Repository {
alarmMap: make(map[string]*Alarm),
stationMap: make(map[string]*Station),
mkxMap: make(map[string]*Mkx),
keyMap: make(map[string]*Key),
}
}
@ -170,6 +171,14 @@ func (repo *Repository) StationList() []*Station {
return list
}
func (repo *Repository) KeyList() []*Key {
var list []*Key
for _, model := range repo.keyMap {
list = append(list, model)
}
return list
}
func (repo *Repository) FindModel(deviceId string, deviceType proto.DeviceType) (Identity, error) {
switch deviceType {
case proto.DeviceType_DeviceType_PhysicalSection:

View File

@ -118,6 +118,10 @@ func buildModels(source *proto.Repository, repository *Repository) error {
m := NewMkx(protoData.Id)
repository.mkxMap[m.Id()] = m
}
for _, protoData := range source.Keys {
m := NewKey(protoData.Id, protoData.Code, protoData.Gear)
repository.keyMap[m.Id()] = m
}
err := repository.generateCoordinateInfo(source.MainCoordinateSystem)
return err
}
@ -885,6 +889,8 @@ func bindIbpDevice(repo *Repository, comps []*proto.ElectronicComponent, refMap
refMap.AddRelay(repo.relayMap[data.Id])
case proto.DeviceType_DeviceType_Light:
refMap.AddLight(repo.lightMap[data.Id])
case proto.DeviceType_DeviceType_Key:
refMap.AddKey(repo.keyMap[data.Id])
default:
slog.Warn("IBP未绑定【%s】类型设备", data.DeviceType.String())
}

View File

@ -37,21 +37,21 @@ func (ibp *IBPSys) Update(w ecs.World) {
// 人员防护继电器控制电路逻辑
func (ibp *IBPSys) spkControl(entry *ecs.Entry, spkState *component.SpkElectronic) {
spksxplaBtn := getBtnVal(spkState.SPKSXPLA_BTN)
spksxplaBtn := getIbpBtnVal(spkState.SPKSXPLA_BTN)
// spksx1j 通电状态
setRelayTdVal(spkState.SPKSX1J, spksxplaBtn || getBtnVal(spkState.SPKSX1J_KEY))
setRelayTdVal(spkState.SPKSX1J, spksxplaBtn || getIbpKeyVal(spkState.SPKSX1J_KEY))
// spksx3j 通电状态
setRelayTdVal(spkState.SPKSX3J, spksxplaBtn || getBtnVal(spkState.SPKSX3J_KEY))
spkssplaBtn := getBtnVal(spkState.SPKSSPLA_BTN)
setRelayTdVal(spkState.SPKSX3J, spksxplaBtn || getIbpKeyVal(spkState.SPKSX3J_KEY))
spkssplaBtn := getIbpBtnVal(spkState.SPKSSPLA_BTN)
// spkss2j 通电状态
setRelayTdVal(spkState.SPKSS2J, spkssplaBtn || getBtnVal(spkState.SPKSS2J_KEY))
setRelayTdVal(spkState.SPKSS2J, spkssplaBtn || getIbpKeyVal(spkState.SPKSS2J_KEY))
// spkss4j 通电状态
setRelayTdVal(spkState.SPKSS4J, spkssplaBtn || getBtnVal(spkState.SPKSS4J_KEY))
setRelayTdVal(spkState.SPKSS4J, spkssplaBtn || getIbpKeyVal(spkState.SPKSS4J_KEY))
}
// 人员防护表示状态电路逻辑
func (ibp *IBPSys) spksState(entry *ecs.Entry, spkState *component.SpkElectronic) {
sda := getBtnVal(spkState.SDA)
sda := getIbpBtnVal(spkState.SDA)
// SPKSXPLAJ
if spkState.SPKSXPLA_BTN.HasComponent(component.SingleLightType) {
singleLight := component.SingleLightType.Get(spkState.SPKSXPLA_BTN)
@ -91,24 +91,24 @@ func (ibp *IBPSys) spkCollect(entry *ecs.Entry, spkState *component.SpkElectroni
// 紧急关闭控制电路
func (ibp *IBPSys) empControl(entry *ecs.Entry, s *component.EmpElectronic) {
xempfab := getBtnVal(s.XEMPFA_BTN)
xempfab := getIbpBtnVal(s.XEMPFA_BTN)
xempj := component.RelayDriveType.Get(s.XEMPJ)
// xempfab接通或者按钮组接通并且xempj继电器吸起状态
xempj.Td = xempfab || (xempj.Xq && getBtnVal(s.EMP1_BTN) && getBtnVal(s.EMP3_BTN) && getBtnVal(s.EMP5_BTN) && getBtnVal(s.EMPX_BTN))
sempfab := getBtnVal(s.SEMPFA_BTN)
xempj.Td = xempfab || (xempj.Xq && getIbpBtnVal(s.EMP1_BTN) && getIbpBtnVal(s.EMP3_BTN) && getIbpBtnVal(s.EMP5_BTN) && getIbpBtnVal(s.EMPX_BTN))
sempfab := getIbpBtnVal(s.SEMPFA_BTN)
sempj := component.RelayDriveType.Get(s.SEMPJ)
// sempfab接通或者按钮组接通并且sempj继电器吸起状态
sempj.Td = sempfab || (sempj.Xq && getBtnVal(s.EMP2_BTN) && getBtnVal(s.EMP4_BTN) && getBtnVal(s.EMP6_BTN) && getBtnVal(s.EMPS_BTN))
sempj.Td = sempfab || (sempj.Xq && getIbpBtnVal(s.EMP2_BTN) && getIbpBtnVal(s.EMP4_BTN) && getIbpBtnVal(s.EMP6_BTN) && getIbpBtnVal(s.EMPS_BTN))
}
// 紧急关闭表示电路
func (ibp *IBPSys) empState(entry *ecs.Entry, s *component.EmpElectronic) {
sda := getBtnVal(s.SDA)
sda := getIbpBtnVal(s.SDA)
xempj := component.RelayDriveType.Get(s.XEMPJ)
setLightTdVal(s.XEMPD, sda || !xempj.Xq)
sempj := component.RelayDriveType.Get(s.SEMPJ)
setLightTdVal(s.SEMPD, sda || !sempj.Xq)
qba := getBtnVal(s.QBA)
qba := getIbpBtnVal(s.QBA)
if qba {
setAlarmTdVal(s.Alarm, xempj.Xq && sempj.Xq)
} else {
@ -124,11 +124,17 @@ func (ibp *IBPSys) empCollect(entry *ecs.Entry, s *component.EmpElectronic) {
}
// 获取按钮状态
func getBtnVal(entry *ecs.Entry) bool {
func getIbpBtnVal(entry *ecs.Entry) bool {
btn := component.BitStateType.Get(entry)
return btn.Val
}
// 获取按钮状态
func getIbpKeyVal(entry *ecs.Entry) bool {
btn := component.GearStateType.Get(entry)
return btn.Val == 1
}
// 设置继电器通电状态
func setRelayTdVal(entry *ecs.Entry, val bool) {
relay := component.RelayDriveType.Get(entry)