Compare commits

..

No commits in common. "521e6c3d591871b37b591e4460dcc14c5b4109fb" and "73ab803b7aaba2906535229fc4843b3275588df8" have entirely different histories.

11 changed files with 1804 additions and 2260 deletions

View File

@ -32,8 +32,6 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
authed.POST("/train/remove", removeTrain)
authed.POST("/train/remove/all", removeAllTrain)
authed.POST("/train/update", updateTrain)
authed.POST("/train/control", controlTrain)
authed.POST("/train/conn", trainConnThird)
authed.POST("/switch/operation", turnoutOperation)
authed.POST("/relay/operation", relayOperation)
authed.POST("/signal/operation", signalOperation)
@ -284,56 +282,6 @@ func updateTrain(c *gin.Context) {
c.JSON(http.StatusOK, &rsp)
}
// ATS测试仿真-列车连接三方
//
// @Summary ATS测试仿真-列车连接三方
//
// @Security JwtAuth
//
// @Description ATS测试仿真-列车连接三方
// @Tags ATS测试仿真Api
// @Accept json
// @Produce json
// @Param Authorization header string true "JWT Token"
// @Param TrainConnThirdDto body dto.TrainConnThirdDto true "ATS测试仿真-修改列车基础信息"
// @Success 200 {object} dto.AddTrainRspDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/train/conn [post]
func trainConnThird(c *gin.Context) {
req := &dto.TrainConnThirdDto{}
if err := c.ShouldBind(req); err != nil {
panic(sys_error.New("修改列车控制参数失败,请求参数异常", err))
}
simulation := checkDeviceDataAndReturn(req.SimulationId)
memory.TrainConnTypeUpdate(simulation, req)
c.JSON(http.StatusOK, "ok")
}
// ATS测试仿真-修改列车控制
//
// @Summary ATS测试仿真-修改列车控制
//
// @Security JwtAuth
//
// @Description ATS测试仿真-修改列车控制
// @Tags ATS测试仿真Api
// @Accept json
// @Produce json
// @Param Authorization header string true "JWT Token"
// @Param ControlTrainReqDtos body dto.ControlTrainReqDtos true "ATS测试仿真-修改列车基础信息"
// @Success 200 {object} dto.AddTrainRspDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/train/control [post]
func controlTrain(c *gin.Context) {
req := &dto.ControlTrainReqDtos{}
if err := c.ShouldBind(req); err != nil {
panic(sys_error.New("修改列车控制参数失败,请求参数异常", err))
}
simulation := checkDeviceDataAndReturn(req.SimulationId)
memory.ControlTrainUpdate(simulation, req)
c.JSON(http.StatusOK, "ok")
}
// ATS测试仿真-移除所有列车
//
// @Summary ATS测试仿真-移除列车

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@ package dto
import (
"joylink.club/bj-rtsts-server/dto/data_proto"
"joylink.club/bj-rtsts-server/dto/request_proto"
"joylink.club/bj-rtsts-server/dto/state_proto"
)
// 创建仿真请求
@ -143,27 +142,6 @@ type UpdateTrainReqDto struct {
WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"`
}
// 列车连接三方类型
type TrainConnThirdDto struct {
// 仿真id
SimulationId string `json:"simulationId" form:"simulationId"`
Id string `json:"id" form:"id"` // 列车Id
ConnType state_proto.TrainConnState_TrainConnType `json:"connType" form:"connType"` //连接类型 0=未连接;1=半实物;2= 车载仿真
}
// 列车控制
type ControlTrainReqDtos struct {
// 仿真id
SimulationId string `json:"simulationId" form:"simulationId"`
// 列车Id
Id string `json:"id" form:"id"`
PressingBrake bool `json:"pressingBrake" form:"pressingBrake"` // 紧急制动
Tc1On bool `json:"tc1On" form:"tc1On"` // 驾驶室激活1
Tc2On bool `json:"tc2On" form:"tc2On"` // 驾驶室激活2
TuningDir uint8 `json:"tuningDir" form:"tuningDir"` // 运行方向 1=前进;2=后退;0=原地等待
TractionOrBrake uint8 `json:"tractionOrBrake" form:"tractionOrBrake"` // 牵引或制动 大于0是牵引小于0是制动 整体按照整型传输(*100)使用时除以100
}
// 为仿真添加测试车请求
type AddTrainRspDto struct {
//仿真id

File diff suppressed because it is too large Load Diff

View File

@ -409,7 +409,6 @@ func convertTrainState(v *state_proto.TrainState) *state_proto.TrainMapState {
TailOffset: v.TailOffset,
TailDevicePort: v.TailDevicePort,
BtmState: v.BtmState,
ConnState: v.ConnState,
}
convertDynamicConfig(v.TrainDynamicConfig, t.TrainDynamicConfig)
convertDynamicConfig(v.TrainEndsA, t.TrainEndsA)

View File

@ -13,9 +13,9 @@ import (
var (
basePath, _ = os.Getwd()
protoFolder = filepath.Join(basePath, "rts-sim-testing-message", "protos")
protocPath = filepath.Join(basePath, "rts-sim-testing-message", "protoc-23.1", "bin", "win64", "protoc")
modulePrefix = "joylink.club/rts-sim-testing-service"
protoFolder = filepath.Join(basePath, "bj-rtss-message", "protos")
protocPath = filepath.Join(basePath, "bj-rtss-message", "protoc-23.1", "bin", "win64", "protoc")
modulePrefix = "joylink.club/bj-rtsts-server"
)
func main() {

@ -1 +1 @@
Subproject commit 88b5ea8c77c150800681a384df96ba6ae81a23f5
Subproject commit ecb43fa7a3538004002cc8eb5d39587080a97029

@ -1 +1 @@
Subproject commit c0f73e7b5d404e4c932711b44770b4e75ebbfe74
Subproject commit 225f92b91cd0ff0371b9fd785f91ddf05903ea8a

View File

@ -71,7 +71,6 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
status.Up = up
status.PointTo = pointTo
status.TrainKilometer = kilometer.Value
status.ConnState = &state_proto.TrainConnState{Conn: false, ConnType: state_proto.TrainConnState_NONE}
status.DynamicState = &state_proto.TrainDynamicState{
HeadLinkId: linkId,
HeadLinkOffset: loffset,
@ -113,62 +112,6 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
allTrainMap.Store(status.Id, status)
return nil
}
func TrainConnTypeUpdate(vs *VerifySimulation, ct *dto.TrainConnThirdDto) {
allTrainMap := &vs.Memory.Status.TrainStateMap
data, ok := allTrainMap.Load(ct.Id)
if !ok {
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.Id)))
}
train := data.(*state_proto.TrainState)
train.ConnState.Conn = true
if ct.ConnType == state_proto.TrainConnState_NONE {
train.ConnState.Conn = false
}
train.ConnState.ConnType = ct.ConnType
}
// 列车控制修改参数
func ControlTrainUpdate(vs *VerifySimulation, ct *dto.ControlTrainReqDtos) {
allTrainMap := &vs.Memory.Status.TrainStateMap
data, ok := allTrainMap.Load(ct.Id)
if !ok {
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.Id)))
}
sta := data.(*state_proto.TrainState)
sta.VobcState.Tc1Active = ct.Tc1On
sta.VobcState.Tc2Active = ct.Tc2On
sta.VobcState.EmergencyBrakingStatus = ct.PressingBrake
switch ct.TuningDir {
case 1:
sta.VobcState.DirectionForward = true
sta.VobcState.DirectionBackward = false
break
case 2:
sta.VobcState.DirectionForward = false
sta.VobcState.DirectionBackward = true
break
default:
sta.VobcState.DirectionForward = false
sta.VobcState.DirectionBackward = false
}
if ct.TractionOrBrake > 0 {
sta.VobcState.BrakingStatus = false
sta.VobcState.BrakeForce = 0
sta.VobcState.TractionStatus = true
sta.VobcState.TractionForce = int64(ct.TractionOrBrake)
} else if ct.TractionOrBrake < 0 {
sta.VobcState.TractionStatus = false
sta.VobcState.TractionForce = 0
sta.VobcState.BrakingStatus = true
sta.VobcState.BrakeForce = int64(ct.TractionOrBrake)
} else if ct.TractionOrBrake == 0 {
sta.VobcState.TractionStatus = false
sta.VobcState.TractionForce = 0
sta.VobcState.BrakingStatus = false
sta.VobcState.BrakeForce = 0
}
}
// 增加列车状态
/*func AddTrainState(vs *VerifySimulation, status *state_proto.TrainState, mapId int32) *state_proto.TrainState {

View File

@ -134,10 +134,6 @@ func CreateSimulation(projectId int32, mapIds []int32, runConfig *dto.ProjectRun
// return s.runState
// }
func (s *VerifySimulation) GetTrainPcSimConfig() config.VehiclePCSimConfig {
return s.runConfig.PcSimConfig
}
// 获取仿真世界信息
func (s *VerifySimulation) GetComIdByUid(uid string) uint32 {
es := s.UidMap
@ -281,18 +277,12 @@ func (s *VerifySimulation) HandleSectionCmdMsg(city string, lineId string, centr
// 处理动力学列车速度消息
func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainInfo) {
trainId := strconv.Itoa(int(info.Number))
trainData, ok := s.Memory.Status.TrainStateMap.Load(trainId)
_, ok := s.Memory.Status.TrainStateMap.Load(trainId)
if !ok {
return
}
train := trainData.(*state_proto.TrainState)
connType := train.ConnState
//列车连接并且是半实物连接 date 2024-3-15
if connType.Conn && connType.ConnType == state_proto.TrainConnState_VOBC {
// 给半实物仿真发送速度
semi_physical_train.Default().SendTrainControlMessage(info)
}
// 给半实物仿真发送速度
semi_physical_train.Default().SendTrainControlMessage(info)
// 更新列车状态
trainState := UpdateTrainStateByDynamics(s, trainId, info)
// 更新电机转速
@ -390,21 +380,17 @@ func (s *VerifySimulation) HandleSemiPhysicalTrainControlMsg(b []byte) {
if !train.Show { // 下线列车
return true
}
connState := train.ConnState
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
return false
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
return true
})
}

View File

@ -4,7 +4,6 @@ import (
"fmt"
"joylink.club/bj-rtsts-server/third_party/acc"
"joylink.club/bj-rtsts-server/third_party/radar"
"joylink.club/bj-rtsts-server/third_party/train_pc_sim"
"log/slog"
"runtime"
"strconv"
@ -137,7 +136,6 @@ func runThirdParty(s *memory.VerifySimulation) error {
radar.Default().Start(s)
//列车加速计发送vobc
acc.Default().Start(s)
train_pc_sim.Default().Start(s)
return nil
}