【link定位逻辑、加车逻辑】
This commit is contained in:
parent
350a94259b
commit
056982b595
|
@ -207,7 +207,7 @@ func addTrain(c *gin.Context) {
|
|||
HeadDeviceId: req.Id,
|
||||
HeadOffset: req.HeadOffset,
|
||||
DevicePort: req.DevicePort,
|
||||
Up: req.Up,
|
||||
RunDirection: req.RunDirection,
|
||||
}
|
||||
memory.AddTrainState(simulation, rsp)
|
||||
c.JSON(http.StatusOK, &rsp)
|
||||
|
|
|
@ -479,6 +479,10 @@ type TrainState struct {
|
|||
HeadOffset int64 `protobuf:"varint,26,opt,name=headOffset,proto3" json:"headOffset,omitempty"`
|
||||
// 设备端口
|
||||
DevicePort string `protobuf:"bytes,27,opt,name=devicePort,proto3" json:"devicePort,omitempty"`
|
||||
// 运行方向指向(区段:A-B,道岔:-> 岔心)
|
||||
PointTo bool `protobuf:"varint,28,opt,name=pointTo,proto3" json:"pointTo,omitempty"`
|
||||
// 运行上下行(公里标 上行:小 -> 大,下行:大 -> 小)
|
||||
RunDirection bool `protobuf:"varint,29,opt,name=runDirection,proto3" json:"runDirection,omitempty"`
|
||||
}
|
||||
|
||||
func (x *TrainState) Reset() {
|
||||
|
@ -702,6 +706,20 @@ func (x *TrainState) GetDevicePort() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *TrainState) GetPointTo() bool {
|
||||
if x != nil {
|
||||
return x.PointTo
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *TrainState) GetRunDirection() bool {
|
||||
if x != nil {
|
||||
return x.RunDirection
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 仿真运行时状态变化量,当前时刻与上一时刻比较得到
|
||||
type VariationStatus struct {
|
||||
state protoimpl.MessageState
|
||||
|
@ -938,7 +956,7 @@ var file_device_state_proto_rawDesc = []byte{
|
|||
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,
|
||||
0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xb2, 0x07, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x69,
|
||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xf0, 0x07, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x69,
|
||||
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, 0x08, 0x52, 0x02, 0x75, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x65, 0x61, 0x64, 0x4c, 0x69,
|
||||
|
@ -997,52 +1015,56 @@ var file_device_state_proto_rawDesc = []byte{
|
|||
0x68, 0x65, 0x61, 0x64, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x0a, 0x68, 0x65, 0x61, 0x64, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1e, 0x0a, 0x0a,
|
||||
0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0a, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x22, 0xe7, 0x01, 0x0a,
|
||||
0x0f, 0x56, 0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||
0x12, 0x35, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e,
|
||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54,
|
||||
0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74,
|
||||
0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76,
|
||||
0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52,
|
||||
0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12,
|
||||
0x38, 0x0a, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68,
|
||||
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53,
|
||||
0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x75, 0x70, 0x64, 0x61,
|
||||
0x74, 0x65, 0x64, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x3b, 0x0a, 0x0e, 0x75, 0x70, 0x64,
|
||||
0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xb4, 0x01, 0x0a, 0x10, 0x41, 0x6c, 0x6c, 0x44, 0x65,
|
||||
0x76, 0x69, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x31, 0x0a, 0x0a, 0x74,
|
||||
0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||
0x11, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x52, 0x0a, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x34,
|
||||
0x0a, 0x0b, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x77, 0x69, 0x74,
|
||||
0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0b, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53,
|
||||
0x74, 0x61, 0x74, 0x65, 0x12, 0x37, 0x0a, 0x0c, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53,
|
||||
0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x61,
|
||||
0x74, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52,
|
||||
0x0c, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x94, 0x01,
|
||||
0x0a, 0x13, 0x50, 0x75, 0x73, 0x68, 0x65, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x53,
|
||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x03, 0x61, 0x6c, 0x6c, 0x12, 0x34, 0x0a, 0x09, 0x76, 0x61, 0x72, 0x53, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x61,
|
||||
0x74, 0x65, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x52, 0x09, 0x76, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a,
|
||||
0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69,
|
||||
0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x2a, 0x37, 0x0a, 0x0b, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54,
|
||||
0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x6e, 0x79, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04,
|
||||
0x41, 0x78, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10,
|
||||
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,
|
||||
0x52, 0x0a, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x6f, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70,
|
||||
0x6f, 0x69, 0x6e, 0x74, 0x54, 0x6f, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x75, 0x6e, 0x44, 0x69, 0x72,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x72, 0x75,
|
||||
0x6e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xe7, 0x01, 0x0a, 0x0f, 0x56,
|
||||
0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35,
|
||||
0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01,
|
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61,
|
||||
0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
|
||||
0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64,
|
||||
0x54, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x72,
|
||||
0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x38, 0x0a,
|
||||
0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x18, 0x03,
|
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x77, 0x69,
|
||||
0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65,
|
||||
0x64, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x3b, 0x0a, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74,
|
||||
0x65, 0x64, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||
0x13, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53,
|
||||
0x74, 0x61, 0x74, 0x65, 0x52, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x22, 0xb4, 0x01, 0x0a, 0x10, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69,
|
||||
0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x31, 0x0a, 0x0a, 0x74, 0x72, 0x61,
|
||||
0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e,
|
||||
0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65,
|
||||
0x52, 0x0a, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x34, 0x0a, 0x0b,
|
||||
0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68,
|
||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0b, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x12, 0x37, 0x0a, 0x0c, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65,
|
||||
0x2e, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0c, 0x73,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x94, 0x01, 0x0a, 0x13,
|
||||
0x50, 0x75, 0x73, 0x68, 0x65, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
|
||||
0x52, 0x03, 0x61, 0x6c, 0x6c, 0x12, 0x34, 0x0a, 0x09, 0x76, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65,
|
||||
0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||
0x52, 0x09, 0x76, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a, 0x09, 0x61,
|
||||
0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17,
|
||||
0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
|
||||
0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x2a, 0x37, 0x0a, 0x0b, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70,
|
||||
0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x6e, 0x79, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x78,
|
||||
0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10, 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 (
|
||||
|
|
|
@ -124,11 +124,12 @@ func convert(info *dynamics.TrainInfo, sta *state.TrainState, vs *memory.VerifyS
|
|||
zap.S().Debugf("原始消息:[%d-%d-%d]", info.Number, info.Link, info.LinkOffset)
|
||||
sta.HeadLinkId = strconv.Itoa(int(info.Link))
|
||||
sta.HeadLinkOffset = int64(info.LinkOffset)
|
||||
id, port, offset := memory.QueryDeviceByCalcLink(vs, int32(info.Link), sta.HeadLinkOffset)
|
||||
zap.S().Debugf("转换后的消息:[%d-%s-%d]", info.Number, id, sta.HeadLinkOffset)
|
||||
id, port, offset, runDirection := memory.QueryDeviceByCalcLink(vs, int32(info.Link), sta.HeadLinkOffset, sta.Up, sta.RunDirection)
|
||||
zap.S().Debugf("转换后的消息:[%d-车头:%s-偏移:%d-上行:%v]", info.Number, id, offset, runDirection)
|
||||
sta.HeadDeviceId = id
|
||||
sta.DevicePort = port
|
||||
sta.HeadOffset = offset
|
||||
sta.RunDirection = runDirection
|
||||
/*
|
||||
modeller := vs.LinkModelMap[int32(info.Link)]
|
||||
model := modeller.(*device.LinkModel)
|
||||
|
|
|
@ -69,12 +69,6 @@ func BuildCalculateLinkData(gd *graphicData.RtssGraphicStorage) []*graphicData.C
|
|||
item.Length = item.Length + calcGraphicLenBySection(section)
|
||||
// 放入设备偏移
|
||||
offset, prevKm = getGraphicSectionRefDevices(refVal, devicePosistionMap, section, offset, prevKm)
|
||||
// 区段时,A点取小端,B点取大端,没有的话赋值 refVal ,只会以道岔为端点
|
||||
//if index == 0 {
|
||||
// item.ARelatedRef = getGraphicSectionPointRef(section, true, refVal)
|
||||
//} else {
|
||||
// item.BRelatedRef = getGraphicSectionPointRef(section, false, refVal)
|
||||
//}
|
||||
} else {
|
||||
allTurnout = allTurnout && true
|
||||
turnout := gm.TurnoutMap[refVal.Id]
|
||||
|
@ -300,32 +294,6 @@ func getGraphicTurnoutRefDevices(refVal *graphicData.RelatedRef, deviceMap map[s
|
|||
return offset, prevKm
|
||||
}
|
||||
|
||||
// 获取区段的对应端
|
||||
func getGraphicSectionPointRef(section *buildCalcSectionStruct, isStart bool, defaultRelateRef *graphicData.RelatedRef) *graphicData.RelatedRef {
|
||||
if len(section.axlePoints) == 0 {
|
||||
return defaultRelateRef
|
||||
}
|
||||
apoint := section.axlePoints[graphicData.RelatedRef_A]
|
||||
bpoint := section.axlePoints[graphicData.RelatedRef_B]
|
||||
if apoint == nil && bpoint == nil {
|
||||
return defaultRelateRef
|
||||
} else if apoint != nil && bpoint == nil {
|
||||
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: apoint.Common.Id}
|
||||
} else if apoint == nil && bpoint != nil {
|
||||
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: bpoint.Common.Id}
|
||||
}
|
||||
startPoint, endPoint := apoint, bpoint
|
||||
if defaultRelateRef.DevicePort == graphicData.RelatedRef_B {
|
||||
startPoint, endPoint = bpoint, apoint
|
||||
}
|
||||
if isStart {
|
||||
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: startPoint.Common.Id}
|
||||
} else {
|
||||
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: endPoint.Common.Id}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 获取link的起始点和包装数据结构方便查找,以道岔的各分支的连接点为起点
|
||||
func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStruct, *list.List) {
|
||||
gm := &buildCalcStruct{
|
||||
|
|
|
@ -55,6 +55,14 @@ type GraphicInfoMapStructure struct {
|
|||
CalcLinkMap map[string]*graphicData.CalculateLink
|
||||
}
|
||||
|
||||
// 计算link、物理区段、道岔相互转换时用到的结构体
|
||||
type calcLinkPositionStruct struct {
|
||||
index string // 地图元素的Index
|
||||
deviceType int // 1 计轴, 2 道岔
|
||||
kilometer *graphicData.KilometerSystem // 元素对应的公里标
|
||||
position *ref.DevicePosition // 元素在link上对应的偏移量
|
||||
}
|
||||
|
||||
// 将发布的地图数据放入内存中
|
||||
func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
|
||||
// 创建一个地图数据模型结构数据
|
||||
|
@ -109,17 +117,17 @@ func QueryMapVerifyStructure(mapId int32) *VerifyStructure {
|
|||
}
|
||||
|
||||
// 根据区段,道岔偏移量返回linkID和link相对偏移量
|
||||
func QueryMapCalcLinkByDeviceInfo(mapId int32, id string, devicePort string, offset int64) (int32, int64) {
|
||||
func QueryMapCalcLinkByDeviceInfo(mapId int32, id string, devicePort string, offset int64, runDirection bool) (int32, int64, bool) {
|
||||
vm := QueryMapVerifyStructure(mapId)
|
||||
if devicePort == "" {
|
||||
return sectionMapToLink(vm, id, offset)
|
||||
return sectionMapToLink(vm, id, offset, runDirection)
|
||||
} else {
|
||||
return turnoutMapToLink(vm, id, devicePort, offset)
|
||||
return turnoutMapToLink(vm, id, devicePort, offset, runDirection)
|
||||
}
|
||||
}
|
||||
|
||||
// 根据物理区段上的偏移量(基于区段A端),找到所在link的linkId与偏移量
|
||||
func sectionMapToLink(vm *VerifyStructure, id string, offset int64) (int32, int64) {
|
||||
func sectionMapToLink(vm *VerifyStructure, id string, offset int64, runDirection bool) (int32, int64, bool) {
|
||||
sm := vm.PhysicalSectionModelMap[id]
|
||||
if sm == nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在区段【index:%s】", id)})
|
||||
|
@ -128,39 +136,45 @@ func sectionMapToLink(vm *VerifyStructure, id string, offset int64) (int32, int6
|
|||
// 确定link信息
|
||||
var linkId int32
|
||||
// 获取计轴信息
|
||||
axlePointMap := make(map[string]*ref.DevicePosition)
|
||||
axlePointPositionMap := make(map[string]*ref.DevicePosition)
|
||||
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
|
||||
_, ok := p.Device.(*device.AxlePointDeviceModel)
|
||||
if ok && sectionModel.AxlePoints[p.Device.GetIndex()] != nil {
|
||||
axlePointPositionMap[p.Device.GetIndex()] = p
|
||||
}
|
||||
}
|
||||
// 如果已经找到计轴则退出
|
||||
if len(axlePointMap) > 0 {
|
||||
if len(axlePointPositionMap) > 0 {
|
||||
linkId = k
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(axlePointMap) == 0 { // 无计轴信息
|
||||
if len(axlePointPositionMap) == 0 { // 无计轴信息
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到区段【id:%s,index:%s】所在link", sectionModel.GraphicId, id)})
|
||||
}
|
||||
pointA := sectionModel.PortAxlePoints[face.A.Name()] // 获取A计轴点
|
||||
if pointA != nil {
|
||||
ap := axlePointMap[pointA.GetIndex()]
|
||||
ap := axlePointPositionMap[pointA.GetIndex()]
|
||||
if ap == nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("link【%d】缺失计轴【%s】", linkId, pointA.GetGraphicId())})
|
||||
}
|
||||
pointB := sectionModel.PortAxlePoints[face.B.Name()] // 获取B计轴点
|
||||
abDirection := pointB == nil
|
||||
p1, p2 := ap.Offset, int32(math.MaxInt32)
|
||||
if !abDirection && axlePointMap[pointB.GetIndex()] != nil {
|
||||
p2 = axlePointMap[pointB.GetIndex()].Offset
|
||||
ak := (pointA.(*device.AxlePointDeviceModel)).KilometerSystem // 获取a点公里标
|
||||
ao, bo := ap.Offset, int32(math.MaxInt32) // a,b的偏移量,默认B点比A点大
|
||||
var bp *ref.DevicePosition // 定义b点偏移对象
|
||||
var bk *graphicData.KilometerSystem // 定义b点公里标
|
||||
if !abDirection && axlePointPositionMap[pointB.GetIndex()] != nil {
|
||||
bp = axlePointPositionMap[pointB.GetIndex()]
|
||||
bo = bp.Offset
|
||||
bk = (pointB.(*device.AxlePointDeviceModel)).KilometerSystem
|
||||
}
|
||||
if p1 < p2 {
|
||||
return linkId, int64(p1) + offset
|
||||
if ao < bo {
|
||||
return linkId, int64(ao) + offset, convertRunDirectionToUp(ak, bk, ap, bp, runDirection)
|
||||
} else {
|
||||
return linkId, int64(p1) - offset
|
||||
return linkId, int64(ao) - offset, convertRunDirectionToUp(ak, bk, ap, bp, runDirection)
|
||||
}
|
||||
} else {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("link【%d】缺失区段【id:%s,index:%s】A点缺失计轴", linkId, sectionModel.GraphicId, id)})
|
||||
|
@ -168,7 +182,7 @@ func sectionMapToLink(vm *VerifyStructure, id string, offset int64) (int32, int6
|
|||
}
|
||||
|
||||
// 根据道岔上的偏移量(基于岔心位置),找到所在link的linkId与偏移量
|
||||
func turnoutMapToLink(vm *VerifyStructure, id string, port string, offset int64) (int32, int64) {
|
||||
func turnoutMapToLink(vm *VerifyStructure, id string, port string, offset int64, runDirection bool) (int32, int64, bool) {
|
||||
tm := vm.SwitchDeviceModelMap[id]
|
||||
if tm == nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", id)})
|
||||
|
@ -177,6 +191,7 @@ func turnoutMapToLink(vm *VerifyStructure, id string, port string, offset int64)
|
|||
var link *device.LinkModel
|
||||
var linkId int32
|
||||
var isStart bool
|
||||
Outter:
|
||||
for i, v := range vm.LinkModelMap {
|
||||
lm := v.(*device.LinkModel)
|
||||
linkId = i
|
||||
|
@ -185,32 +200,44 @@ func turnoutMapToLink(vm *VerifyStructure, id string, port string, offset int64)
|
|||
link = lm
|
||||
} else if lm.BRelatedSwitchRef.SwitchDevice.GetIndex() == turnoutModel.Index && lm.BRelatedSwitchRef.Port.Name() == port {
|
||||
link = lm
|
||||
break
|
||||
}
|
||||
if link != nil {
|
||||
break Outter
|
||||
}
|
||||
}
|
||||
if link == nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到道岔【id:%s,index:%s】端口【%s】所在link", turnoutModel.GraphicId, id, port)})
|
||||
}
|
||||
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
|
||||
}
|
||||
calcPositionArr := convertPositionToCalcPosition(link)
|
||||
var vp *calcLinkPositionStruct
|
||||
var index int
|
||||
for i, v := range calcPositionArr {
|
||||
if v.index == turnoutModel.GetIndex() {
|
||||
vp = v
|
||||
index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if vp != nil && len(calcPositionArr) > 1 {
|
||||
var np *calcLinkPositionStruct
|
||||
if index+1 < len(calcPositionArr) {
|
||||
np = calcPositionArr[index+1]
|
||||
} else {
|
||||
np = calcPositionArr[index-1]
|
||||
}
|
||||
up := convertRunDirectionToUp(vp.kilometer, np.kilometer, vp.position, np.position, runDirection)
|
||||
if isStart {
|
||||
return linkId, int64(vp.position.Offset) + offset, up
|
||||
} else {
|
||||
return linkId, int64(vp.position.Offset) - offset, up
|
||||
}
|
||||
}
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("link【%d】缺失道岔【id:%s,index:%s】端口【%s】偏移量", linkId, turnoutModel.GraphicId, id, port)})
|
||||
}
|
||||
|
||||
// 根据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) {
|
||||
// 设备ID、端口、偏移量、上下行
|
||||
func QueryDeviceByCalcLink(vm *VerifyStructure, id int32, offset int64, up, defaultRunDirection bool) (string, string, int64, bool) {
|
||||
lm := vm.LinkModelMap[id]
|
||||
if lm == nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到link【%d】", id)})
|
||||
|
@ -219,47 +246,83 @@ func QueryDeviceByCalcLink(vm *VerifyStructure, id int32, offset int64) (string,
|
|||
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) {
|
||||
calcPositionArr := convertPositionToCalcPosition(linkModel) // 转换位置对象
|
||||
var prevPosition, devicePosition, nextPosition *calcLinkPositionStruct // 获取上一个、当前、下一个节点
|
||||
for _, v := range calcPositionArr {
|
||||
if v.position.Offset > int32(offset) {
|
||||
nextPosition = v
|
||||
break
|
||||
} else {
|
||||
prevPosition = devicePosition
|
||||
devicePosition = v
|
||||
}
|
||||
}
|
||||
sectionModel, ok := linkOffsetQuerySection(vm, devicePosition)
|
||||
if ok {
|
||||
pointA := sectionModel.PortAxlePoints[face.A.Name()]
|
||||
if devicePosition.Device.GetIndex() == pointA.GetIndex() {
|
||||
return sectionModel.Index, "", offset - int64(devicePosition.Offset)
|
||||
// 偏移量增加
|
||||
var calcPosition *calcLinkPositionStruct
|
||||
if up {
|
||||
calcPosition = prevPosition
|
||||
} else { // 偏移量减小
|
||||
calcPosition = nextPosition
|
||||
}
|
||||
// 运行方向
|
||||
var runDirection bool
|
||||
if calcPosition != nil {
|
||||
runDirection = devicePosition.kilometer.Kilometer > calcPosition.kilometer.Kilometer
|
||||
} else {
|
||||
runDirection = defaultRunDirection
|
||||
}
|
||||
isSwitch := (devicePosition.deviceType == 2) // 道岔
|
||||
// 获取另一个端点
|
||||
if calcPosition != nil {
|
||||
isSwitch = isSwitch || calcPosition.deviceType == 2 // 道岔
|
||||
}
|
||||
if isSwitch {
|
||||
var sid string
|
||||
var op int64
|
||||
if devicePosition.deviceType == 2 {
|
||||
sid = devicePosition.index
|
||||
op = int64(devicePosition.position.Offset)
|
||||
|
||||
} else {
|
||||
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】A端计轴缺失", sectionModel.GraphicId)})
|
||||
sid = calcPosition.index
|
||||
op = int64(calcPosition.position.Offset)
|
||||
}
|
||||
tm := vm.SwitchDeviceModelMap[sid]
|
||||
if tm == nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", sid)})
|
||||
}
|
||||
if linkModel.ARelatedSwitchRef.SwitchDevice.GetIndex() == sid { // 起始点
|
||||
return sid, linkModel.ARelatedSwitchRef.Port.Name(), offset - op, runDirection
|
||||
} else if linkModel.BRelatedSwitchRef.SwitchDevice.GetIndex() == sid { // 结束点
|
||||
return sid, linkModel.BRelatedSwitchRef.Port.Name(), op - offset, runDirection
|
||||
} else {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", devicePosition.index)})
|
||||
}
|
||||
} else {
|
||||
tm := vm.SwitchDeviceModelMap[devicePosition.Device.GetIndex()]
|
||||
if tm == nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", devicePosition.Device.GetIndex())})
|
||||
}
|
||||
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
|
||||
sectionModel, ok := linkOffsetQuerySection(vm, devicePosition, calcPosition)
|
||||
if ok {
|
||||
pointA := sectionModel.PortAxlePoints[face.A.Name()]
|
||||
if devicePosition.index == pointA.GetIndex() {
|
||||
return sectionModel.Index, "", offset - int64(devicePosition.position.Offset), runDirection
|
||||
} else {
|
||||
for _, v := range calcPositionArr {
|
||||
if v.deviceType == 1 && v.index == pointA.GetIndex() { // 计轴
|
||||
return sectionModel.Index, "", int64(v.position.Offset) - offset, runDirection
|
||||
}
|
||||
}
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("区段【%s】A端计轴缺失", sectionModel.GraphicId)})
|
||||
}
|
||||
} else {
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", devicePosition.Device.GetIndex())})
|
||||
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到区段【index:%s-index:%s】", devicePosition.index, calcPosition.index)})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func linkOffsetQuerySection(vm *VerifyStructure, devicePosition *ref.DevicePosition) (*section.PhysicalSectionModel, bool) {
|
||||
func linkOffsetQuerySection(vm *VerifyStructure, devicePosition, calcPosition *calcLinkPositionStruct) (*section.PhysicalSectionModel, bool) {
|
||||
var sectionModel *section.PhysicalSectionModel
|
||||
for _, s := range vm.PhysicalSectionModelMap {
|
||||
sectionModel = s.(*section.PhysicalSectionModel)
|
||||
if sectionModel.AxlePoints[devicePosition.Device.GetIndex()] != nil {
|
||||
if sectionModel.AxlePoints[devicePosition.index] != nil && (calcPosition == nil || sectionModel.AxlePoints[calcPosition.index] != nil) {
|
||||
return sectionModel, true
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +430,7 @@ func initGraphicAxlePoints(axlePoints []*graphicData.AxleCounting, data *VerifyS
|
|||
GraphicId: a.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
KilometerSystem: *a.GetKilometerSystem(),
|
||||
KilometerSystem: a.GetKilometerSystem(),
|
||||
SwitchDevices: make(map[string]*ref.SwitchRef),
|
||||
AreaPhysicalSections: make(map[string]face.PhysicalSectionModeller),
|
||||
}
|
||||
|
@ -713,6 +776,9 @@ func buildAxlePointDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *
|
|||
Port: face.PortEnum(relatedRef.DevicePort),
|
||||
}
|
||||
case graphicData.RelatedRef_Section:
|
||||
if relatedRef.Id == "4" {
|
||||
fmt.Println("")
|
||||
}
|
||||
s := mapData.PhysicalSectionMap[relatedRef.Id]
|
||||
if s == nil {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点关联的物理区段[%s]不存在", id, relatedRef.Id)
|
||||
|
@ -743,3 +809,42 @@ func buildPhysicalAxlePointDeviceRef(verifyStructure *VerifyStructure) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将linkPosition转换为计算对象
|
||||
func convertPositionToCalcPosition(link *device.LinkModel) []*calcLinkPositionStruct {
|
||||
result := []*calcLinkPositionStruct{}
|
||||
for _, p := range link.DevicePositions {
|
||||
s, sok := p.Device.(*device.SwitchDeviceModel)
|
||||
if sok {
|
||||
result = append(result, &calcLinkPositionStruct{
|
||||
index: p.Device.GetIndex(),
|
||||
deviceType: 2,
|
||||
position: p,
|
||||
kilometer: s.KilometerSystems[0],
|
||||
})
|
||||
} else {
|
||||
a, aok := p.Device.(*device.AxlePointDeviceModel)
|
||||
if aok {
|
||||
result = append(result, &calcLinkPositionStruct{
|
||||
index: p.Device.GetIndex(),
|
||||
deviceType: 1,
|
||||
position: p,
|
||||
kilometer: a.KilometerSystem,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// 判断上下行与link方向是否一直
|
||||
func convertRunDirectionToUp(ak, bk *graphicData.KilometerSystem, ap, bp *ref.DevicePosition, direction bool) bool {
|
||||
if bk == nil {
|
||||
return direction
|
||||
}
|
||||
if (ak.Kilometer > bk.Kilometer) == (ap.Offset > bp.Offset) {
|
||||
return direction
|
||||
} else {
|
||||
return !direction
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@ func AddTrainState(simulation *VerifySimulation, status *state.TrainState) {
|
|||
status.Show = true
|
||||
//向动力学发送初始化请求
|
||||
trainIndex, _ := strconv.ParseUint(status.Id, 10, 16)
|
||||
linkId, loffset := QueryMapCalcLinkByDeviceInfo(simulation.MapId, status.Id, status.DevicePort, status.HeadOffset)
|
||||
// 映射link、偏移量、运行方向
|
||||
linkId, loffset, up := QueryMapCalcLinkByDeviceInfo(simulation.MapId, status.HeadDeviceId, status.DevicePort, status.HeadOffset, status.RunDirection)
|
||||
status.Up = up
|
||||
httpCode, _, err := dynamics.SendInitTrainReq(&dynamics.InitTrainInfo{
|
||||
TrainIndex: uint16(trainIndex),
|
||||
LinkIndex: uint16(linkId),
|
||||
|
@ -58,6 +60,8 @@ func UpdateTrainState(simulation *VerifySimulation, status *state.TrainState) {
|
|||
t.Up = status.Up
|
||||
t.Upslope = status.Upslope
|
||||
t.RunningUp = status.RunningUp
|
||||
t.RunDirection = status.RunDirection
|
||||
t.PointTo = status.PointTo
|
||||
// 合并其他信息
|
||||
proto.Merge(t, status)
|
||||
// 更新全量信息
|
||||
|
|
|
@ -11,7 +11,7 @@ type AxlePointDeviceModel struct {
|
|||
//计轴检测点基本信息
|
||||
face.DeviceModel
|
||||
//端点的公里标,单位为mm
|
||||
KilometerSystem graphicData.KilometerSystem
|
||||
KilometerSystem *graphicData.KilometerSystem
|
||||
//与该计轴点关联的道岔
|
||||
//key为图形id
|
||||
SwitchDevices map[string]*ref.SwitchRef
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5618f0586e6862a174579fd14151b46f45d14cb3
|
||||
Subproject commit ab41f6836f96e8a06ff6edfee202f0bf0c7aecf5
|
|
@ -21,7 +21,7 @@ type AddTrainReqDto struct {
|
|||
//仿真id
|
||||
SimulationId string `json:"simulationId" form:"simulationId"`
|
||||
//列车方向,true-上行,false-下行
|
||||
Up bool `json:"up" form:"up"`
|
||||
RunDirection bool `json:"up" form:"up"`
|
||||
//车头所在link的索引
|
||||
HeadLinkId string `json:"headLinkId" form:"headLinkId"`
|
||||
//车头所在link内的偏移量,单位为mm
|
||||
|
|
Loading…
Reference in New Issue