123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541 |
- package config
- import (
- "cicv-data-closedloop/aarch64/pjisuv/common/config"
- "cicv-data-closedloop/common/config/c_log"
- "cicv-data-closedloop/common/util"
- "cicv-data-closedloop/pjisuv_msgs"
- "cicv-data-closedloop/pjisuv_ticker"
- "github.com/bluenviron/goroslib/v2/pkg/msgs/geometry_msgs"
- "github.com/bluenviron/goroslib/v2/pkg/msgs/nav_msgs"
- "github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
- "github.com/bluenviron/goroslib/v2/pkg/msgs/tf2_msgs"
- "github.com/bluenviron/goroslib/v2/pkg/msgs/visualization_msgs"
- "plugin"
- "slices"
- "sync"
- )
- func InitTriggerConfig() {
- config.OssMutex.Lock()
- defer config.OssMutex.Unlock()
- triggerLocalPathsMapTriggerId := make(map[string]string)
- c_log.GlobalLogger.Info("主节点加载触发器插件 - 开始。")
- // 1 获取数采任务的触发器列表
- cloudTriggers := &config.PlatformConfig.TaskTriggers
- // 2 获取本地触发器列表(触发器目录的一级子目录为【触发器ID_触发器Label】)
- localTriggerIds := util.GetFirstLevelSubdirectories(config.CloudConfig.TriggersDir)
- // 3 对比触发器列表,本地没有的则下载
- for _, trigger := range *cloudTriggers {
- id := util.ToString(trigger.TriggerId)
- hasIdDir := slices.Contains(localTriggerIds, id) // 改成了 slices 工具库
- triggerLocalDir := config.CloudConfig.TriggersDir + id + "/"
- hasLabelSo, soPaths := util.CheckSoFilesInDirectory(triggerLocalDir)
- var triggerLocalPath string
- if hasIdDir && hasLabelSo { // 已存在的触发器需要判断是否大小一致
- triggerLocalPath = soPaths[0]
- ossSize, _ := util.GetOSSFileSize(config.OssBucket, trigger.TriggerScriptPath)
- localSize, _ := util.GetFileSize(triggerLocalPath)
- if ossSize == localSize {
- c_log.GlobalLogger.Info("触发器插件 ", triggerLocalPath, " 存在且与云端触发器大小一致。")
- triggerLocalPathsMapTriggerId[triggerLocalPath] = id
- continue
- }
- }
- label := util.GetFileNameWithoutExtension(config.CloudConfig.TriggersDir + trigger.TriggerScriptPath)
- triggerLocalPath = config.CloudConfig.TriggersDir + id + "/" + label + ".so"
- c_log.GlobalLogger.Info("开始下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
- _ = util.CreateParentDir(triggerLocalPath)
- for {
- if err := config.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath); err != nil {
- c_log.GlobalLogger.Error("下载触发器插件失败,再次尝试:", err)
- continue
- }
- break
- }
- triggerLocalPathsMapTriggerId[triggerLocalPath] = id
- }
- success := 0
- // 加载所有触发器的文件
- for triggerLocalPath, triggerId := range triggerLocalPathsMapTriggerId {
- // 载入插件到数组
- open, err := plugin.Open(triggerLocalPath)
- if err != nil {
- c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "失败。", err)
- continue
- }
- topic0, err := open.Lookup("Topic")
- if err != nil {
- c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Topic方法失败。", err)
- continue
- }
- topic1, ok := topic0.(func() string)
- if ok != true {
- c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func() string):", err)
- continue
- }
- topic2 := topic1()
- rule, err := open.Lookup("Rule")
- if err != nil {
- c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Rule方法失败。", err)
- continue
- }
- if pjisuv_ticker.TickerTopic == topic2 { // 定时任务触发器
- if f, ok1 := rule.(func(shareVars *sync.Map)); ok1 {
- RuleOfCicvTicker = append(RuleOfCicvTicker, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfAmrPose == topic2 { //1
- if f, ok1 := rule.(func(data *visualization_msgs.MarkerArray) string); ok1 {
- RuleOfAmrPose1 = append(RuleOfAmrPose1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *visualization_msgs.MarkerArray) string); ok3 {
- RuleOfAmrPose3 = append(RuleOfAmrPose3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfBoundingBoxesFast == topic2 { //2
- if f, ok1 := rule.(func(data *pjisuv_msgs.BoundingBoxArray) string); ok1 {
- RuleOfBoundingBoxesFast1 = append(RuleOfBoundingBoxesFast1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.BoundingBoxArray) string); ok3 {
- RuleOfBoundingBoxesFast3 = append(RuleOfBoundingBoxesFast3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCameraFault == topic2 { //3
- if f, ok1 := rule.(func(data *pjisuv_msgs.FaultVec) string); ok1 {
- RuleOfCameraFault1 = append(RuleOfCameraFault1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.FaultVec) string); ok3 {
- RuleOfCameraFault3 = append(RuleOfCameraFault3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCanData == topic2 { //4
- if f, ok1 := rule.(func(data *pjisuv_msgs.Frame) string); ok1 {
- RuleOfCanData1 = append(RuleOfCanData1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Frame) string); ok3 {
- RuleOfCanData3 = append(RuleOfCanData3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCh128x1LslidarPointCloud == topic2 { //5
- if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
- RuleOfCh128x1LslidarPointCloud1 = append(RuleOfCh128x1LslidarPointCloud1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
- RuleOfCh128x1LslidarPointCloud3 = append(RuleOfCh128x1LslidarPointCloud3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCh64wLLslidarPointCloud == topic2 { //6
- if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
- RuleOfCh64wLLslidarPointCloud1 = append(RuleOfCh64wLLslidarPointCloud1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
- RuleOfCh64wLLslidarPointCloud3 = append(RuleOfCh64wLLslidarPointCloud3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCh64wLScan == topic2 { //7
- if f, ok1 := rule.(func(data *sensor_msgs.LaserScan) string); ok1 {
- RuleOfCh64wLScan1 = append(RuleOfCh64wLScan1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.LaserScan) string); ok3 {
- RuleOfCh64wLScan3 = append(RuleOfCh64wLScan3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCh64wRLslidarPointCloud == topic2 { //8
- if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
- RuleOfCh64wRLslidarPointCloud1 = append(RuleOfCh64wRLslidarPointCloud1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
- RuleOfCh64wRLslidarPointCloud3 = append(RuleOfCh64wRLslidarPointCloud3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCh64wRScan == topic2 { //9
- if f, ok1 := rule.(func(data *sensor_msgs.LaserScan) string); ok1 {
- RuleOfCh64wRScan1 = append(RuleOfCh64wRScan1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.LaserScan) string); ok3 {
- RuleOfCh64wRScan3 = append(RuleOfCh64wRScan3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCicvLidarclusterMovingObjects == topic2 { //10
- if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionCicvMovingObjects) string); ok1 {
- RuleOfCicvLidarclusterMovingObjects1 = append(RuleOfCicvLidarclusterMovingObjects1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionCicvMovingObjects) string); ok3 {
- RuleOfCicvLidarclusterMovingObjects3 = append(RuleOfCicvLidarclusterMovingObjects3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCicvAmrTrajectory == topic2 { //11
- if f, ok1 := rule.(func(data *pjisuv_msgs.Trajectory) string); ok1 {
- RuleOfCicvAmrTrajectory1 = append(RuleOfCicvAmrTrajectory1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Trajectory) string); ok3 {
- RuleOfCicvAmrTrajectory3 = append(RuleOfCicvAmrTrajectory3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCicvLocation == topic2 { //12
- if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionLocalization) string); ok1 {
- RuleOfCicvLocation1 = append(RuleOfCicvLocation1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string); ok3 {
- RuleOfCicvLocation3 = append(RuleOfCicvLocation3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCloudClusters == topic2 { //13
- if f, ok1 := rule.(func(data *pjisuv_msgs.AutowareCloudClusterArray) string); ok1 {
- RuleOfCloudClusters1 = append(RuleOfCloudClusters1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.AutowareCloudClusterArray) string); ok3 {
- RuleOfCloudClusters3 = append(RuleOfCloudClusters3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfHeartbeatInfo == topic2 { //14
- if f, ok1 := rule.(func(data *pjisuv_msgs.HeartBeatInfo) string); ok1 {
- RuleOfHeartbeatInfo1 = append(RuleOfHeartbeatInfo1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.HeartBeatInfo) string); ok3 {
- RuleOfHeartbeatInfo3 = append(RuleOfHeartbeatInfo3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfLidarPretreatmentCost == topic2 { //15
- if f, ok1 := rule.(func(data *geometry_msgs.Vector3Stamped) string); ok1 {
- RuleOfLidarPretreatmentCost1 = append(RuleOfLidarPretreatmentCost1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *geometry_msgs.Vector3Stamped) string); ok3 {
- RuleOfLidarPretreatmentCost3 = append(RuleOfLidarPretreatmentCost3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfLidarPretreatmentOdometry == topic2 { //16
- if f, ok1 := rule.(func(data *nav_msgs.Odometry) string); ok1 {
- RuleOfLidarPretreatmentOdometry1 = append(RuleOfLidarPretreatmentOdometry1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Odometry) string); ok3 {
- RuleOfLidarPretreatmentOdometry3 = append(RuleOfLidarPretreatmentOdometry3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfLidarRoi == topic2 { //17
- if f, ok1 := rule.(func(data *geometry_msgs.PolygonStamped) string); ok1 {
- RuleOfLidarRoi1 = append(RuleOfLidarRoi1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *geometry_msgs.PolygonStamped) string); ok3 {
- RuleOfLidarRoi3 = append(RuleOfLidarRoi3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfLine1 == topic2 { //18
- if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
- RuleOfLine11 = append(RuleOfLine11, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
- RuleOfLine13 = append(RuleOfLine13, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfLine2 == topic2 { //19
- if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
- RuleOfLine21 = append(RuleOfLine21, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
- RuleOfLine23 = append(RuleOfLine23, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfMapPolygon == topic2 { //20
- if f, ok1 := rule.(func(data *pjisuv_msgs.PolygonStamped) string); ok1 {
- RuleOfMapPolygon1 = append(RuleOfMapPolygon1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PolygonStamped) string); ok3 {
- RuleOfMapPolygon3 = append(RuleOfMapPolygon3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfObstacleDisplay == topic2 { //21
- if f, ok1 := rule.(func(data *visualization_msgs.MarkerArray) string); ok1 {
- RuleOfObstacleDisplay1 = append(RuleOfObstacleDisplay1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *visualization_msgs.MarkerArray) string); ok3 {
- RuleOfObstacleDisplay3 = append(RuleOfObstacleDisplay3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfPjControlPub == topic2 { //22
- if f, ok1 := rule.(func(data *pjisuv_msgs.CommonVehicleCmd) string); ok1 {
- RuleOfPjControlPub1 = append(RuleOfPjControlPub1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.CommonVehicleCmd) string); ok3 {
- RuleOfPjControlPub3 = append(RuleOfPjControlPub3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfPointsCluster == topic2 { //23
- if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
- RuleOfPointsCluster1 = append(RuleOfPointsCluster1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
- RuleOfPointsCluster3 = append(RuleOfPointsCluster3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfPointsConcat == topic2 { //24
- if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
- RuleOfPointsConcat1 = append(RuleOfPointsConcat1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
- RuleOfPointsConcat3 = append(RuleOfPointsConcat3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfReferenceDisplay == topic2 { //25
- if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
- RuleOfReferenceDisplay1 = append(RuleOfReferenceDisplay1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
- RuleOfReferenceDisplay3 = append(RuleOfReferenceDisplay3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfReferenceTrajectory == topic2 { //26
- if f, ok1 := rule.(func(data *pjisuv_msgs.Trajectory) string); ok1 {
- RuleOfReferenceTrajectory1 = append(RuleOfReferenceTrajectory1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Trajectory) string); ok3 {
- RuleOfReferenceTrajectory3 = append(RuleOfReferenceTrajectory3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfRoiPoints == topic2 { //27
- if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
- RuleOfRoiPoints1 = append(RuleOfRoiPoints1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
- RuleOfRoiPoints3 = append(RuleOfRoiPoints3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfRoiPolygon == topic2 { //28
- if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
- RuleOfRoiPolygon1 = append(RuleOfRoiPolygon1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
- RuleOfRoiPolygon3 = append(RuleOfRoiPolygon3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfTf == topic2 { //29
- if f, ok1 := rule.(func(data *tf2_msgs.TFMessage) string); ok1 {
- RuleOfTf1 = append(RuleOfTf1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *tf2_msgs.TFMessage) string); ok3 {
- RuleOfTf3 = append(RuleOfTf3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfTpperception == topic2 { //30
- if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionObjects) string); ok1 {
- RuleOfTpperception1 = append(RuleOfTpperception1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionObjects) string); ok3 {
- RuleOfTpperception3 = append(RuleOfTpperception3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfTpperceptionVis == topic2 { //31
- if f, ok1 := rule.(func(data *visualization_msgs.MarkerArray) string); ok1 {
- RuleOfTpperceptionVis1 = append(RuleOfTpperceptionVis1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *visualization_msgs.MarkerArray) string); ok3 {
- RuleOfTpperceptionVis3 = append(RuleOfTpperceptionVis3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfTprouteplan == topic2 { //32
- if f, ok1 := rule.(func(data *pjisuv_msgs.RoutePlan) string); ok1 {
- RuleOfTprouteplan1 = append(RuleOfTprouteplan1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.RoutePlan) string); ok3 {
- RuleOfTprouteplan3 = append(RuleOfTprouteplan3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfTrajectoryDisplay == topic2 { //33
- if f, ok1 := rule.(func(data *nav_msgs.Path) string); ok1 {
- RuleOfTrajectoryDisplay1 = append(RuleOfTrajectoryDisplay1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *nav_msgs.Path) string); ok3 {
- RuleOfTrajectoryDisplay3 = append(RuleOfTrajectoryDisplay3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfUngroundCloudpoints == topic2 { //34
- if f, ok1 := rule.(func(data *sensor_msgs.PointCloud2) string); ok1 {
- RuleOfUngroundCloudpoints1 = append(RuleOfUngroundCloudpoints1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.PointCloud2) string); ok3 {
- RuleOfUngroundCloudpoints3 = append(RuleOfUngroundCloudpoints3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfCameraImage == topic2 { //35
- if f, ok1 := rule.(func(data *sensor_msgs.Image) string); ok1 {
- RuleOfCameraImage1 = append(RuleOfCameraImage1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *sensor_msgs.Image) string); ok3 {
- RuleOfCameraImage3 = append(RuleOfCameraImage3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfDataRead == topic2 { //36
- if f, ok1 := rule.(func(data *pjisuv_msgs.Retrieval) string); ok1 {
- RuleOfDataRead1 = append(RuleOfDataRead1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.Retrieval) string); ok3 {
- RuleOfDataRead3 = append(RuleOfDataRead3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfPjiGps == topic2 { //37
- if f, ok1 := rule.(func(data *pjisuv_msgs.PerceptionLocalization) string); ok1 {
- RuleOfPjiGps1 = append(RuleOfPjiGps1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string); ok3 {
- RuleOfPjiGps3 = append(RuleOfPjiGps3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfFaultInfo == topic2 { //38
- if f, ok1 := rule.(func(data *pjisuv_msgs.FaultVec) string); ok1 {
- RuleOfFaultInfo1 = append(RuleOfFaultInfo1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.FaultVec) string); ok3 {
- RuleOfFaultInfo3 = append(RuleOfFaultInfo3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else if TopicOfPjVehicleFdbPub == topic2 { //39
- if f, ok1 := rule.(func(data *pjisuv_msgs.VehicleFdb) string); ok1 {
- RuleOfPjVehicleFdbPub1 = append(RuleOfPjVehicleFdbPub1, f)
- goto JudgeDone
- }
- if f, ok3 := rule.(func(shareVars *sync.Map, data *pjisuv_msgs.VehicleFdb) string); ok3 {
- RuleOfPjVehicleFdbPub3 = append(RuleOfPjVehicleFdbPub3, f)
- goto JudgeDone
- }
- log(triggerLocalPath)
- continue
- } else {
- c_log.GlobalLogger.Error("未知的topic:", topic2)
- continue
- }
- JudgeDone:
- label, err := open.Lookup("Label")
- if err != nil {
- c_log.GlobalLogger.Error("加载本地插件 ", triggerLocalPath, " 中的 Label 方法失败。", err)
- continue
- }
- labelFunc := label.(func() string)
- labelString := labelFunc()
- LabelMapTriggerId.Store(labelString, triggerId)
- success++
- }
- c_log.GlobalLogger.Info("一共应加载", len(config.PlatformConfig.TaskTriggers), "个触发器,实际加载 ", success, " 个触发器。")
- }
- func log(triggerLocalPath string) {
- c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的 Rule 方法参数格式不正确。")
- }
|