2023-08-01 17:08:45 +08:00
|
|
|
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"
|
2023-09-28 17:28:20 +08:00
|
|
|
"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-08-01 17:08:45 +08:00
|
|
|
)
|
|
|
|
|
2023-10-13 17:43:48 +08:00
|
|
|
// 处理道岔操作
|
2023-11-03 17:27:37 +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{})
|
2023-11-03 17:27:37 +08:00
|
|
|
var err error
|
2023-10-13 17:43:48 +08:00
|
|
|
switch req.Operation {
|
|
|
|
case request_proto.Turnout_DC:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.DriveTurnoutDCOn(simulation.World, uid)
|
2023-10-13 17:43:48 +08:00
|
|
|
case request_proto.Turnout_CancelDC:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.DriveTurnoutDCOff(simulation.World, uid)
|
2023-10-13 17:43:48 +08:00
|
|
|
case request_proto.Turnout_FC:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.DriveTurnoutFCOn(simulation.World, uid)
|
2023-10-13 17:43:48 +08:00
|
|
|
case request_proto.Turnout_CancelFC:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.DriveTurnoutFCOff(simulation.World, uid)
|
2023-10-13 17:43:48 +08:00
|
|
|
case request_proto.Turnout_SetSB:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_SB)
|
2023-10-13 17:43:48 +08:00
|
|
|
case request_proto.Turnout_CancelSB:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.CancelTurnoutFault(simulation.World, uid, component_proto.Turnout_SB)
|
2023-10-13 17:43:48 +08:00
|
|
|
case request_proto.Turnout_SetJC:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.SetTurnoutFault(simulation.World, uid, component_proto.Turnout_JC)
|
2023-10-13 17:43:48 +08:00
|
|
|
case request_proto.Turnout_CancelJC:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.CancelTurnoutFault(simulation.World, uid, component_proto.Turnout_JC)
|
2023-10-31 11:22:50 +08:00
|
|
|
case request_proto.Turnout_ForceDw:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.ForceTurnoutDw(simulation.World, uid)
|
2023-10-31 11:22:50 +08:00
|
|
|
case request_proto.Turnout_ForceFw:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.ForceTurnoutFw(simulation.World, uid)
|
2023-10-31 11:22:50 +08:00
|
|
|
case request_proto.Turnout_CancelForce:
|
2023-11-03 17:27:37 +08:00
|
|
|
err = fi.CancelTurnoutForce(simulation.World, uid)
|
2023-10-13 17:43:48 +08:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("未知的道岔操作:%s", req.Operation))
|
|
|
|
}
|
2023-11-03 17:27:37 +08:00
|
|
|
return err
|
2023-10-13 17:43:48 +08:00
|
|
|
}
|