列车折返rm模式调整
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 2m58s
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 2m58s
This commit is contained in:
parent
449162856b
commit
15bdc45892
@ -6,8 +6,8 @@ server:
|
|||||||
# 数据源
|
# 数据源
|
||||||
datasource:
|
datasource:
|
||||||
# 数据库访问url
|
# 数据库访问url
|
||||||
dsn: root:root@tcp(127.0.0.1:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
# dsn: root:root@tcp(127.0.0.1:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
||||||
# dsn: root:joylink0503@tcp(192.168.33.233:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
dsn: root:joylink0503@tcp(192.168.33.233:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
||||||
|
|
||||||
# 日志配置
|
# 日志配置
|
||||||
logging:
|
logging:
|
||||||
@ -33,7 +33,7 @@ logging:
|
|||||||
# 消息配置
|
# 消息配置
|
||||||
messaging:
|
messaging:
|
||||||
mqtt:
|
mqtt:
|
||||||
address: tcp://127.0.0.1:1883
|
# address: tcp://127.0.0.1:1883
|
||||||
# address: tcp://192.168.33.233:1883
|
address: tcp://192.168.33.233:1883
|
||||||
username: rtsts_service
|
username: rtsts_service
|
||||||
password: joylink@0503
|
password: joylink@0503
|
@ -1211,7 +1211,7 @@ type TrainState struct {
|
|||||||
ProjectCode string `protobuf:"bytes,39,opt,name=projectCode,proto3" json:"projectCode,omitempty"`
|
ProjectCode string `protobuf:"bytes,39,opt,name=projectCode,proto3" json:"projectCode,omitempty"`
|
||||||
// TrainBtmCache BtmBaliseCache = 40;
|
// TrainBtmCache BtmBaliseCache = 40;
|
||||||
TrainPort TrainState_TrainPort `protobuf:"varint,40,opt,name=trainPort,proto3,enum=state.TrainState_TrainPort" json:"trainPort,omitempty"` //列车当前驾驶的端口
|
TrainPort TrainState_TrainPort `protobuf:"varint,40,opt,name=trainPort,proto3,enum=state.TrainState_TrainPort" json:"trainPort,omitempty"` //列车当前驾驶的端口
|
||||||
PulseCountMap map[int32]*SensorSpeedPulseCount `protobuf:"bytes,41,rep,name=pulseCountMap,proto3" json:"pulseCountMap,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
PulseCountMap map[int32]*SensorSpeedPulseCount `protobuf:"bytes,41,rep,name=pulseCountMap,proto3" json:"pulseCountMap,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //列车每端对应的速度 key = TrainPort 枚举的值
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TrainState) Reset() {
|
func (x *TrainState) Reset() {
|
||||||
@ -5226,14 +5226,6 @@ type TrainControlState struct {
|
|||||||
// DirectionKeySwitch dirKey = 3; //接车运行方向
|
// DirectionKeySwitch dirKey = 3; //接车运行方向
|
||||||
PushHandler *TrainControlState_PushHandler `protobuf:"bytes,4,opt,name=pushHandler,proto3" json:"pushHandler,omitempty"` //牵引制动手柄
|
PushHandler *TrainControlState_PushHandler `protobuf:"bytes,4,opt,name=pushHandler,proto3" json:"pushHandler,omitempty"` //牵引制动手柄
|
||||||
LightMaps map[string]*TrainControlState_ControlLight `protobuf:"bytes,5,rep,name=lightMaps,proto3" json:"lightMaps,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
LightMaps map[string]*TrainControlState_ControlLight `protobuf:"bytes,5,rep,name=lightMaps,proto3" json:"lightMaps,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
LineInitTimeStamp12PortA int64 `protobuf:"varint,6,opt,name=lineInitTimeStamp12PortA,proto3" json:"lineInitTimeStamp12PortA,omitempty"` //12号线列出初始化时间戳
|
|
||||||
LineInitTimeStamp12PortB int64 `protobuf:"varint,7,opt,name=lineInitTimeStamp12PortB,proto3" json:"lineInitTimeStamp12PortB,omitempty"` //12号线列出初始化时间戳
|
|
||||||
Line12ConnErrPortA bool `protobuf:"varint,8,opt,name=line12ConnErrPortA,proto3" json:"line12ConnErrPortA,omitempty"` //12号线连接错误,因为12号线atp故障(此时atp需要重启)时,还是会发送数据通过此次属性标记atp状态情况(多次观察atp故障时,atp输出数字量返回的数据最后一个直接是0)
|
|
||||||
Line12ConnErrPortB bool `protobuf:"varint,9,opt,name=line12ConnErrPortB,proto3" json:"line12ConnErrPortB,omitempty"` //12号线连接错误,因为12号线atp故障(此时atp需要重启)时,还是会发送数据通过此次属性标记atp状态情况(多次观察atp故障时,atp输出数字量返回的数据最后一个直接是0)
|
|
||||||
TrainConnInitComplatePortA bool `protobuf:"varint,10,opt,name=TrainConnInitComplatePortA,proto3" json:"TrainConnInitComplatePortA,omitempty"`
|
|
||||||
TrainConnInitComplatePortB bool `protobuf:"varint,11,opt,name=TrainConnInitComplatePortB,proto3" json:"TrainConnInitComplatePortB,omitempty"`
|
|
||||||
ActiveTrainA bool `protobuf:"varint,12,opt,name=activeTrainA,proto3" json:"activeTrainA,omitempty"`
|
|
||||||
ActiveTrainB bool `protobuf:"varint,13,opt,name=activeTrainB,proto3" json:"activeTrainB,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TrainControlState) Reset() {
|
func (x *TrainControlState) Reset() {
|
||||||
@ -5303,62 +5295,6 @@ func (x *TrainControlState) GetLightMaps() map[string]*TrainControlState_Control
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TrainControlState) GetLineInitTimeStamp12PortA() int64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.LineInitTimeStamp12PortA
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *TrainControlState) GetLineInitTimeStamp12PortB() int64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.LineInitTimeStamp12PortB
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *TrainControlState) GetLine12ConnErrPortA() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Line12ConnErrPortA
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *TrainControlState) GetLine12ConnErrPortB() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Line12ConnErrPortB
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *TrainControlState) GetTrainConnInitComplatePortA() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.TrainConnInitComplatePortA
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *TrainControlState) GetTrainConnInitComplatePortB() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.TrainConnInitComplatePortB
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *TrainControlState) GetActiveTrainA() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.ActiveTrainA
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *TrainControlState) GetActiveTrainB() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.ActiveTrainB
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回前端列车控制状态
|
// 返回前端列车控制状态
|
||||||
type TrainControlStateMsg struct {
|
type TrainControlStateMsg struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -5565,6 +5501,14 @@ func (x *StationQc_State) GetOn() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int64 lineInitTimeStamp12PortA = 6; //12号线列出初始化时间戳
|
||||||
|
// int64 lineInitTimeStamp12PortB = 7; //12号线列出初始化时间戳
|
||||||
|
// bool line12ConnErrPortA = 8;//12号线连接错误,因为12号线atp故障(此时atp需要重启)时,还是会发送数据通过此次属性标记atp状态情况(多次观察atp故障时,atp输出数字量返回的数据最后一个直接是0)
|
||||||
|
// bool line12ConnErrPortB = 9;//12号线连接错误,因为12号线atp故障(此时atp需要重启)时,还是会发送数据通过此次属性标记atp状态情况(多次观察atp故障时,atp输出数字量返回的数据最后一个直接是0)
|
||||||
|
// bool TrainConnInitComplatePortA = 10;
|
||||||
|
// bool TrainConnInitComplatePortB = 11;
|
||||||
|
// bool activeTrainA = 12;
|
||||||
|
// bool activeTrainB = 13;
|
||||||
// bool Line12ConnErr = 14;
|
// bool Line12ConnErr = 14;
|
||||||
// int64 lineInitTimeStamp12 = 15;
|
// int64 lineInitTimeStamp12 = 15;
|
||||||
type TrainControlState_ControlButton struct {
|
type TrainControlState_ControlButton struct {
|
||||||
@ -6824,7 +6768,7 @@ var file_device_state_proto_rawDesc = []byte{
|
|||||||
0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12,
|
0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12,
|
||||||
0x20, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03,
|
0x20, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d,
|
||||||
0x65, 0x22, 0xd5, 0x0a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72,
|
0x65, 0x22, 0xb5, 0x07, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72,
|
||||||
0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3f, 0x0a, 0x07, 0x62, 0x75, 0x74, 0x74, 0x6f,
|
0x6f, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3f, 0x0a, 0x07, 0x62, 0x75, 0x74, 0x74, 0x6f,
|
||||||
0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65,
|
0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65,
|
||||||
0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61,
|
0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x53, 0x74, 0x61,
|
||||||
@ -6847,33 +6791,7 @@ var file_device_state_proto_rawDesc = []byte{
|
|||||||
0x74, 0x4d, 0x61, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x74,
|
0x74, 0x4d, 0x61, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x74,
|
||||||
0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
0x61, 0x74, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x61, 0x70, 0x73, 0x45,
|
0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x61, 0x70, 0x73, 0x45,
|
||||||
0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x61, 0x70, 0x73, 0x12,
|
0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x4d, 0x61, 0x70, 0x73, 0x1a,
|
||||||
0x3a, 0x0a, 0x18, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53,
|
|
||||||
0x74, 0x61, 0x6d, 0x70, 0x31, 0x32, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x18, 0x06, 0x20, 0x01, 0x28,
|
|
||||||
0x03, 0x52, 0x18, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53,
|
|
||||||
0x74, 0x61, 0x6d, 0x70, 0x31, 0x32, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x12, 0x3a, 0x0a, 0x18, 0x6c,
|
|
||||||
0x69, 0x6e, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70,
|
|
||||||
0x31, 0x32, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x18, 0x6c,
|
|
||||||
0x69, 0x6e, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70,
|
|
||||||
0x31, 0x32, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x12, 0x2e, 0x0a, 0x12, 0x6c, 0x69, 0x6e, 0x65, 0x31,
|
|
||||||
0x32, 0x43, 0x6f, 0x6e, 0x6e, 0x45, 0x72, 0x72, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x18, 0x08, 0x20,
|
|
||||||
0x01, 0x28, 0x08, 0x52, 0x12, 0x6c, 0x69, 0x6e, 0x65, 0x31, 0x32, 0x43, 0x6f, 0x6e, 0x6e, 0x45,
|
|
||||||
0x72, 0x72, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x12, 0x2e, 0x0a, 0x12, 0x6c, 0x69, 0x6e, 0x65, 0x31,
|
|
||||||
0x32, 0x43, 0x6f, 0x6e, 0x6e, 0x45, 0x72, 0x72, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x18, 0x09, 0x20,
|
|
||||||
0x01, 0x28, 0x08, 0x52, 0x12, 0x6c, 0x69, 0x6e, 0x65, 0x31, 0x32, 0x43, 0x6f, 0x6e, 0x6e, 0x45,
|
|
||||||
0x72, 0x72, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x12, 0x3e, 0x0a, 0x1a, 0x54, 0x72, 0x61, 0x69, 0x6e,
|
|
||||||
0x43, 0x6f, 0x6e, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,
|
|
||||||
0x50, 0x6f, 0x72, 0x74, 0x41, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x54, 0x72, 0x61,
|
|
||||||
0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x61,
|
|
||||||
0x74, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x12, 0x3e, 0x0a, 0x1a, 0x54, 0x72, 0x61, 0x69, 0x6e,
|
|
||||||
0x43, 0x6f, 0x6e, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,
|
|
||||||
0x50, 0x6f, 0x72, 0x74, 0x42, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x54, 0x72, 0x61,
|
|
||||||
0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x61,
|
|
||||||
0x74, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76,
|
|
||||||
0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x41, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x61,
|
|
||||||
0x63, 0x74, 0x69, 0x76, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x41, 0x12, 0x22, 0x0a, 0x0c, 0x61,
|
|
||||||
0x63, 0x74, 0x69, 0x76, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x42, 0x18, 0x0d, 0x20, 0x01, 0x28,
|
|
||||||
0x08, 0x52, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x42, 0x1a,
|
|
||||||
0x62, 0x0a, 0x0c, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
|
0x62, 0x0a, 0x0c, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
|
||||||
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65,
|
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65,
|
||||||
0x79, 0x12, 0x3c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
0x79, 0x12, 0x3c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 35c2c8e7748a4a30230ef4fcaedbfd7d2466299d
|
Subproject commit 76a91b6495fc3a6b725b4ff3ba003423e3efb38e
|
@ -18,7 +18,20 @@ type TrainPcReciverData struct {
|
|||||||
speedPlace *message.TrainSpeedPlaceReportMsg
|
speedPlace *message.TrainSpeedPlaceReportMsg
|
||||||
train *state_proto.TrainState
|
train *state_proto.TrainState
|
||||||
success bool
|
success bool
|
||||||
aPort bool
|
//aPort bool //列车钥匙激活端口 true = 1端 ,false = 2端
|
||||||
|
RealTrainPort state_proto.TrainState_TrainPort
|
||||||
|
LineInitTimeStamp int64
|
||||||
|
TrainConnInitComplate bool
|
||||||
|
ConnErr bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rd *TrainPcReciverData) ConnError() bool {
|
||||||
|
connState := tpapi.ThirdPartyState_Normal
|
||||||
|
if rd.ConnErr {
|
||||||
|
connState = tpapi.ThirdPartyState_Broken
|
||||||
|
}
|
||||||
|
rd.updateState(connState)
|
||||||
|
return rd.ConnErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rd *TrainPcReciverData) Name() string {
|
func (rd *TrainPcReciverData) Name() string {
|
||||||
@ -40,10 +53,13 @@ func (d *TrainPcReciverData) readError(err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *TrainPcReciverData) ServiceDesc() string {
|
func (d *TrainPcReciverData) ServiceDesc() string {
|
||||||
if d.aPort {
|
if d.RealTrainPort == state_proto.TrainState_PORT_A {
|
||||||
return fmt.Sprintf("%v-A端", d.clientKey)
|
return fmt.Sprintf("%v-A端", d.clientKey)
|
||||||
} else {
|
} else if d.RealTrainPort == state_proto.TrainState_PORT_B {
|
||||||
return fmt.Sprintf("%v-B端", d.clientKey)
|
return fmt.Sprintf("%v-B端", d.clientKey)
|
||||||
|
} else {
|
||||||
|
return fmt.Sprintf("%v-位置服务端口", d.clientKey)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,11 +86,11 @@ func (rd *TrainPcReciverData) receiverDataHandle(n int, data []byte) {
|
|||||||
//case RECIVE_TRAIN_CREATE_REMOVE:
|
//case RECIVE_TRAIN_CREATE_REMOVE:
|
||||||
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
||||||
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
||||||
rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(rd.aPort, rd.tcpClient, train, baseMsg.Data)
|
rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(rd, train, baseMsg.Data)
|
||||||
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
|
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
|
||||||
rd.pcSimManage.TrainPcSimDigitalReportHandle(train, baseMsg.Data)
|
rd.pcSimManage.TrainPcSimDigitalReportHandle(train, baseMsg.Data)
|
||||||
case message.RECIVE_TRAIN_QUERY_STATUS:
|
case message.RECIVE_TRAIN_QUERY_STATUS:
|
||||||
rd.pcSimManage.TrainBtmQuery2(train, baseMsg.Data, rd.aPort)
|
rd.pcSimManage.TrainBtmQuery2(train, baseMsg.Data, rd.RealTrainPort)
|
||||||
//case message.RECIVE_TRAIN_MOCK_DATA:
|
//case message.RECIVE_TRAIN_MOCK_DATA:
|
||||||
// rd.pcSimManage.TrainPcSimMockInfo(train, baseMsg.Data)
|
// rd.pcSimManage.TrainPcSimMockInfo(train, baseMsg.Data)
|
||||||
|
|
||||||
|
132
third_party/train_pc_sim/train_pc_sim.go
vendored
132
third_party/train_pc_sim/train_pc_sim.go
vendored
@ -36,12 +36,13 @@ type TrainPcSim interface {
|
|||||||
//因文档说明不清楚,在调用的时候目前是注释状态,现场调试可能会用到
|
//因文档说明不清楚,在调用的时候目前是注释状态,现场调试可能会用到
|
||||||
SendTrainDirection(train *state_proto.TrainState, trainForward, trainBackward bool)
|
SendTrainDirection(train *state_proto.TrainState, trainForward, trainBackward bool)
|
||||||
//发送应答器信息数据
|
//发送应答器信息数据
|
||||||
SendBaliseData(train *state_proto.TrainState, trainPort bool, msgType byte, data []byte)
|
|
||||||
|
SendBaliseData2(train *state_proto.TrainState, trainClientPort state_proto.TrainState_TrainPort, msgType byte, data []byte)
|
||||||
|
|
||||||
//发布列车控制的相关事件
|
//发布列车控制的相关事件
|
||||||
//PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent)
|
//PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent)
|
||||||
|
|
||||||
SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, aport bool)
|
SendTrainControlMsg2(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, trainClientPort state_proto.TrainState_TrainPort)
|
||||||
// CreateOrRemoveSpeedPLace 创建或删除速度位置信息
|
// CreateOrRemoveSpeedPLace 创建或删除速度位置信息
|
||||||
//CreateOrRemoveSpeedPLace(train *state_proto.TrainState)
|
//CreateOrRemoveSpeedPLace(train *state_proto.TrainState)
|
||||||
// CreateOrRemoveTrain 创建或删除列车
|
// CreateOrRemoveTrain 创建或删除列车
|
||||||
@ -57,7 +58,7 @@ type TrainPcSimManage interface {
|
|||||||
//获取列车模拟量数据
|
//获取列车模拟量数据
|
||||||
ObtainTrainDigitalMockData(train *state_proto.TrainState) []message.TrainPcSimBaseMessage
|
ObtainTrainDigitalMockData(train *state_proto.TrainState) []message.TrainPcSimBaseMessage
|
||||||
// TrainPcSimDigitalOutInfoHandle 4.4.1. 车载输出数字量信息报文内容
|
// TrainPcSimDigitalOutInfoHandle 4.4.1. 车载输出数字量信息报文内容
|
||||||
TrainPcSimDigitalOutInfoHandle(aport bool, client *tcp.TcpClient, train *state_proto.TrainState, data []byte) bool
|
TrainPcSimDigitalOutInfoHandle(pc *TrainPcReciverData, train *state_proto.TrainState, data []byte) bool
|
||||||
// TrainPcSimDigitalReportHandle 4.4.2. 车载输出数字反馈量信息报文内容
|
// TrainPcSimDigitalReportHandle 4.4.2. 车载输出数字反馈量信息报文内容
|
||||||
TrainPcSimDigitalReportHandle(train *state_proto.TrainState, data []byte)
|
TrainPcSimDigitalReportHandle(train *state_proto.TrainState, data []byte)
|
||||||
FindConnTrain(ct state_proto.TrainConnState_TrainConnType) *state_proto.TrainState
|
FindConnTrain(ct state_proto.TrainConnState_TrainConnType) *state_proto.TrainState
|
||||||
@ -67,7 +68,7 @@ type TrainPcSimManage interface {
|
|||||||
TrainPcSimMockInfo(train *state_proto.TrainState, data []byte)
|
TrainPcSimMockInfo(train *state_proto.TrainState, data []byte)
|
||||||
// TrainBtmQuery 处理列车btm查询
|
// TrainBtmQuery 处理列车btm查询
|
||||||
|
|
||||||
TrainBtmQuery2(train *state_proto.TrainState, data []byte, trainPort bool)
|
TrainBtmQuery2(train *state_proto.TrainState, data []byte, trainClientPort state_proto.TrainState_TrainPort)
|
||||||
}
|
}
|
||||||
type trainPcSimService struct {
|
type trainPcSimService struct {
|
||||||
state tpapi.ThirdPartyApiServiceState
|
state tpapi.ThirdPartyApiServiceState
|
||||||
@ -116,18 +117,19 @@ func (d *trainPcSimService) ServiceDesc() string {
|
|||||||
func FindTrainPcSimClientKey2(t *state_proto.TrainState) string {
|
func FindTrainPcSimClientKey2(t *state_proto.TrainState) string {
|
||||||
return t.ConnState.TypeName
|
return t.ConnState.TypeName
|
||||||
}
|
}
|
||||||
func (d *trainPcSimService) findTrainConnForPort(sta *state_proto.TrainState, aport bool) (*TrainPcReciverData, error) {
|
func (d *trainPcSimService) findTrainConnForPort2(sta *state_proto.TrainState, trainClientPort state_proto.TrainState_TrainPort) (*TrainPcReciverData, error) {
|
||||||
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
||||||
if rds == nil {
|
if rds == nil {
|
||||||
return nil, fmt.Errorf("")
|
return nil, fmt.Errorf("")
|
||||||
}
|
}
|
||||||
for _, rd := range rds {
|
for _, rd := range rds {
|
||||||
if rd.aPort == aport {
|
if rd.RealTrainPort == trainClientPort {
|
||||||
return rd, nil
|
return rd, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("")
|
return nil, fmt.Errorf("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) findTrainConn(sta *state_proto.TrainState) (*TrainPcReciverData, error) {
|
func (d *trainPcSimService) findTrainConn(sta *state_proto.TrainState) (*TrainPcReciverData, error) {
|
||||||
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
||||||
if rds == nil {
|
if rds == nil {
|
||||||
@ -260,13 +262,21 @@ func (d *trainPcSimService) initConn2(clientKey string) error {
|
|||||||
}
|
}
|
||||||
e1 := d.connServer(cfg.OpenA, cfg.APcSimIp, cfg.APcSimPort, rd1)
|
e1 := d.connServer(cfg.OpenA, cfg.APcSimIp, cfg.APcSimPort, rd1)
|
||||||
if e1 != nil {
|
if e1 != nil {
|
||||||
|
rd1.updateState(tpapi.ThirdPartyState_Broken)
|
||||||
return sys_error.New(fmt.Sprintf("配置:%v 端口A连接失败", clientKey))
|
return sys_error.New(fmt.Sprintf("配置:%v 端口A连接失败", clientKey))
|
||||||
}
|
}
|
||||||
e2 := d.connServer(cfg.OpenB, cfg.BPcSimIp, cfg.BPcSimPort, rd2)
|
e2 := d.connServer(cfg.OpenB, cfg.BPcSimIp, cfg.BPcSimPort, rd2)
|
||||||
if e2 != nil {
|
if e2 != nil {
|
||||||
|
rd1.updateState(tpapi.ThirdPartyState_Broken)
|
||||||
return sys_error.New(fmt.Sprintf("配置:%v 端口B连接失败", clientKey))
|
return sys_error.New(fmt.Sprintf("配置:%v 端口B连接失败", clientKey))
|
||||||
}
|
}
|
||||||
rd1.aPort = true
|
if rd1.success {
|
||||||
|
//rd1.aPort = true
|
||||||
|
rd1.RealTrainPort = state_proto.TrainState_PORT_A
|
||||||
|
}
|
||||||
|
if rd2.success {
|
||||||
|
rd2.RealTrainPort = state_proto.TrainState_PORT_B
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +294,7 @@ func (d *trainPcSimService) connServer(open bool, ip string, port uint32, rd *Tr
|
|||||||
//slog.Info(addr, "连接.,...")
|
//slog.Info(addr, "连接.,...")
|
||||||
client2, err := tcp.StartTcpClient(addr, rd.receiverDataHandle, rd.readError)
|
client2, err := tcp.StartTcpClient(addr, rd.receiverDataHandle, rd.readError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rd.updateState(tpapi.ThirdPartyState_Broken)
|
return sys_error.New(fmt.Sprintf("车载atp连接失败,add:%v ,message:%v", addr, err))
|
||||||
} else {
|
} else {
|
||||||
rd.success = true
|
rd.success = true
|
||||||
rd.tcpClient = client2
|
rd.tcpClient = client2
|
||||||
@ -348,13 +358,14 @@ func (d *trainPcSimService) Stop() {
|
|||||||
|
|
||||||
func (d *trainPcSimService) CreateOrRemoveTrain(train *state_proto.TrainState, isCreate bool) error {
|
func (d *trainPcSimService) CreateOrRemoveTrain(train *state_proto.TrainState, isCreate bool) error {
|
||||||
clientKey := FindTrainPcSimClientKey2(train)
|
clientKey := FindTrainPcSimClientKey2(train)
|
||||||
|
|
||||||
|
data := []byte{message.FLAG_CAMMAND_REMOVE_TRAIN}
|
||||||
|
if isCreate {
|
||||||
err := d.initConn2(clientKey)
|
err := d.initConn2(clientKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.newCloseConn(clientKey)
|
d.newCloseConn(clientKey)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
data := []byte{message.FLAG_CAMMAND_REMOVE_TRAIN}
|
|
||||||
if isCreate {
|
|
||||||
data[0] = message.FLAG_CAMMAND_CREATE_TRAIN
|
data[0] = message.FLAG_CAMMAND_CREATE_TRAIN
|
||||||
}
|
}
|
||||||
msg := &message.TrainPcSimBaseMessage{Data: data, Type: message.RECIVE_TRAIN_CREATE_REMOVE}
|
msg := &message.TrainPcSimBaseMessage{Data: data, Type: message.RECIVE_TRAIN_CREATE_REMOVE}
|
||||||
@ -386,12 +397,9 @@ func (d *trainPcSimService) initTrain(rd *TrainPcReciverData, train *state_proto
|
|||||||
train.PulseCountMap[int32(state_proto.TrainState_PORT_B.Number())] = &state_proto.SensorSpeedPulseCount{}
|
train.PulseCountMap[int32(state_proto.TrainState_PORT_B.Number())] = &state_proto.SensorSpeedPulseCount{}
|
||||||
rd.train = train
|
rd.train = train
|
||||||
tcc := train.Tcc
|
tcc := train.Tcc
|
||||||
tcc.LineInitTimeStamp12PortA = 0
|
rd.TrainConnInitComplate = false
|
||||||
tcc.LineInitTimeStamp12PortB = 0
|
rd.LineInitTimeStamp = 0
|
||||||
tcc.Line12ConnErrPortA = false
|
|
||||||
tcc.Line12ConnErrPortB = false
|
|
||||||
//tcc.LineInitTimeStamp12 = 0
|
|
||||||
//tcc.Line12ConnErr = false
|
|
||||||
if isCreate {
|
if isCreate {
|
||||||
tmpMsgs := d.trainPcSimManage.ObtainTrainDigitalMockData(train)
|
tmpMsgs := d.trainPcSimManage.ObtainTrainDigitalMockData(train)
|
||||||
msgs = append(msgs, tmpMsgs...)
|
msgs = append(msgs, tmpMsgs...)
|
||||||
@ -433,35 +441,22 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
|||||||
if train.ConnState.Conn {
|
if train.ConnState.Conn {
|
||||||
for numKey, pc := range train.PulseCountMap {
|
for numKey, pc := range train.PulseCountMap {
|
||||||
trainPort := state_proto.TrainState_TrainPort(numKey)
|
trainPort := state_proto.TrainState_TrainPort(numKey)
|
||||||
aPort := true
|
trainClient, _ := d.findTrainConnForPort2(train, trainPort)
|
||||||
if trainPort == state_proto.TrainState_PORT_B {
|
|
||||||
aPort = false
|
|
||||||
}
|
|
||||||
trainClient, _ := d.findTrainConnForPort(train, aPort)
|
|
||||||
if trainClient.success {
|
if trainClient.success {
|
||||||
if trainClient.speedPlace == nil || trainClient.tcpClient == nil {
|
if trainClient.speedPlace == nil || trainClient.tcpClient == nil {
|
||||||
slog.Error(fmt.Sprintf("pc仿真速度位置脉冲对象为空 列车id:%v", train.Id))
|
slog.Error(fmt.Sprintf("pc仿真速度位置脉冲对象为空 列车id:%v", train.Id))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
connState := tpapi.ThirdPartyState_Normal
|
if trainClient.ConnError() {
|
||||||
if trainClient.aPort && train.Tcc.Line12ConnErrPortA {
|
continue
|
||||||
connState = tpapi.ThirdPartyState_Broken
|
|
||||||
} else if trainClient.aPort == false && train.Tcc.Line12ConnErrPortB {
|
|
||||||
connState = tpapi.ThirdPartyState_Broken
|
|
||||||
}
|
|
||||||
trainClient.updateState(connState)
|
|
||||||
s1, _ := d.pluseSpeed(pc, train.WheelDiameter)
|
|
||||||
runDir := uint16(2)
|
|
||||||
if train.VobcState.DirectionForward {
|
|
||||||
runDir = 1
|
|
||||||
} else if train.VobcState.DirectionBackward {
|
|
||||||
runDir = 0
|
|
||||||
}
|
}
|
||||||
|
s1, speed := d.pluseSpeed(pc, train.WheelDiameter)
|
||||||
|
runDir := d.trainDirection(speed, train, trainClient.RealTrainPort)
|
||||||
disPluse := pluseCountSpeed(train.WheelDiameter, trainClient.speedPlace.PulseCount1)
|
disPluse := pluseCountSpeed(train.WheelDiameter, trainClient.speedPlace.PulseCount1)
|
||||||
data := trainClient.speedPlace.Encode(runDir, s1, disPluse)
|
data := trainClient.speedPlace.Encode(runDir, s1, disPluse)
|
||||||
bm := &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_LOCATION_INFO, Data: data}
|
bm := &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_LOCATION_INFO, Data: data}
|
||||||
dataCode := bm.Encode()
|
dataCode := bm.Encode()
|
||||||
//slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,A端:%v,列车速度:%v,计数脉冲: %v,累计里程: %v ,发送数据:%v", train.Id, trainClient.aPort, speed, s1, trainClient.speedPlace.PulseCount1, hex.EncodeToString(dataCode)), trainClient.aPort)
|
slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,列车服务端:%v,列车速度:%v,计数脉冲: %v,累计里程: %v ,发送数据:%X", train.Id, trainClient.RealTrainPort.String(), speed, s1, trainClient.speedPlace.PulseCount1, dataCode))
|
||||||
err := trainClient.tcpClient.Send(dataCode)
|
err := trainClient.tcpClient.Send(dataCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(fmt.Sprintf("发送列车速度位置失败,列车:%v,发送数据:%v", train.Id, hex.EncodeToString(dataCode)))
|
slog.Error(fmt.Sprintf("发送列车速度位置失败,列车:%v,发送数据:%v", train.Id, hex.EncodeToString(dataCode)))
|
||||||
@ -473,44 +468,28 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendDriverActive Deprecated 发送驾驶激活
|
func (d *trainPcSimService) trainDirection(speed float32, train *state_proto.TrainState, clientPort state_proto.TrainState_TrainPort) uint16 {
|
||||||
/*func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
|
runDir := uint16(2)
|
||||||
trainClient, trainDataErr := d.findTrainConn(train)
|
|
||||||
if trainDataErr != nil {
|
|
||||||
slog.Error(fmt.Sprintf("发送驾驶激活,未找到对应的列车连接,列车id:%v", train.Id))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
vobc := train.VobcState
|
vobc := train.VobcState
|
||||||
msg := &message.TrainPcSimBaseMessage{}
|
if speed == 0 || train.TrainPort == state_proto.TrainState_PORT_NONE || (vobc.DirectionForward == false && vobc.DirectionBackward == false) {
|
||||||
|
return runDir
|
||||||
|
}
|
||||||
|
if vobc.DirectionForward {
|
||||||
|
runDir = 1
|
||||||
|
} else if vobc.DirectionBackward {
|
||||||
|
runDir = 0
|
||||||
|
}
|
||||||
|
if train.TrainPort != clientPort {
|
||||||
|
if vobc.DirectionForward {
|
||||||
|
runDir = 0
|
||||||
|
} else if vobc.DirectionBackward {
|
||||||
|
runDir = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if trainClient.aPort {
|
return runDir
|
||||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
}
|
||||||
if vobc.Tc1Active {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
|
||||||
if vobc.Tc2Active {
|
|
||||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msgs := make([]byte, 0)
|
|
||||||
if msg.Type == message.SENDER_TRAIN_TC_ACTIVE {
|
|
||||||
dd3 := message.TrainPcSimBaseMessage{Data: []byte{message.KEY_STATE, 1}, Type: message.SENDER_TRAIN_OUTR_INFO}
|
|
||||||
msgs = append(msgs, dd3.Encode()...)
|
|
||||||
} else {
|
|
||||||
dd3 := message.TrainPcSimBaseMessage{Data: []byte{message.KEY_STATE, 0}, Type: message.SENDER_TRAIN_OUTR_INFO}
|
|
||||||
msgs = append(msgs, dd3.Encode()...)
|
|
||||||
}
|
|
||||||
msgs = append(msgs, msg.Encode()...)
|
|
||||||
hexData := hex.EncodeToString(msgs)
|
|
||||||
slog.Info(fmt.Sprintf("发送驾驶激活列车id:%v,数据:%v", train.Id, hexData), trainClient.aPort)
|
|
||||||
err := trainClient.tcpClient.Send(msgs)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
slog.Error(fmt.Sprintf("发送驾驶激活失败列车id:%v,数据:%v,err:%v", train.Id, hexData, err.Error()))
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
func (d *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, tractionState bool, train *state_proto.TrainState) {
|
func (d *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, tractionState bool, train *state_proto.TrainState) {
|
||||||
trainClient, trainDataErr := d.findTrainConn(train)
|
trainClient, trainDataErr := d.findTrainConn(train)
|
||||||
if trainDataErr != nil {
|
if trainDataErr != nil {
|
||||||
@ -580,9 +559,9 @@ func (d *trainPcSimService) SendTrainDirection(train *state_proto.TrainState, tr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, trainPort bool, msgType byte, data []byte) {
|
func (d *trainPcSimService) SendBaliseData2(train *state_proto.TrainState, trainClientPort state_proto.TrainState_TrainPort, msgType byte, data []byte) {
|
||||||
//trainClient, trainDataErr := d.findTrainConn(train)
|
|
||||||
trainClient, trainDataErr := d.findTrainConnForPort(train, trainPort)
|
trainClient, trainDataErr := d.findTrainConnForPort2(train, trainClientPort)
|
||||||
if trainDataErr != nil {
|
if trainDataErr != nil {
|
||||||
slog.Error(fmt.Sprintf("发送列车PC仿真应答器信息失败,未找到列车连接,trainId:%v", train.Id))
|
slog.Error(fmt.Sprintf("发送列车PC仿真应答器信息失败,未找到列车连接,trainId:%v", train.Id))
|
||||||
return
|
return
|
||||||
@ -599,12 +578,12 @@ func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, trainP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, aport bool) {
|
func (d *trainPcSimService) SendTrainControlMsg2(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, trainClientPort state_proto.TrainState_TrainPort) {
|
||||||
if len(baseMessage) <= 0 {
|
if len(baseMessage) <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//trainClient, trainDataErr := d.findTrainConn(train)
|
//trainClient, trainDataErr := d.findTrainConn(train)
|
||||||
trainClient, trainDataErr := d.findTrainConnForPort(train, aport)
|
trainClient, trainDataErr := d.findTrainConnForPort2(train, trainClientPort)
|
||||||
if trainDataErr != nil {
|
if trainDataErr != nil {
|
||||||
slog.Error(fmt.Sprintf("发送列车控制信息失败,无连接,列车Id:%v", train.Id))
|
slog.Error(fmt.Sprintf("发送列车控制信息失败,无连接,列车Id:%v", train.Id))
|
||||||
return
|
return
|
||||||
@ -612,10 +591,11 @@ func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, b
|
|||||||
|
|
||||||
for _, msg := range baseMessage {
|
for _, msg := range baseMessage {
|
||||||
dd := msg.Encode()
|
dd := msg.Encode()
|
||||||
slog.Info(fmt.Sprintf("发送操控列车控制信息:%x", dd), aport)
|
//slog.Info(fmt.Sprintf("发送操控列车控制信息:%x", dd), aport)
|
||||||
d.sendData(trainClient.tcpClient, dd)
|
d.sendData(trainClient.tcpClient, dd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *trainPcSimService) sendData(client *tcp.TcpClient, data []byte) {
|
func (d *trainPcSimService) sendData(client *tcp.TcpClient, data []byte) {
|
||||||
err := client.Send(data)
|
err := client.Send(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -171,8 +171,8 @@ func TrainConnTypeUpdate(vs *VerifySimulation, ct *dto.TrainConnThirdDto) {
|
|||||||
train.ConnState.TypeName = ct.TypeName
|
train.ConnState.TypeName = ct.TypeName
|
||||||
if ct.ConnType == state_proto.TrainConnState_PC_SIM {
|
if ct.ConnType == state_proto.TrainConnState_PC_SIM {
|
||||||
//train.Tcc.LineInitTimeStamp12 = 0
|
//train.Tcc.LineInitTimeStamp12 = 0
|
||||||
train.Tcc.LineInitTimeStamp12PortA = 0
|
//train.Tcc.LineInitTimeStamp12PortA = 0
|
||||||
train.Tcc.LineInitTimeStamp12PortB = 0
|
//train.Tcc.LineInitTimeStamp12PortB = 0
|
||||||
|
|
||||||
err := TrainPcSimConnOrRemoveHandle(train, true)
|
err := TrainPcSimConnOrRemoveHandle(train, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -356,6 +356,13 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
|||||||
if sta.OldLinkOffset != outLinkOffset {
|
if sta.OldLinkOffset != outLinkOffset {
|
||||||
sta.OldLinkOffset = outLinkOffset
|
sta.OldLinkOffset = outLinkOffset
|
||||||
}
|
}
|
||||||
|
if sta.OldTailLink != tailLinkId {
|
||||||
|
sta.OldTailLink = tailLinkId
|
||||||
|
}
|
||||||
|
if sta.OldTailLinkOffset != tailLinkOffset {
|
||||||
|
sta.OldTailLinkOffset = tailLinkOffset
|
||||||
|
}
|
||||||
|
|
||||||
sta.HeadDeviceId = vs.GetComIdByUid(id)
|
sta.HeadDeviceId = vs.GetComIdByUid(id)
|
||||||
sta.DevicePort = port
|
sta.DevicePort = port
|
||||||
sta.HeadOffset = offset
|
sta.HeadOffset = offset
|
||||||
|
@ -272,14 +272,12 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
|
|||||||
acc.Default().TrainAccSender(info, trainState)
|
acc.Default().TrainAccSender(info, trainState)
|
||||||
}
|
}
|
||||||
if vs.Ato {
|
if vs.Ato {
|
||||||
trainPort := true
|
|
||||||
if train.TrainPort == state_proto.TrainState_PORT_B {
|
if train.TrainPort == state_proto.TrainState_PORT_NONE {
|
||||||
trainPort = false
|
|
||||||
} else if train.TrainPort == state_proto.TrainState_PORT_NONE {
|
|
||||||
slog.Info("")
|
slog.Info("")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
trainAtoControlTractionAndBrake(train, trainPort)
|
trainAtoControlTractionAndBrake(train)
|
||||||
var msgs []message.TrainPcSimBaseMessage
|
var msgs []message.TrainPcSimBaseMessage
|
||||||
if vs.AtoOpenRightDoor || vs.AtoOpenLeftDoor {
|
if vs.AtoOpenRightDoor || vs.AtoOpenLeftDoor {
|
||||||
btn := train.Tcc.Buttons[KZM]
|
btn := train.Tcc.Buttons[KZM]
|
||||||
@ -294,7 +292,7 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
|
|||||||
}
|
}
|
||||||
msgs = controlDoorCloseBtn(train.VobcState, true, btn, vs.AtoOpenLeftDoor, false)
|
msgs = controlDoorCloseBtn(train.VobcState, true, btn, vs.AtoOpenLeftDoor, false)
|
||||||
}
|
}
|
||||||
train_pc_sim.Default().SendTrainControlMsg(train, msgs, trainPort)
|
train_pc_sim.Default().SendTrainControlMsg2(train, msgs, train.TrainPort)
|
||||||
} else if vs.TractionStatus {
|
} else if vs.TractionStatus {
|
||||||
f := trainTractionPower(train.TrainLoad, train.Tcc.PushHandler.Val, trainState.DynamicState.Speed, train.TrainMaxAcc, train.TrainMaxSpeed)
|
f := trainTractionPower(train.TrainLoad, train.Tcc.PushHandler.Val, trainState.DynamicState.Speed, train.TrainMaxAcc, train.TrainMaxSpeed)
|
||||||
vs.TractionForce = f / 1000 * 100
|
vs.TractionForce = f / 1000 * 100
|
||||||
|
@ -80,16 +80,10 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) {
|
|||||||
vobc.TractionForce = 0
|
vobc.TractionForce = 0
|
||||||
}
|
}
|
||||||
if sta.ConnState.Conn && (sta.ConnState.ConnType == state_proto.TrainConnState_PC_SIM) && baseMsg != nil {
|
if sta.ConnState.Conn && (sta.ConnState.ConnType == state_proto.TrainConnState_PC_SIM) && baseMsg != nil {
|
||||||
if sta.TrainPort == state_proto.TrainState_PORT_A {
|
train_pc_sim.Default().SendTrainControlMsg2(sta, baseMsg, sta.TrainPort)
|
||||||
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, true)
|
|
||||||
} else if sta.TrainPort == state_proto.TrainState_PORT_B {
|
|
||||||
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, false)
|
|
||||||
}
|
|
||||||
if vobc.Tc1Active == false && vobc.Tc2Active == false {
|
if vobc.Tc1Active == false && vobc.Tc2Active == false {
|
||||||
sta.TrainPort = state_proto.TrainState_PORT_NONE
|
sta.TrainPort = state_proto.TrainState_PORT_NONE
|
||||||
}
|
}
|
||||||
//train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, aPort)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,10 +393,13 @@ func trainControlDriverKey(train *state_proto.TrainState, request *request_proto
|
|||||||
if obj.Code == SKQYS1 {
|
if obj.Code == SKQYS1 {
|
||||||
vobc.Tc1Active = request.Val
|
vobc.Tc1Active = request.Val
|
||||||
train.TrainPort = state_proto.TrainState_PORT_A
|
train.TrainPort = state_proto.TrainState_PORT_A
|
||||||
|
train.BtmBaliseCacheA = &state_proto.TrainBtmCache{BaliseList: make([]*state_proto.BTMState, 3)}
|
||||||
} else if obj.Code == SKQYS2 {
|
} else if obj.Code == SKQYS2 {
|
||||||
vobc.Tc2Active = request.Val
|
vobc.Tc2Active = request.Val
|
||||||
train.TrainPort = state_proto.TrainState_PORT_B
|
train.TrainPort = state_proto.TrainState_PORT_B
|
||||||
|
train.BtmBaliseCacheB = &state_proto.TrainBtmCache{BaliseList: make([]*state_proto.BTMState, 3)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if vobc.Tc1Active && vobc.Tc2Active {
|
if vobc.Tc1Active && vobc.Tc2Active {
|
||||||
if obj.Code == SKQYS1 {
|
if obj.Code == SKQYS1 {
|
||||||
vobc.Tc1Active = false
|
vobc.Tc1Active = false
|
||||||
@ -411,26 +408,26 @@ func trainControlDriverKey(train *state_proto.TrainState, request *request_proto
|
|||||||
}
|
}
|
||||||
panic(sys_error.New("驾驶端不能同时激活"))
|
panic(sys_error.New("驾驶端不能同时激活"))
|
||||||
}
|
}
|
||||||
var addNew = true
|
|
||||||
for _, k := range tcc.DriverKey {
|
for _, k := range tcc.DriverKey {
|
||||||
if k.Id == deviceId {
|
if k.Id == deviceId {
|
||||||
k.Id = deviceId
|
k.Id = deviceId
|
||||||
k.Val = request.Val
|
k.Val = request.Val
|
||||||
addNew = false
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if addNew {
|
|
||||||
tcc.DriverKey = append(tcc.DriverKey, &state_proto.TrainControlState_DriverKeySwitch{Id: deviceId, Val: request.Val})
|
|
||||||
}
|
|
||||||
tce := make([]message.TrainPcSimBaseMessage, 0)
|
tce := make([]message.TrainPcSimBaseMessage, 0)
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.KEY_STATE, message.IsTrue(request.Val)}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.KEY_STATE, message.IsTrue(request.Val)}})
|
||||||
|
train.OldLink = ""
|
||||||
|
train.OldLinkOffset = 0
|
||||||
|
train.OldTailLink = ""
|
||||||
|
train.OldTailLinkOffset = 0
|
||||||
if request.Val {
|
if request.Val {
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_ACTIVE})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_ACTIVE})
|
||||||
} else {
|
} else {
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_NOT_ACTIVE})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_NOT_ACTIVE})
|
||||||
}
|
}
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, message.IsTrue(request.Val)}})
|
|
||||||
|
|
||||||
return tce
|
return tce
|
||||||
|
|
||||||
@ -503,7 +500,7 @@ func trainTractionPowerAtoStepLevel(trainLoad int32, speedKM int32, stepLevel in
|
|||||||
f := float64(m) * (acc * (1 - speedM/sp))
|
f := float64(m) * (acc * (1 - speedM/sp))
|
||||||
return int64(f)
|
return int64(f)
|
||||||
}
|
}
|
||||||
func trainAtoControlTractionAndBrake(train *state_proto.TrainState, aport bool) {
|
func trainAtoControlTractionAndBrake(train *state_proto.TrainState) {
|
||||||
vs := train.VobcState
|
vs := train.VobcState
|
||||||
vs.TractionStatus = false
|
vs.TractionStatus = false
|
||||||
vs.TractionForce = 0
|
vs.TractionForce = 0
|
||||||
@ -534,7 +531,7 @@ func trainAtoControlTractionAndBrake(train *state_proto.TrainState, aport bool)
|
|||||||
{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, notBreak}},
|
{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, notBreak}},
|
||||||
}
|
}
|
||||||
slog.Info(fmt.Sprintf("列车 id:%v,ato:%v,AtoLevle:%v,牵引:%v,制动:%v,牵引力:%v,制动力%v", train.Id, vs.Ato, vs.AtoStepLevel, vs.AtoTractionCommandOut, vs.AtoBrakeCommand, vs.TractionForce, vs.BrakeForce))
|
slog.Info(fmt.Sprintf("列车 id:%v,ato:%v,AtoLevle:%v,牵引:%v,制动:%v,牵引力:%v,制动力%v", train.Id, vs.Ato, vs.AtoStepLevel, vs.AtoTractionCommandOut, vs.AtoBrakeCommand, vs.TractionForce, vs.BrakeForce))
|
||||||
train_pc_sim.Default().SendTrainControlMsg(train, msg, aport)
|
train_pc_sim.Default().SendTrainControlMsg2(train, msg, train.TrainPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 列车牵引控制
|
// 列车牵引控制
|
||||||
@ -629,95 +626,7 @@ func (s *VerifySimulation) FindConnTrain(ct state_proto.TrainConnState_TrainConn
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 反馈atp输出数字量数据
|
// 反馈atp输出数字量数据
|
||||||
func (s *VerifySimulation) reportTrainMockInitMsg(aport bool, client *tcp.TcpClient, train *state_proto.TrainState, data1, data3 byte) {
|
func (s *VerifySimulation) reportTrainMockInitMsg2(driverActive, initConn bool, initTimeStamp int64, trainClientPort state_proto.TrainState_TrainPort, train *state_proto.TrainState, data1, data3 byte) (int64, bool, bool, []message.TrainPcSimBaseMessage) {
|
||||||
vobc := train.VobcState
|
|
||||||
tcc := train.Tcc
|
|
||||||
tce := make([]message.TrainPcSimBaseMessage, 0)
|
|
||||||
initTimeStamp := tcc.LineInitTimeStamp12PortA
|
|
||||||
connErr := tcc.Line12ConnErrPortA
|
|
||||||
initConn := tcc.TrainConnInitComplatePortA
|
|
||||||
if vobc.Tc2Active {
|
|
||||||
initTimeStamp = tcc.LineInitTimeStamp12PortB
|
|
||||||
connErr = tcc.Line12ConnErrPortB
|
|
||||||
initConn = tcc.TrainConnInitComplatePortB
|
|
||||||
}
|
|
||||||
|
|
||||||
//tcc.Line12ConnErr = false
|
|
||||||
if vobc.Tc1Active || vobc.Tc2Active {
|
|
||||||
state := message.GetBit(data1, 3)
|
|
||||||
if /* vobc.TrainConnInitComplate*/ initConn {
|
|
||||||
if data1 == 0 {
|
|
||||||
//tcc.Line12ConnErr = true
|
|
||||||
connErr = true
|
|
||||||
}
|
|
||||||
if state == 0 {
|
|
||||||
jjzdBtn := tcc.Buttons[JJZD]
|
|
||||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
|
||||||
tce = append(tce, ebTce...)
|
|
||||||
} else if message.GetBit(data1, 0) == 0 {
|
|
||||||
jjzdBtn := tcc.Buttons[JJZD]
|
|
||||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
|
||||||
tce = append(tce, ebTce...)
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_TRACTION_CUTED, 1}})
|
|
||||||
} else {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
initConn = true
|
|
||||||
if initTimeStamp <= 0 {
|
|
||||||
initTimeStamp = time.Now().Add(time.Second * 6).Unix()
|
|
||||||
}
|
|
||||||
if initTimeStamp > time.Now().Unix() {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
|
||||||
tce = append(tce, initData...)
|
|
||||||
if aport {
|
|
||||||
tcc.ActiveTrainA = true
|
|
||||||
} else {
|
|
||||||
tcc.ActiveTrainB = true
|
|
||||||
}
|
|
||||||
initConn = false
|
|
||||||
}
|
|
||||||
/*if vobc.LineInitTimeStamp12 <= 0 {
|
|
||||||
vobc.LineInitTimeStamp12 = time.Now().Add(time.Second * 6).Unix()
|
|
||||||
}*/
|
|
||||||
/*if tcc.LineInitTimeStamp12 > time.Now().Unix() {
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
|
||||||
tce = append(tce, initData...)
|
|
||||||
vobc.TrainConnInitComplate = false
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
|
||||||
if vobc.Tc1Active {
|
|
||||||
tcc.LineInitTimeStamp12PortA = initTimeStamp
|
|
||||||
tcc.Line12ConnErrPortB = connErr
|
|
||||||
tcc.TrainConnInitComplatePortA = initConn
|
|
||||||
} else if vobc.Tc2Active {
|
|
||||||
tcc.LineInitTimeStamp12PortA = initTimeStamp
|
|
||||||
tcc.Line12ConnErrPortB = connErr
|
|
||||||
tcc.TrainConnInitComplatePortB = initConn
|
|
||||||
}
|
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, 1}})
|
|
||||||
//驾驶室激活反馈
|
|
||||||
if message.GetBit(data3, 3) == 0 {
|
|
||||||
act := byte(0)
|
|
||||||
if vobc.Tc1Active || vobc.Tc2Active {
|
|
||||||
act = 1
|
|
||||||
}
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, act}})
|
|
||||||
}
|
|
||||||
|
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//train_pc_sim.Default().SendTrainControlMsg(train, tce)
|
|
||||||
//return initResult
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *VerifySimulation) reportTrainMockInitMsg2(aport, act, initConn bool, initTimeStamp int64, train *state_proto.TrainState, data1, data3 byte) (int64, bool, bool, []message.TrainPcSimBaseMessage) {
|
|
||||||
|
|
||||||
tcc := train.Tcc
|
tcc := train.Tcc
|
||||||
tce := make([]message.TrainPcSimBaseMessage, 0)
|
tce := make([]message.TrainPcSimBaseMessage, 0)
|
||||||
@ -727,16 +636,14 @@ func (s *VerifySimulation) reportTrainMockInitMsg2(aport, act, initConn bool, in
|
|||||||
|
|
||||||
if message.GetBit(data3, 3) == 0 {
|
if message.GetBit(data3, 3) == 0 {
|
||||||
actt := byte(0)
|
actt := byte(0)
|
||||||
if act {
|
if driverActive {
|
||||||
actt = 1
|
actt = 1
|
||||||
}
|
}
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, actt}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, actt}})
|
||||||
}
|
}
|
||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
||||||
|
|
||||||
if act == false {
|
if driverActive == false {
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
|
||||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.TRAIN_INTEGRITY, 1}})
|
|
||||||
return initTimeStamp, initConn, false, tce
|
return initTimeStamp, initConn, false, tce
|
||||||
}
|
}
|
||||||
if initConn {
|
if initConn {
|
||||||
@ -744,12 +651,10 @@ func (s *VerifySimulation) reportTrainMockInitMsg2(aport, act, initConn bool, in
|
|||||||
connErr = true
|
connErr = true
|
||||||
}
|
}
|
||||||
if state == 0 {
|
if state == 0 {
|
||||||
//slog.Info("列车紧急制动%v", aport)
|
|
||||||
jjzdBtn := tcc.Buttons[JJZD]
|
jjzdBtn := tcc.Buttons[JJZD]
|
||||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
ebTce := controlEBBtn(train, true, jjzdBtn)
|
||||||
tce = append(tce, ebTce...)
|
tce = append(tce, ebTce...)
|
||||||
} else if message.GetBit(data1, 0) == 0 {
|
} else if message.GetBit(data1, 0) == 0 {
|
||||||
//slog.Info(fmt.Sprintf("列车紧切牵引%v ,state :%v", aport, state))
|
|
||||||
jjzdBtn := tcc.Buttons[JJZD]
|
jjzdBtn := tcc.Buttons[JJZD]
|
||||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
ebTce := controlEBBtn(train, true, jjzdBtn)
|
||||||
tce = append(tce, ebTce...)
|
tce = append(tce, ebTce...)
|
||||||
@ -766,11 +671,11 @@ func (s *VerifySimulation) reportTrainMockInitMsg2(aport, act, initConn bool, in
|
|||||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.OUTER_EMERGENCY_BRAKE, state}})
|
||||||
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
initData := s.ObtainTrainDigitalMockDataForStatus(train)
|
||||||
tce = append(tce, initData...)
|
tce = append(tce, initData...)
|
||||||
if aport {
|
/* if trainClientPort == state_proto.TrainState_PORT_A {
|
||||||
tcc.ActiveTrainA = true
|
tcc.ActiveTrainA = true
|
||||||
} else if aport == false {
|
} else if trainClientPort == state_proto.TrainState_PORT_A {
|
||||||
tcc.ActiveTrainB = true
|
tcc.ActiveTrainB = true
|
||||||
}
|
}*/
|
||||||
initConn = false
|
initConn = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -797,7 +702,7 @@ func trainAtoLevel(at3, at2, at1 bool) state_proto.TrainVobcState_AtoStepLevel {
|
|||||||
return state_proto.TrainVobcState_ATO_STEP_LEVEL_NONE
|
return state_proto.TrainVobcState_ATO_STEP_LEVEL_NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s *VerifySimulation) shuziliang(aport bool, client *tcp.TcpClient, baseMessage []message.TrainPcSimBaseMessage) {
|
func (s *VerifySimulation) shuziliang(client *tcp.TcpClient, baseMessage []message.TrainPcSimBaseMessage) {
|
||||||
for _, msg := range baseMessage {
|
for _, msg := range baseMessage {
|
||||||
dd := msg.Encode()
|
dd := msg.Encode()
|
||||||
//slog.Info(fmt.Sprintf("发送列车控制信息:%x", dd), aport)
|
//slog.Info(fmt.Sprintf("发送列车控制信息:%x", dd), aport)
|
||||||
@ -807,7 +712,7 @@ func (s *VerifySimulation) shuziliang(aport bool, client *tcp.TcpClient, baseMes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4.4.1. 车载输出数字量信息报文内容
|
// 4.4.1. 车载输出数字量信息报文内容
|
||||||
func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(aport bool, client *tcp.TcpClient, train *state_proto.TrainState, data []byte) bool {
|
func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(pc *train_pc_sim.TrainPcReciverData, train *state_proto.TrainState, data []byte) bool {
|
||||||
|
|
||||||
//slog.Info("开始接受atp输出模拟量==============%v", aport)
|
//slog.Info("开始接受atp输出模拟量==============%v", aport)
|
||||||
/* for i, d := range data {
|
/* for i, d := range data {
|
||||||
@ -823,16 +728,35 @@ func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(aport bool, client *tc
|
|||||||
|
|
||||||
//s.reportTrainMockInitMsg(aport, client, train, data[4], data[1])
|
//s.reportTrainMockInitMsg(aport, client, train, data[4], data[1])
|
||||||
vobc := train.VobcState
|
vobc := train.VobcState
|
||||||
|
act := vobc.Tc1Active
|
||||||
|
if pc.RealTrainPort == state_proto.TrainState_PORT_B {
|
||||||
|
act = vobc.Tc2Active
|
||||||
|
}
|
||||||
|
ts, initConn, connErr, tce := s.reportTrainMockInitMsg2(act, pc.TrainConnInitComplate, pc.LineInitTimeStamp, pc.RealTrainPort, train, data[4], data[1])
|
||||||
|
pc.TrainConnInitComplate = initConn
|
||||||
|
pc.LineInitTimeStamp = ts
|
||||||
|
pc.ConnErr = connErr
|
||||||
|
|
||||||
if aport {
|
train_pc_sim.Default().SendTrainControlMsg2(train, tce, pc.RealTrainPort)
|
||||||
ts, initConn, connErr, tce := s.reportTrainMockInitMsg2(aport, vobc.Tc1Active, train.Tcc.TrainConnInitComplatePortA, train.Tcc.LineInitTimeStamp12PortA, train, data[4], data[1])
|
if act {
|
||||||
if train.Tcc.ActiveTrainA {
|
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
||||||
train.Tcc.LineInitTimeStamp12PortA = ts
|
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
||||||
train.Tcc.TrainConnInitComplatePortA = initConn
|
trainPcSimDigitalOutInfoHandleCode23_16(data[2], vobc)
|
||||||
train.Tcc.Line12ConnErrPortA = connErr
|
trainPcSimDigitalOutInfoHandleCode31_24(data[1], vobc)
|
||||||
s.shuziliang(aport, client, tce)
|
trainPcSimDigitalOutInfoHandleCode39_32(data[0], vobc)
|
||||||
|
if vobc.Ato {
|
||||||
|
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if pc.RealTrainPort == state_proto.TrainState_PORT_A {
|
||||||
|
ts, initConn, connErr, tce := s.reportTrainMockInitMsg2(vobc.Tc1Active, pc.TrainConnInitComplate, pc.LineInitTimeStamp, pc.RealTrainPort, train, data[4], data[1])
|
||||||
|
pc.TrainConnInitComplate = initConn
|
||||||
|
pc.LineInitTimeStamp = ts
|
||||||
|
pc.ConnErr = connErr
|
||||||
|
|
||||||
|
train_pc_sim.Default().SendTrainControlMsg2(train, tce, pc.RealTrainPort)
|
||||||
if train.VobcState.Tc1Active {
|
if train.VobcState.Tc1Active {
|
||||||
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
||||||
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
||||||
@ -843,14 +767,13 @@ func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(aport bool, client *tc
|
|||||||
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if pc.RealTrainPort == state_proto.TrainState_PORT_B {
|
||||||
ts, initConn, connErr, tce := s.reportTrainMockInitMsg2(aport, vobc.Tc2Active, train.Tcc.TrainConnInitComplatePortB, train.Tcc.LineInitTimeStamp12PortB, train, data[4], data[1])
|
ts, initConn, connErr, tce := s.reportTrainMockInitMsg2(vobc.Tc2Active, pc.TrainConnInitComplate, pc.LineInitTimeStamp, pc.RealTrainPort, train, data[4], data[1])
|
||||||
if train.Tcc.ActiveTrainB {
|
pc.TrainConnInitComplate = initConn
|
||||||
train.Tcc.LineInitTimeStamp12PortB = ts
|
pc.LineInitTimeStamp = ts
|
||||||
train.Tcc.TrainConnInitComplatePortB = initConn
|
pc.ConnErr = connErr
|
||||||
train.Tcc.Line12ConnErrPortB = connErr
|
|
||||||
s.shuziliang(aport, client, tce)
|
train_pc_sim.Default().SendTrainControlMsg2(train, tce, pc.RealTrainPort)
|
||||||
}
|
|
||||||
if train.VobcState.Tc2Active {
|
if train.VobcState.Tc2Active {
|
||||||
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
||||||
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
||||||
@ -861,7 +784,7 @@ func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(aport bool, client *tc
|
|||||||
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
vobc.AtoStepLevel = trainAtoLevel(vobc.AtoTractionCommand3, vobc.AtoTractionCommand2, vobc.AtoTractionCommand1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
@ -1003,7 +926,7 @@ func (s *VerifySimulation) TrainPcSimMockInfo(train *state_proto.TrainState, dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4.4.4. 车载输出BTM查询同步帧报文内容(0x04)
|
// 4.4.4. 车载输出BTM查询同步帧报文内容(0x04)
|
||||||
func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []byte, trainPort bool) {
|
func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []byte, trainClientPort state_proto.TrainState_TrainPort) {
|
||||||
|
|
||||||
ts := time.Now().UnixMilli()
|
ts := time.Now().UnixMilli()
|
||||||
if len(data) < 12 {
|
if len(data) < 12 {
|
||||||
@ -1020,9 +943,10 @@ func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []
|
|||||||
var balise *state_proto.BTMState
|
var balise *state_proto.BTMState
|
||||||
var dsn, bc, mc byte
|
var dsn, bc, mc byte
|
||||||
btmCache := train.BtmBaliseCacheA
|
btmCache := train.BtmBaliseCacheA
|
||||||
if train.VobcState.Tc2Active {
|
if train.TrainPort != trainClientPort {
|
||||||
btmCache = train.BtmBaliseCacheB
|
btmCache = train.BtmBaliseCacheB
|
||||||
}
|
}
|
||||||
|
|
||||||
if atpReq.IsResend() {
|
if atpReq.IsResend() {
|
||||||
balise, dsn, bc, mc = can_btm.FindBaliseResend(btmCache, true)
|
balise, dsn, bc, mc = can_btm.FindBaliseResend(btmCache, true)
|
||||||
} else {
|
} else {
|
||||||
@ -1034,27 +958,23 @@ func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []
|
|||||||
timeSyncF.T2 = cl.BtmTk
|
timeSyncF.T2 = cl.BtmTk
|
||||||
timeSyncF.T3 = cl.TkNow()
|
timeSyncF.T3 = cl.TkNow()
|
||||||
if balise == nil {
|
if balise == nil {
|
||||||
queryData := make([]byte, 0)
|
queryData := createLine12EmptyBaliseData(btmRepFrame, timeSyncF)
|
||||||
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
|
sendLine12EmptyBaliseData(train, trainClientPort, queryData)
|
||||||
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
|
|
||||||
train_pc_sim.Default().SendBaliseData(train, trainPort, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
|
|
||||||
//slog.Info(fmt.Sprintf("接受应答器查询:%x发送无应答器数据,id:%v,数据:%X", data, trainAtm.CanId.ID4, queryData))
|
//slog.Info(fmt.Sprintf("接受应答器查询:%x发送无应答器数据,id:%v,数据:%X", data, trainAtm.CanId.ID4, queryData))
|
||||||
} else {
|
} else {
|
||||||
logstr := ""
|
logstr := ""
|
||||||
if atpReq.IsResend() {
|
if atpReq.IsResend() {
|
||||||
logstr = fmt.Sprintf("准备重新发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v,接受应答器报文:%X", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc, data)
|
logstr = fmt.Sprintf("准备重新发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v,接受应答器报文:%X clientPoret:%v trainPort:%v", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc, data, trainClientPort.String(), train.TrainPort.String())
|
||||||
|
|
||||||
} else if !balise.IsSend {
|
} else if !balise.IsSend {
|
||||||
balise.IsSend = true
|
balise.IsSend = true
|
||||||
logstr = fmt.Sprintf("准备发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v,接受应答器报文:%X", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc, data)
|
logstr = fmt.Sprintf("准备发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v,接受应答器报文:%X clientPoret:%v trainPort:%v", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc, data, trainClientPort.String(), train.TrainPort.String())
|
||||||
} else {
|
} /*else {
|
||||||
queryData := make([]byte, 0)
|
queryData := createLine12EmptyBaliseData(btmRepFrame, timeSyncF)
|
||||||
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
|
sendLine12EmptyBaliseData(train, trainClientPort, queryData)
|
||||||
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
|
|
||||||
train_pc_sim.Default().SendBaliseData(train, trainPort, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
|
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
slog.Info(logstr, trainPort)
|
slog.Info(logstr, trainClientPort.String())
|
||||||
aliseData, _ := hex.DecodeString(balise.Telegram)
|
aliseData, _ := hex.DecodeString(balise.Telegram)
|
||||||
stateRepFrame := btmRepFrame.EncodeBtmAtp()
|
stateRepFrame := btmRepFrame.EncodeBtmAtp()
|
||||||
statusDataCf, statusDataCfOk := message.CreateBtmAtpDataRspFramesData(stateRepFrame, aliseData, false, balise.HasData, cl.BtmTk, cl.BtmTk, cl.BtmTk)
|
statusDataCf, statusDataCfOk := message.CreateBtmAtpDataRspFramesData(stateRepFrame, aliseData, false, balise.HasData, cl.BtmTk, cl.BtmTk, cl.BtmTk)
|
||||||
@ -1066,13 +986,24 @@ func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []
|
|||||||
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
|
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
|
||||||
queryData = append(queryData, statusDataCf...) //数据帧包含结束帧
|
queryData = append(queryData, statusDataCf...) //数据帧包含结束帧
|
||||||
balise.BaliseTelegramForPcSimResend = fmt.Sprintf("%X", statusDataCf)
|
balise.BaliseTelegramForPcSimResend = fmt.Sprintf("%X", statusDataCf)
|
||||||
train_pc_sim.Default().SendBaliseData(train, trainPort, message.RECIVE_TRAIN_BTM_HAS_DATA, queryData)
|
train_pc_sim.Default().SendBaliseData2(train, trainClientPort, message.RECIVE_TRAIN_BTM_HAS_DATA, queryData)
|
||||||
} else {
|
} else {
|
||||||
slog.Error("列车pc仿真 BtmCanetClient应答帧、数据帧编码失败")
|
slog.Error("列车pc仿真 BtmCanetClient应答帧、数据帧编码失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendLine12EmptyBaliseData(train *state_proto.TrainState, trainClientPort state_proto.TrainState_TrainPort, emptyBaliseData []byte) {
|
||||||
|
train_pc_sim.Default().SendBaliseData2(train, trainClientPort, message.RECIVE_TRAIN_BTM_NOT_DATA, emptyBaliseData)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createLine12EmptyBaliseData(btmRepFrame *message.BtmStatusRspFrame, timeSyncFrame *message.BtmTimeSyncCheckFrame) []byte {
|
||||||
|
queryData := make([]byte, 0)
|
||||||
|
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
|
||||||
|
queryData = append(queryData, timeSyncFrame.EncodeBtmAtp().Encode()...)
|
||||||
|
return queryData
|
||||||
|
}
|
||||||
|
|
||||||
func createBtmStatus(canIdSn byte, btmState *state_proto.BTMState, atpReq *message.AtpRequestFrame, cl can_btm.BtmClock, dsn, baliseCount, messageCount byte) *message.BtmStatusRspFrame {
|
func createBtmStatus(canIdSn byte, btmState *state_proto.BTMState, atpReq *message.AtpRequestFrame, cl can_btm.BtmClock, dsn, baliseCount, messageCount byte) *message.BtmStatusRspFrame {
|
||||||
statusF := message.NewBtmStatusRspFrame(canIdSn)
|
statusF := message.NewBtmStatusRspFrame(canIdSn)
|
||||||
statusF.PowerAmplifierOn = true
|
statusF.PowerAmplifierOn = true
|
||||||
|
Loading…
Reference in New Issue
Block a user