Compare commits

...

2 Commits

Author SHA1 Message Date
tiger_zhou
e0b0ae4566 列车pc仿真调整
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 1m43s
2024-04-13 09:40:25 +08:00
43022220a0 233发布docker运行暴露4000端口 2024-04-11 10:32:08 +08:00
19 changed files with 334 additions and 215 deletions

View File

@ -51,7 +51,7 @@ jobs:
script: |
docker rm -f rts-sim-testing-service || echo "rts-sim-testing-service not exist"
docker pull gitea.joylink.club/joylink/rts-sim-testing-service:local-test
docker run --name rts-sim-testing-service --restart=always --network net --ip 192.168.53.191 -d -p 9091:9091 -v /usr/local/joylink/logs/bjrtsts:/logs/bjrtsts gitea.joylink.club/joylink/rts-sim-testing-service:local-test rts-sim-testing-service -config test_local
docker run --name rts-sim-testing-service --restart=always --network net --ip 192.168.53.191 -d -p 9091:9091 -p 4000:4000 -v /usr/local/joylink/logs/bjrtsts:/logs/bjrtsts gitea.joylink.club/joylink/rts-sim-testing-service:local-test rts-sim-testing-service -config test_local
- name: 清理tag为none的镜像
run: |
docker rmi $(docker images --filter "dangling=true" -q)

View File

@ -63,7 +63,8 @@ type TrainDynamicConfig struct {
// 过标/欠标mm正数过标负数欠标
StopSign int32 `protobuf:"varint,17,opt,name=stopSign,proto3" json:"stopSign,omitempty"`
// 前溜/后溜m/s默认0
Slide float32 `protobuf:"fixed32,18,opt,name=slide,proto3" json:"slide,omitempty"`
Slide float32 `protobuf:"fixed32,18,opt,name=slide,proto3" json:"slide,omitempty"`
TrainLoad int32 `protobuf:"varint,19,opt,name=trainLoad,proto3" json:"trainLoad,omitempty"` //列车载荷
}
func (x *TrainDynamicConfig) Reset() {
@ -217,6 +218,13 @@ func (x *TrainDynamicConfig) GetSlide() float32 {
return 0
}
func (x *TrainDynamicConfig) GetTrainLoad() int32 {
if x != nil {
return x.TrainLoad
}
return 0
}
// 列车一端的状态
type TrainEndsState struct {
state protoimpl.MessageState
@ -350,7 +358,7 @@ var File_common_data_proto protoreflect.FileDescriptor
var file_common_data_proto_rawDesc = []byte{
0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22, 0xe0, 0x04, 0x0a, 0x12,
0x6f, 0x74, 0x6f, 0x12, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22, 0xfe, 0x04, 0x0a, 0x12,
0x54, 0x72, 0x61, 0x69, 0x6e, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x61, 0x76, 0x69, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x41, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0b, 0x64, 0x61, 0x76, 0x69, 0x73, 0x50, 0x61,
@ -388,37 +396,39 @@ var file_common_data_proto_rawDesc = []byte{
0x01, 0x28, 0x05, 0x52, 0x07, 0x69, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x44, 0x12, 0x1a, 0x0a, 0x08,
0x73, 0x74, 0x6f, 0x70, 0x53, 0x69, 0x67, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
0x73, 0x74, 0x6f, 0x70, 0x53, 0x69, 0x67, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x6c, 0x69, 0x64,
0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x73, 0x6c, 0x69, 0x64, 0x65, 0x22, 0xa4,
0x03, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x45, 0x6e, 0x64, 0x73, 0x53, 0x74, 0x61, 0x74,
0x65, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72,
0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x73,
0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x41, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72,
0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x42, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x73,
0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x42, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x61, 0x64, 0x61, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x72, 0x61, 0x64, 0x61, 0x72, 0x45, 0x6e, 0x61,
0x62, 0x6c, 0x65, 0x12, 0x30, 0x0a, 0x13, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63,
0x6b, 0x53, 0x70, 0x65, 0x65, 0x64, 0x44, 0x69, 0x66, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02,
0x52, 0x13, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x70, 0x65, 0x65,
0x64, 0x44, 0x69, 0x66, 0x66, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x72,
0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a,
0x09, 0x61, 0x63, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08,
0x52, 0x09, 0x61, 0x63, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x11, 0x61,
0x63, 0x63, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x70, 0x65, 0x65, 0x64, 0x44, 0x69, 0x66, 0x66,
0x18, 0x07, 0x20, 0x01, 0x28, 0x02, 0x52, 0x11, 0x61, 0x63, 0x63, 0x43, 0x68, 0x65, 0x63, 0x6b,
0x53, 0x70, 0x65, 0x65, 0x64, 0x44, 0x69, 0x66, 0x66, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x63, 0x63,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52,
0x0c, 0x61, 0x63, 0x63, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a,
0x0b, 0x61, 0x63, 0x63, 0x4f, 0x75, 0x74, 0x53, 0x70, 0x65, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01,
0x28, 0x05, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x4f, 0x75, 0x74, 0x53, 0x70, 0x65, 0x65, 0x64, 0x12,
0x24, 0x0a, 0x0d, 0x72, 0x61, 0x64, 0x61, 0x72, 0x4f, 0x75, 0x74, 0x53, 0x70, 0x65, 0x65, 0x64,
0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x61, 0x64, 0x61, 0x72, 0x4f, 0x75, 0x74,
0x53, 0x70, 0x65, 0x65, 0x64, 0x42, 0x2f, 0x5a, 0x2d, 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, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x73, 0x6c, 0x69, 0x64, 0x65, 0x12, 0x1c,
0x0a, 0x09, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x4c, 0x6f, 0x61, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28,
0x05, 0x52, 0x09, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x4c, 0x6f, 0x61, 0x64, 0x22, 0xa4, 0x03, 0x0a,
0x0e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x45, 0x6e, 0x64, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12,
0x2e, 0x0a, 0x12, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e,
0x61, 0x62, 0x6c, 0x65, 0x41, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x73, 0x70, 0x65,
0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x12,
0x2e, 0x0a, 0x12, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e,
0x61, 0x62, 0x6c, 0x65, 0x42, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x73, 0x70, 0x65,
0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x42, 0x12,
0x20, 0x0a, 0x0b, 0x72, 0x61, 0x64, 0x61, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x72, 0x61, 0x64, 0x61, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c,
0x65, 0x12, 0x30, 0x0a, 0x13, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53,
0x70, 0x65, 0x65, 0x64, 0x44, 0x69, 0x66, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x13,
0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x70, 0x65, 0x65, 0x64, 0x44,
0x69, 0x66, 0x66, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63,
0x6b, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x72, 0x61, 0x64,
0x61, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61,
0x63, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09,
0x61, 0x63, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x11, 0x61, 0x63, 0x63,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x70, 0x65, 0x65, 0x64, 0x44, 0x69, 0x66, 0x66, 0x18, 0x07,
0x20, 0x01, 0x28, 0x02, 0x52, 0x11, 0x61, 0x63, 0x63, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x70,
0x65, 0x65, 0x64, 0x44, 0x69, 0x66, 0x66, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x61,
0x63, 0x63, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x61,
0x63, 0x63, 0x4f, 0x75, 0x74, 0x53, 0x70, 0x65, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05,
0x52, 0x0b, 0x61, 0x63, 0x63, 0x4f, 0x75, 0x74, 0x53, 0x70, 0x65, 0x65, 0x64, 0x12, 0x24, 0x0a,
0x0d, 0x72, 0x61, 0x64, 0x61, 0x72, 0x4f, 0x75, 0x74, 0x53, 0x70, 0x65, 0x65, 0x64, 0x18, 0x0a,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x61, 0x64, 0x61, 0x72, 0x4f, 0x75, 0x74, 0x53, 0x70,
0x65, 0x65, 0x64, 0x42, 0x2f, 0x5a, 0x2d, 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, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -123,12 +123,12 @@ type ConfigTrainData struct {
SlipR float32 `json:"slipR"` // 打滑冲击率(m/s) 默认0
SlipD int32 `json:"slipD"` // 打滑持续时间ms 默认0
Slide float32 `json:"slide"` // 前溜/后溜m/s正数前溜负数后溜默认值0
StopSign int32 `json:"stopSign"` // 过标/欠标mm正数过标负数欠标
IdlingA float32 `json:"idlingA"` // 空转加速度(m/s) 默认0
IdlingR float32 `json:"idlingR"` // 空转冲击率(m/s) 默认0
IdlingD int32 `json:"idlingD"` // 空转持续时间s 默认0
Slide float32 `json:"slide"` // 前溜/后溜m/s正数前溜负数后溜默认值0
StopSign int32 `json:"stopSign"` // 过标/欠标mm正数过标负数欠标
IdlingA float32 `json:"idlingA"` // 空转加速度(m/s) 默认0
IdlingR float32 `json:"idlingR"` // 空转冲击率(m/s) 默认0
IdlingD int32 `json:"idlingD"` // 空转持续时间s 默认0
TrainLoad int32 `json:"trainLoad"` // 列车载重 默认 16000
//TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
//TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
}

View File

@ -261,6 +261,8 @@ const (
SimulationThirdPartyApiService_Dynamics SimulationThirdPartyApiService_Type = 1
// 与半实物列车接口服务
SimulationThirdPartyApiService_SemiPhysicalTrain SimulationThirdPartyApiService_Type = 2
// 列车pc仿真
SimulationThirdPartyApiService_Train_pc_sim SimulationThirdPartyApiService_Type = 3
)
// Enum value maps for SimulationThirdPartyApiService_Type.
@ -269,11 +271,13 @@ var (
0: "Undefined",
1: "Dynamics",
2: "SemiPhysicalTrain",
3: "Train_pc_sim",
}
SimulationThirdPartyApiService_Type_value = map[string]int32{
"Undefined": 0,
"Dynamics": 1,
"SemiPhysicalTrain": 2,
"Train_pc_sim": 3,
}
)
@ -5903,73 +5907,74 @@ var file_device_state_proto_rawDesc = []byte{
0x74, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07,
0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x61, 0x75,
0x73, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x03, 0x12,
0x0b, 0x0a, 0x07, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x10, 0x04, 0x22, 0xc0, 0x01, 0x0a,
0x0b, 0x0a, 0x07, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x10, 0x04, 0x22, 0xd2, 0x01, 0x0a,
0x1e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x68, 0x69, 0x72, 0x64,
0x50, 0x61, 0x72, 0x74, 0x79, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
0x42, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x2a, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x54, 0x68, 0x69, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x79, 0x41, 0x70, 0x69, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x06, 0x73, 0x74, 0x61,
0x74, 0x65, 0x73, 0x22, 0x3a, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x55,
0x74, 0x65, 0x73, 0x22, 0x4c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x55,
0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x79,
0x6e, 0x61, 0x6d, 0x69, 0x63, 0x73, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x65, 0x6d, 0x69,
0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x10, 0x02, 0x22,
0x1e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x6f, 0x72, 0x6d,
0x61, 0x6c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x22,
0xa8, 0x01, 0x0a, 0x23, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x68,
0x69, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x79, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3e, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69,
0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x68, 0x69, 0x72, 0x64, 0x50, 0x61, 0x72,
0x74, 0x79, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x79, 0x70,
0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x41, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53,
0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x68, 0x69, 0x72, 0x64, 0x50, 0x61,
0x72, 0x74, 0x79, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x74,
0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x83, 0x04, 0x0a, 0x11, 0x54,
0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65,
0x12, 0x41, 0x0a, 0x07, 0x65, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x27, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43,
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x45, 0x6d, 0x65, 0x72,
0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x62, 0x75, 0x74,
0x74, 0x6f, 0x6e, 0x12, 0x46, 0x0a, 0x09, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b, 0x65, 0x79,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54,
0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65,
0x2e, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68,
0x52, 0x09, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x12, 0x43, 0x0a, 0x06, 0x64,
0x69, 0x72, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x73, 0x74,
0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4b,
0x65, 0x79, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x52, 0x06, 0x64, 0x69, 0x72, 0x4b, 0x65, 0x79,
0x12, 0x46, 0x0a, 0x0b, 0x70, 0x75, 0x73, 0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x18,
0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72,
0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e,
0x50, 0x75, 0x73, 0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x0b, 0x70, 0x75, 0x73,
0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x1a, 0x38, 0x0a, 0x0e, 0x45, 0x6d, 0x65, 0x72,
0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61,
0x73, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x61, 0x73, 0x73,
0x65, 0x64, 0x1a, 0x33, 0x0a, 0x0f, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x53,
0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x1a, 0x36, 0x0a, 0x12, 0x44, 0x69, 0x72, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a,
0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x1a,
0x2f, 0x0a, 0x0b, 0x50, 0x75, 0x73, 0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10,
0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x61, 0x6c,
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, 0x67, 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, 0x2c, 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, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x10, 0x02, 0x12,
0x10, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x70, 0x63, 0x5f, 0x73, 0x69, 0x6d, 0x10,
0x03, 0x22, 0x1e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x6f,
0x72, 0x6d, 0x61, 0x6c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10,
0x01, 0x22, 0xa8, 0x01, 0x0a, 0x23, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x54, 0x68, 0x69, 0x72, 0x64, 0x50, 0x61, 0x72, 0x74, 0x79, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3e, 0x0a, 0x04, 0x74, 0x79, 0x70,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e,
0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x68, 0x69, 0x72, 0x64, 0x50,
0x61, 0x72, 0x74, 0x79, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54,
0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x41, 0x0a, 0x05, 0x73, 0x74, 0x61,
0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65,
0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x68, 0x69, 0x72, 0x64,
0x50, 0x61, 0x72, 0x74, 0x79, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e,
0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x83, 0x04, 0x0a,
0x11, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61,
0x74, 0x65, 0x12, 0x41, 0x0a, 0x07, 0x65, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69,
0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x45, 0x6d,
0x65, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x62,
0x75, 0x74, 0x74, 0x6f, 0x6e, 0x12, 0x46, 0x0a, 0x09, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b,
0x65, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65,
0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61,
0x74, 0x65, 0x2e, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x53, 0x77, 0x69, 0x74,
0x63, 0x68, 0x52, 0x09, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x12, 0x43, 0x0a,
0x06, 0x64, 0x69, 0x72, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e,
0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72,
0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x4b, 0x65, 0x79, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x52, 0x06, 0x64, 0x69, 0x72, 0x4b,
0x65, 0x79, 0x12, 0x46, 0x0a, 0x0b, 0x70, 0x75, 0x73, 0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65,
0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e,
0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74,
0x65, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x0b, 0x70,
0x75, 0x73, 0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x1a, 0x38, 0x0a, 0x0e, 0x45, 0x6d,
0x65, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06,
0x70, 0x61, 0x73, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x61,
0x73, 0x73, 0x65, 0x64, 0x1a, 0x33, 0x0a, 0x0f, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, 0x4b, 0x65,
0x79, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02,
0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x1a, 0x36, 0x0a, 0x12, 0x44, 0x69, 0x72,
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12,
0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12,
0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x76, 0x61,
0x6c, 0x1a, 0x2f, 0x0a, 0x0b, 0x50, 0x75, 0x73, 0x68, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72,
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64,
0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76,
0x61, 0x6c, 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, 0x67, 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, 0x2c, 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, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -45,6 +45,7 @@ func TrainConfigToDtoConvert(dc *common_proto.TrainDynamicConfig) *ConfigTrainDa
CurveResistanceParamR1: dc.CurveResistanceParamR1, CurveResistanceParamR2: dc.CurveResistanceParamR2, CurveResistanceParamR3: dc.CurveResistanceParamR3,
CurveResistanceParamR4: dc.CurveResistanceParamR4, RevolvingMassParam: dc.RevolvingMassParam,
Jump: dc.Jump, SlipA: dc.SlipA, SlipR: dc.SlipR, SlipD: dc.SlipD, Slide: dc.Slide, IdlingA: dc.IdlingA, IdlingR: dc.IdlingR, IdlingD: dc.IdlingD, StopSign: dc.StopSign,
TrainLoad: dc.TrainLoad,
}
}
return nil

View File

@ -547,7 +547,10 @@ func setVal(source, dest interface{}, fieldName string) {
debug.PrintStack()
}
}()
if destVal.Kind() == reflect.Invalid {
slog.Warn(fieldName, "赋值失败,源数据类型", sourceType.Kind().String(), "目标数据类型:", destVal.Kind().String())
return
}
if destVal.Kind() == reflect.String {
destVal.Set(reflect.ValueOf(fmt.Sprintf("%v", sourceData)))
} else {

@ -1 +1 @@
Subproject commit 7d576a6c69ccbcdcdf14219f992602ccf0b1b30f
Subproject commit df112c429875bb39908c0a387f49ef095c82fabe

View File

@ -72,7 +72,7 @@ func TrainConfigToProtoConvert(t *dto.ConfigTrainData) *common_proto.TrainDynami
DavisParamA: t.DavisParamA, DavisParamB: t.DavisParamB, DavisParamC: t.DavisParamC,
CurveResistanceParamR1: t.CurveResistanceParamR1, CurveResistanceParamR2: t.CurveResistanceParamR2, CurveResistanceParamR3: t.CurveResistanceParamR3, CurveResistanceParamR4: t.CurveResistanceParamR4,
RevolvingMassParam: t.RevolvingMassParam, Jump: t.Jump, SlipA: t.SlipA, SlipR: t.SlipR, SlipD: t.SlipD, IdlingA: t.IdlingA, IdlingR: t.IdlingR, IdlingD: t.IdlingD,
Slide: t.Slide, StopSign: t.StopSign,
Slide: t.Slide, StopSign: t.StopSign, TrainLoad: t.TrainLoad,
}
}

View File

@ -20,6 +20,8 @@ import (
type DynamicsMessageManager interface {
CollectDynamicsTurnoutInfo() *message.DynamicsTurnoutInfo
CollectTrainControlState() []message.TrainControlMsg
HandleDynamicsTrainInfo(info *message.DynamicsTrainInfo)
GetDynamicsRunConfig() *config.DynamicsConfig
GetDynamicsRunRepository() *message.LineBaseInfo
@ -303,10 +305,32 @@ func (d *dynamics) Stop() {
const (
// 道岔消息发送间隔,单位ms
TurnoutMessageSendInterval = 50
TurnoutMessageSendInterval = 50
TrainControlMessageSendInterval = 15
)
var turnoutStateLifeSignal uint16 //道岔消息生命信号
// 定时发送列车控制状态
func (d *dynamics) sendTrainControlStateTask(ctx context.Context) {
defer func() {
if err := recover(); err != nil {
slog.Error("定时发送列车控制状态任务异常", "error", err, "stack", string(debug.Stack()))
debug.PrintStack()
}
}()
for {
select {
case <-ctx.Done():
return
default:
}
tccs := d.manager.CollectTrainControlState()
for _, tcc := range tccs {
d.SendTrainControl(&tcc)
}
time.Sleep(time.Millisecond * TrainControlMessageSendInterval)
}
}
// 定时发送道岔状态任务
func (d *dynamics) sendTurnoutStateTask(ctx context.Context) {

View File

@ -2,6 +2,7 @@ package message
import (
"encoding/binary"
"fmt"
"joylink.club/bj-rtsts-server/dto/state_proto"
"math"
"strconv"
@ -12,12 +13,27 @@ import (
type TrainControlMsg struct {
ControlInfo *state_proto.TrainVobcState
TrainId string
FromVobc bool
}
func boolsToByte2(flags [8]bool) byte {
var result uint8
for index, b := range flags {
if b {
result = result + (1 << index)
}
}
return result
}
func (r *TrainControlMsg) Encode() []byte {
if !r.FromVobc {
ls := r.ControlInfo.LifeSignal
r.ControlInfo.LifeSignal = ls + 1
}
data := make([]byte, 0)
data = binary.BigEndian.AppendUint16(data, uint16(r.ControlInfo.LifeSignal))
var b2 byte
var b2 uint8
b2 = setBit(b2, 0, IsTrue(r.ControlInfo.Tc1Active))
b2 = setBit(b2, 1, IsTrue(r.ControlInfo.Tc2Active))
b2 = setBit(b2, 2, IsTrue(r.ControlInfo.DirectionForward))
@ -26,7 +42,8 @@ func (r *TrainControlMsg) Encode() []byte {
b2 = setBit(b2, 5, IsTrue(r.ControlInfo.BrakingStatus))
b2 = setBit(b2, 6, IsTrue(r.ControlInfo.EmergencyBrakingStatus))
b2 = setBit(b2, 7, IsTrue(r.ControlInfo.TurnbackStatus))
var b3 byte
fmt.Println(fmt.Sprintf("%b", b2))
var b3 uint8
b3 = setBit(b3, 0, IsTrue(r.ControlInfo.JumpStatus))
b3 = setBit(b3, 1, IsTrue(r.ControlInfo.Ato))
b3 = setBit(b3, 2, IsTrue(r.ControlInfo.Fam))
@ -34,6 +51,7 @@ func (r *TrainControlMsg) Encode() []byte {
b3 = setBit(b3, 4, IsTrue(r.ControlInfo.TractionSafetyCircuit))
b3 = setBit(b3, 5, IsTrue(r.ControlInfo.ParkingBrakeStatus))
b3 = setBit(b3, 6, IsTrue(r.ControlInfo.MaintainBrakeStatus))
b3 = setBit(b3, 7, IsTrue(true))
data = append(data, b2)
data = append(data, b3)
data = binary.BigEndian.AppendUint16(data, uint16(r.ControlInfo.TractionForce))
@ -41,18 +59,20 @@ func (r *TrainControlMsg) Encode() []byte {
data = binary.BigEndian.AppendUint16(data, uint16(r.ControlInfo.TrainLoad))
data = binary.BigEndian.AppendUint16(data, uint16(0)) //预留
data = binary.BigEndian.AppendUint16(data, uint16(0)) //预留
data = append(data, 0) //预留
data = append(data, uint8(0)) //预留
var b4 byte
b4 = setBit(b4, 0, IsTrue(r.ControlInfo.LeftDoorOpenCommand))
b4 = setBit(b4, 1, IsTrue(r.ControlInfo.RightDoorOpenCommand))
b4 = setBit(b4, 2, IsTrue(r.ControlInfo.LeftDoorCloseCommand))
b4 = setBit(b4, 3, IsTrue(r.ControlInfo.RightDoorCloseCommand))
b4 = setBit(b4, 4, IsTrue(r.ControlInfo.AllDoorClose))
b4 = setBit(b4, 5, IsTrue(false))
b4 = setBit(b4, 6, IsTrue(false))
b4 = setBit(b4, 7, IsTrue(false))
data = append(data, b4)
data = binary.BigEndian.AppendUint16(data, uint16(0)) //预留
data = append(data, 0) //预留
data = append(data, 0) //预留
data = binary.BigEndian.AppendUint16(data, 0) //预留
data = append(data, uint8(0)) //预留
data = append(data, uint8(0)) //预留
ti, _ := strconv.Atoi(r.TrainId)
data = append(data, byte(ti))
return data

View File

@ -1,6 +1,7 @@
package tcp
import (
"context"
"fmt"
"io"
"log/slog"
@ -10,41 +11,50 @@ import (
type TcpClient struct {
conn *net.TCPConn
handler func(n int, data []byte)
ctx context.CancelFunc
}
func StartTcpClient(rAddr string, handler func(n int, data []byte)) (*TcpClient, error) {
func StartTcpClient(rAddr string, handler func(n int, data []byte), readErr func(err error)) (*TcpClient, error) {
raddr, addErr := net.ResolveTCPAddr("tcp", rAddr)
if addErr != nil {
return nil, addErr
}
conn, err := net.DialTCP("tcp", nil, raddr)
ctx, ctxFun := context.WithCancel(context.Background())
if err != nil {
return nil, err
}
go func() {
for {
select {
case <-ctx.Done():
return
default:
}
data := make([]byte, 1024)
l, err := conn.Read(data)
if err != nil {
if opErr, ok := err.(*net.OpError); ok {
slog.Error(fmt.Sprintf("TCP客户端[rAddr:%s]读取数据异常:", rAddr), opErr)
readErr(err)
}
if err == io.EOF {
slog.Warn(fmt.Sprintf("TCP客户端[rAddr:%s]断开连接:", rAddr))
break
}
slog.Error(fmt.Sprintf("TCP客户端[rAddr:%s]读取数据异常:", rAddr), err)
}
handler(l, data)
}
}()
return &TcpClient{conn: conn}, nil
return &TcpClient{conn: conn, ctx: ctxFun}, nil
}
func (c *TcpClient) Close() {
if c.conn != nil {
slog.Info(fmt.Sprintf("TCP客户端[rAddr:%s]关闭连接", c.conn.RemoteAddr().String()))
c.ctx()
c.conn.Close()
c.conn = nil
slog.Info(fmt.Sprintf("TCP客户端[rAddr:%s]关闭连接", c.conn.RemoteAddr().String()))
} else {
slog.Info(fmt.Sprintf("TCP客户端[rAddr:%s]未连接", c.conn.RemoteAddr().String()))
}
}
func (c *TcpClient) Send(data []byte) error {

View File

@ -1,6 +1,7 @@
package third_party
import (
"joylink.club/bj-rtsts-server/third_party/train_pc_sim"
"log/slog"
"joylink.club/bj-rtsts-server/dto/state_proto"
@ -15,6 +16,7 @@ func Init() {
tpapiService = append(
tpapiService, dynamics.Default(),
semi_physical_train.Default(),
train_pc_sim.Default(),
)
}
@ -28,6 +30,8 @@ func convertServiceName(name string) state_proto.SimulationThirdPartyApiService_
return state_proto.SimulationThirdPartyApiService_Dynamics
case semi_physical_train.Name:
return state_proto.SimulationThirdPartyApiService_SemiPhysicalTrain
case train_pc_sim.Name:
return state_proto.SimulationThirdPartyApiService_Train_pc_sim
default:
return state_proto.SimulationThirdPartyApiService_Undefined
}
@ -52,6 +56,7 @@ func GetRunningServiceStates() *state_proto.SimulationThirdPartyApiService {
Type: t,
State: state_proto.SimulationThirdPartyApiService_Error,
})
}
}
return ss

View File

@ -36,7 +36,9 @@ func tcpRunReadTask(conn net.Conn, port int, msgHandler TcpMsgHandler) {
defer func() {
if err := recover(); err != nil {
slog.Error(fmt.Sprintf("TCP服务端[port:%d]读数据任务异常:", port), err)
tcpRunReadTask(conn, port, msgHandler)
serConn.Close()
serConn = nil
}
}()
for {
@ -48,7 +50,7 @@ func tcpRunReadTask(conn net.Conn, port int, msgHandler TcpMsgHandler) {
break
}
slog.Error(fmt.Sprintf("TCP服务端[port:%d]读取[%s]数据出错:", port, conn.RemoteAddr().String()), err)
serConn = nil
}
msgHandler(l, data)
}

View File

@ -7,6 +7,7 @@ import (
"joylink.club/bj-rtsts-server/dto/state_proto"
"joylink.club/bj-rtsts-server/third_party/message"
"joylink.club/bj-rtsts-server/third_party/tcp"
"joylink.club/bj-rtsts-server/third_party/tpapi"
"joylink.club/ecs"
"log/slog"
"sync"
@ -33,6 +34,9 @@ type TrainPcSim interface {
PublishTrainControlEvent(world ecs.World, events []TrainControlEvent)
CreateOrRemoveSpeedPLace(train *state_proto.TrainState)
CreateOrRemoveTrain(msgType byte, data []byte)
tpapi.ThirdPartyApiService
}
type TrainPcSimManage interface {
@ -42,16 +46,27 @@ type TrainPcSimManage interface {
TrainPcSimDigitalOutInfoHandle(data []byte)
//4.4.2. 车载输出数字反馈量信息报文内容
TrainPcSimDigitalReportHandle(data []byte)
//创建/删除列车
TrainPcSimConnOrRemoveHandle(state byte)
//门模式
TrainDoorModeHandle(state byte)
//TrainDoorModeHandle(state byte)
//处理列车pc仿真模拟量数据
TrainPcSimMockInfo(data []byte)
//处理列车btm查询
TrainBtmQuery(data []byte)
}
const Name = "车载pc仿真"
func (d *trainPcSimService) Name() string {
return Name
}
func (d *trainPcSimService) State() tpapi.ThirdPartyApiServiceState {
return d.state
}
func (d *trainPcSimService) updateState(state tpapi.ThirdPartyApiServiceState) {
d.state = state
}
var (
initLock = &sync.Mutex{}
singleObj *trainPcSimService
@ -67,83 +82,98 @@ func Default() TrainPcSim {
}
type trainPcSimService struct {
state tpapi.ThirdPartyApiServiceState
pcSimClient *tcp.TcpClient
cancleContext context.CancelFunc
trainPcSimManage TrainPcSimManage
speedPlace *message.TrainSpeedPlaceReportMsg
}
func (pc *trainPcSimService) Start(wd ecs.World, pcSimManage TrainPcSimManage) {
// 接受来自pc仿真的消息
func (d *trainPcSimService) readError(err error) {
slog.Error("连接车载pc仿真tcp服务断开", err)
d.updateState(tpapi.ThirdPartyState_Broken)
d.pcSimClient.Close()
}
func (d *trainPcSimService) Start(wd ecs.World, pcSimManage TrainPcSimManage) {
config := pcSimManage.GetTrainPcSimConfig()
if config.PcSimIp == "" || !config.Open {
slog.Info("车载pc仿真配置未开启")
return
}
client, err := tcp.StartTcpClient(fmt.Sprintf("%v:%v", config.PcSimIp, config.PcSimPort), pc.reivceData)
client, err := tcp.StartTcpClient(fmt.Sprintf("%v:%v", config.PcSimIp, config.PcSimPort), d.reivceData, d.readError)
if err != nil {
slog.Error("连接车载pc平台失败", err)
d.updateState(tpapi.ThirdPartyState_Broken)
return
}
pc.pcSimClient = client
d.pcSimClient = client
ctx, ctxFun := context.WithCancel(context.Background())
pc.cancleContext = ctxFun
pc.trainPcSimManage = pcSimManage
d.cancleContext = ctxFun
d.trainPcSimManage = pcSimManage
FireTrainControlEventType.Subscribe(wd, pc.trainControlEventHandle)
FireTrainControlEventType.Subscribe(wd, d.trainControlEventHandle)
d.updateState(tpapi.ThirdPartyState_Normal)
go d.sendTrainLocationAndSpeedTask(ctx)
go pc.sendTrainLocationAndSpeedTask(ctx)
}
func (pc *trainPcSimService) Stop() {
if pc.cancleContext != nil {
pc.cancleContext()
pc.cancleContext = nil
}
if pc.pcSimClient != nil {
pc.pcSimClient.Close()
func (d *trainPcSimService) Stop() {
d.updateState(tpapi.ThirdPartyState_Closed)
if d.cancleContext != nil {
d.cancleContext()
d.cancleContext = nil
}
if d.pcSimClient != nil {
//d.pcSimClient.
d.pcSimClient.Close()
}
}
func (pc *trainPcSimService) CreateOrRemoveSpeedPLace(train *state_proto.TrainState) {
func (d *trainPcSimService) CreateOrRemoveSpeedPLace(train *state_proto.TrainState) {
if train.ConnState.Conn {
train.PluseCount = &state_proto.SensorSpeedPulseCount{}
pc.speedPlace = &message.TrainSpeedPlaceReportMsg{TrainId: train.Id}
d.speedPlace = &message.TrainSpeedPlaceReportMsg{TrainId: train.Id}
} else {
train.PluseCount = nil
pc.speedPlace = nil
d.speedPlace = nil
}
}
func (d *trainPcSimService) CreateOrRemoveTrain(msgType byte, data []byte) {
msg := &message.TrainPcSimBaseMessage{Data: data, Type: uint16(msgType)}
d.pcSimClient.Send(msg.Encode())
}
// 依据文档80ms发送列车速度位置
func (pc *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
default:
}
train := pc.trainPcSimManage.GetConnTrain()
train := d.trainPcSimManage.GetConnTrain()
if train != nil && train.ConnState.Conn {
s1, s2 := train.PluseCount.PulseCount1, train.PluseCount.PulseCount2
pc.speedPlace.ParsePulseCount1(s1, s2)
data := pc.speedPlace.Encode(train.RunDirection, s1, s2)
d.speedPlace.ParsePulseCount1(s1, s2)
data := d.speedPlace.Encode(train.RunDirection, s1, s2)
bm := &message.TrainPcSimBaseMessage{Type: SENDER_TRAIN_LOCATION_INFO, Data: data}
train.PluseCount.PulseCount1 = 0
train.PluseCount.PulseCount2 = 0
pc.pcSimClient.Send(bm.Encode())
} else {
d.pcSimClient.Send(bm.Encode())
} /*else {
m1 := "未找到对应连接车载pc仿真的列车"
if train != nil {
m1 = fmt.Sprintf("对应的列车没有连接上车载pc仿真列车ID%v", train.Id)
}
slog.Info(m1)
}
}*/
time.Sleep(time.Millisecond * 80)
}
}
// 发送驾驶激活
func (pc *trainPcSimService) SendDriverActive(tc *state_proto.TrainConnState, vobc *state_proto.TrainVobcState) {
func (d *trainPcSimService) SendDriverActive(tc *state_proto.TrainConnState, vobc *state_proto.TrainVobcState) {
if tc.Conn && tc.ConnType == state_proto.TrainConnState_PC_SIM {
defulatBuf := make([]byte, 0)
msg := &message.TrainPcSimBaseMessage{Data: defulatBuf}
@ -152,10 +182,10 @@ func (pc *trainPcSimService) SendDriverActive(tc *state_proto.TrainConnState, vo
} else if vobc.Tc1Active == false && vobc.Tc2Active == false {
msg.Type = SENDER_TRAIN_TC_NOT_ACTIVE
}
pc.pcSimClient.Send(msg.Encode())
d.pcSimClient.Send(msg.Encode())
}
}
func (pc *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, tc *state_proto.TrainConnState, vobc *state_proto.TrainVobcState) {
func (d *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, tc *state_proto.TrainConnState, vobc *state_proto.TrainVobcState) {
if tc.Conn && tc.ConnType == state_proto.TrainConnState_PC_SIM {
msg := &message.TrainPcSimBaseMessage{}
newTraction := vobc.TractionForce
@ -176,26 +206,26 @@ func (pc *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64,
slog.Error("")
return
}
pc.pcSimClient.Send(msg.Encode())
d.pcSimClient.Send(msg.Encode())
}
}
func (pc *trainPcSimService) SendBaliseData(msgType uint16, data []byte) {
func (d *trainPcSimService) SendBaliseData(msgType uint16, data []byte) {
msg := &message.TrainPcSimBaseMessage{}
msg.Type = msgType
msg.Data = data
pc.pcSimClient.Send(msg.Encode())
d.pcSimClient.Send(msg.Encode())
}
func (pc *trainPcSimService) trainControlEventHandle(w ecs.World, event TrainControlEvent) {
func (d *trainPcSimService) trainControlEventHandle(w ecs.World, event TrainControlEvent) {
fmt.Println(event.Status)
msg := &message.TrainPcSimBaseMessage{}
msg.Type = SENDER_TRAIN_OUTR_INFO
data := []byte{event.Command, event.Status}
msg.Data = data
pc.pcSimClient.Send(msg.Encode())
d.pcSimClient.Send(msg.Encode())
}
func (pc *trainPcSimService) PublishTrainControlEvent(world ecs.World, events []TrainControlEvent) {
func (d *trainPcSimService) PublishTrainControlEvent(world ecs.World, events []TrainControlEvent) {
if len(events) <= 0 {
slog.Warn("发布事件数量为空")
return
@ -206,7 +236,7 @@ func (pc *trainPcSimService) PublishTrainControlEvent(world ecs.World, events []
}
// 接受来自pc仿真的消息
func (pc *trainPcSimService) reivceData(len int, data []byte) {
func (d *trainPcSimService) reivceData(len int, data []byte) {
baseMsg := &message.TrainPcSimBaseMessage{}
err := baseMsg.Decode(data)
if err != nil {
@ -215,18 +245,17 @@ func (pc *trainPcSimService) reivceData(len int, data []byte) {
}
switch baseMsg.Type {
case RECIVE_TRAIN_CREATE_REMOVE:
pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
//case RECIVE_TRAIN_CREATE_REMOVE:
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
case RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
pc.trainPcSimManage.TrainPcSimDigitalOutInfoHandle(baseMsg.Data)
d.trainPcSimManage.TrainPcSimDigitalOutInfoHandle(baseMsg.Data)
case RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
pc.trainPcSimManage.TrainPcSimDigitalReportHandle(baseMsg.Data)
d.trainPcSimManage.TrainPcSimDigitalReportHandle(baseMsg.Data)
case RECIVE_TRAIN_QUERY_STATUS:
pc.trainPcSimManage.TrainBtmQuery(baseMsg.Data)
d.trainPcSimManage.TrainBtmQuery(baseMsg.Data)
case RECIVE_TRAIN_MOCK_DATA:
pc.trainPcSimManage.TrainPcSimMockInfo(baseMsg.Data)
case RECIVE_TRAIN_DOOR_MODE:
pc.trainPcSimManage.TrainDoorModeHandle(baseMsg.Data[0])
d.trainPcSimManage.TrainPcSimMockInfo(baseMsg.Data)
//case RECIVE_TRAIN_DOOR_MODE:
// pc.trainPcSimManage.TrainDoorModeHandle(baseMsg.Data[0])
}
}

View File

@ -30,7 +30,7 @@ const (
RECIVE_TRAIN_BTM_NOT_DATA = 0x32
//清空所有预发应答器
recive_train_btn_clear_all_pre_data = 0x33
//recive_train_btn_clear_all_pre_data = 0x33
//创建/删除列车
RECIVE_TRAIN_CREATE_REMOVE = 0x50

View File

@ -76,7 +76,11 @@ func initTrainTcc(vs *VerifySimulation, runDir bool) *state_proto.TrainControlSt
ds := make([]*state_proto.TrainControlState_DriverKeySwitch, 0)
for _, b := range tccGI.TccKeys {
if b.GetType() == data_proto.TccKey_driverControllerActivationClint {
ds = append(ds, &state_proto.TrainControlState_DriverKeySwitch{Id: b.Common.Id, Val: false})
val := false
if b.Code == "SKQYS1" {
val = true
}
ds = append(ds, &state_proto.TrainControlState_DriverKeySwitch{Id: b.Common.Id, Val: val})
} else if b.GetType() == data_proto.TccKey_frontAndRearDirectionalControl {
tcc.DirKey = &state_proto.TrainControlState_DirectionKeySwitch{Id: b.Common.Id, Val: uint32(message.IsTrue(runDir))}
}

View File

@ -76,8 +76,6 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
status.PointTo = pointTo
status.TrainKilometer = kilometer.Value
//status.Tcc = &state_proto.TrainControlState{}
status.Tcc = initTrainTcc(vs, status.RunDirection)
status.DynamicState = &state_proto.TrainDynamicState{
HeadLinkId: linkId,
HeadLinkOffset: loffset,
@ -90,13 +88,15 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
status.TailDevicePort = tailDevicePort
//初始化列车参数状态
createOrUpdateStateDynamicConfig(status, configTrainData, trainEndsA, trainEndsB)
status.VobcState = &state_proto.TrainVobcState{}
status.VobcState = &state_proto.TrainVobcState{Tc1Active: true}
if status.RunDirection {
status.VobcState.DirectionForward = true
} else {
status.VobcState.DirectionBackward = true
}
status.VobcState.TrainLoad = int64(configTrainData.TrainLoad)
status.Tcc = initTrainTcc(vs, status.RunDirection)
slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset)
linkIdInt, _ := strconv.Atoi(linkId)
@ -152,16 +152,10 @@ func TrainConnTypeUpdate(vs *VerifySimulation, ct *dto.TrainConnThirdDto) {
}
return true
})
if ct.ConnType == state_proto.TrainConnState_VOBC && conn {
//半实物直接更改连接状态
//车载仿真有创建/删除,列车的操作,通过连接状态区分车载pc是否创建列车
train.ConnState.Conn = true
}
} else {
train.ConnState.Conn = false
}
train.ConnState.Conn = conn
train.ConnState.ConnType = ct.ConnType
TrainPcSimConnOrRemoveHandle(train)
}
func createOrUpdateStateDynamicConfig(trainState *state_proto.TrainState, configTrainData dto.ConfigTrainData, trainEndsA dto.ConfigTrainEnds,
@ -240,7 +234,7 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
sta := data.(*state_proto.TrainState)
delayTime := time.Now().UnixMilli() - sta.VobcState.UpdateTime
sta.ControlDelayTime = (int64(sta.VobcState.LifeSignal)-int64(info.VobcLifeSignal))*20 + delayTime
//slog.Debug("收到动力学原始消息", "Number", info.Number, "Link", info.Link, "LinkOffset", info.LinkOffset)
slog.Debug("收到动力学原始消息", "Number", info.Number, "Link", info.Link, "LinkOffset", info.LinkOffset)
inLinkId, inLinkOffset := strconv.Itoa(int(info.Link)), int64(info.LinkOffset)
outLinkId, id, port, outLinkOffset, offset, kilometer, e1 := CalcInitializeLink(vs, inLinkId, inLinkOffset, info.Up)
if e1 != nil {
@ -250,7 +244,7 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
//slog.Debug("处理动力学转换后的消息", "number", info.Number, "车头位置", id, "偏移", offset, "是否上行", runDirection, "是否ab", pointTo)
// 车尾相对车头link的偏移量
calctailOffset := calcTrailTailOffset(outLinkOffset, int64(info.Len), info.Up)
tailLinkId, tailDeviceId, tailDevicePort, tailLinkOffset, tailOffset, _, e2 := CalcInitializeLink(vs, outLinkId, calctailOffset, info.Up)
tailLinkId, tailDeviceId, tailDevicePort, tailLinkOffset, tailOffset, _, e2 := CalcInitializeLink(vs, outLinkId, calctailOffset, !info.Up)
if e2 != nil {
panic(sys_error.New("动力学传输数据:列车车尾位置计算出错", e2))
}

View File

@ -16,7 +16,6 @@ import (
"joylink.club/bj-rtsts-server/dto/data_proto"
"joylink.club/bj-rtsts-server/dto/state_proto"
"joylink.club/bj-rtsts-server/sys_error"
"joylink.club/bj-rtsts-server/third_party/dynamics"
"joylink.club/bj-rtsts-server/third_party/electrical_machinery"
"joylink.club/bj-rtsts-server/third_party/message"
"joylink.club/bj-rtsts-server/third_party/semi_physical_train"
@ -277,11 +276,15 @@ func (s *VerifySimulation) HandleSectionCmdMsg(city string, lineId string, centr
// 处理动力学列车速度消息
func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainInfo) {
trainId := strconv.Itoa(int(info.Number))
_, ok := s.Memory.Status.TrainStateMap.Load(trainId)
t, ok := s.Memory.Status.TrainStateMap.Load(trainId)
if !ok {
return
}
semi_physical_train.Default().SendTrainControlMessage(info)
train := t.(*state_proto.TrainState)
if train.ConnState.Conn && train.ConnState.ConnType == state_proto.TrainConnState_VOBC {
semi_physical_train.Default().SendTrainControlMessage(info)
}
// 更新列车状态
trainState := UpdateTrainStateByDynamics(s, trainId, info)
// 更新电机转速
@ -380,15 +383,15 @@ func (s *VerifySimulation) HandleSemiPhysicalTrainControlMsg(b []byte) {
return true
}
connState := train.ConnState
trainId, err := strconv.Atoi(train.Id)
d := append(b, uint8(trainId))
// 发送给动力学,不论列车是否连接三方服务都将数据发送给动力学
dynamics.Default().SendTrainControlMessage(d)
if err != nil {
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
if connState.Conn == true && connState.ConnType == state_proto.TrainConnState_VOBC {
/*trainId, err := strconv.Atoi(train.Id)
if err != nil {
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}*/
// 存放至列车中
//接收半实物列车控制不单独发送动力学,由动力学统一发送
//d := append(b, uint8(trainId))
//dynamics.Default().SendTrainControlMessage(d)
controlMessage := &message.TrainControlMsg{}
controlMessage.Decode(b)
train.VobcState = controlMessage.ControlInfo
@ -397,6 +400,22 @@ func (s *VerifySimulation) HandleSemiPhysicalTrainControlMsg(b []byte) {
return true
})
}
func (s *VerifySimulation) CollectTrainControlState() []message.TrainControlMsg {
cms := make([]message.TrainControlMsg, 0)
s.Memory.Status.TrainStateMap.Range(func(_, value any) bool {
train := value.(*state_proto.TrainState)
if !train.Show { // 下线列车
return true
}
vobc := false
if train.ConnState.Conn == true && train.ConnState.ConnType == state_proto.TrainConnState_VOBC {
vobc = true
}
cms = append(cms, message.TrainControlMsg{ControlInfo: train.VobcState, TrainId: train.Id, FromVobc: vobc})
return true
})
return cms
}
// 获取半实物运行配置信息
func (s *VerifySimulation) GetSemiPhysicalRunConfig() *config.VobcConfig {

View File

@ -83,15 +83,10 @@ func trainControlDirKey(trainState *state_proto.TrainState, request *request_pro
}
trainState.VobcState.DirectionForward = false
trainState.VobcState.DirectionBackward = false
trainState.RunDirection = false
if request.Val == 1 {
trainState.VobcState.DirectionForward = true
trainState.RunDirection = true
} else if request.Val == 0 {
trainState.VobcState.DirectionBackward = true
trainState.RunDirection = false
}
if trainState.Tcc.DirKey == nil {
trainState.Tcc.DirKey = &state_proto.TrainControlState_DirectionKeySwitch{Id: deviceId, Val: request.Val}
@ -108,6 +103,8 @@ func trainControlDriverKey(trainState *state_proto.TrainState, request *request_
slog.Error("未找到对应的驾驶端激活设备deviceId:", deviceId)
return nil
}
trainState.VobcState.Tc1Active = false
trainState.VobcState.Tc2Active = false
if obj.Code == "SKQYS1" {
trainState.VobcState.Tc1Active = request.Val
@ -147,12 +144,15 @@ func trainControlHandle(trainState *state_proto.TrainState, request *request_pro
tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_BACKWORD, Status: 0})
tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_TO_ZERO, Status: 0})
if request.Val > 0 {
trainState.VobcState.MaintainBrakeStatus = false
trainState.VobcState.TractionStatus = true
trainState.VobcState.TractionForce = int64(request.Val * 18000)
trainState.VobcState.TractionForce = int64(request.Val * 180)
tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_FORWORD, Status: 1})
} else if request.Val < 0 {
trainState.VobcState.MaintainBrakeStatus = true
trainState.VobcState.BrakingStatus = true
trainState.VobcState.BrakeForce = int64(request.Val * 18000)
trainState.VobcState.BrakeForce = int64(-request.Val * 180)
//trainState.VobcState.BrakeForce = 19400
tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_BACKWORD, Status: 1})
} else {
@ -287,8 +287,8 @@ func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(data []byte) {
trainPcSimDigitalOutInfoHandleCode23_16(data[2], vobc)
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
cm := &message.TrainControlMsg{TrainId: train.Id, ControlInfo: vobc}
dynamics.Default().SendTrainControl(cm)
//cm := &message.TrainControlMsg{TrainId: train.Id, ControlInfo: vobc}
//dynamics.Default().SendTrainControl(cm)
}
func trainPcSimDigitalOutInfoHandleCode39_32(d byte, vobc *state_proto.TrainVobcState) {
vobc.MostUseBrake = message.IsTrueForByte(message.GetBit(d, 0)) //? //常用制动
@ -373,28 +373,21 @@ func (s *VerifySimulation) TrainPcSimDigitalReportHandle(data []byte) {
}
// 创建/删除列车
func (s *VerifySimulation) TrainPcSimConnOrRemoveHandle(state byte) {
train := s.findConnTrain(state_proto.TrainConnState_PC_SIM)
if train == nil {
slog.Error("创建删除列车未找到连接车载pc仿真的列车")
func TrainPcSimConnOrRemoveHandle(train *state_proto.TrainState) {
if train.ConnState.ConnType != state_proto.TrainConnState_PC_SIM {
slog.Error("创建移除列车类型不正确 conType:", train.ConnState.ConnType)
return
}
connState := train.ConnState
if state == 0x01 {
connState.Conn = true
} else {
connState.Conn = false
var data byte = 0x01
if train.ConnState.Conn == false {
data = 0x00
}
train_pc_sim.Default().CreateOrRemoveTrain(train_pc_sim.RECIVE_TRAIN_CREATE_REMOVE, []byte{data})
train_pc_sim.Default().CreateOrRemoveSpeedPLace(train)
}
// 门模式
func (s *VerifySimulation) TrainDoorModeHandle(state byte) {
train := s.findConnTrain(state_proto.TrainConnState_PC_SIM)
if train == nil {
slog.Error("车载pc仿真门模式未找到连接车载pc仿真的列车")
return
}
/*func TrainDoorModeHandle(train *state_proto.TrainState) {
if !train.ConnState.Conn {
slog.Error("车载pc仿真门模式,列车未连接车载pc仿真")
return
@ -410,7 +403,7 @@ func (s *VerifySimulation) TrainDoorModeHandle(state byte) {
//0x02表示人开人关MM
train.VobcState.DoorModeMM = true
}
}
}*/
// 4.4.3. 车载输出模拟量信息报文内容(0x03)
func (s *VerifySimulation) TrainPcSimMockInfo(data []byte) {