信号机操作集成

This commit is contained in:
xzb 2023-10-13 14:41:55 +08:00
parent 92494a6dd2
commit 23ce6f910c
5 changed files with 620 additions and 311 deletions

View File

@ -31,6 +31,7 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
authed.POST("/switch/operation", switchOperation)
authed.GET("/getDataChannelName", getDataChannelName)
authed.POST("/relay/operation", relayOperation)
authed.POST("/signal/operation", signalOperation)
// 初始化地图信息
initPublishMapInfo()
@ -247,6 +248,36 @@ func switchOperation(c *gin.Context) {
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 SignalOperationReqDto body dto.SignalOperationReqDto true "ATS测试仿真-操作信号机"
//
// @Success 200 {object} string
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/signal/operation [post]
func signalOperation(c *gin.Context) {
req := &dto.SignalOperationReqDto{}
if err := c.ShouldBind(&req); err != nil {
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}
simulation := checkDeviceDataAndReturn(req.SimulationId)
slog.Info("传入状态参数", req)
memory.ChangeSignalState(simulation, &state.SignalState{
Id: req.DeviceId,
Aspect: req.Aspect,
}, req.MapId)
c.JSON(http.StatusOK, "ok")
}
// 获取仿真信息更新通道名称
//
// @Summary 获取仿真信息更新通道名称

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
package memory
import (
"fmt"
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
"joylink.club/ecs"
"joylink.club/rtsssimulation/consts"
"joylink.club/rtsssimulation/fi"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto"
)
func ChangeSignalState(simulation *VerifySimulation, status *state.SignalState, mapId int32) {
signalUid := QueryUidByMidAndComId(mapId, status.Id, &graphicData.Signal{})
signalModel, err := simulation.Repo.FindModel(signalUid, proto.DeviceType_DeviceType_Signal)
if err != nil {
panic(fmt.Sprintf("信号机[%s]模型不存在", signalUid))
}
signalGroupCode := signalModel.(*repository.Signal).Code()
switch signalGroupCode {
case consts.SIGNAL_2XH1:
changeSignal2XH1State(simulation.World, signalUid, status.GetAspect())
case consts.SIGNAL_3XH1:
changeSignal3XH1State(simulation.World, signalUid, status.GetAspect())
case consts.SIGNAL_3XH2:
changeSignal3XH2State(simulation.World, signalUid, status.GetAspect())
case consts.SIGNAL_3XH3:
changeSignal3XH3State(simulation.World, signalUid, status.GetAspect())
case consts.SIGNAL_3XH4:
changeSignal3XH4State(simulation.World, signalUid, status.GetAspect())
case consts.SIGNAL_DCXH:
changeSignalDCXHState(simulation.World, signalUid, status.GetAspect())
case consts.SIGNAL_JCKXH:
changeSignalJCKXHState(simulation.World, signalUid, status.GetAspect())
default:
panic(fmt.Sprintf("操作[%s]的信号机,无法识别组合类型[%s]", signalUid, signalGroupCode))
}
}
func changeSignalJCKXHState(w ecs.World, signalUid string, toAspect state.Signal_Aspect) {
switch toAspect {
case state.Signal_U:
fi.DriveSignalJCKXHLx(w, signalUid)
case state.Signal_B:
fi.DriveSignalJCKXHDx(w, signalUid)
case state.Signal_H:
fi.DriveSignalJCKXHNon(w, signalUid)
}
}
func changeSignalDCXHState(w ecs.World, signalUid string, toAspect state.Signal_Aspect) {
switch toAspect {
case state.Signal_B:
fi.DriveSignalDCXHDx(w, signalUid)
case state.Signal_A:
fi.DriveSignalDCXHNon(w, signalUid)
}
}
func changeSignal3XH4State(w ecs.World, signalUid string, toAspect state.Signal_Aspect) {
switch toAspect {
case state.Signal_ON:
fi.DriveSignal3XH4Dd(w, signalUid, true)
case state.Signal_OFF:
fi.DriveSignal3XH4Dd(w, signalUid, false)
case state.Signal_L:
fi.DriveSignal3XH4Lx(w, signalUid, true)
case state.Signal_U:
fi.DriveSignal3XH4Lx(w, signalUid, false)
case state.Signal_H:
fi.DriveSignal3XH4Non(w, signalUid)
}
}
func changeSignal3XH3State(w ecs.World, signalUid string, toAspect state.Signal_Aspect) {
switch toAspect {
case state.Signal_ON:
fi.DriveSignal3XH3Dd(w, signalUid, true)
case state.Signal_OFF:
fi.DriveSignal3XH3Dd(w, signalUid, false)
case state.Signal_U:
fi.DriveSignal3XH3Lx(w, signalUid)
case state.Signal_HU:
fi.DriveSignal3XH3Yx(w, signalUid)
case state.Signal_H:
fi.DriveSignal3XH3Non(w, signalUid)
}
}
func changeSignal3XH2State(w ecs.World, signalUid string, toAspect state.Signal_Aspect) {
switch toAspect {
case state.Signal_ON:
fi.DriveSignal3XH2Dd(w, signalUid, true)
case state.Signal_OFF:
fi.DriveSignal3XH2Dd(w, signalUid, false)
case state.Signal_L:
fi.DriveSignal3XH2Lx(w, signalUid)
case state.Signal_HU:
fi.DriveSignal3XH2Yx(w, signalUid)
case state.Signal_H:
fi.DriveSignal3XH2Non(w, signalUid)
}
}
func changeSignal3XH1State(w ecs.World, signalUid string, toAspect state.Signal_Aspect) {
switch toAspect {
case state.Signal_ON:
fi.DriveSignal3XH1Dd(w, signalUid, true)
case state.Signal_OFF:
fi.DriveSignal3XH1Dd(w, signalUid, false)
case state.Signal_L:
fi.DriveSignal3XH1Lx(w, signalUid, true)
case state.Signal_U:
fi.DriveSignal3XH1Lx(w, signalUid, false)
case state.Signal_HU:
fi.DriveSignal3XH1Yx(w, signalUid)
case state.Signal_H:
fi.DriveSignal3XH1Non(w, signalUid)
}
}
func changeSignal2XH1State(w ecs.World, signalUid string, toAspect state.Signal_Aspect) {
switch toAspect {
case state.Signal_ON:
fi.DriveSignal2XH1Dd(w, signalUid, true)
case state.Signal_OFF:
fi.DriveSignal2XH1Dd(w, signalUid, false)
case state.Signal_L:
fi.DriveSignal2XH1Lx(w, signalUid)
case state.Signal_H:
fi.DriveSignal2XH1Non(w, signalUid)
}
}

@ -1 +1 @@
Subproject commit 5604ad84ed5c6af4206937f5bbba9b2debfbfb6f
Subproject commit 7a24c7aae20f83fa2bba4639066dff9b267f6d38

View File

@ -1,5 +1,7 @@
package dto
import "joylink.club/bj-rtsts-server/ats/verify/protos/state"
// 创建仿真请求
type SimulationCreateReqDto struct {
//地图id
@ -68,6 +70,12 @@ type SwitchOperationReqDto struct {
TurnNormal bool `form:"turnNormal" json:"turnNormal"`
TurnReverse bool `form:"turnReverse" json:"turnReverse"`
}
type SignalOperationReqDto struct {
SimulationId string `form:"simulationId" json:"simulationId" binding:"required"`
MapId int32 `json:"mapId" from:"mapId" binding:"required"`
DeviceId string `form:"id" json:"id" binding:"required"`
Aspect state.Signal_Aspect `form:"aspect" json:"aspect"`
}
/////////////////////////////////////////////////////////////////////////////////