信号机操作集成

This commit is contained in:
xzb 2023-10-13 17:44:17 +08:00
parent 88e4dc7266
commit ba019810d6
2 changed files with 10 additions and 13 deletions

View File

@ -271,10 +271,7 @@ func signalOperation(c *gin.Context) {
}
simulation := checkDeviceDataAndReturn(req.SimulationId)
slog.Info("传入状态参数", req)
memory.ChangeSignalState(simulation, &state.SignalState{
Id: req.DeviceId,
Aspect: req.Aspect,
}, req.MapId)
memory.ChangeSignalState(simulation, req.MapId, req.DeviceId, req.Aspect)
c.JSON(http.StatusOK, "ok")
}

View File

@ -11,8 +11,8 @@ import (
"joylink.club/rtsssimulation/repository/model/proto"
)
func ChangeSignalState(simulation *VerifySimulation, status *state.SignalState, mapId int32) {
signalUid := QueryUidByMidAndComId(mapId, status.Id, &graphicData.Signal{})
func ChangeSignalState(simulation *VerifySimulation, mapId int32, signalDeviceId string, toAspect state.Signal_Aspect) {
signalUid := QueryUidByMidAndComId(mapId, signalDeviceId, &graphicData.Signal{})
signalModel, err := simulation.Repo.FindModel(signalUid, proto.DeviceType_DeviceType_Signal)
if err != nil {
panic(fmt.Sprintf("信号机[%s]模型不存在", signalUid))
@ -20,19 +20,19 @@ func ChangeSignalState(simulation *VerifySimulation, status *state.SignalState,
signalGroupCode := signalModel.(*repository.Signal).Code()
switch signalGroupCode {
case consts.SIGNAL_2XH1:
changeSignal2XH1State(simulation.World, signalUid, status.GetAspect())
changeSignal2XH1State(simulation.World, signalUid, toAspect)
case consts.SIGNAL_3XH1:
changeSignal3XH1State(simulation.World, signalUid, status.GetAspect())
changeSignal3XH1State(simulation.World, signalUid, toAspect)
case consts.SIGNAL_3XH2:
changeSignal3XH2State(simulation.World, signalUid, status.GetAspect())
changeSignal3XH2State(simulation.World, signalUid, toAspect)
case consts.SIGNAL_3XH3:
changeSignal3XH3State(simulation.World, signalUid, status.GetAspect())
changeSignal3XH3State(simulation.World, signalUid, toAspect)
case consts.SIGNAL_3XH4:
changeSignal3XH4State(simulation.World, signalUid, status.GetAspect())
changeSignal3XH4State(simulation.World, signalUid, toAspect)
case consts.SIGNAL_DCXH:
changeSignalDCXHState(simulation.World, signalUid, status.GetAspect())
changeSignalDCXHState(simulation.World, signalUid, toAspect)
case consts.SIGNAL_JCKXH:
changeSignalJCKXHState(simulation.World, signalUid, status.GetAspect())
changeSignalJCKXHState(simulation.World, signalUid, toAspect)
default:
panic(fmt.Sprintf("操作[%s]的信号机,无法识别组合类型[%s]", signalUid, signalGroupCode))
}