From ba019810d642516892fe59d9a0a12ec6215adbb4 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Fri, 13 Oct 2023 17:44:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/simulation.go | 5 +---- .../wayside/memory/wayside_memory_signal.go | 18 +++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/api/simulation.go b/api/simulation.go index 542f042..0b9dc12 100644 --- a/api/simulation.go +++ b/api/simulation.go @@ -271,10 +271,7 @@ func signalOperation(c *gin.Context) { } simulation := checkDeviceDataAndReturn(req.SimulationId) slog.Info("传入状态参数", req) - memory.ChangeSignalState(simulation, &state.SignalState{ - Id: req.DeviceId, - Aspect: req.Aspect, - }, req.MapId) + memory.ChangeSignalState(simulation, req.MapId, req.DeviceId, req.Aspect) c.JSON(http.StatusOK, "ok") } diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_signal.go b/ats/verify/simulation/wayside/memory/wayside_memory_signal.go index 1727cc9..04ef3c6 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_signal.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_signal.go @@ -11,8 +11,8 @@ import ( "joylink.club/rtsssimulation/repository/model/proto" ) -func ChangeSignalState(simulation *VerifySimulation, status *state.SignalState, mapId int32) { - signalUid := QueryUidByMidAndComId(mapId, status.Id, &graphicData.Signal{}) +func ChangeSignalState(simulation *VerifySimulation, mapId int32, signalDeviceId string, toAspect state.Signal_Aspect) { + signalUid := QueryUidByMidAndComId(mapId, signalDeviceId, &graphicData.Signal{}) signalModel, err := simulation.Repo.FindModel(signalUid, proto.DeviceType_DeviceType_Signal) if err != nil { panic(fmt.Sprintf("信号机[%s]模型不存在", signalUid)) @@ -20,19 +20,19 @@ func ChangeSignalState(simulation *VerifySimulation, status *state.SignalState, signalGroupCode := signalModel.(*repository.Signal).Code() switch signalGroupCode { case consts.SIGNAL_2XH1: - changeSignal2XH1State(simulation.World, signalUid, status.GetAspect()) + changeSignal2XH1State(simulation.World, signalUid, toAspect) case consts.SIGNAL_3XH1: - changeSignal3XH1State(simulation.World, signalUid, status.GetAspect()) + changeSignal3XH1State(simulation.World, signalUid, toAspect) case consts.SIGNAL_3XH2: - changeSignal3XH2State(simulation.World, signalUid, status.GetAspect()) + changeSignal3XH2State(simulation.World, signalUid, toAspect) case consts.SIGNAL_3XH3: - changeSignal3XH3State(simulation.World, signalUid, status.GetAspect()) + changeSignal3XH3State(simulation.World, signalUid, toAspect) case consts.SIGNAL_3XH4: - changeSignal3XH4State(simulation.World, signalUid, status.GetAspect()) + changeSignal3XH4State(simulation.World, signalUid, toAspect) case consts.SIGNAL_DCXH: - changeSignalDCXHState(simulation.World, signalUid, status.GetAspect()) + changeSignalDCXHState(simulation.World, signalUid, toAspect) case consts.SIGNAL_JCKXH: - changeSignalJCKXHState(simulation.World, signalUid, status.GetAspect()) + changeSignalJCKXHState(simulation.World, signalUid, toAspect) default: panic(fmt.Sprintf("操作[%s]的信号机,无法识别组合类型[%s]", signalUid, signalGroupCode)) } From f4617f8248be1af7bc6c1bf644c1f8767a8a80d4 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Fri, 13 Oct 2023 17:50:36 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtss_simulation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtss_simulation b/rtss_simulation index f9d845a..e0385a4 160000 --- a/rtss_simulation +++ b/rtss_simulation @@ -1 +1 @@ -Subproject commit f9d845a0cf0bb6375eaa93c2011b46b63c5a0e9f +Subproject commit e0385a482d539bb70d24e36280a97470fe80a29c From 1b7d2d882b541916bb39bcd23093b0aedf23c60b Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 13 Oct 2023 17:57:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E3=80=90IBP=20UID=E7=94=9F=E6=88=90?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wayside/memory/wayside_memory_map_init.go | 50 ++- dto/request_proto/request.pb.go | 308 ++++++++++++++++++ 2 files changed, 352 insertions(+), 6 deletions(-) create mode 100644 dto/request_proto/request.pb.go diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go b/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go index 3902236..463ea42 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go @@ -176,13 +176,46 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *stationUidStructure { // 处理IBP盘信息 func initIBPUid(gus *stationUidStructure, city, lineId string, station *graphicData.Station, data *graphicData.IBPGraphicStorage) { - /*for _, d := range data.IbpButtons { - + // 设备所属组合 + refMap := make(map[string]string) + for _, r := range data.IbpRelatedDevices { + for _, c := range r.Combinationtypes { + for _, i := range c.RefDevices { + refMap[i] = c.Code + } + } + } + getCode := func(id, code string) string { + p := refMap[id] + if p == "" { + return code + } + return p + "_" + code + } + for _, d := range data.IbpButtons { // ibp按钮 + gus.IBPIds[d.Common.Id] = &elementIdStructure{ + CommonId: d.Common.Id, + Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), + } + } + for _, d := range data.IbpKeys { // ibp钥匙 + gus.IBPIds[d.Common.Id] = &elementIdStructure{ + CommonId: d.Common.Id, + Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), + } + } + for _, d := range data.IbpAlarms { // ibp报警器 + gus.IBPIds[d.Common.Id] = &elementIdStructure{ + CommonId: d.Common.Id, + Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), + } + } + for _, d := range data.IbpLights { // ibp指示灯 + gus.IBPIds[d.Common.Id] = &elementIdStructure{ + CommonId: d.Common.Id, + Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), + } } - - for _, d := range data.IbpAlarms { - - }*/ } // 初始化继电器柜 UID @@ -303,6 +336,11 @@ func getUidMapByType(uidData any, m interface{}) map[string]*elementIdStructure return (uidData.(*relayUidStructure)).RelayCabinetIds case *graphicData.Relay: return (uidData.(*relayUidStructure)).RelayIds + case *graphicData.EsbButton: + return (uidData.(*stationUidStructure)).ButtonIds + // Ibp相关 + case *graphicData.IBPButton, *graphicData.IbpAlarm, *graphicData.IbpKey, *graphicData.IbpLight: + return (uidData.(*stationUidStructure)).IBPIds default: panic(&dto.ErrorDto{Code: dto.ArgumentParseError, Message: "类型未映射字段"}) } diff --git a/dto/request_proto/request.pb.go b/dto/request_proto/request.pb.go new file mode 100644 index 0000000..a82a603 --- /dev/null +++ b/dto/request_proto/request.pb.go @@ -0,0 +1,308 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v4.23.1 +// source: request.proto + +package request_proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// 道岔操作 +type Turnout_Operation int32 + +const ( + Turnout_Undefined Turnout_Operation = 0 // 未定义 + Turnout_DC Turnout_Operation = 1 // 定操 + Turnout_CancelDC Turnout_Operation = 2 // 取消定操 + Turnout_FC Turnout_Operation = 3 // 反操 + Turnout_CancelFC Turnout_Operation = 4 // 取消反操 + Turnout_SetSB Turnout_Operation = 5 // 设置失表故障 + Turnout_CancelSB Turnout_Operation = 6 // 取消失表故障 + Turnout_SetJC Turnout_Operation = 7 // 设置挤岔故障 + Turnout_CancelJC Turnout_Operation = 8 // 取消挤岔故障 +) + +// Enum value maps for Turnout_Operation. +var ( + Turnout_Operation_name = map[int32]string{ + 0: "Undefined", + 1: "DC", + 2: "CancelDC", + 3: "FC", + 4: "CancelFC", + 5: "SetSB", + 6: "CancelSB", + 7: "SetJC", + 8: "CancelJC", + } + Turnout_Operation_value = map[string]int32{ + "Undefined": 0, + "DC": 1, + "CancelDC": 2, + "FC": 3, + "CancelFC": 4, + "SetSB": 5, + "CancelSB": 6, + "SetJC": 7, + "CancelJC": 8, + } +) + +func (x Turnout_Operation) Enum() *Turnout_Operation { + p := new(Turnout_Operation) + *p = x + return p +} + +func (x Turnout_Operation) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Turnout_Operation) Descriptor() protoreflect.EnumDescriptor { + return file_request_proto_enumTypes[0].Descriptor() +} + +func (Turnout_Operation) Type() protoreflect.EnumType { + return &file_request_proto_enumTypes[0] +} + +func (x Turnout_Operation) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Turnout_Operation.Descriptor instead. +func (Turnout_Operation) EnumDescriptor() ([]byte, []int) { + return file_request_proto_rawDescGZIP(), []int{0, 0} +} + +// 道岔 +type Turnout struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *Turnout) Reset() { + *x = Turnout{} + if protoimpl.UnsafeEnabled { + mi := &file_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Turnout) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Turnout) ProtoMessage() {} + +func (x *Turnout) ProtoReflect() protoreflect.Message { + mi := &file_request_proto_msgTypes[0] + 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 Turnout.ProtoReflect.Descriptor instead. +func (*Turnout) Descriptor() ([]byte, []int) { + return file_request_proto_rawDescGZIP(), []int{0} +} + +// 道岔操作请求 +type TurnoutOperationReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SimulationId string `protobuf:"bytes,1,opt,name=simulationId,proto3" json:"simulationId,omitempty"` // 仿真id + MapId int32 `protobuf:"varint,2,opt,name=mapId,proto3" json:"mapId,omitempty"` // 图id + DeviceId string `protobuf:"bytes,3,opt,name=deviceId,proto3" json:"deviceId,omitempty"` // 设备id + Operation Turnout_Operation `protobuf:"varint,4,opt,name=operation,proto3,enum=request.Turnout_Operation" json:"operation,omitempty"` // 道岔操作 +} + +func (x *TurnoutOperationReq) Reset() { + *x = TurnoutOperationReq{} + if protoimpl.UnsafeEnabled { + mi := &file_request_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TurnoutOperationReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TurnoutOperationReq) ProtoMessage() {} + +func (x *TurnoutOperationReq) ProtoReflect() protoreflect.Message { + mi := &file_request_proto_msgTypes[1] + 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 TurnoutOperationReq.ProtoReflect.Descriptor instead. +func (*TurnoutOperationReq) Descriptor() ([]byte, []int) { + return file_request_proto_rawDescGZIP(), []int{1} +} + +func (x *TurnoutOperationReq) GetSimulationId() string { + if x != nil { + return x.SimulationId + } + return "" +} + +func (x *TurnoutOperationReq) GetMapId() int32 { + if x != nil { + return x.MapId + } + return 0 +} + +func (x *TurnoutOperationReq) GetDeviceId() string { + if x != nil { + return x.DeviceId + } + return "" +} + +func (x *TurnoutOperationReq) GetOperation() Turnout_Operation { + if x != nil { + return x.Operation + } + return Turnout_Undefined +} + +var File_request_proto protoreflect.FileDescriptor + +var file_request_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x83, 0x01, 0x0a, 0x07, 0x54, 0x75, 0x72, + 0x6e, 0x6f, 0x75, 0x74, 0x22, 0x78, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, + 0x12, 0x06, 0x0a, 0x02, 0x44, 0x43, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, + 0x65, 0x6c, 0x44, 0x43, 0x10, 0x02, 0x12, 0x06, 0x0a, 0x02, 0x46, 0x43, 0x10, 0x03, 0x12, 0x0c, + 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x46, 0x43, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, + 0x53, 0x65, 0x74, 0x53, 0x42, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, + 0x6c, 0x53, 0x42, 0x10, 0x06, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x65, 0x74, 0x4a, 0x43, 0x10, 0x07, + 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x4a, 0x43, 0x10, 0x08, 0x22, 0xa5, + 0x01, 0x0a, 0x13, 0x54, 0x75, 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x69, 0x6d, 0x75, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, + 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, + 0x70, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d, 0x61, 0x70, 0x49, 0x64, + 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x38, 0x0a, 0x09, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1a, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x75, 0x72, 0x6e, 0x6f, 0x75, + 0x74, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x64, 0x74, 0x6f, 0x2f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_request_proto_rawDescOnce sync.Once + file_request_proto_rawDescData = file_request_proto_rawDesc +) + +func file_request_proto_rawDescGZIP() []byte { + file_request_proto_rawDescOnce.Do(func() { + file_request_proto_rawDescData = protoimpl.X.CompressGZIP(file_request_proto_rawDescData) + }) + return file_request_proto_rawDescData +} + +var file_request_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_request_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_request_proto_goTypes = []interface{}{ + (Turnout_Operation)(0), // 0: request.Turnout.Operation + (*Turnout)(nil), // 1: request.Turnout + (*TurnoutOperationReq)(nil), // 2: request.TurnoutOperationReq +} +var file_request_proto_depIdxs = []int32{ + 0, // 0: request.TurnoutOperationReq.operation:type_name -> request.Turnout.Operation + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_request_proto_init() } +func file_request_proto_init() { + if File_request_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_request_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Turnout); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_request_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TurnoutOperationReq); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_request_proto_rawDesc, + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_request_proto_goTypes, + DependencyIndexes: file_request_proto_depIdxs, + EnumInfos: file_request_proto_enumTypes, + MessageInfos: file_request_proto_msgTypes, + }.Build() + File_request_proto = out.File + file_request_proto_rawDesc = nil + file_request_proto_goTypes = nil + file_request_proto_depIdxs = nil +} From 7890fbfa06979377eb189f880c0f1c177d133504 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 13 Oct 2023 18:20:16 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BF=A1=E5=8F=B7?= =?UTF-8?q?=E6=9C=BA=E4=B8=AD=E9=87=8D=E5=A4=8D=E5=AE=9A=E4=B9=89=E7=9A=84?= =?UTF-8?q?Code=E6=96=B9=E6=B3=95=EF=BC=9B=E6=8F=90=E4=BA=A4=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E9=97=A8=E5=92=8C=E9=97=A8=E6=8E=A7=E7=AE=B1=E7=9A=84?= =?UTF-8?q?ecs=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 2 +- rtss_simulation | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bj-rtss-message b/bj-rtss-message index 7a24c7a..c18ac28 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit 7a24c7aae20f83fa2bba4639066dff9b267f6d38 +Subproject commit c18ac281a6360f6ceceb1df93c86dc888879fe46 diff --git a/rtss_simulation b/rtss_simulation index f9d845a..1babd47 160000 --- a/rtss_simulation +++ b/rtss_simulation @@ -1 +1 @@ -Subproject commit f9d845a0cf0bb6375eaa93c2011b46b63c5a0e9f +Subproject commit 1babd47d2877b3d2485432c78a92d749290e86dd