rts-sim-testing-service/ts/simulation/wayside/memory/wayside_memory_turnout.go

45 lines
1.6 KiB
Go
Raw Normal View History

package memory
import (
2023-09-28 18:24:36 +08:00
"fmt"
2023-10-13 17:43:48 +08:00
"joylink.club/rtsssimulation/component/component_proto"
"joylink.club/rtsssimulation/fi"
2023-09-22 18:10:46 +08:00
2023-10-13 17:43:48 +08:00
"joylink.club/bj-rtsts-server/dto/request_proto"
2023-10-26 17:16:07 +08:00
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
)
2023-10-13 17:43:48 +08:00
// 处理道岔操作
func HandleTurnoutOperation(simulation *VerifySimulation, req *request_proto.TurnoutOperationReq) error {
2023-10-13 17:43:48 +08:00
uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &graphicData.Turnout{})
var err error
2023-10-13 17:43:48 +08:00
switch req.Operation {
case request_proto.Turnout_DC:
err = fi.DriveTurnoutDCOn(simulation.World, uid)
2023-10-13 17:43:48 +08:00
case request_proto.Turnout_CancelDC:
err = fi.DriveTurnoutDCOff(simulation.World, uid)
2023-10-13 17:43:48 +08:00
case request_proto.Turnout_FC:
err = fi.DriveTurnoutFCOn(simulation.World, uid)
2023-10-13 17:43:48 +08:00
case request_proto.Turnout_CancelFC:
err = fi.DriveTurnoutFCOff(simulation.World, uid)
2023-10-13 17:43:48 +08:00
case request_proto.Turnout_SetSB:
err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_SB)
2023-10-13 17:43:48 +08:00
case request_proto.Turnout_CancelSB:
err = fi.CancelTurnoutFault(simulation.World, uid, component_proto.Turnout_SB)
2023-10-13 17:43:48 +08:00
case request_proto.Turnout_SetJC:
err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_JC)
2023-10-13 17:43:48 +08:00
case request_proto.Turnout_CancelJC:
err = fi.CancelTurnoutFault(simulation.World, uid, component_proto.Turnout_JC)
case request_proto.Turnout_ForceDw:
err = fi.ForceTurnoutDw(simulation.World, uid)
case request_proto.Turnout_ForceFw:
err = fi.ForceTurnoutFw(simulation.World, uid)
case request_proto.Turnout_CancelForce:
err = fi.CancelTurnoutForce(simulation.World, uid)
2023-10-13 17:43:48 +08:00
default:
panic(fmt.Sprintf("未知的道岔操作:%s", req.Operation))
}
return err
2023-10-13 17:43:48 +08:00
}