2023-09-27 18:02:07 +08:00
|
|
|
package memory
|
|
|
|
|
|
|
|
import (
|
2024-01-10 11:13:13 +08:00
|
|
|
"fmt"
|
|
|
|
|
2024-01-11 10:24:56 +08:00
|
|
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
2024-01-10 11:13:13 +08:00
|
|
|
"joylink.club/bj-rtsts-server/dto/request_proto"
|
2023-10-08 10:35:40 +08:00
|
|
|
"joylink.club/rtsssimulation/fi"
|
2023-09-27 18:02:07 +08:00
|
|
|
)
|
|
|
|
|
2024-01-10 11:13:13 +08:00
|
|
|
// 处理继电器操作
|
|
|
|
func HandleRelayOperation(simulation *VerifySimulation, req *request_proto.RelayOperationReq) error {
|
2024-01-11 10:24:56 +08:00
|
|
|
uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.Relay{})
|
2024-01-10 11:13:13 +08:00
|
|
|
var err error
|
|
|
|
switch req.Operation {
|
|
|
|
case request_proto.Relay_ForceQw:
|
|
|
|
err = fi.SetRelayFaultForce(simulation.World, uid, true)
|
|
|
|
case request_proto.Relay_ForceHw:
|
|
|
|
err = fi.SetRelayFaultForce(simulation.World, uid, false)
|
|
|
|
case request_proto.Relay_CancelForce:
|
|
|
|
err = fi.CancelRelayFaultForce(simulation.World, uid)
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("未知的继电器操作:%s", req.Operation))
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|