【初始化IBP盘实例】
This commit is contained in:
parent
dbb5eaa417
commit
abeeb595dc
@ -21,12 +21,12 @@ var (
|
||||
)
|
||||
|
||||
// 蜂鸣器驱动
|
||||
type FMQDrive struct {
|
||||
type AlarmDrive struct {
|
||||
Td bool
|
||||
}
|
||||
|
||||
// 蜂鸣器驱动组件
|
||||
var FMQDriveType = ecs.NewComponentType[FMQDrive]()
|
||||
var AlarmDriveType = ecs.NewComponentType[AlarmDrive]()
|
||||
|
||||
// SPK继电器控制电路
|
||||
type SpkElectronic struct {
|
||||
@ -89,7 +89,7 @@ type EmpElectronic struct {
|
||||
SEMPD *ecs.Entry
|
||||
SDA *ecs.Entry // 按钮
|
||||
QBA *ecs.Entry // 非自复位按钮
|
||||
FMQ *ecs.Entry // 蜂鸣器
|
||||
Alarm *ecs.Entry // 蜂鸣器
|
||||
}
|
||||
|
||||
var EmpElectronicType = ecs.NewComponentType[EmpElectronic]()
|
||||
|
158
entity/ibp.go
158
entity/ibp.go
@ -10,10 +10,10 @@ import (
|
||||
)
|
||||
|
||||
// 创建IBP实体
|
||||
func NewIBPEntity(w ecs.World, entityMap map[string]*ecs.Entry) {
|
||||
func NewIBPEntity(w ecs.World, ibp *repository.IBP, entityMap map[string]*ecs.Entry) {
|
||||
entry := w.Entry(w.Create(component.IBP))
|
||||
loadSPKEntity(w, entry, entityMap)
|
||||
loadEMPEntity(w, entry, entityMap)
|
||||
loadSPKEntity(w, entry, ibp.Spk, entityMap)
|
||||
loadEMPEntity(w, entry, ibp.Emp, entityMap)
|
||||
}
|
||||
|
||||
// 创建按钮实体
|
||||
@ -36,41 +36,64 @@ func NewButtonEntity(w ecs.World, data *repository.Button, entityMap map[string]
|
||||
default:
|
||||
btnType = component.UnknowBtn
|
||||
}
|
||||
entry = w.Entry(w.Create(btnType, component.BitStateType))
|
||||
entry = w.Entry(w.Create(btnType, component.UidType, component.BitStateType))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
entityMap[uid] = entry
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
// 创建蜂鸣器实体
|
||||
func NewFMQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||
func NewAlarmEntity(w ecs.World, alarm *repository.Alarm, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||
uid := alarm.Id()
|
||||
entry, ok := entityMap[uid]
|
||||
if !ok {
|
||||
entry = w.Entry(w.Create(component.FMQDriveType, component.BitStateType))
|
||||
entry = w.Entry(w.Create(component.UidType, component.AlarmDriveType, component.BitStateType))
|
||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||
entityMap[uid] = entry
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
// 构建人员防护实体
|
||||
func loadSPKEntity(w ecs.World, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
|
||||
func loadSPKEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap, entityMap map[string]*ecs.Entry) error {
|
||||
spk := &component.SpkElectronic{}
|
||||
// 按钮组
|
||||
spk.SPKSXPLA_BTN = NewButtonEntity(w, nil, entityMap)
|
||||
spk.SPKSSPLA_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)
|
||||
for _, btn := range spkData.Buttons() {
|
||||
switch btn.GetCode() {
|
||||
case "SPKSXPLA":
|
||||
spk.SPKSXPLA_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "SPKSSPLA":
|
||||
spk.SPKSSPLA_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "SPKS1":
|
||||
spk.SPKSX1J_KEY = NewButtonEntity(w, btn, entityMap)
|
||||
case "SPKS3":
|
||||
spk.SPKSX3J_KEY = NewButtonEntity(w, btn, entityMap)
|
||||
case "SPKS2":
|
||||
spk.SPKSS2J_KEY = NewButtonEntity(w, btn, entityMap)
|
||||
case "SPKS4":
|
||||
spk.SPKSS4J_KEY = NewButtonEntity(w, btn, entityMap)
|
||||
case "SDA":
|
||||
spk.SDA = NewButtonEntity(w, btn, 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)
|
||||
for _, relay := range spkData.Relays() {
|
||||
switch relay.Code() {
|
||||
case "SPKSX1J":
|
||||
spk.SPKSX1J = NewRelayEntity(w, relay, entityMap)
|
||||
case "SPKSX3J":
|
||||
spk.SPKSX3J = NewRelayEntity(w, relay, entityMap)
|
||||
case "SPKSS2J":
|
||||
spk.SPKSS2J = NewRelayEntity(w, relay, entityMap)
|
||||
case "SPKSS4J":
|
||||
spk.SPKSS4J = NewRelayEntity(w, relay, entityMap)
|
||||
case "SPKSXPLAJ":
|
||||
spk.SPKSXPLAJ = NewRelayEntity(w, relay, entityMap)
|
||||
case "SPKSSPLAJ":
|
||||
spk.SPKSSPLAJ = NewRelayEntity(w, relay, entityMap)
|
||||
}
|
||||
}
|
||||
// 灯组
|
||||
spk.SPKSX1D = NewLightHEntity(w)
|
||||
spk.SPKSX3D = NewLightHEntity(w)
|
||||
@ -78,36 +101,97 @@ func loadSPKEntity(w ecs.World, entry *ecs.Entry, entityMap map[string]*ecs.Entr
|
||||
spk.SPKSS4D = NewLightHEntity(w)
|
||||
spk.SPKSXPLAD = NewLightHEntity(w)
|
||||
spk.SPKSSPLAD = NewLightHEntity(w)
|
||||
// 设置默认值
|
||||
setSpkDefault(spk)
|
||||
// 绑定组件
|
||||
entry.AddComponent(component.SpkElectronicType, unsafe.Pointer(spk))
|
||||
entry.AddComponent(component.SpkCollectStateType, unsafe.Pointer(&component.SpkCollectState{}))
|
||||
return nil
|
||||
}
|
||||
|
||||
// 人员防护设置默认值
|
||||
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)
|
||||
}
|
||||
|
||||
// 构建紧急关闭实体
|
||||
func loadEMPEntity(w ecs.World, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
|
||||
func loadEMPEntity(w ecs.World, entry *ecs.Entry, spkData *repository.IBPRefMap, 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)
|
||||
for _, btn := range spkData.Buttons() {
|
||||
switch btn.GetCode() {
|
||||
case "EMP1":
|
||||
emp.EMP1_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "EMP3":
|
||||
emp.EMP3_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "EMP5":
|
||||
emp.EMP5_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "EMPX":
|
||||
emp.EMPX_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "EMP2":
|
||||
emp.EMP2_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "EMP4":
|
||||
emp.EMP4_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "EMP6":
|
||||
emp.EMP6_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "EMPS":
|
||||
emp.EMPS_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "XEMPFA":
|
||||
emp.XEMPFA_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "SEMPFA":
|
||||
emp.SEMPFA_BTN = NewButtonEntity(w, btn, entityMap)
|
||||
case "QBA":
|
||||
emp.QBA = NewButtonEntity(w, btn, entityMap)
|
||||
case "SDA":
|
||||
emp.SDA = NewButtonEntity(w, btn, entityMap)
|
||||
}
|
||||
}
|
||||
// 继电器组
|
||||
emp.XEMPJ = NewRelayEntity(w, nil, entityMap)
|
||||
emp.SEMPJ = NewRelayEntity(w, nil, entityMap)
|
||||
for _, relay := range spkData.Relays() {
|
||||
switch relay.Code() {
|
||||
case "XEMPJ":
|
||||
emp.XEMPJ = NewRelayEntity(w, relay, entityMap)
|
||||
case "SEMPJ":
|
||||
emp.SEMPJ = NewRelayEntity(w, relay, entityMap)
|
||||
}
|
||||
}
|
||||
// 灯组
|
||||
emp.XEMPD = NewLightHEntity(w)
|
||||
emp.SEMPD = NewLightHEntity(w)
|
||||
// 蜂鸣器
|
||||
emp.FMQ = NewFMQEntity(w, "", entityMap)
|
||||
for _, alarm := range spkData.Alarms() {
|
||||
switch alarm.Code() {
|
||||
case "蜂鸣器":
|
||||
emp.Alarm = NewAlarmEntity(w, alarm, entityMap)
|
||||
}
|
||||
}
|
||||
// 设置默认值
|
||||
setEmpDefault(emp)
|
||||
entry.AddComponent(component.EmpElectronicType, unsafe.Pointer(emp))
|
||||
entry.AddComponent(component.EmpCollectStateType, unsafe.Pointer(&component.EmpCollectState{}))
|
||||
return nil
|
||||
}
|
||||
|
||||
// 紧急关闭设置默认值
|
||||
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)
|
||||
}
|
||||
|
||||
// 获取按钮状态
|
||||
func setBtnVal(entry *ecs.Entry, val bool) {
|
||||
if entry == nil {
|
||||
return
|
||||
}
|
||||
btn := component.BitStateType.Get(entry)
|
||||
btn.Val = val
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ enum DeviceType {
|
||||
DeviceType_PhaseFailureProtector = 11;
|
||||
DeviceType_Button = 12;
|
||||
DeviceType_Light = 13;
|
||||
DeviceType_FMQ = 14;
|
||||
DeviceType_Alarm = 14;
|
||||
}
|
||||
|
||||
enum Port {
|
||||
@ -183,5 +183,6 @@ message Button {
|
||||
Key_Knob = 5;
|
||||
}
|
||||
string id = 1;
|
||||
ButtonType buttonType = 2;
|
||||
string code = 2;
|
||||
ButtonType buttonType = 3;
|
||||
}
|
@ -4,13 +4,14 @@ import "joylink.club/rtsssimulation/repository/model/proto"
|
||||
|
||||
type Button struct {
|
||||
Identity
|
||||
|
||||
code string
|
||||
buttonType proto.Button_ButtonType
|
||||
}
|
||||
|
||||
func NewButton(id string, buttonType proto.Button_ButtonType) *Button {
|
||||
func NewButton(id string, code string, buttonType proto.Button_ButtonType) *Button {
|
||||
return &Button{
|
||||
Identity: identity{id, proto.DeviceType_DeviceType_Button},
|
||||
code: code,
|
||||
buttonType: buttonType,
|
||||
}
|
||||
}
|
||||
@ -18,3 +19,7 @@ func NewButton(id string, buttonType proto.Button_ButtonType) *Button {
|
||||
func (btn *Button) GetBtnType() proto.Button_ButtonType {
|
||||
return btn.buttonType
|
||||
}
|
||||
|
||||
func (btn *Button) GetCode() string {
|
||||
return btn.code
|
||||
}
|
||||
|
19
repository/fmq.go
Normal file
19
repository/fmq.go
Normal file
@ -0,0 +1,19 @@
|
||||
package repository
|
||||
|
||||
import "joylink.club/rtsssimulation/repository/model/proto"
|
||||
|
||||
type Alarm struct {
|
||||
Identity
|
||||
code string
|
||||
}
|
||||
|
||||
func NewAlarm(id string, code string) *Alarm {
|
||||
return &Alarm{
|
||||
Identity: identity{id, proto.DeviceType_DeviceType_Alarm},
|
||||
code: code,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Alarm) Code() string {
|
||||
return a.code
|
||||
}
|
63
repository/ibp.go
Normal file
63
repository/ibp.go
Normal file
@ -0,0 +1,63 @@
|
||||
package repository
|
||||
|
||||
type IBP struct {
|
||||
Spk *IBPRefMap
|
||||
Emp *IBPRefMap
|
||||
}
|
||||
|
||||
func NewIBP(id string) *IBP {
|
||||
return &IBP{
|
||||
Spk: &IBPRefMap{
|
||||
buttonMap: make(map[string]*Button),
|
||||
relayMap: make(map[string]*Relay),
|
||||
alarmMap: make(map[string]*Alarm),
|
||||
},
|
||||
Emp: &IBPRefMap{
|
||||
buttonMap: make(map[string]*Button),
|
||||
relayMap: make(map[string]*Relay),
|
||||
alarmMap: make(map[string]*Alarm),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type IBPRefMap struct {
|
||||
buttonMap map[string]*Button
|
||||
relayMap map[string]*Relay
|
||||
alarmMap map[string]*Alarm
|
||||
}
|
||||
|
||||
func (ibp *IBPRefMap) AddButton(btn *Button) {
|
||||
ibp.buttonMap[btn.Id()] = btn
|
||||
}
|
||||
|
||||
func (ibp *IBPRefMap) AddRelay(relay *Relay) {
|
||||
ibp.relayMap[relay.Id()] = relay
|
||||
}
|
||||
|
||||
func (ibp *IBPRefMap) AddAlarm(fmq *Alarm) {
|
||||
ibp.alarmMap[fmq.Id()] = fmq
|
||||
}
|
||||
|
||||
func (ibp *IBPRefMap) Buttons() []*Button {
|
||||
var buttons []*Button
|
||||
for _, b := range ibp.buttonMap {
|
||||
buttons = append(buttons, b)
|
||||
}
|
||||
return buttons
|
||||
}
|
||||
|
||||
func (ibp *IBPRefMap) Relays() []*Relay {
|
||||
var relays []*Relay
|
||||
for _, b := range ibp.relayMap {
|
||||
relays = append(relays, b)
|
||||
}
|
||||
return relays
|
||||
}
|
||||
|
||||
func (ibp *IBPRefMap) Alarms() []*Alarm {
|
||||
var alarms []*Alarm
|
||||
for _, b := range ibp.alarmMap {
|
||||
alarms = append(alarms, b)
|
||||
}
|
||||
return alarms
|
||||
}
|
@ -37,7 +37,7 @@ const (
|
||||
DeviceType_DeviceType_PhaseFailureProtector DeviceType = 11
|
||||
DeviceType_DeviceType_Button DeviceType = 12
|
||||
DeviceType_DeviceType_Light DeviceType = 13
|
||||
DeviceType_DeviceType_FMQ DeviceType = 14
|
||||
DeviceType_DeviceType_Alarm DeviceType = 14
|
||||
)
|
||||
|
||||
// Enum value maps for DeviceType.
|
||||
@ -57,7 +57,7 @@ var (
|
||||
11: "DeviceType_PhaseFailureProtector",
|
||||
12: "DeviceType_Button",
|
||||
13: "DeviceType_Light",
|
||||
14: "DeviceType_FMQ",
|
||||
14: "DeviceType_Alarm",
|
||||
}
|
||||
DeviceType_value = map[string]int32{
|
||||
"DeviceType_Unknown": 0,
|
||||
@ -74,7 +74,7 @@ var (
|
||||
"DeviceType_PhaseFailureProtector": 11,
|
||||
"DeviceType_Button": 12,
|
||||
"DeviceType_Light": 13,
|
||||
"DeviceType_FMQ": 14,
|
||||
"DeviceType_Alarm": 14,
|
||||
}
|
||||
)
|
||||
|
||||
@ -1459,14 +1459,15 @@ func (x *ElectronicComponentGroup) GetComponentIds() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 按钮
|
||||
// 开关、按钮、旋钮
|
||||
type Button struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
ButtonType Button_ButtonType `protobuf:"varint,2,opt,name=buttonType,proto3,enum=model.Button_ButtonType" json:"buttonType,omitempty"`
|
||||
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
|
||||
ButtonType Button_ButtonType `protobuf:"varint,3,opt,name=buttonType,proto3,enum=model.Button_ButtonType" json:"buttonType,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Button) Reset() {
|
||||
@ -1508,6 +1509,13 @@ func (x *Button) GetId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Button) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Button) GetButtonType() Button_ButtonType {
|
||||
if x != nil {
|
||||
return x.ButtonType
|
||||
@ -1694,55 +1702,56 @@ 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, 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, 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, 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,
|
||||
0x64, 0x73, 0x22, 0xd3, 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, 0x12, 0x0a,
|
||||
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x12, 0x38, 0x0a, 0x0a, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18,
|
||||
0x03, 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, 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, 0x12, 0x0c, 0x0a, 0x08, 0x4b, 0x65,
|
||||
0x79, 0x5f, 0x4b, 0x6e, 0x6f, 0x62, 0x10, 0x05, 0x2a, 0x90, 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, 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 (
|
||||
|
@ -87,7 +87,7 @@ func buildModels(source *proto.Repository, repository *Repository) {
|
||||
repository.phaseFailureProtectorMap[m.Id()] = m
|
||||
}
|
||||
for _, protoData := range source.Buttons {
|
||||
m := NewButton(protoData.Id, protoData.ButtonType)
|
||||
m := NewButton(protoData.Id, protoData.Code, protoData.ButtonType)
|
||||
repository.buttonMap[m.Id()] = m
|
||||
}
|
||||
}
|
||||
|
@ -104,9 +104,9 @@ func (ibp *IBPSys) empState(entry *ecs.Entry, s *component.EmpElectronic) {
|
||||
setLightTdVal(s.SEMPD, sda || !sempj.Xq)
|
||||
qba := getBtnVal(s.QBA)
|
||||
if qba {
|
||||
setFMQTdVal(s.FMQ, xempj.Xq && sempj.Xq)
|
||||
setAlarmTdVal(s.Alarm, xempj.Xq && sempj.Xq)
|
||||
} else {
|
||||
setFMQTdVal(s.FMQ, (!xempj.Xq) || (!sempj.Xq))
|
||||
setAlarmTdVal(s.Alarm, (!xempj.Xq) || (!sempj.Xq))
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ func setLightTdVal(entry *ecs.Entry, val bool) {
|
||||
}
|
||||
|
||||
// 设置蜂鸣器通电状态
|
||||
func setFMQTdVal(entry *ecs.Entry, val bool) {
|
||||
fmq := component.FMQDriveType.Get(entry)
|
||||
func setAlarmTdVal(entry *ecs.Entry, val bool) {
|
||||
fmq := component.AlarmDriveType.Get(entry)
|
||||
fmq.Td = val
|
||||
}
|
||||
|
26
sys/device_sys/alarm.go
Normal file
26
sys/device_sys/alarm.go
Normal file
@ -0,0 +1,26 @@
|
||||
package device_sys
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
)
|
||||
|
||||
// FMQSys 蜂鸣系统
|
||||
type AlarmSys struct {
|
||||
query *ecs.Query
|
||||
}
|
||||
|
||||
func NewAlarmSys() *AlarmSys {
|
||||
return &AlarmSys{query: ecs.NewQuery(filter.Contains(component.AlarmDriveType, component.BitStateType))}
|
||||
}
|
||||
|
||||
func (alarm *AlarmSys) Update(w ecs.World) {
|
||||
alarm.query.Each(w, func(entry *ecs.Entry) {
|
||||
drive := component.AlarmDriveType.Get(entry)
|
||||
state := component.BitStateType.Get(entry)
|
||||
if drive.Td != state.Val {
|
||||
state.Val = drive.Td
|
||||
}
|
||||
})
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package device_sys
|
||||
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
)
|
||||
|
||||
// FMQSys 蜂鸣系统
|
||||
type FMQSys struct {
|
||||
query *ecs.Query
|
||||
}
|
||||
|
||||
func NewFMQSys() *FMQSys {
|
||||
return &FMQSys{query: ecs.NewQuery(filter.Contains(component.FMQDriveType, component.BitStateType))}
|
||||
}
|
||||
|
||||
func (fmq *FMQSys) Update(w ecs.World) {
|
||||
fmq.query.Each(w, func(entry *ecs.Entry) {
|
||||
drive := component.FMQDriveType.Get(entry)
|
||||
state := component.BitStateType.Get(entry)
|
||||
if drive.Td != state.Val {
|
||||
state.Val = drive.Td
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user