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

45 lines
1.6 KiB
Go

package memory
import (
"fmt"
"joylink.club/rtsssimulation/component/component_proto"
"joylink.club/rtsssimulation/fi"
"joylink.club/bj-rtsts-server/dto/data_proto"
"joylink.club/bj-rtsts-server/dto/request_proto"
)
// 处理道岔操作
func HandleTurnoutOperation(simulation *VerifySimulation, req *request_proto.TurnoutOperationReq) error {
uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.Turnout{})
var err error
switch req.Operation {
case request_proto.Turnout_DC:
err = fi.DriveTurnoutDCOn(simulation.World, uid)
case request_proto.Turnout_CancelDC:
err = fi.DriveTurnoutDCOff(simulation.World, uid)
case request_proto.Turnout_FC:
err = fi.DriveTurnoutFCOn(simulation.World, uid)
case request_proto.Turnout_CancelFC:
err = fi.DriveTurnoutFCOff(simulation.World, uid)
case request_proto.Turnout_SetSB:
err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_SB)
case request_proto.Turnout_CancelSB:
err = fi.CancelTurnoutFault(simulation.World, uid, component_proto.Turnout_SB)
case request_proto.Turnout_SetJC:
err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_JC)
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)
default:
panic(fmt.Sprintf("未知的道岔操作:%s", req.Operation))
}
return err
}