【修改获取IBP UID集合逻辑】
This commit is contained in:
parent
ec9f8a380e
commit
584c6311dd
@ -328,7 +328,7 @@ func ibpBtnOperation(c *gin.Context) {
|
||||
}
|
||||
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
||||
slog.Info("传入状态参数", req)
|
||||
memory.ChangeIBPButtonState(simulation, req.MapId, req.StationId, req.Id, req.Down)
|
||||
memory.ChangeIBPButtonState(simulation, req.MapId, req.Station, req.Id, req.Down)
|
||||
c.JSON(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// 操作IBP按钮
|
||||
func ChangeIBPButtonState(sim *VerifySimulation, mapId int32, stationId, btnId string, pressDown bool) {
|
||||
uid := QueryIBPUidByMidAndComId(mapId, btnId, stationId)
|
||||
func ChangeIBPButtonState(sim *VerifySimulation, mapId int32, station, btnId string, pressDown bool) {
|
||||
uid := QueryIBPUidByMidAndComId(mapId, btnId, station)
|
||||
if pressDown {
|
||||
fi.PressDownButton(sim.World, uid)
|
||||
} else {
|
||||
@ -19,13 +19,13 @@ func ChangeIBPButtonState(sim *VerifySimulation, mapId int32, stationId, btnId s
|
||||
}
|
||||
|
||||
// 获取仿真车站按钮状态,前端推送
|
||||
func GetMapAllIBPState(sim *VerifySimulation, mapId int32, stationId string) *state.AllDevicesStatus {
|
||||
func GetMapAllIBPState(sim *VerifySimulation, mapId int32, station string) *state.AllDevicesStatus {
|
||||
status := &state.AllDevicesStatus{
|
||||
ButtonState: []*state.ButtonState{},
|
||||
LightState: []*state.LightState{},
|
||||
AlarmState: []*state.AlarmState{},
|
||||
}
|
||||
uidMap := QueryIBPUidMapByType(mapId, stationId)
|
||||
uidMap := QueryIBPUidMapByType(mapId, station)
|
||||
for _, u := range uidMap {
|
||||
entry, ok := entity.GetEntityByUid(sim.World, u.Uid)
|
||||
if !ok {
|
||||
|
@ -215,7 +215,7 @@ func initIBPUid(gus *stationUidStructure, city, lineId string, station *graphicD
|
||||
Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)),
|
||||
}
|
||||
}
|
||||
gus.IBPIds[station.Common.Id] = uidMap
|
||||
gus.IBPIds[station.Code] = uidMap
|
||||
}
|
||||
|
||||
// 初始化继电器柜 UID
|
||||
@ -367,17 +367,17 @@ func QueryUidByMidAndComId(mapId int32, comId string, m interface{}) string {
|
||||
}
|
||||
|
||||
// 根据地图、车站CODE、设备类型获取UID集合
|
||||
func QueryIBPUidMapByType(mapId int32, stationCommonId string) map[string]*elementIdStructure {
|
||||
func QueryIBPUidMapByType(mapId int32, station string) map[string]*elementIdStructure {
|
||||
uidData, ok := giUidMap.Load(mapId)
|
||||
if !ok {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("地图【id:%d】不存在uid缓存", mapId)})
|
||||
}
|
||||
return (uidData.(*stationUidStructure)).IBPIds[stationCommonId]
|
||||
return (uidData.(*stationUidStructure)).IBPIds[station]
|
||||
}
|
||||
|
||||
// 根据地图的comId获取UID
|
||||
func QueryIBPUidByMidAndComId(mapId int32, comId, stationCommonId string) string {
|
||||
uidMap := QueryIBPUidMapByType(mapId, stationCommonId)
|
||||
func QueryIBPUidByMidAndComId(mapId int32, comId, station string) string {
|
||||
uidMap := QueryIBPUidMapByType(mapId, station)
|
||||
if uidMap[comId] != nil {
|
||||
return uidMap[comId].Uid
|
||||
}
|
||||
|
@ -4752,7 +4752,7 @@ const docTemplate = `{
|
||||
"simulationId": {
|
||||
"type": "string"
|
||||
},
|
||||
"stationId": {
|
||||
"stationCode": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
|
@ -4745,7 +4745,7 @@
|
||||
"simulationId": {
|
||||
"type": "string"
|
||||
},
|
||||
"stationId": {
|
||||
"stationCode": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ definitions:
|
||||
type: integer
|
||||
simulationId:
|
||||
type: string
|
||||
stationId:
|
||||
stationCode:
|
||||
type: string
|
||||
required:
|
||||
- down
|
||||
|
@ -80,7 +80,7 @@ type SignalOperationReqDto struct {
|
||||
type ButtonOperationReqDto struct {
|
||||
SimulationId string `form:"simulationId" json:"simulationId" binding:"required"`
|
||||
MapId int32 `json:"mapId" from:"mapId" binding:"required"`
|
||||
StationId string `form:"stationId" json:"stationId"`
|
||||
Station string `form:"stationCode" json:"stationCode"`
|
||||
Id string `form:"id" json:"id" binding:"required"`
|
||||
Down bool `form:"down" json:"down" binding:"required"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user