|
@@ -1,9 +1,9 @@
|
|
package config
|
|
package config
|
|
|
|
|
|
import (
|
|
import (
|
|
- "cicv-data-closedloop/kinglong/common/cfg"
|
|
|
|
- "cicv-data-closedloop/kinglong/common/cutil"
|
|
|
|
- "cicv-data-closedloop/kinglong/common/log"
|
|
|
|
|
|
+ "cicv-data-closedloop/aarch64/pjisuv/common/config"
|
|
|
|
+ "cicv-data-closedloop/common/config/c_log"
|
|
|
|
+ "cicv-data-closedloop/common/util"
|
|
"cicv-data-closedloop/kinglong_msgs"
|
|
"cicv-data-closedloop/kinglong_msgs"
|
|
"plugin"
|
|
"plugin"
|
|
"strconv"
|
|
"strconv"
|
|
@@ -25,92 +25,92 @@ var (
|
|
)
|
|
)
|
|
|
|
|
|
func InitTriggerConfig() {
|
|
func InitTriggerConfig() {
|
|
- log.GlobalLogger.Info("主节点加载触发器插件 - 开始。")
|
|
|
|
|
|
+ c_log.GlobalLogger.Info("主节点加载触发器插件 - 开始。")
|
|
// 下载所有触发器的文件
|
|
// 下载所有触发器的文件
|
|
- for _, trigger := range cfg.PlatformConfig.TaskTriggers {
|
|
|
|
|
|
+ for _, trigger := range config.PlatformConfig.TaskTriggers {
|
|
// 获取文件名
|
|
// 获取文件名
|
|
pathSplit := strings.Split(trigger.TriggerScriptPath, "/")
|
|
pathSplit := strings.Split(trigger.TriggerScriptPath, "/")
|
|
fileName := pathSplit[len(pathSplit)-1]
|
|
fileName := pathSplit[len(pathSplit)-1]
|
|
// 下载
|
|
// 下载
|
|
- triggerLocalPath := cfg.CloudConfig.TriggersDir + fileName
|
|
|
|
- cutil.CreateParentDir(triggerLocalPath)
|
|
|
|
- log.GlobalLogger.Info("下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
|
|
|
|
- err := cfg.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath)
|
|
|
|
|
|
+ triggerLocalPath := config.CloudConfig.TriggersDir + fileName
|
|
|
|
+ _ = util.CreateParentDir(triggerLocalPath)
|
|
|
|
+ c_log.GlobalLogger.Info("下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
|
|
|
|
+ err := config.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath)
|
|
if err != nil {
|
|
if err != nil {
|
|
- log.GlobalLogger.Error("下载 oss 上的触发器插件失败:", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("下载 oss 上的触发器插件失败:", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 载入插件到数组
|
|
// 载入插件到数组
|
|
open, err := plugin.Open(triggerLocalPath)
|
|
open, err := plugin.Open(triggerLocalPath)
|
|
if err != nil {
|
|
if err != nil {
|
|
- log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "失败。", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "失败。", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
topic0, err := open.Lookup("Topic")
|
|
topic0, err := open.Lookup("Topic")
|
|
if err != nil {
|
|
if err != nil {
|
|
- log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Topic方法失败。", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Topic方法失败。", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
topic1, ok := topic0.(func() string)
|
|
topic1, ok := topic0.(func() string)
|
|
if ok != true {
|
|
if ok != true {
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func() string):", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func() string):", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
topic2 := topic1()
|
|
topic2 := topic1()
|
|
rule, err := open.Lookup("Rule")
|
|
rule, err := open.Lookup("Rule")
|
|
if err != nil {
|
|
if err != nil {
|
|
- log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Rule方法失败。", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件", triggerLocalPath, "中的Rule方法失败。", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
if TopicOfNodeFaultInfo == topic2 {
|
|
if TopicOfNodeFaultInfo == topic2 {
|
|
f, ok := rule.(func(data *kinglong_msgs.FaultInfo) string)
|
|
f, ok := rule.(func(data *kinglong_msgs.FaultInfo) string)
|
|
if ok != true {
|
|
if ok != true {
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.FaultInfo) string):", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.FaultInfo) string):", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
RuleOfNodefaultInfo = append(RuleOfNodefaultInfo, f)
|
|
RuleOfNodefaultInfo = append(RuleOfNodefaultInfo, f)
|
|
} else if TopicOfCicvLocation == topic2 {
|
|
} else if TopicOfCicvLocation == topic2 {
|
|
f, ok := rule.(func(data *kinglong_msgs.PerceptionLocalization) string)
|
|
f, ok := rule.(func(data *kinglong_msgs.PerceptionLocalization) string)
|
|
if ok != true {
|
|
if ok != true {
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.PerceptionLocalization) string):", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.PerceptionLocalization) string):", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
RuleOfCicvLocation = append(RuleOfCicvLocation, f)
|
|
RuleOfCicvLocation = append(RuleOfCicvLocation, f)
|
|
} else if TopicOfTpperception == topic2 {
|
|
} else if TopicOfTpperception == topic2 {
|
|
f, ok := rule.(func(data *kinglong_msgs.PerceptionObjects, velocityX float64, velocityY float64, yaw float64) string)
|
|
f, ok := rule.(func(data *kinglong_msgs.PerceptionObjects, velocityX float64, velocityY float64, yaw float64) string)
|
|
if ok != true {
|
|
if ok != true {
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.PerceptionObjects, velocityX float64, velocityY float64, yaw float64) string):", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.PerceptionObjects, velocityX float64, velocityY float64, yaw float64) string):", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
RuleOfTpperception = append(RuleOfTpperception, f)
|
|
RuleOfTpperception = append(RuleOfTpperception, f)
|
|
} else if TopicOfFaultInfo == topic2 {
|
|
} else if TopicOfFaultInfo == topic2 {
|
|
f, ok := rule.(func(data *kinglong_msgs.FaultVec) string)
|
|
f, ok := rule.(func(data *kinglong_msgs.FaultVec) string)
|
|
if ok != true {
|
|
if ok != true {
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.FaultVec) string):", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.FaultVec) string):", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
RuleOfFaultInfo = append(RuleOfFaultInfo, f)
|
|
RuleOfFaultInfo = append(RuleOfFaultInfo, f)
|
|
} else if TopicOfDataRead == topic2 {
|
|
} else if TopicOfDataRead == topic2 {
|
|
f, ok := rule.(func(data *kinglong_msgs.Retrieval) string)
|
|
f, ok := rule.(func(data *kinglong_msgs.Retrieval) string)
|
|
if ok != true {
|
|
if ok != true {
|
|
- log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.Retrieval) string):", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("插件", triggerLocalPath, "中的Topic方法必须是(func(data *kinglong_msgs.Retrieval) string):", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
RuleOfDataRead = append(RuleOfDataRead, f)
|
|
RuleOfDataRead = append(RuleOfDataRead, f)
|
|
} else {
|
|
} else {
|
|
- log.GlobalLogger.Error("未知的topic:", topic2)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("未知的topic:", topic2)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
|
|
label, err := open.Lookup("Label")
|
|
label, err := open.Lookup("Label")
|
|
if err != nil {
|
|
if err != nil {
|
|
- log.GlobalLogger.Error("加载本地插件 ", triggerLocalPath, " 中的 Label 方法失败。", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("加载本地插件 ", triggerLocalPath, " 中的 Label 方法失败。", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
labelFunc := label.(func() string)
|
|
labelFunc := label.(func() string)
|
|
labelString := labelFunc()
|
|
labelString := labelFunc()
|
|
LabelMapTriggerId[labelString] = strconv.Itoa(trigger.TriggerId)
|
|
LabelMapTriggerId[labelString] = strconv.Itoa(trigger.TriggerId)
|
|
- log.GlobalLogger.Info("主节点加载触发器插件:【ros topic】=", topic2, ",【触发器label】=", labelString, "【触发器ID】=", trigger.TriggerId, "【label和id映射关系】=", LabelMapTriggerId)
|
|
|
|
|
|
+ c_log.GlobalLogger.Info("主节点加载触发器插件:【ros topic】=", topic2, ",【触发器label】=", labelString, "【触发器ID】=", trigger.TriggerId, "【label和id映射关系】=", LabelMapTriggerId)
|
|
}
|
|
}
|
|
- log.GlobalLogger.Info("主节点加载触发器插件 - 成功。")
|
|
|
|
|
|
+ c_log.GlobalLogger.Info("主节点加载触发器插件 - 成功。")
|
|
}
|
|
}
|