From ea29848a7495befa963bb86e97b0abe816bc86cd Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 25 Sep 2023 18:14:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96UI?= =?UTF-8?q?D=E6=98=A0=E5=B0=84=E9=9B=86=E5=90=88=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wayside/memory/wayside_memory_map_init.go | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go b/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go index 0624ec1..3ca5a7a 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go @@ -2,7 +2,6 @@ package memory import ( "fmt" - "reflect" "sync" "joylink.club/bj-rtsts-server/ats/verify/protos/graphicData" @@ -208,26 +207,26 @@ func queryUidStructure[T *stationUidStructure | *relayUidStructure](mapId int32) } // 获取设备类型获取对应字段 -func getFieldNameByType(m interface{}) string { +func getUidMapByType(uidData any, m interface{}) map[string]*elementIdStructure { switch m.(type) { case *graphicData.AxleCounting: - return "AxlePointIds" + return (uidData.(*stationUidStructure)).AxlePointIds case *graphicData.Turnout: - return "TurnoutIds" + return (uidData.(*stationUidStructure)).TurnoutIds case *graphicData.Section: - return "PhysicalSectionIds" + return (uidData.(*stationUidStructure)).PhysicalSectionIds case *graphicData.Signal: - return "SignalIds" + return (uidData.(*stationUidStructure)).SignalIds case *graphicData.Transponder: - return "TransponderIds" + return (uidData.(*stationUidStructure)).TransponderIds case *graphicData.Slope: - return "SlopeIds" + return (uidData.(*stationUidStructure)).SlopeIds case *graphicData.Curvature: - return "CurvatureIds" + return (uidData.(*stationUidStructure)).CurvatureIds case *graphicData.RelayCabinet: - return "RelayCabinetIds" + return (uidData.(*relayUidStructure)).RelayCabinetIds case *graphicData.Relay: - return "RelayIds" + return (uidData.(*relayUidStructure)).RelayIds default: panic(&dto.ErrorDto{Code: dto.ArgumentParseError, Message: "类型未映射字段"}) } @@ -239,18 +238,7 @@ func QueryMapUidMapByType(mapId int32, m interface{}) map[string]*elementIdStruc if !ok { panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("地图【id:%d】不存在uid缓存", mapId)}) } - // 字段名称 - fieldName := getFieldNameByType(m) - reflectUidMap := reflect.ValueOf(&uidData).Elem() - um := reflectUidMap.Elem().Elem().FieldByName(fieldName) - if !um.CanAddr() { - panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "类型不匹配"}) - } - uidMap, ok := um.Interface().(map[string]*elementIdStructure) - if !ok { - panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "类型不匹配"}) - } - return uidMap + return getUidMapByType(uidData, m) } // 根据地图的comId获取UID