区段操作调整

This commit is contained in:
walker 2024-01-22 15:56:40 +08:00
parent c8fb83952c
commit 71bda3db44
7 changed files with 352 additions and 125 deletions

View File

@ -372,15 +372,15 @@ func signalOperation(c *gin.Context) {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/axleSection/operation [post]
func axleSectionOperation(c *gin.Context) { //操作:设置故障占用、取消故障占用
req := &dto.AxleSectionOperationReqDto{}
req := &request_proto.SectionOperationReq{}
if err := c.ShouldBind(&req); err != nil {
panic(sys_error.New("输入参数格式错误", err))
}
simulation := checkDeviceDataAndReturn(req.SimulationId)
slog.Info("传入状态参数", req)
err := memory.ChangeAxleSectionState(simulation, req)
slog.Info("传入状态参数", "req", req)
err := memory.HandleSectionOperation(simulation, req)
if err != nil {
panic(sys_error.New("操作失败", err))
panic(sys_error.New("区段操作失败", err))
}
c.JSON(http.StatusOK, "ok")
}

@ -1 +1 @@
Subproject commit 3a30efc9fe949cd5ab9898073f00a093716f279e
Subproject commit bdd66d8625e76afb23f501de306224d35a8958d1

View File

@ -344,31 +344,26 @@ func (Signal_Force) EnumDescriptor() ([]byte, []int) {
type Section_Operation int32
const (
Section_SetDrst Section_Operation = 0 //设置计轴直接复位
Section_CancelDrst Section_Operation = 1 //取消计轴直接复位
Section_SetPdrst Section_Operation = 2 //设置计轴预复位
Section_CancelPdrst Section_Operation = 3 //取消计轴预复位
Section_Undefined Section_Operation = 0 // 未定义
Section_SetParams Section_Operation = 1 // 设置参数
// SetDrst = 0;//设置计轴直接复位
// CancelDrst = 1;//取消计轴直接复位
// SetPdrst = 2;//设置计轴预复位
// CancelPdrst = 3;//取消计轴预复位
Section_SetFaultOcc Section_Operation = 4 //设置故障占用
Section_CancelFaultOcc Section_Operation = 5 //取消故障占用
)
// Enum value maps for Section_Operation.
var (
Section_Operation_name = map[int32]string{
0: "SetDrst",
1: "CancelDrst",
2: "SetPdrst",
3: "CancelPdrst",
0: "Undefined",
1: "SetParams",
4: "SetFaultOcc",
5: "CancelFaultOcc",
}
Section_Operation_value = map[string]int32{
"SetDrst": 0,
"CancelDrst": 1,
"SetPdrst": 2,
"CancelPdrst": 3,
"Undefined": 0,
"SetParams": 1,
"SetFaultOcc": 4,
"CancelFaultOcc": 5,
}
)
@ -497,7 +492,7 @@ func (x Psd_Operation) Number() protoreflect.EnumNumber {
// Deprecated: Use Psd_Operation.Descriptor instead.
func (Psd_Operation) EnumDescriptor() ([]byte, []int) {
return file_request_proto_rawDescGZIP(), []int{9, 0}
return file_request_proto_rawDescGZIP(), []int{11, 0}
}
// 继电器
@ -990,6 +985,141 @@ func (*Section) Descriptor() ([]byte, []int) {
return file_request_proto_rawDescGZIP(), []int{8}
}
type SectionOperationReq 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 uint32 `protobuf:"varint,3,opt,name=deviceId,proto3" json:"deviceId,omitempty"` // 设备id
Operation Section_Operation `protobuf:"varint,4,opt,name=operation,proto3,enum=request.Section_Operation" json:"operation,omitempty"` // 区段操作
Param *SectionParam `protobuf:"bytes,5,opt,name=param,proto3" json:"param,omitempty"` // 区段参数,当operation为SetParams时有效
}
func (x *SectionOperationReq) Reset() {
*x = SectionOperationReq{}
if protoimpl.UnsafeEnabled {
mi := &file_request_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SectionOperationReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SectionOperationReq) ProtoMessage() {}
func (x *SectionOperationReq) ProtoReflect() protoreflect.Message {
mi := &file_request_proto_msgTypes[9]
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 SectionOperationReq.ProtoReflect.Descriptor instead.
func (*SectionOperationReq) Descriptor() ([]byte, []int) {
return file_request_proto_rawDescGZIP(), []int{9}
}
func (x *SectionOperationReq) GetSimulationId() string {
if x != nil {
return x.SimulationId
}
return ""
}
func (x *SectionOperationReq) GetMapId() int32 {
if x != nil {
return x.MapId
}
return 0
}
func (x *SectionOperationReq) GetDeviceId() uint32 {
if x != nil {
return x.DeviceId
}
return 0
}
func (x *SectionOperationReq) GetOperation() Section_Operation {
if x != nil {
return x.Operation
}
return Section_Undefined
}
func (x *SectionOperationReq) GetParam() *SectionParam {
if x != nil {
return x.Param
}
return nil
}
type SectionParam struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// bool faultOcc = 1; // 故障占用
MockDrst bool `protobuf:"varint,2,opt,name=mockDrst,proto3" json:"mockDrst,omitempty"` // 模拟CI计轴复位(临时)
MockPdrst bool `protobuf:"varint,3,opt,name=mockPdrst,proto3" json:"mockPdrst,omitempty"` // 模拟CI计轴预复位(临时)
}
func (x *SectionParam) Reset() {
*x = SectionParam{}
if protoimpl.UnsafeEnabled {
mi := &file_request_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SectionParam) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SectionParam) ProtoMessage() {}
func (x *SectionParam) ProtoReflect() protoreflect.Message {
mi := &file_request_proto_msgTypes[10]
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 SectionParam.ProtoReflect.Descriptor instead.
func (*SectionParam) Descriptor() ([]byte, []int) {
return file_request_proto_rawDescGZIP(), []int{10}
}
func (x *SectionParam) GetMockDrst() bool {
if x != nil {
return x.MockDrst
}
return false
}
func (x *SectionParam) GetMockPdrst() bool {
if x != nil {
return x.MockPdrst
}
return false
}
// 屏蔽门
type Psd struct {
state protoimpl.MessageState
@ -1000,7 +1130,7 @@ type Psd struct {
func (x *Psd) Reset() {
*x = Psd{}
if protoimpl.UnsafeEnabled {
mi := &file_request_proto_msgTypes[9]
mi := &file_request_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1013,7 +1143,7 @@ func (x *Psd) String() string {
func (*Psd) ProtoMessage() {}
func (x *Psd) ProtoReflect() protoreflect.Message {
mi := &file_request_proto_msgTypes[9]
mi := &file_request_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1026,7 +1156,7 @@ func (x *Psd) ProtoReflect() protoreflect.Message {
// Deprecated: Use Psd.ProtoReflect.Descriptor instead.
func (*Psd) Descriptor() ([]byte, []int) {
return file_request_proto_rawDescGZIP(), []int{9}
return file_request_proto_rawDescGZIP(), []int{11}
}
// 屏蔽门操作请求
@ -1046,7 +1176,7 @@ type PsdOperationReq struct {
func (x *PsdOperationReq) Reset() {
*x = PsdOperationReq{}
if protoimpl.UnsafeEnabled {
mi := &file_request_proto_msgTypes[10]
mi := &file_request_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1059,7 +1189,7 @@ func (x *PsdOperationReq) String() string {
func (*PsdOperationReq) ProtoMessage() {}
func (x *PsdOperationReq) ProtoReflect() protoreflect.Message {
mi := &file_request_proto_msgTypes[10]
mi := &file_request_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1072,7 +1202,7 @@ func (x *PsdOperationReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use PsdOperationReq.ProtoReflect.Descriptor instead.
func (*PsdOperationReq) Descriptor() ([]byte, []int) {
return file_request_proto_rawDescGZIP(), []int{10}
return file_request_proto_rawDescGZIP(), []int{12}
}
func (x *PsdOperationReq) GetSimulationId() string {
@ -1193,48 +1323,63 @@ var file_request_proto_rawDesc = []byte{
0x61, 0x6c, 0x2e, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x52, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x12,
0x2a, 0x0a, 0x06, 0x64, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32,
0x12, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c,
0x2e, 0x44, 0x53, 0x52, 0x06, 0x64, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x77, 0x0a, 0x07, 0x53,
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x6c, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x65, 0x74, 0x44, 0x72, 0x73, 0x74, 0x10, 0x00,
0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x44, 0x72, 0x73, 0x74, 0x10, 0x01,
0x12, 0x0c, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x50, 0x64, 0x72, 0x73, 0x74, 0x10, 0x02, 0x12, 0x0f,
0x0a, 0x0b, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x64, 0x72, 0x73, 0x74, 0x10, 0x03, 0x12,
0x0f, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4f, 0x63, 0x63, 0x10, 0x04,
0x12, 0x12, 0x0a, 0x0e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4f,
0x63, 0x63, 0x10, 0x05, 0x22, 0x87, 0x02, 0x0a, 0x03, 0x50, 0x73, 0x64, 0x22, 0xff, 0x01, 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, 0x4b, 0x6d, 0x10,
0x01, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x4b, 0x6d, 0x10, 0x02, 0x12,
0x06, 0x0a, 0x02, 0x47, 0x6d, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65,
0x6c, 0x47, 0x6d, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x4b, 0x6d,
0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x47, 0x6d, 0x10, 0x06, 0x12,
0x0f, 0x0a, 0x0b, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x10, 0x0a,
0x12, 0x11, 0x0a, 0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70, 0x65,
0x6e, 0x10, 0x0b, 0x12, 0x17, 0x0a, 0x13, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x73, 0x64,
0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70, 0x65, 0x6e, 0x10, 0x0c, 0x12, 0x12, 0x0a, 0x0e,
0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x0d,
0x12, 0x18, 0x0a, 0x14, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e,
0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x0e, 0x12, 0x08, 0x0a, 0x04, 0x51, 0x44,
0x54, 0x43, 0x10, 0x0f, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x51, 0x44,
0x54, 0x43, 0x10, 0x10, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x5a, 0x54, 0x43, 0x10, 0x11, 0x12, 0x0e,
0x0a, 0x0a, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x54, 0x5a, 0x54, 0x43, 0x10, 0x12, 0x22, 0xcf,
0x01, 0x0a, 0x0f, 0x50, 0x73, 0x64, 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, 0x0d, 0x52, 0x08,
0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x72, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x73, 0x64, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a,
0x0a, 0x08, 0x61, 0x73, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x05,
0x52, 0x08, 0x61, 0x73, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72,
0x6f, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x42, 0x30, 0x5a, 0x2e, 0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x63, 0x6c, 0x75, 0x62,
0x2f, 0x62, 0x6a, 0x2d, 0x72, 0x74, 0x73, 0x74, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
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,
0x2e, 0x44, 0x53, 0x52, 0x06, 0x64, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x45, 0x0a, 0x07, 0x53,
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 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, 0x0d, 0x0a, 0x09, 0x53, 0x65, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x10,
0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4f, 0x63, 0x63,
0x10, 0x04, 0x22, 0xd2, 0x01, 0x0a, 0x13, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 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, 0x0d, 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, 0x53, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x05, 0x70, 0x61,
0x72, 0x61, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x22, 0x48, 0x0a, 0x0c, 0x53, 0x65, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x6f, 0x63, 0x6b, 0x44,
0x72, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6d, 0x6f, 0x63, 0x6b, 0x44,
0x72, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x6f, 0x63, 0x6b, 0x50, 0x64, 0x72, 0x73, 0x74,
0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6d, 0x6f, 0x63, 0x6b, 0x50, 0x64, 0x72, 0x73,
0x74, 0x22, 0x87, 0x02, 0x0a, 0x03, 0x50, 0x73, 0x64, 0x22, 0xff, 0x01, 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, 0x4b, 0x6d, 0x10, 0x01, 0x12, 0x0c,
0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x4b, 0x6d, 0x10, 0x02, 0x12, 0x06, 0x0a, 0x02,
0x47, 0x6d, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x47, 0x6d,
0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x4b, 0x6d, 0x10, 0x05, 0x12,
0x0b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x47, 0x6d, 0x10, 0x06, 0x12, 0x0f, 0x0a, 0x0b,
0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x11, 0x0a,
0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70, 0x65, 0x6e, 0x10, 0x0b,
0x12, 0x17, 0x0a, 0x13, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e,
0x6e, 0x6f, 0x74, 0x4f, 0x70, 0x65, 0x6e, 0x10, 0x0c, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x73, 0x64,
0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x0d, 0x12, 0x18, 0x0a,
0x14, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74,
0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x0e, 0x12, 0x08, 0x0a, 0x04, 0x51, 0x44, 0x54, 0x43, 0x10,
0x0f, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x51, 0x44, 0x54, 0x43, 0x10,
0x10, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x5a, 0x54, 0x43, 0x10, 0x11, 0x12, 0x0e, 0x0a, 0x0a, 0x43,
0x61, 0x6e, 0x63, 0x65, 0x6c, 0x54, 0x5a, 0x54, 0x43, 0x10, 0x12, 0x22, 0xcf, 0x01, 0x0a, 0x0f,
0x50, 0x73, 0x64, 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, 0x0d, 0x52, 0x08, 0x64, 0x65, 0x76,
0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x2e, 0x50, 0x73, 0x64, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61,
0x73, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x05, 0x52, 0x08, 0x61,
0x73, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x42, 0x30, 0x5a,
0x2e, 0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x63, 0x6c, 0x75, 0x62, 0x2f, 0x62, 0x6a,
0x2d, 0x72, 0x74, 0x73, 0x74, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 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 (
@ -1250,7 +1395,7 @@ func file_request_proto_rawDescGZIP() []byte {
}
var file_request_proto_enumTypes = make([]protoimpl.EnumInfo, 8)
var file_request_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_request_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_request_proto_goTypes = []interface{}{
(Relay_Operation)(0), // 0: request.Relay.Operation
(Points_Operation)(0), // 1: request.Points.Operation
@ -1269,8 +1414,10 @@ var file_request_proto_goTypes = []interface{}{
(*SignalOperationReq)(nil), // 14: request.SignalOperationReq
(*SignalParam)(nil), // 15: request.SignalParam
(*Section)(nil), // 16: request.Section
(*Psd)(nil), // 17: request.Psd
(*PsdOperationReq)(nil), // 18: request.PsdOperationReq
(*SectionOperationReq)(nil), // 17: request.SectionOperationReq
(*SectionParam)(nil), // 18: request.SectionParam
(*Psd)(nil), // 19: request.Psd
(*PsdOperationReq)(nil), // 20: request.PsdOperationReq
}
var file_request_proto_depIdxs = []int32{
0, // 0: request.RelayOperationReq.operation:type_name -> request.Relay.Operation
@ -1281,12 +1428,14 @@ var file_request_proto_depIdxs = []int32{
15, // 5: request.SignalOperationReq.param:type_name -> request.SignalParam
5, // 6: request.SignalParam.force:type_name -> request.Signal.Force
4, // 7: request.SignalParam.dsList:type_name -> request.Signal.DS
7, // 8: request.PsdOperationReq.operation:type_name -> request.Psd.Operation
9, // [9:9] is the sub-list for method output_type
9, // [9:9] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
6, // 8: request.SectionOperationReq.operation:type_name -> request.Section.Operation
18, // 9: request.SectionOperationReq.param:type_name -> request.SectionParam
7, // 10: request.PsdOperationReq.operation:type_name -> request.Psd.Operation
11, // [11:11] is the sub-list for method output_type
11, // [11:11] is the sub-list for method input_type
11, // [11:11] is the sub-list for extension type_name
11, // [11:11] is the sub-list for extension extendee
0, // [0:11] is the sub-list for field type_name
}
func init() { file_request_proto_init() }
@ -1404,7 +1553,7 @@ func file_request_proto_init() {
}
}
file_request_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Psd); i {
switch v := v.(*SectionOperationReq); i {
case 0:
return &v.state
case 1:
@ -1416,6 +1565,30 @@ func file_request_proto_init() {
}
}
file_request_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SectionParam); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_request_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Psd); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_request_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PsdOperationReq); i {
case 0:
return &v.state
@ -1434,7 +1607,7 @@ func file_request_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_request_proto_rawDesc,
NumEnums: 8,
NumMessages: 11,
NumMessages: 13,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -2,6 +2,7 @@ package semi_physical_train
import (
"fmt"
"log/slog"
"sync"
"joylink.club/bj-rtsts-server/config"
@ -41,6 +42,7 @@ type semiPhysicalTrainImpl struct {
func (s *semiPhysicalTrainImpl) handleTrainControlMsg(b []byte) {
s.udpDelayRecorder.RecordInterval()
slog.Debug(fmt.Sprintf("半实物列车控制消息近期消息间隔: %v", s.udpDelayRecorder.GetIntervals()))
handler := s.manager
if handler != nil {
handler.HandleSemiPhysicalTrainControlMsg(b)

View File

@ -52,6 +52,8 @@ type UdpDelayRecorder struct {
interval int
// 上一次收到消息时刻
lastReceiedTime int64
// 近期收到消息时间间隔
intervals []int64
// 是否发生异常
err error
// 长时间未收到消息或恢复处理回调
@ -119,7 +121,18 @@ func (r *UdpDelayRecorder) RecordInterval() {
r.mu.Lock()
defer r.mu.Unlock()
// 记录时间及间隔
r.lastReceiedTime = time.Now().UnixMilli()
ts := time.Now().UnixMilli()
if r.lastReceiedTime > 0 {
r.intervals = append(r.intervals, ts-r.lastReceiedTime)
if len(r.intervals) > 10 {
r.intervals = r.intervals[1:]
}
}
r.lastReceiedTime = ts
}
func (r *UdpDelayRecorder) GetIntervals() []int64 {
return r.intervals
}
func calUdpTimeout(interval int) int {

View File

@ -8,4 +8,5 @@ import (
var (
PointsParamType = ecs.NewComponentType[request_proto.PointsParam]()
SignalParamType = ecs.NewComponentType[request_proto.SignalParam]()
SectionParamType = ecs.NewComponentType[request_proto.SectionParam]()
)

View File

@ -1,36 +1,74 @@
package memory
import (
"log/slog"
"fmt"
"unsafe"
"joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/dto/data_proto"
"joylink.club/bj-rtsts-server/dto/request_proto"
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
"joylink.club/ecs"
"joylink.club/rtsssimulation/fi"
)
func ChangeAxleSectionState(simulation *VerifySimulation, req *dto.AxleSectionOperationReqDto) error {
sectionUid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.Section{})
slog.Debug("操作计轴区段", "axleSectionUid", sectionUid)
if req.TrainIn {
return fi.AxleSectionTrainDrive(simulation.World, sectionUid, true)
}
if req.TrainOut {
return fi.AxleSectionTrainDrive(simulation.World, sectionUid, false)
}
// 处理区段操作
func HandleSectionOperation(simulation *VerifySimulation, req *request_proto.SectionOperationReq) error {
uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.Section{})
// 区段操作
switch req.Operation {
case request_proto.Section_CancelDrst:
return fi.AxleSectionDrstDrive(simulation.World, sectionUid, false)
case request_proto.Section_SetDrst:
return fi.AxleSectionDrstDrive(simulation.World, sectionUid, true)
case request_proto.Section_CancelPdrst:
return fi.AxleSectionPdrstDrive(simulation.World, sectionUid, false)
case request_proto.Section_SetPdrst:
return fi.AxleSectionPdrstDrive(simulation.World, sectionUid, true)
case request_proto.Section_CancelFaultOcc:
return fi.AxleSectionFaultOccDrive(simulation.World, sectionUid, false)
case request_proto.Section_SetFaultOcc:
return fi.AxleSectionFaultOccDrive(simulation.World, sectionUid, true)
return fi.AxleSectionFaultOccDrive(simulation.World, uid, true)
case request_proto.Section_SetParams:
var err error
setSectionParam(simulation.World, uid, req.Param)
if req.Param.MockDrst {
err = fi.AxleSectionDrstDrive(simulation.World, uid, true)
} else {
err = fi.AxleSectionDrstDrive(simulation.World, uid, false)
}
if err != nil {
return err
}
if req.Param.MockPdrst {
err = fi.AxleSectionPdrstDrive(simulation.World, uid, true)
} else {
err = fi.AxleSectionPdrstDrive(simulation.World, uid, false)
}
return err
default:
return fmt.Errorf("未知的区段操作:%s", req.Operation)
}
}
func setSectionParam(world ecs.World, uid string, sectionParam *request_proto.SectionParam) error {
return handleEntityState(world, uid, func(e *ecs.Entry) error {
e.AddComponent(appcomponent.SectionParamType, unsafe.Pointer(sectionParam))
return nil
})
}
// func ChangeAxleSectionState(simulation *VerifySimulation, req *dto.AxleSectionOperationReqDto) error {
// sectionUid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.Section{})
// slog.Debug("操作计轴区段", "axleSectionUid", sectionUid)
// if req.TrainIn {
// return fi.AxleSectionTrainDrive(simulation.World, sectionUid, true)
// }
// if req.TrainOut {
// return fi.AxleSectionTrainDrive(simulation.World, sectionUid, false)
// }
// switch req.Operation {
// case request_proto.Section_CancelDrst:
// return fi.AxleSectionDrstDrive(simulation.World, sectionUid, false)
// case request_proto.Section_SetDrst:
// return fi.AxleSectionDrstDrive(simulation.World, sectionUid, true)
// case request_proto.Section_CancelPdrst:
// return fi.AxleSectionPdrstDrive(simulation.World, sectionUid, false)
// case request_proto.Section_SetPdrst:
// return fi.AxleSectionPdrstDrive(simulation.World, sectionUid, true)
// case request_proto.Section_CancelFaultOcc:
// return fi.AxleSectionFaultOccDrive(simulation.World, sectionUid, false)
// case request_proto.Section_SetFaultOcc:
// return fi.AxleSectionFaultOccDrive(simulation.World, sectionUid, true)
// }
// return nil
// }