【修改列车偏移信息】
This commit is contained in:
parent
00b396d41c
commit
3eb9fa1f70
@ -203,10 +203,11 @@ func addTrain(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
id := strconv.Itoa(i)
|
id := strconv.Itoa(i)
|
||||||
rsp := &state.TrainState{
|
rsp := &state.TrainState{
|
||||||
Id: id,
|
Id: id,
|
||||||
HeadLinkId: req.HeadLinkId,
|
HeadDeviceId: req.Id,
|
||||||
HeadLinkOffset: req.HeadLinkOffset,
|
HeadOffset: req.HeadOffset,
|
||||||
Up: req.Up,
|
DevicePort: req.DevicePort,
|
||||||
|
Up: req.Up,
|
||||||
}
|
}
|
||||||
memory.AddTrainState(simulation, rsp)
|
memory.AddTrainState(simulation, rsp)
|
||||||
c.JSON(http.StatusOK, &rsp)
|
c.JSON(http.StatusOK, &rsp)
|
||||||
|
@ -473,6 +473,12 @@ type TrainState struct {
|
|||||||
TrainLength int64 `protobuf:"varint,23,opt,name=trainLength,proto3" json:"trainLength,omitempty"`
|
TrainLength int64 `protobuf:"varint,23,opt,name=trainLength,proto3" json:"trainLength,omitempty"`
|
||||||
// 列车是否显示
|
// 列车是否显示
|
||||||
Show bool `protobuf:"varint,24,opt,name=show,proto3" json:"show,omitempty"`
|
Show bool `protobuf:"varint,24,opt,name=show,proto3" json:"show,omitempty"`
|
||||||
|
// 列车车头所在设备ID
|
||||||
|
HeadDeviceId string `protobuf:"bytes,25,opt,name=headDeviceId,proto3" json:"headDeviceId,omitempty"`
|
||||||
|
// 列车车头所在设备偏移量
|
||||||
|
HeadOffset int64 `protobuf:"varint,26,opt,name=headOffset,proto3" json:"headOffset,omitempty"`
|
||||||
|
// 设备端口
|
||||||
|
DevicePort string `protobuf:"bytes,27,opt,name=devicePort,proto3" json:"devicePort,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TrainState) Reset() {
|
func (x *TrainState) Reset() {
|
||||||
@ -675,6 +681,27 @@ func (x *TrainState) GetShow() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *TrainState) GetHeadDeviceId() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.HeadDeviceId
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TrainState) GetHeadOffset() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.HeadOffset
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TrainState) GetDevicePort() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.DevicePort
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// 仿真运行时状态变化量,当前时刻与上一时刻比较得到
|
// 仿真运行时状态变化量,当前时刻与上一时刻比较得到
|
||||||
type VariationStatus struct {
|
type VariationStatus struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -911,7 +938,7 @@ var file_device_state_proto_rawDesc = []byte{
|
|||||||
0x72, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
0x72, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x1e, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x69,
|
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x1e, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x69,
|
||||||
0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xce, 0x06, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x69,
|
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xb2, 0x07, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x69,
|
||||||
0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x75, 0x70, 0x18, 0x02, 0x20, 0x01,
|
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x75, 0x70, 0x18, 0x02, 0x20, 0x01,
|
||||||
0x28, 0x08, 0x52, 0x02, 0x75, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x65, 0x61, 0x64, 0x4c, 0x69,
|
0x28, 0x08, 0x52, 0x02, 0x75, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x65, 0x61, 0x64, 0x4c, 0x69,
|
||||||
@ -964,52 +991,58 @@ var file_device_state_proto_rawDesc = []byte{
|
|||||||
0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74,
|
0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74,
|
||||||
0x68, 0x18, 0x17, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x4c, 0x65,
|
0x68, 0x18, 0x17, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x4c, 0x65,
|
||||||
0x6e, 0x67, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x18, 0x18, 0x20, 0x01,
|
0x6e, 0x67, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x18, 0x18, 0x20, 0x01,
|
||||||
0x28, 0x08, 0x52, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x22, 0xe7, 0x01, 0x0a, 0x0f, 0x56, 0x61, 0x72,
|
0x28, 0x08, 0x52, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x12, 0x22, 0x0a, 0x0c, 0x68, 0x65, 0x61, 0x64,
|
||||||
0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a, 0x0c,
|
0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c,
|
||||||
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x03,
|
0x68, 0x65, 0x61, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a,
|
||||||
0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e,
|
0x68, 0x65, 0x61, 0x64, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x03,
|
||||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x72,
|
0x52, 0x0a, 0x68, 0x65, 0x61, 0x64, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1e, 0x0a, 0x0a,
|
||||||
0x61, 0x69, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x54, 0x72,
|
0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x61, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x72, 0x65, 0x6d,
|
0x52, 0x0a, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x22, 0xe7, 0x01, 0x0a,
|
||||||
0x6f, 0x76, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x38, 0x0a, 0x0d, 0x75,
|
0x0f, 0x56, 0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||||
0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03,
|
0x12, 0x35, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e,
|
||||||
0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x77, 0x69, 0x74, 0x63,
|
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54,
|
||||||
0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53,
|
0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74,
|
||||||
0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x3b, 0x0a, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
|
0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76,
|
||||||
0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e,
|
0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52,
|
||||||
0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61,
|
0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12,
|
||||||
0x74, 0x65, 0x52, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x63, 0x74, 0x69,
|
0x38, 0x0a, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68,
|
||||||
0x6f, 0x6e, 0x22, 0xb4, 0x01, 0x0a, 0x10, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
|
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53,
|
||||||
0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x31, 0x0a, 0x0a, 0x74, 0x72, 0x61, 0x69, 0x6e,
|
0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x75, 0x70, 0x64, 0x61,
|
||||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, 0x74,
|
0x74, 0x65, 0x64, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x3b, 0x0a, 0x0e, 0x75, 0x70, 0x64,
|
||||||
0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0a,
|
0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28,
|
||||||
0x74, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x34, 0x0a, 0x0b, 0x73, 0x77,
|
0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||||
0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53,
|
||||||
0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74,
|
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xb4, 0x01, 0x0a, 0x10, 0x41, 0x6c, 0x6c, 0x44, 0x65,
|
||||||
0x61, 0x74, 0x65, 0x52, 0x0b, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65,
|
0x76, 0x69, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x31, 0x0a, 0x0a, 0x74,
|
||||||
0x12, 0x37, 0x0a, 0x0c, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65,
|
0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||||
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53,
|
0x11, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61,
|
||||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0c, 0x73, 0x65, 0x63,
|
0x74, 0x65, 0x52, 0x0a, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x34,
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x94, 0x01, 0x0a, 0x13, 0x50, 0x75,
|
0x0a, 0x0b, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20,
|
||||||
0x73, 0x68, 0x65, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75,
|
0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x77, 0x69, 0x74,
|
||||||
0x73, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03,
|
0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0b, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53,
|
||||||
0x61, 0x6c, 0x6c, 0x12, 0x34, 0x0a, 0x09, 0x76, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
0x74, 0x61, 0x74, 0x65, 0x12, 0x37, 0x0a, 0x0c, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53,
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56,
|
0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x61,
|
||||||
0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09,
|
0x74, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52,
|
||||||
0x76, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a, 0x09, 0x61, 0x6c, 0x6c,
|
0x0c, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x94, 0x01,
|
||||||
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73,
|
0x0a, 0x13, 0x50, 0x75, 0x73, 0x68, 0x65, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x53,
|
||||||
0x74, 0x61, 0x74, 0x65, 0x2e, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x53,
|
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
0x28, 0x08, 0x52, 0x03, 0x61, 0x6c, 0x6c, 0x12, 0x34, 0x0a, 0x09, 0x76, 0x61, 0x72, 0x53, 0x74,
|
||||||
0x2a, 0x37, 0x0a, 0x0b, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12,
|
0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x61,
|
||||||
0x07, 0x0a, 0x03, 0x41, 0x6e, 0x79, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x78, 0x6c, 0x65,
|
0x74, 0x65, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74,
|
||||||
0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10, 0x02, 0x12, 0x0a, 0x0a,
|
0x75, 0x73, 0x52, 0x09, 0x76, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a,
|
||||||
0x06, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x10, 0x03, 0x42, 0x54, 0x0a, 0x25, 0x63, 0x6c, 0x75,
|
0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
|
||||||
0x62, 0x2e, 0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x62, 0x6a, 0x72, 0x74, 0x73, 0x73,
|
0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69,
|
||||||
0x2e, 0x61, 0x74, 0x73, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74,
|
||||||
0x6f, 0x73, 0x42, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50,
|
0x61, 0x74, 0x75, 0x73, 0x2a, 0x37, 0x0a, 0x0b, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x19, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69,
|
0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x6e, 0x79, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04,
|
||||||
0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x62,
|
0x41, 0x78, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10,
|
||||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x02, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x10, 0x03, 0x42, 0x54, 0x0a,
|
||||||
|
0x25, 0x63, 0x6c, 0x75, 0x62, 0x2e, 0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x62, 0x6a,
|
||||||
|
0x72, 0x74, 0x73, 0x73, 0x2e, 0x61, 0x74, 0x73, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2e,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x42, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74,
|
||||||
|
0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x19, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f,
|
||||||
|
0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x74,
|
||||||
|
0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package simulation
|
package simulation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/device"
|
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/device"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||||
"joylink.club/bj-rtsts-server/config"
|
"joylink.club/bj-rtsts-server/config"
|
||||||
"joylink.club/bj-rtsts-server/dynamics"
|
"joylink.club/bj-rtsts-server/dynamics"
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
|
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory"
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/memory"
|
||||||
"joylink.club/bj-rtsts-server/dto"
|
"joylink.club/bj-rtsts-server/dto"
|
||||||
@ -41,7 +42,7 @@ func init() {
|
|||||||
for _, simulation := range GetSimulationArr() {
|
for _, simulation := range GetSimulationArr() {
|
||||||
sta, ok := simulation.Memory.Status.TrainStateMap.Load(strconv.Itoa(int(info.Number)))
|
sta, ok := simulation.Memory.Status.TrainStateMap.Load(strconv.Itoa(int(info.Number)))
|
||||||
if ok {
|
if ok {
|
||||||
memory.UpdateTrainState(simulation, convert(info, *sta.(*state.TrainState), memory.QueryMapVerifyStructure(simulation.MapId)))
|
memory.UpdateTrainState(simulation, convert(info, sta.(*state.TrainState), memory.QueryMapVerifyStructure(simulation.MapId)))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,30 +120,15 @@ func GetSimulationArr() []*memory.VerifySimulation {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func convert(info *dynamics.TrainInfo, sta state.TrainState, vs *memory.VerifyStructure) *state.TrainState {
|
func convert(info *dynamics.TrainInfo, sta *state.TrainState, vs *memory.VerifyStructure) *state.TrainState {
|
||||||
zap.S().Debugf("原始消息:[%d-%d-%d]", info.Number, info.Link, info.LinkOffset)
|
zap.S().Debugf("原始消息:[%d-%d-%d]", info.Number, info.Link, info.LinkOffset)
|
||||||
modeller := vs.LinkModelMap[int32(info.Link)]
|
sta.HeadLinkId = strconv.Itoa(int(info.Link))
|
||||||
model := modeller.(*device.LinkModel)
|
sta.HeadLinkOffset = int64(info.LinkOffset)
|
||||||
for i, dp := range model.DevicePositions {
|
id, port, offset := memory.QueryDeviceByCalcLink(vs, int32(info.Link), sta.HeadLinkOffset)
|
||||||
if uint32(dp.Offset) >= info.LinkOffset {
|
zap.S().Debugf("转换后的消息:[%d-%s-%d]", info.Number, id, sta.HeadLinkOffset)
|
||||||
var linkRef *graphicData.RelatedRef
|
sta.HeadDeviceId = id
|
||||||
if i == 0 {
|
sta.DevicePort = port
|
||||||
linkRef = model.SectionLinkMap[dp.Device.GetGraphicId()]
|
sta.HeadOffset = offset
|
||||||
} else {
|
|
||||||
linkRef = model.SectionLinkMap[model.DevicePositions[i-1].Device.GetGraphicId()]
|
|
||||||
}
|
|
||||||
switch linkRef.DevicePort {
|
|
||||||
case 0:
|
|
||||||
sta.HeadLinkId = linkRef.GetId()
|
|
||||||
sta.HeadLinkOffset = int64(info.LinkOffset - uint32(dp.Offset))
|
|
||||||
case 1:
|
|
||||||
sta.HeadLinkId = linkRef.GetId()
|
|
||||||
sta.HeadLinkOffset = int64(uint32(model.DevicePositions[i+1].Offset) - info.LinkOffset)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zap.S().Debugf("转换后的消息:[%d-%s-%d]", info.Number, sta.HeadLinkId, sta.HeadLinkOffset)
|
|
||||||
sta.Slope = int32(info.Slope)
|
sta.Slope = int32(info.Slope)
|
||||||
sta.Upslope = info.UpSlope
|
sta.Upslope = info.UpSlope
|
||||||
sta.RunningUp = info.Up
|
sta.RunningUp = info.Up
|
||||||
@ -157,7 +143,7 @@ func convert(info *dynamics.TrainInfo, sta state.TrainState, vs *memory.VerifySt
|
|||||||
sta.TailSensorSpeed2 = info.TailSpeed2 * 3.6
|
sta.TailSensorSpeed2 = info.TailSpeed2 * 3.6
|
||||||
sta.HeadRadarSpeed = info.HeadRadarSpeed * 3.6
|
sta.HeadRadarSpeed = info.HeadRadarSpeed * 3.6
|
||||||
sta.TailRadarSpeed = info.TailRadarSpeed * 3.6
|
sta.TailRadarSpeed = info.TailRadarSpeed * 3.6
|
||||||
return &sta
|
return sta
|
||||||
}
|
}
|
||||||
|
|
||||||
func dynamicsRun(verifySimulation *memory.VerifySimulation) {
|
func dynamicsRun(verifySimulation *memory.VerifySimulation) {
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/section"
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/section"
|
||||||
"joylink.club/bj-rtsts-server/db/dbquery"
|
"joylink.club/bj-rtsts-server/db/dbquery"
|
||||||
"joylink.club/bj-rtsts-server/db/model"
|
"joylink.club/bj-rtsts-server/db/model"
|
||||||
|
"joylink.club/bj-rtsts-server/dto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 仿真存储集合 ID
|
// 仿真存储集合 ID
|
||||||
@ -82,7 +83,7 @@ func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
|
|||||||
// 初始化地图结构
|
// 初始化地图结构
|
||||||
initGraphicStructure(graphicStorage, verifyStructure, graphicInfoMap)
|
initGraphicStructure(graphicStorage, verifyStructure, graphicInfoMap)
|
||||||
// 构建设备间的关联关系(8.8 注释掉构建逻辑)
|
// 构建设备间的关联关系(8.8 注释掉构建逻辑)
|
||||||
// buildDeviceRef(graphicInfoMap, verifyStructure)
|
buildDeviceRef(graphicInfoMap, verifyStructure)
|
||||||
graphicDataMap.Store(graphic.ID, verifyStructure)
|
graphicDataMap.Store(graphic.ID, verifyStructure)
|
||||||
return verifyStructure
|
return verifyStructure
|
||||||
}
|
}
|
||||||
@ -106,6 +107,152 @@ func QueryMapVerifyStructure(mapId int32) *VerifyStructure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据区段,道岔偏移量返回linkID和link相对偏移量
|
||||||
|
func QueryMapCalcLinkByDeviceInfo(mapId int32, id string, devicePort string, offset int64) (int32, int64) {
|
||||||
|
vm := QueryMapVerifyStructure(mapId)
|
||||||
|
sm := vm.PhysicalSectionModelMap[id]
|
||||||
|
tm := vm.SwitchDeviceModelMap[id]
|
||||||
|
if sm == nil && tm == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在ID【%s】的设备", id)})
|
||||||
|
}
|
||||||
|
if sm != nil { // 区段添加
|
||||||
|
sectionModel := sm.(*section.PhysicalSectionModel)
|
||||||
|
pointA := sectionModel.PortAxlePoints[face.A.Name()]
|
||||||
|
pointB := sectionModel.PortAxlePoints[face.B.Name()]
|
||||||
|
if pointA == nil && pointB == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("区段【%s】计轴缺失", sectionModel.GraphicId)})
|
||||||
|
}
|
||||||
|
// 获取计轴信息
|
||||||
|
axlePointMap := make(map[string]*ref.DevicePosition)
|
||||||
|
// 确定link信息
|
||||||
|
var linkId int32
|
||||||
|
for k, v := range vm.LinkModelMap {
|
||||||
|
lm := v.(*device.LinkModel)
|
||||||
|
for _, p := range lm.DevicePositions {
|
||||||
|
if sectionModel.AxlePoints[p.Device.GetIndex()] != nil {
|
||||||
|
axlePointMap[p.Device.GetIndex()] = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果已经找到计轴则退出
|
||||||
|
if len(axlePointMap) > 0 {
|
||||||
|
linkId = k
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(axlePointMap) == 0 {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到【%s】所在link", id)})
|
||||||
|
}
|
||||||
|
// 计算相对位置
|
||||||
|
if pointA != nil && pointB != nil {
|
||||||
|
linkA := axlePointMap[pointA.GetIndex()]
|
||||||
|
linkB := axlePointMap[pointB.GetIndex()]
|
||||||
|
if linkA == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("link【%s】缺失计轴【%s】", id, pointA.GetGraphicId())})
|
||||||
|
}
|
||||||
|
if linkB == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("link【%s】缺失计轴【%s】", id, pointB.GetGraphicId())})
|
||||||
|
}
|
||||||
|
if linkA.Offset > linkB.Offset {
|
||||||
|
return linkId, int64(linkA.Offset) - offset
|
||||||
|
} else {
|
||||||
|
return linkId, int64(linkA.Offset) + offset
|
||||||
|
}
|
||||||
|
} else if pointA != nil {
|
||||||
|
linkA := axlePointMap[pointA.GetIndex()]
|
||||||
|
if linkA == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("link【%s】缺失计轴【%s】", id, pointA.GetGraphicId())})
|
||||||
|
}
|
||||||
|
return linkId, int64(linkA.Offset) + offset
|
||||||
|
} else {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("link【%s】缺失计轴【%s】", id, pointA.GetGraphicId())})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
turnoutModel := tm.(*device.SwitchDeviceModel)
|
||||||
|
var link *device.LinkModel
|
||||||
|
var linkId int32
|
||||||
|
var isStart bool
|
||||||
|
for i, v := range vm.LinkModelMap {
|
||||||
|
lm := v.(*device.LinkModel)
|
||||||
|
linkId = i
|
||||||
|
if lm.ARelatedSwitchRef.SwitchDevice.GetIndex() == turnoutModel.Index && lm.ARelatedSwitchRef.Port.Name() == devicePort {
|
||||||
|
isStart = true
|
||||||
|
link = lm
|
||||||
|
} else if lm.BRelatedSwitchRef.SwitchDevice.GetIndex() == turnoutModel.Index && lm.BRelatedSwitchRef.Port.Name() == devicePort {
|
||||||
|
link = lm
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range link.DevicePositions {
|
||||||
|
if v.Device.GetIndex() == turnoutModel.GetIndex() {
|
||||||
|
if isStart {
|
||||||
|
return linkId, int64(v.Offset) + offset
|
||||||
|
} else {
|
||||||
|
return linkId, int64(v.Offset) - offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到【%s】所在link", id)})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据linkID和link相对偏移量返回区段,道岔偏移量
|
||||||
|
// 设备ID、端口、偏移量
|
||||||
|
func QueryMapDeviceByCalcLink(mapId int32, id int32, offset int64) (string, string, int64) {
|
||||||
|
vm := QueryMapVerifyStructure(mapId)
|
||||||
|
return QueryDeviceByCalcLink(vm, id, offset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func QueryDeviceByCalcLink(vm *VerifyStructure, id int32, offset int64) (string, string, int64) {
|
||||||
|
lm := vm.LinkModelMap[id]
|
||||||
|
if lm == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到link【%d】", id)})
|
||||||
|
}
|
||||||
|
linkModel := lm.(*device.LinkModel)
|
||||||
|
if offset > int64(linkModel.Length) {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("偏移超出link范围【%d】", id)})
|
||||||
|
}
|
||||||
|
var devicePosition *ref.DevicePosition
|
||||||
|
for _, v := range linkModel.DevicePositions {
|
||||||
|
if v.Offset > int32(offset) {
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
devicePosition = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sm := vm.PhysicalSectionModelMap[devicePosition.Device.GetIndex()]
|
||||||
|
tm := vm.SwitchDeviceModelMap[devicePosition.Device.GetIndex()]
|
||||||
|
if sm == nil && tm == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在ID【%s】的设备", devicePosition.Device.GetIndex())})
|
||||||
|
}
|
||||||
|
if sm != nil {
|
||||||
|
sectionModel := sm.(*section.PhysicalSectionModel)
|
||||||
|
// 判断AB走向
|
||||||
|
pointA := sectionModel.PortAxlePoints[face.A.Name()]
|
||||||
|
pointB := sectionModel.PortAxlePoints[face.B.Name()]
|
||||||
|
if pointA == nil && pointB == nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("区段【%s】计轴缺失", sectionModel.GraphicId)})
|
||||||
|
}
|
||||||
|
if pointA.GetIndex() == devicePosition.Device.GetIndex() { // A-B走向
|
||||||
|
return sectionModel.Index, "", offset - int64(devicePosition.Offset)
|
||||||
|
} else if pointB.GetIndex() == devicePosition.Device.GetIndex() { // B-A走向,偏移为A - offset
|
||||||
|
for _, v := range linkModel.DevicePositions {
|
||||||
|
if v.Device.GetIndex() == pointA.GetIndex() {
|
||||||
|
return sectionModel.Index, "", int64(devicePosition.Offset) - offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("区段【%s】计轴缺失", sectionModel.GraphicId)})
|
||||||
|
} else {
|
||||||
|
if linkModel.ARelatedSwitchRef.SwitchDevice.GetIndex() == devicePosition.Device.GetIndex() { // 起始点
|
||||||
|
return devicePosition.Device.GetIndex(), linkModel.ARelatedSwitchRef.Port.Name(), offset - int64(devicePosition.Offset)
|
||||||
|
} else if linkModel.BRelatedSwitchRef.SwitchDevice.GetIndex() == devicePosition.Device.GetIndex() { // 结束点
|
||||||
|
return devicePosition.Device.GetIndex(), linkModel.BRelatedSwitchRef.Port.Name(), int64(devicePosition.Offset) - offset
|
||||||
|
} else {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在ID【%s】的设备", devicePosition.Device.GetIndex())})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化地图结构
|
// 初始化地图结构
|
||||||
func initGraphicStructure(graphicData *graphicData.RtssGraphicStorage, verifyStructure *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
func initGraphicStructure(graphicData *graphicData.RtssGraphicStorage, verifyStructure *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||||
// 初始化计轴信息
|
// 初始化计轴信息
|
||||||
@ -225,6 +372,7 @@ func initGraphicTurnout(turnouts []*graphicData.Turnout, data *VerifyStructure,
|
|||||||
Index: id,
|
Index: id,
|
||||||
},
|
},
|
||||||
KilometerSystems: t.GetKilometerSystem(),
|
KilometerSystems: t.GetKilometerSystem(),
|
||||||
|
AxlePoints: make(map[string]*device.AxlePointDeviceModel),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,9 +418,10 @@ func initGraphicPhysicalSections(physicalSections []*graphicData.Section, data *
|
|||||||
GraphicId: s.Common.Id,
|
GraphicId: s.Common.Id,
|
||||||
Index: id,
|
Index: id,
|
||||||
},
|
},
|
||||||
SwitchArea: len(s.AxleCountings) > 2,
|
SwitchArea: len(s.AxleCountings) > 2,
|
||||||
AxlePoints: make(map[string]face.AxlePointDeviceModeller),
|
AxlePoints: make(map[string]face.AxlePointDeviceModeller),
|
||||||
AxleSections: make(map[string]face.AxleSectionModeller),
|
AxleSections: make(map[string]face.AxleSectionModeller),
|
||||||
|
PortAxlePoints: make(map[string]face.AxlePointDeviceModeller),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,6 +576,7 @@ func buildTurnoutDeviceRef(verifyStructure *VerifyStructure) {
|
|||||||
buildTurnoutCommMethod(s, s.SwitchRefA, face.A)
|
buildTurnoutCommMethod(s, s.SwitchRefA, face.A)
|
||||||
buildTurnoutCommMethod(s, s.SwitchRefB, face.B)
|
buildTurnoutCommMethod(s, s.SwitchRefB, face.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildTurnoutCommMethod(s *section.LinkSectionModel, linkSwitch *ref.SwitchRef, p face.PortEnum) {
|
func buildTurnoutCommMethod(s *section.LinkSectionModel, linkSwitch *ref.SwitchRef, p face.PortEnum) {
|
||||||
@ -543,6 +693,8 @@ func buildAxlePointDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *
|
|||||||
zap.S().Warnf("id为[%s]的计轴检测点关联的道岔[%s]不存在", id, relatedRef.Id)
|
zap.S().Warnf("id为[%s]的计轴检测点关联的道岔[%s]不存在", id, relatedRef.Id)
|
||||||
}
|
}
|
||||||
switchDeviceModel := (verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]).(*device.SwitchDeviceModel)
|
switchDeviceModel := (verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]).(*device.SwitchDeviceModel)
|
||||||
|
// 道岔端口对应的计轴
|
||||||
|
switchDeviceModel.AxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||||
axlePointDeviceModel.SwitchDevices[switchDeviceModel.Index] = &ref.SwitchRef{
|
axlePointDeviceModel.SwitchDevices[switchDeviceModel.Index] = &ref.SwitchRef{
|
||||||
SwitchDevice: switchDeviceModel,
|
SwitchDevice: switchDeviceModel,
|
||||||
Port: face.PortEnum(relatedRef.DevicePort),
|
Port: face.PortEnum(relatedRef.DevicePort),
|
||||||
@ -556,6 +708,7 @@ func buildAxlePointDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *
|
|||||||
if physicalSectionModel.SwitchArea {
|
if physicalSectionModel.SwitchArea {
|
||||||
zap.S().Warnf("id为[%s]的计轴检测点proto数据关联岔区物理区段[%s]不存在", id, relatedRef.Id)
|
zap.S().Warnf("id为[%s]的计轴检测点proto数据关联岔区物理区段[%s]不存在", id, relatedRef.Id)
|
||||||
}
|
}
|
||||||
|
physicalSectionModel.PortAxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||||
switch relatedRef.DevicePort {
|
switch relatedRef.DevicePort {
|
||||||
case graphicData.RelatedRef_A:
|
case graphicData.RelatedRef_A:
|
||||||
axlePointDeviceModel.LinePhysicalSectionA = physicalSectionModel
|
axlePointDeviceModel.LinePhysicalSectionA = physicalSectionModel
|
||||||
|
@ -2,13 +2,13 @@ package memory
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.uber.org/zap"
|
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/device"
|
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"joylink.club/bj-rtsts-server/dto"
|
"joylink.club/bj-rtsts-server/dto"
|
||||||
"joylink.club/bj-rtsts-server/dynamics"
|
"joylink.club/bj-rtsts-server/dynamics"
|
||||||
|
|
||||||
@ -27,39 +27,16 @@ func AddTrainState(simulation *VerifySimulation, status *state.TrainState) {
|
|||||||
status.Show = true
|
status.Show = true
|
||||||
//向动力学发送初始化请求
|
//向动力学发送初始化请求
|
||||||
trainIndex, _ := strconv.ParseUint(status.Id, 10, 16)
|
trainIndex, _ := strconv.ParseUint(status.Id, 10, 16)
|
||||||
var linkIndex uint64
|
linkId, loffset := QueryMapCalcLinkByDeviceInfo(simulation.MapId, status.Id, status.DevicePort, status.HeadOffset)
|
||||||
var linkOffset uint32
|
|
||||||
vs := QueryMapVerifyStructure(simulation.MapId)
|
|
||||||
Outer:
|
|
||||||
for _, modeller := range vs.LinkModelMap {
|
|
||||||
link := modeller.(*device.LinkModel)
|
|
||||||
for dId, sl := range link.SectionLinkMap {
|
|
||||||
if sl.Id != status.HeadLinkId {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
linkIndex, _ = strconv.ParseUint(link.Index, 10, 16)
|
|
||||||
for i, dp := range link.DevicePositions {
|
|
||||||
if dp.Device.GetGraphicId() == dId {
|
|
||||||
switch sl.DevicePort {
|
|
||||||
case 0:
|
|
||||||
linkOffset = uint32(dp.Offset) + uint32(status.HeadLinkOffset)
|
|
||||||
case 1:
|
|
||||||
linkOffset = uint32(link.DevicePositions[i+1].Offset) - uint32(status.HeadLinkOffset)
|
|
||||||
}
|
|
||||||
break Outer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
httpCode, _, err := dynamics.SendInitTrainReq(&dynamics.InitTrainInfo{
|
httpCode, _, err := dynamics.SendInitTrainReq(&dynamics.InitTrainInfo{
|
||||||
TrainIndex: uint16(trainIndex),
|
TrainIndex: uint16(trainIndex),
|
||||||
LinkIndex: uint16(linkIndex),
|
LinkIndex: uint16(linkId),
|
||||||
LinkOffset: linkOffset,
|
LinkOffset: uint32(loffset),
|
||||||
Speed: uint16(math.Round(float64(status.Speed * 10))),
|
Speed: uint16(math.Round(float64(status.Speed * 10))),
|
||||||
Up: status.Up,
|
Up: status.Up,
|
||||||
})
|
})
|
||||||
zap.S().Debugf("添加列车:[%d-%s-%d]", trainIndex, status.HeadLinkId, status.HeadLinkOffset)
|
zap.S().Debugf("添加列车:[%d-%s-%d]", trainIndex, status.HeadLinkId, status.HeadLinkOffset)
|
||||||
zap.S().Debugf("列车初始化:[%d-%d-%d]", trainIndex, linkIndex, linkOffset)
|
zap.S().Debugf("列车初始化:[%d-%d-%d]", trainIndex, linkId, loffset)
|
||||||
if err != nil || httpCode != http.StatusOK {
|
if err != nil || httpCode != http.StatusOK {
|
||||||
panic(dto.ErrorDto{Code: dto.LogicError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
|
panic(dto.ErrorDto{Code: dto.LogicError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ type SwitchDeviceModel struct {
|
|||||||
LinkRefB *ref.LinkRef
|
LinkRefB *ref.LinkRef
|
||||||
//道岔C端连接的link
|
//道岔C端连接的link
|
||||||
LinkRefC *ref.LinkRef
|
LinkRefC *ref.LinkRef
|
||||||
|
// 道岔相连的计轴信息
|
||||||
|
AxlePoints map[string]*AxlePointDeviceModel
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取道岔端口关联的轨道
|
// 获取道岔端口关联的轨道
|
||||||
|
@ -14,6 +14,8 @@ type PhysicalSectionModel struct {
|
|||||||
//该物理区段中包含的所有计轴区段
|
//该物理区段中包含的所有计轴区段
|
||||||
//key-图形id
|
//key-图形id
|
||||||
AxleSections map[string]face.AxleSectionModeller
|
AxleSections map[string]face.AxleSectionModeller
|
||||||
|
// 端口对应的计轴信息
|
||||||
|
PortAxlePoints map[string]face.AxlePointDeviceModeller
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加计轴检测点
|
// 添加计轴检测点
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 7bc8fe711369ec3be8b0dcfe8c96ab7ec48990c9
|
Subproject commit 269cba242ab05d5c664386075386eb6a624bc861
|
@ -32,6 +32,7 @@ func newCategory(db *gorm.DB, opts ...gen.DOOption) category {
|
|||||||
_category.Config = field.NewString(tableName, "config")
|
_category.Config = field.NewString(tableName, "config")
|
||||||
_category.CreatedAt = field.NewTime(tableName, "created_at")
|
_category.CreatedAt = field.NewTime(tableName, "created_at")
|
||||||
_category.UpdateAt = field.NewTime(tableName, "update_at")
|
_category.UpdateAt = field.NewTime(tableName, "update_at")
|
||||||
|
_category.Code = field.NewString(tableName, "code")
|
||||||
|
|
||||||
_category.fillFieldMap()
|
_category.fillFieldMap()
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ type category struct {
|
|||||||
Config field.String // 厂家配置
|
Config field.String // 厂家配置
|
||||||
CreatedAt field.Time // 创建时间
|
CreatedAt field.Time // 创建时间
|
||||||
UpdateAt field.Time // 修改时间
|
UpdateAt field.Time // 修改时间
|
||||||
|
Code field.String // 编码
|
||||||
|
|
||||||
fieldMap map[string]field.Expr
|
fieldMap map[string]field.Expr
|
||||||
}
|
}
|
||||||
@ -68,6 +70,7 @@ func (c *category) updateTableName(table string) *category {
|
|||||||
c.Config = field.NewString(table, "config")
|
c.Config = field.NewString(table, "config")
|
||||||
c.CreatedAt = field.NewTime(table, "created_at")
|
c.CreatedAt = field.NewTime(table, "created_at")
|
||||||
c.UpdateAt = field.NewTime(table, "update_at")
|
c.UpdateAt = field.NewTime(table, "update_at")
|
||||||
|
c.Code = field.NewString(table, "code")
|
||||||
|
|
||||||
c.fillFieldMap()
|
c.fillFieldMap()
|
||||||
|
|
||||||
@ -84,12 +87,13 @@ func (c *category) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *category) fillFieldMap() {
|
func (c *category) fillFieldMap() {
|
||||||
c.fieldMap = make(map[string]field.Expr, 5)
|
c.fieldMap = make(map[string]field.Expr, 6)
|
||||||
c.fieldMap["id"] = c.ID
|
c.fieldMap["id"] = c.ID
|
||||||
c.fieldMap["name"] = c.Name
|
c.fieldMap["name"] = c.Name
|
||||||
c.fieldMap["config"] = c.Config
|
c.fieldMap["config"] = c.Config
|
||||||
c.fieldMap["created_at"] = c.CreatedAt
|
c.fieldMap["created_at"] = c.CreatedAt
|
||||||
c.fieldMap["update_at"] = c.UpdateAt
|
c.fieldMap["update_at"] = c.UpdateAt
|
||||||
|
c.fieldMap["code"] = c.Code
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c category) clone(db *gorm.DB) category {
|
func (c category) clone(db *gorm.DB) category {
|
||||||
|
@ -33,7 +33,7 @@ func newDrafting(db *gorm.DB, opts ...gen.DOOption) drafting {
|
|||||||
_drafting.CreatorID = field.NewInt32(tableName, "creator_id")
|
_drafting.CreatorID = field.NewInt32(tableName, "creator_id")
|
||||||
_drafting.CreatedAt = field.NewTime(tableName, "created_at")
|
_drafting.CreatedAt = field.NewTime(tableName, "created_at")
|
||||||
_drafting.UpdateAt = field.NewTime(tableName, "update_at")
|
_drafting.UpdateAt = field.NewTime(tableName, "update_at")
|
||||||
_drafting.Category = field.NewInt32(tableName, "category")
|
_drafting.Category = field.NewString(tableName, "category")
|
||||||
|
|
||||||
_drafting.fillFieldMap()
|
_drafting.fillFieldMap()
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ type drafting struct {
|
|||||||
CreatorID field.Int32 // 创建人id
|
CreatorID field.Int32 // 创建人id
|
||||||
CreatedAt field.Time // 创建时间
|
CreatedAt field.Time // 创建时间
|
||||||
UpdateAt field.Time // 修改时间
|
UpdateAt field.Time // 修改时间
|
||||||
Category field.Int32 // 厂家id
|
Category field.String // 厂家编码
|
||||||
|
|
||||||
fieldMap map[string]field.Expr
|
fieldMap map[string]field.Expr
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ func (d *drafting) updateTableName(table string) *drafting {
|
|||||||
d.CreatorID = field.NewInt32(table, "creator_id")
|
d.CreatorID = field.NewInt32(table, "creator_id")
|
||||||
d.CreatedAt = field.NewTime(table, "created_at")
|
d.CreatedAt = field.NewTime(table, "created_at")
|
||||||
d.UpdateAt = field.NewTime(table, "update_at")
|
d.UpdateAt = field.NewTime(table, "update_at")
|
||||||
d.Category = field.NewInt32(table, "category")
|
d.Category = field.NewString(table, "category")
|
||||||
|
|
||||||
d.fillFieldMap()
|
d.fillFieldMap()
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ func newPublishedGi(db *gorm.DB, opts ...gen.DOOption) publishedGi {
|
|||||||
_publishedGi.Proto = field.NewBytes(tableName, "proto")
|
_publishedGi.Proto = field.NewBytes(tableName, "proto")
|
||||||
_publishedGi.UserID = field.NewInt32(tableName, "user_id")
|
_publishedGi.UserID = field.NewInt32(tableName, "user_id")
|
||||||
_publishedGi.PublishAt = field.NewTime(tableName, "publish_at")
|
_publishedGi.PublishAt = field.NewTime(tableName, "publish_at")
|
||||||
_publishedGi.Category = field.NewInt32(tableName, "category")
|
_publishedGi.Category = field.NewString(tableName, "category")
|
||||||
_publishedGi.Note = field.NewString(tableName, "note")
|
_publishedGi.Note = field.NewString(tableName, "note")
|
||||||
_publishedGi.Status = field.NewInt32(tableName, "status")
|
_publishedGi.Status = field.NewInt32(tableName, "status")
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ type publishedGi struct {
|
|||||||
Proto field.Bytes // 图形界面数据
|
Proto field.Bytes // 图形界面数据
|
||||||
UserID field.Int32 // 发布用户id
|
UserID field.Int32 // 发布用户id
|
||||||
PublishAt field.Time // 发布时间
|
PublishAt field.Time // 发布时间
|
||||||
Category field.Int32 // 厂家信息
|
Category field.String // 厂家信息
|
||||||
Note field.String // 发布描述
|
Note field.String // 发布描述
|
||||||
Status field.Int32 // 显示状态
|
Status field.Int32 // 显示状态
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ func (p *publishedGi) updateTableName(table string) *publishedGi {
|
|||||||
p.Proto = field.NewBytes(table, "proto")
|
p.Proto = field.NewBytes(table, "proto")
|
||||||
p.UserID = field.NewInt32(table, "user_id")
|
p.UserID = field.NewInt32(table, "user_id")
|
||||||
p.PublishAt = field.NewTime(table, "publish_at")
|
p.PublishAt = field.NewTime(table, "publish_at")
|
||||||
p.Category = field.NewInt32(table, "category")
|
p.Category = field.NewString(table, "category")
|
||||||
p.Note = field.NewString(table, "note")
|
p.Note = field.NewString(table, "note")
|
||||||
p.Status = field.NewInt32(table, "status")
|
p.Status = field.NewInt32(table, "status")
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ type Category struct {
|
|||||||
Config string `gorm:"column:config;comment:厂家配置" json:"config"` // 厂家配置
|
Config string `gorm:"column:config;comment:厂家配置" json:"config"` // 厂家配置
|
||||||
CreatedAt time.Time `gorm:"column:created_at;not null;comment:创建时间" json:"created_at"` // 创建时间
|
CreatedAt time.Time `gorm:"column:created_at;not null;comment:创建时间" json:"created_at"` // 创建时间
|
||||||
UpdateAt time.Time `gorm:"column:update_at;comment:修改时间" json:"update_at"` // 修改时间
|
UpdateAt time.Time `gorm:"column:update_at;comment:修改时间" json:"update_at"` // 修改时间
|
||||||
|
Code string `gorm:"column:code;comment:编码" json:"code"` // 编码
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName Category's table name
|
// TableName Category's table name
|
||||||
|
@ -18,7 +18,7 @@ type Drafting struct {
|
|||||||
CreatorID int32 `gorm:"column:creator_id;not null;comment:创建人id" json:"creator_id"` // 创建人id
|
CreatorID int32 `gorm:"column:creator_id;not null;comment:创建人id" json:"creator_id"` // 创建人id
|
||||||
CreatedAt time.Time `gorm:"column:created_at;not null;comment:创建时间" json:"created_at"` // 创建时间
|
CreatedAt time.Time `gorm:"column:created_at;not null;comment:创建时间" json:"created_at"` // 创建时间
|
||||||
UpdateAt time.Time `gorm:"column:update_at;comment:修改时间" json:"update_at"` // 修改时间
|
UpdateAt time.Time `gorm:"column:update_at;comment:修改时间" json:"update_at"` // 修改时间
|
||||||
Category int32 `gorm:"column:category;comment:厂家id" json:"category"` // 厂家id
|
Category string `gorm:"column:category;comment:厂家编码" json:"category"` // 厂家编码
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName Drafting's table name
|
// TableName Drafting's table name
|
||||||
|
@ -17,7 +17,7 @@ type PublishedGi struct {
|
|||||||
Proto []byte `gorm:"column:proto;not null;comment:图形界面数据" json:"proto"` // 图形界面数据
|
Proto []byte `gorm:"column:proto;not null;comment:图形界面数据" json:"proto"` // 图形界面数据
|
||||||
UserID int32 `gorm:"column:user_id;not null;comment:发布用户id" json:"user_id"` // 发布用户id
|
UserID int32 `gorm:"column:user_id;not null;comment:发布用户id" json:"user_id"` // 发布用户id
|
||||||
PublishAt time.Time `gorm:"column:publish_at;not null;comment:发布时间" json:"publish_at"` // 发布时间
|
PublishAt time.Time `gorm:"column:publish_at;not null;comment:发布时间" json:"publish_at"` // 发布时间
|
||||||
Category int32 `gorm:"column:category;comment:厂家信息" json:"category"` // 厂家信息
|
Category string `gorm:"column:category;comment:厂家信息" json:"category"` // 厂家信息
|
||||||
Note string `gorm:"column:note;comment:发布描述" json:"note"` // 发布描述
|
Note string `gorm:"column:note;comment:发布描述" json:"note"` // 发布描述
|
||||||
Status int32 `gorm:"column:status;default:1;comment:显示状态" json:"status"` // 显示状态
|
Status int32 `gorm:"column:status;default:1;comment:显示状态" json:"status"` // 显示状态
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ type PageCategoryReqDto struct {
|
|||||||
|
|
||||||
type CategoryDto struct {
|
type CategoryDto struct {
|
||||||
Id int `json:"id" form:"id"`
|
Id int `json:"id" form:"id"`
|
||||||
|
Code string `json:"code" form:"code"`
|
||||||
Name string `json:"name" form:"name"`
|
Name string `json:"name" form:"name"`
|
||||||
Config string `json:"config" form:"config"`
|
Config string `json:"config" form:"config"`
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ type PageDraftingReqDto struct {
|
|||||||
type DraftingDto struct {
|
type DraftingDto struct {
|
||||||
Id int `json:"id" form:"id"`
|
Id int `json:"id" form:"id"`
|
||||||
Name string `json:"name" form:"name"`
|
Name string `json:"name" form:"name"`
|
||||||
Category int32 `json:"category" form:"category"`
|
Category string `json:"category" form:"category"`
|
||||||
Proto []byte `json:"proto" from:"proto"`
|
Proto []byte `json:"proto" from:"proto"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,12 @@ type AddTrainReqDto struct {
|
|||||||
HeadLinkId string `json:"headLinkId" form:"headLinkId"`
|
HeadLinkId string `json:"headLinkId" form:"headLinkId"`
|
||||||
//车头所在link内的偏移量,单位为mm
|
//车头所在link内的偏移量,单位为mm
|
||||||
HeadLinkOffset int64 `json:"headLinkOffset" form:"headLinkOffset"`
|
HeadLinkOffset int64 `json:"headLinkOffset" form:"headLinkOffset"`
|
||||||
|
//物理区段、道岔ID
|
||||||
|
Id string `json:"id" form:"id"`
|
||||||
|
//道岔端口
|
||||||
|
DevicePort string `json:"devicePort" form:"devicePort"`
|
||||||
|
//车头所在link内的偏移量,单位为mm
|
||||||
|
HeadOffset int64 `json:"headOffset" form:"headOffset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为仿真添加测试车请求
|
// 为仿真添加测试车请求
|
||||||
|
@ -30,7 +30,7 @@ func ListCategoryQuery(query *dto.PageCategoryReqDto) ([]*model.Category, error)
|
|||||||
if query.Name != "" {
|
if query.Name != "" {
|
||||||
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name)))
|
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name)))
|
||||||
}
|
}
|
||||||
records, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).Find()
|
records, err := dq.Debug().Select(d.ID, d.Code, d.Name, d.UpdateAt, d.CreatedAt).Find()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -44,6 +44,7 @@ func CreateCategory(dto *dto.CategoryDto) (*model.Category, error) {
|
|||||||
}
|
}
|
||||||
d := model.Category{
|
d := model.Category{
|
||||||
Name: dto.Name,
|
Name: dto.Name,
|
||||||
|
Code: dto.Code,
|
||||||
Config: dto.Config,
|
Config: dto.Config,
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
UpdateAt: time.Now(),
|
UpdateAt: time.Now(),
|
||||||
|
Loading…
Reference in New Issue
Block a user