|
@@ -0,0 +1,9259 @@
|
|
|
+package service
|
|
|
+
|
|
|
+import (
|
|
|
+ commonConfig "cicv-data-closedloop/aarch64/pjibot_clean/common/config"
|
|
|
+ commonService "cicv-data-closedloop/aarch64/pjibot_clean/common/service"
|
|
|
+ masterConfig "cicv-data-closedloop/aarch64/pjibot_clean/master/package/config"
|
|
|
+ "cicv-data-closedloop/common/config/c_log"
|
|
|
+ "cicv-data-closedloop/common/entity"
|
|
|
+ "cicv-data-closedloop/common/util"
|
|
|
+ commonUtil "cicv-data-closedloop/common/util"
|
|
|
+ "cicv-data-closedloop/pjibot_clean_msgs/cartographer_ros_msgs"
|
|
|
+ "cicv-data-closedloop/pjibot_clean_msgs/clean_msg"
|
|
|
+ "cicv-data-closedloop/pjibot_clean_msgs/common_msgs"
|
|
|
+ "cicv-data-closedloop/pjibot_clean_msgs/dynamic_reconfigure"
|
|
|
+ "cicv-data-closedloop/pjibot_clean_msgs/ipa_building_msgs"
|
|
|
+ "cicv-data-closedloop/pjibot_clean_msgs/localization_monitor"
|
|
|
+ "cicv-data-closedloop/pjibot_clean_msgs/theora_image_transport"
|
|
|
+ "encoding/json"
|
|
|
+ "github.com/bluenviron/goroslib/v2"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/actionlib_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/diagnostic_msgs"
|
|
|
+ "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/rosgraph_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/sensor_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/std_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/tf2_msgs"
|
|
|
+ "github.com/bluenviron/goroslib/v2/pkg/msgs/visualization_msgs"
|
|
|
+ "sync"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+var (
|
|
|
+ triggerInterval = 3.0 // 每个触发器3秒触发一次
|
|
|
+ logInterval = 3.0
|
|
|
+ logTime = time.Now()
|
|
|
+)
|
|
|
+
|
|
|
+// 负责监听所有主题并修改时间窗口
|
|
|
+func PrepareTimeWindowProducerQueue() {
|
|
|
+
|
|
|
+ var err error
|
|
|
+ subscribers := make([]*goroslib.Subscriber, masterConfig.AllTopicsNumber)
|
|
|
+ subscribersTimes := make([]time.Time, masterConfig.AllTopicsNumber)
|
|
|
+ subscribersTimeMutexes := make([]sync.Mutex, masterConfig.AllTopicsNumber)
|
|
|
+ subscribersMutexes := make([]sync.Mutex, masterConfig.AllTopicsNumber)
|
|
|
+ for i, topic := range masterConfig.AllTopics {
|
|
|
+ for {
|
|
|
+ create := false // 判断是否创建成功,用于打印日志
|
|
|
+ if topic == masterConfig.Topic1 && len(masterConfig.Rule1) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int16MultiArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule1 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic2 && len(masterConfig.Rule2) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule2 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic3 && len(masterConfig.Rule3) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule3 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic4 && len(masterConfig.Rule4) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule4 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic5 && len(masterConfig.Rule5) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule5 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic6 && len(masterConfig.Rule6) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseWithCovarianceStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule6 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic7 && len(masterConfig.Rule7) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule7 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic8 && len(masterConfig.Rule8) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule8 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic9 && len(masterConfig.Rule9) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule9 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic10 && len(masterConfig.Rule10) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int8) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule10 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic11 && len(masterConfig.Rule11) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int8) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule11 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic12 && len(masterConfig.Rule12) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule12 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic13 && len(masterConfig.Rule13) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.BatteryState) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule13 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic14 && len(masterConfig.Rule14) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int16) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule14 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic15 && len(masterConfig.Rule15) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *visualization_msgs.Marker) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule15 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic16 && len(masterConfig.Rule16) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule16 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic17 && len(masterConfig.Rule17) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CameraInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule17 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic18 && len(masterConfig.Rule18) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Image) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule18 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic19 && len(masterConfig.Rule19) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule19 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic20 && len(masterConfig.Rule20) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule20 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic21 && len(masterConfig.Rule21) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule21 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic22 && len(masterConfig.Rule22) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule22 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic23 && len(masterConfig.Rule23) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule23 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic24 && len(masterConfig.Rule24) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule24 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic25 && len(masterConfig.Rule25) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *theora_image_transport.Packet) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule25 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic26 && len(masterConfig.Rule26) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule26 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic27 && len(masterConfig.Rule27) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule27 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic28 && len(masterConfig.Rule28) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule28 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic29 && len(masterConfig.Rule29) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CameraInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule29 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic30 && len(masterConfig.Rule30) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Image) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule30 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic31 && len(masterConfig.Rule31) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule31 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic32 && len(masterConfig.Rule32) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule32 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic33 && len(masterConfig.Rule33) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule33 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic34 && len(masterConfig.Rule34) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule34 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic35 && len(masterConfig.Rule35) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule35 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic36 && len(masterConfig.Rule36) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule36 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic37 && len(masterConfig.Rule37) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *theora_image_transport.Packet) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule37 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic38 && len(masterConfig.Rule38) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule38 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic39 && len(masterConfig.Rule39) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule39 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic40 && len(masterConfig.Rule40) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule40 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic41 && len(masterConfig.Rule41) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule41 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic42 && len(masterConfig.Rule42) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule42 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic43 && len(masterConfig.Rule43) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int8) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule43 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic44 && len(masterConfig.Rule44) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule44 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic45 && len(masterConfig.Rule45) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule45 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic46 && len(masterConfig.Rule46) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule46 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic47 && len(masterConfig.Rule47) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule47 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic48 && len(masterConfig.Rule48) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule48 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic49 && len(masterConfig.Rule49) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule49 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic50 && len(masterConfig.Rule50) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *visualization_msgs.MarkerArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule50 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic51 && len(masterConfig.Rule51) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PolygonStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule51 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic52 && len(masterConfig.Rule52) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule52 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic53 && len(masterConfig.Rule53) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule53 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic54 && len(masterConfig.Rule54) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule54 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic55 && len(masterConfig.Rule55) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Float32) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule55 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic56 && len(masterConfig.Rule56) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int32) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule56 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic57 && len(masterConfig.Rule57) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule57 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic58 && len(masterConfig.Rule58) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *clean_msg.ErrorInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule58 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic59 && len(masterConfig.Rule59) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule59 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic60 && len(masterConfig.Rule60) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule60 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic61 && len(masterConfig.Rule61) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule61 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic62 && len(masterConfig.Rule62) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule62 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic63 && len(masterConfig.Rule63) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule63 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic64 && len(masterConfig.Rule64) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule64 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic65 && len(masterConfig.Rule65) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule65 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic66 && len(masterConfig.Rule66) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule66 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic67 && len(masterConfig.Rule67) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule67 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic68 && len(masterConfig.Rule68) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PolygonStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule68 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic69 && len(masterConfig.Rule69) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PointStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule69 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic70 && len(masterConfig.Rule70) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule70 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic71 && len(masterConfig.Rule71) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Twist) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule71 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic72 && len(masterConfig.Rule72) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Twist) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule72 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic73 && len(masterConfig.Rule73) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule73 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic74 && len(masterConfig.Rule74) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.CreateMapInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule74 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic75 && len(masterConfig.Rule75) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Twist) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule75 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic76 && len(masterConfig.Rule76) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.SensorStatus) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule76 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic77 && len(masterConfig.Rule77) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule77 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic78 && len(masterConfig.Rule78) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule78 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic79 && len(masterConfig.Rule79) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.IdentifierObjsInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule79 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic80 && len(masterConfig.Rule80) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.McuDiagnostic) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule80 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic81 && len(masterConfig.Rule81) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *diagnostic_msgs.DiagnosticArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule81 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic82 && len(masterConfig.Rule82) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int8) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule82 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic83 && len(masterConfig.Rule83) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int16) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule83 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic84 && len(masterConfig.Rule84) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Vector3Stamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule84 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic85 && len(masterConfig.Rule85) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule85 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic86 && len(masterConfig.Rule86) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule86 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic87 && len(masterConfig.Rule87) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule87 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic88 && len(masterConfig.Rule88) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule88 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic89 && len(masterConfig.Rule89) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule89 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic90 && len(masterConfig.Rule90) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int32) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule90 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic91 && len(masterConfig.Rule91) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.TaskInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule91 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic92 && len(masterConfig.Rule92) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.MapInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule92 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic93 && len(masterConfig.Rule93) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule93 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic94 && len(masterConfig.Rule94) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.VideoStream) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule94 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic95 && len(masterConfig.Rule95) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule95 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic96 && len(masterConfig.Rule96) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule96 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic97 && len(masterConfig.Rule97) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule97 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic98 && len(masterConfig.Rule98) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule98 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic99 && len(masterConfig.Rule99) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule99 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic100 && len(masterConfig.Rule100) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PointStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule100 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic101 && len(masterConfig.Rule101) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule101 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic102 && len(masterConfig.Rule102) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule102 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic103 && len(masterConfig.Rule103) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseWithCovarianceStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule103 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic104 && len(masterConfig.Rule104) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Pose) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule104 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic105 && len(masterConfig.Rule105) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule105 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic106 && len(masterConfig.Rule106) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule106 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic107 && len(masterConfig.Rule107) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule107 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic108 && len(masterConfig.Rule108) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule108 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic109 && len(masterConfig.Rule109) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Float64) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule109 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic110 && len(masterConfig.Rule110) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule110 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic111 && len(masterConfig.Rule111) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule111 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic112 && len(masterConfig.Rule112) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Imu) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule112 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic113 && len(masterConfig.Rule113) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule113 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic114 && len(masterConfig.Rule114) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int8) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule114 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic115 && len(masterConfig.Rule115) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Int16) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule115 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic116 && len(masterConfig.Rule116) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule116 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic117 && len(masterConfig.Rule117) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule117 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic118 && len(masterConfig.Rule118) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseWithCovarianceStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule118 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic119 && len(masterConfig.Rule119) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.JointState) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule119 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic120 && len(masterConfig.Rule120) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule120 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic121 && len(masterConfig.Rule121) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *cartographer_ros_msgs.LandmarkList) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule121 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic122 && len(masterConfig.Rule122) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Odometry) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule122 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic123 && len(masterConfig.Rule123) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule123 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic124 && len(masterConfig.Rule124) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule124 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic125 && len(masterConfig.Rule125) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule125 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic126 && len(masterConfig.Rule126) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule126 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic127 && len(masterConfig.Rule127) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule127 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic128 && len(masterConfig.Rule128) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule128 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic129 && len(masterConfig.Rule129) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule129 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic130 && len(masterConfig.Rule130) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseWithCovarianceStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule130 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic131 && len(masterConfig.Rule131) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule131 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic132 && len(masterConfig.Rule132) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule132 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic133 && len(masterConfig.Rule133) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.LocateInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule133 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic134 && len(masterConfig.Rule134) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule134 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic135 && len(masterConfig.Rule135) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Float64MultiArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule135 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic136 && len(masterConfig.Rule136) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule136 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic137 && len(masterConfig.Rule137) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule137 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic138 && len(masterConfig.Rule138) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule138 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic139 && len(masterConfig.Rule139) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule139 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic140 && len(masterConfig.Rule140) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule140 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic141 && len(masterConfig.Rule141) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule141 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic142 && len(masterConfig.Rule142) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule142 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic143 && len(masterConfig.Rule143) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.MapMetaData) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule143 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic144 && len(masterConfig.Rule144) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule144 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic145 && len(masterConfig.Rule145) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule145 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic146 && len(masterConfig.Rule146) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule146 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic147 && len(masterConfig.Rule147) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule147 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic148 && len(masterConfig.Rule148) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule148 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic149 && len(masterConfig.Rule149) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule149 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic150 && len(masterConfig.Rule150) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule150 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic151 && len(masterConfig.Rule151) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule151 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic152 && len(masterConfig.Rule152) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule152 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic153 && len(masterConfig.Rule153) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CameraInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule153 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic154 && len(masterConfig.Rule154) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Image) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule154 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic155 && len(masterConfig.Rule155) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule155 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic156 && len(masterConfig.Rule156) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule156 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic157 && len(masterConfig.Rule157) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule157 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic158 && len(masterConfig.Rule158) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule158 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic159 && len(masterConfig.Rule159) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule159 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic160 && len(masterConfig.Rule160) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule160 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic161 && len(masterConfig.Rule161) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *theora_image_transport.Packet) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule161 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic162 && len(masterConfig.Rule162) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule162 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic163 && len(masterConfig.Rule163) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule163 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic164 && len(masterConfig.Rule164) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CameraInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule164 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic165 && len(masterConfig.Rule165) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Image) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule165 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic166 && len(masterConfig.Rule166) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule166 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic167 && len(masterConfig.Rule167) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule167 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic168 && len(masterConfig.Rule168) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule168 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic169 && len(masterConfig.Rule169) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule169 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic170 && len(masterConfig.Rule170) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule170 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic171 && len(masterConfig.Rule171) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule171 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic172 && len(masterConfig.Rule172) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *theora_image_transport.Packet) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule172 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic173 && len(masterConfig.Rule173) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule173 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic174 && len(masterConfig.Rule174) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule174 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic175 && len(masterConfig.Rule175) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule175 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic176 && len(masterConfig.Rule176) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CameraInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule176 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic177 && len(masterConfig.Rule177) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Image) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule177 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic178 && len(masterConfig.Rule178) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule178 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic179 && len(masterConfig.Rule179) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule179 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic180 && len(masterConfig.Rule180) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule180 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic181 && len(masterConfig.Rule181) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule181 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic182 && len(masterConfig.Rule182) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule182 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic183 && len(masterConfig.Rule183) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule183 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic184 && len(masterConfig.Rule184) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *theora_image_transport.Packet) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule184 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic185 && len(masterConfig.Rule185) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule185 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic186 && len(masterConfig.Rule186) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule186 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic187 && len(masterConfig.Rule187) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CameraInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule187 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic188 && len(masterConfig.Rule188) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Image) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule188 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic189 && len(masterConfig.Rule189) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule189 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic190 && len(masterConfig.Rule190) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule190 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic191 && len(masterConfig.Rule191) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule191 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic192 && len(masterConfig.Rule192) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule192 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic193 && len(masterConfig.Rule193) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule193 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic194 && len(masterConfig.Rule194) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule194 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic195 && len(masterConfig.Rule195) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *theora_image_transport.Packet) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule195 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic196 && len(masterConfig.Rule196) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule196 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic197 && len(masterConfig.Rule197) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule197 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic198 && len(masterConfig.Rule198) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule198 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic199 && len(masterConfig.Rule199) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule199 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic200 && len(masterConfig.Rule200) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule200 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic201 && len(masterConfig.Rule201) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.UInt8) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule201 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic202 && len(masterConfig.Rule202) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Odometry) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule202 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic203 && len(masterConfig.Rule203) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule203 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic204 && len(masterConfig.Rule204) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule204 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic205 && len(masterConfig.Rule205) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Odometry) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule205 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic206 && len(masterConfig.Rule206) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Imu) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule206 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic207 && len(masterConfig.Rule207) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule207 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic208 && len(masterConfig.Rule208) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule208 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic209 && len(masterConfig.Rule209) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule209 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic210 && len(masterConfig.Rule210) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule210 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic211 && len(masterConfig.Rule211) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseWithCovarianceStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule211 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic212 && len(masterConfig.Rule212) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Vector3Stamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule212 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic213 && len(masterConfig.Rule213) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule213 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic214 && len(masterConfig.Rule214) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.FunctionAreas) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule214 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic215 && len(masterConfig.Rule215) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule215 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic216 && len(masterConfig.Rule216) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule216 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic217 && len(masterConfig.Rule217) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Float64MultiArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule217 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic218 && len(masterConfig.Rule218) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule218 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic219 && len(masterConfig.Rule219) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule219 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic220 && len(masterConfig.Rule220) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule220 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic221 && len(masterConfig.Rule221) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule221 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic222 && len(masterConfig.Rule222) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseWithCovarianceStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule222 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic223 && len(masterConfig.Rule223) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule223 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic224 && len(masterConfig.Rule224) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule224 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic225 && len(masterConfig.Rule225) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *localization_monitor.RobotStatus) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule225 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic226 && len(masterConfig.Rule226) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Float64MultiArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule226 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic227 && len(masterConfig.Rule227) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule227 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic228 && len(masterConfig.Rule228) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *actionlib_msgs.GoalID) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule228 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic229 && len(masterConfig.Rule229) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *ipa_building_msgs.MapSegmentationActionFeedback) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule229 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic230 && len(masterConfig.Rule230) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *ipa_building_msgs.MapSegmentationActionGoal) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule230 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic231 && len(masterConfig.Rule231) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule231 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic232 && len(masterConfig.Rule232) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule232 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic233 && len(masterConfig.Rule233) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *ipa_building_msgs.MapSegmentationActionResult) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule233 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic234 && len(masterConfig.Rule234) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.OccupancyGrid) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule234 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic235 && len(masterConfig.Rule235) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *actionlib_msgs.GoalStatusArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule235 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic236 && len(masterConfig.Rule236) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *rosgraph_msgs.Log) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule236 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic237 && len(masterConfig.Rule237) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *rosgraph_msgs.Log) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule237 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic238 && len(masterConfig.Rule238) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule238 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic239 && len(masterConfig.Rule239) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Vector3Stamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule239 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic240 && len(masterConfig.Rule240) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule240 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic241 && len(masterConfig.Rule241) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule241 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic242 && len(masterConfig.Rule242) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule242 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic243 && len(masterConfig.Rule243) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule243 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic244 && len(masterConfig.Rule244) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule244 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic245 && len(masterConfig.Rule245) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule245 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic246 && len(masterConfig.Rule246) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.PointCloud2) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule246 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic247 && len(masterConfig.Rule247) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *visualization_msgs.MarkerArray) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule247 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic248 && len(masterConfig.Rule248) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.SensorTask) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule248 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic249 && len(masterConfig.Rule249) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule249 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic250 && len(masterConfig.Rule250) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Vector3Stamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule250 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic251 && len(masterConfig.Rule251) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.SonarList) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule251 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic252 && len(masterConfig.Rule252) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Odometry) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule252 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic253 && len(masterConfig.Rule253) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule253 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic254 && len(masterConfig.Rule254) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule254 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic255 && len(masterConfig.Rule255) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule255 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic256 && len(masterConfig.Rule256) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule256 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic257 && len(masterConfig.Rule257) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule257 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic258 && len(masterConfig.Rule258) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CameraInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule258 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic259 && len(masterConfig.Rule259) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.SysInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule259 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic260 && len(masterConfig.Rule260) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Image) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule260 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic261 && len(masterConfig.Rule261) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule261 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic262 && len(masterConfig.Rule262) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule262 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic263 && len(masterConfig.Rule263) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule263 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic264 && len(masterConfig.Rule264) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.CompressedImage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule264 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic265 && len(masterConfig.Rule265) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule265 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic266 && len(masterConfig.Rule266) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule266 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic267 && len(masterConfig.Rule267) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *theora_image_transport.Packet) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule267 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic268 && len(masterConfig.Rule268) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.ConfigDescription) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule268 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic269 && len(masterConfig.Rule269) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *dynamic_reconfigure.Config) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule269 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic270 && len(masterConfig.Rule270) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.Bool) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule270 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic271 && len(masterConfig.Rule271) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.PoseStamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule271 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic272 && len(masterConfig.Rule272) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *geometry_msgs.Vector3Stamped) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule272 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic273 && len(masterConfig.Rule273) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.TaskFeedbackInfo) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule273 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic274 && len(masterConfig.Rule274) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.Points) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule274 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic275 && len(masterConfig.Rule275) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *tf2_msgs.TFMessage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule275 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic276 && len(masterConfig.Rule276) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *std_msgs.String) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule276 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic277 && len(masterConfig.Rule277) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *tf2_msgs.TFMessage) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule277 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic278 && len(masterConfig.Rule278) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *nav_msgs.Path) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule278 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic279 && len(masterConfig.Rule279) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *common_msgs.UpLoadFileList) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule279 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic280 && len(masterConfig.Rule280) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.Range) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule280 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic281 && len(masterConfig.Rule281) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule281 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic282 && len(masterConfig.Rule282) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule282 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic283 && len(masterConfig.Rule283) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule283 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if topic == masterConfig.Topic284 && len(masterConfig.Rule284) > 0 {
|
|
|
+ subscribers[i], err = goroslib.NewSubscriber(goroslib.SubscriberConf{
|
|
|
+ Node: commonConfig.RosNode,
|
|
|
+ Topic: topic,
|
|
|
+ Callback: func(data *sensor_msgs.LaserScan) {
|
|
|
+ subscribersTimeMutexes[i].Lock()
|
|
|
+ if time.Since(subscribersTimes[i]).Seconds() > triggerInterval {
|
|
|
+ subscribersMutexes[i].Lock()
|
|
|
+ faultHappenTime := commonUtil.GetNowTimeCustom() // 获取当前故障发生时间
|
|
|
+ lastTimeWindow := entity.GetLastTimeWindow() // 获取最后一个时间窗口
|
|
|
+ var faultLabel string
|
|
|
+ for _, f := range masterConfig.Rule284 {
|
|
|
+ faultLabel = f(data)
|
|
|
+ if faultLabel != "" {
|
|
|
+ if !canCollect() {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ subscribersTimes[i] = time.Now()
|
|
|
+ c_log.GlobalLogger.Errorf("触发事件【xxx】,开始采集。", faultLabel)
|
|
|
+ saveTimeWindow(faultLabel, faultHappenTime, lastTimeWindow)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subscribersMutexes[i].Unlock()
|
|
|
+ }
|
|
|
+ subscribersTimeMutexes[i].Unlock()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err == nil {
|
|
|
+ create = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ c_log.GlobalLogger.Infof("创建订阅者报错,可能由于节点未启动,再次尝试【%v】", err)
|
|
|
+ time.Sleep(time.Duration(2) * time.Second)
|
|
|
+ continue
|
|
|
+ } else {
|
|
|
+ if create {
|
|
|
+ c_log.GlobalLogger.Infof("创建订阅者订阅话题【%v】", topic)
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ c_log.GlobalLogger.Infof("全部订阅者创建完成。")
|
|
|
+ select {
|
|
|
+ case signal := <-commonService.ChannelKillSubscriber:
|
|
|
+ if signal == 1 {
|
|
|
+ commonConfig.RosNode.Close()
|
|
|
+ commonService.AddKillTimes("3")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func saveTimeWindow(faultLabel string, faultHappenTime string, lastTimeWindow *entity.TimeWindow) {
|
|
|
+ masterTopics, slaveTopics := getTopicsOfNode(faultLabel)
|
|
|
+ if lastTimeWindow == nil || commonUtil.TimeCustom1GreaterTimeCustom2(faultHappenTime, lastTimeWindow.TimeWindowEnd) {
|
|
|
+ // 2-1 如果是不在旧故障窗口内,添加一个新窗口
|
|
|
+ newTimeWindow := entity.TimeWindow{
|
|
|
+ FaultTime: faultHappenTime,
|
|
|
+ TimeWindowBegin: commonUtil.TimeCustomChange(faultHappenTime, -commonConfig.PlatformConfig.TaskBeforeTime),
|
|
|
+ TimeWindowEnd: commonUtil.TimeCustomChange(faultHappenTime, commonConfig.PlatformConfig.TaskAfterTime),
|
|
|
+ Length: commonConfig.PlatformConfig.TaskBeforeTime + commonConfig.PlatformConfig.TaskAfterTime + 1,
|
|
|
+ Labels: []string{faultLabel},
|
|
|
+ MasterTopics: masterTopics,
|
|
|
+ SlaveTopics: slaveTopics,
|
|
|
+ }
|
|
|
+ c_log.GlobalLogger.Infof("不在旧故障窗口内,向生产者队列添加一个新窗口,【Lable】=%v,【FaultTime】=%v,【Length】=%v", newTimeWindow.Labels, newTimeWindow.FaultTime, newTimeWindow.Length)
|
|
|
+ entity.AddTimeWindowToTimeWindowProducerQueue(newTimeWindow)
|
|
|
+ } else {
|
|
|
+ // 2-2 如果在旧故障窗口内
|
|
|
+ entity.TimeWindowProducerQueueMutex.RLock()
|
|
|
+ defer entity.TimeWindowProducerQueueMutex.RUnlock()
|
|
|
+ // 2-2-1 更新故障窗口end时间
|
|
|
+ maxEnd := commonUtil.TimeCustomChange(lastTimeWindow.TimeWindowBegin, commonConfig.PlatformConfig.TaskMaxTime)
|
|
|
+ expectEnd := commonUtil.TimeCustomChange(faultHappenTime, commonConfig.PlatformConfig.TaskAfterTime)
|
|
|
+ if commonUtil.TimeCustom1GreaterTimeCustom2(expectEnd, maxEnd) {
|
|
|
+ lastTimeWindow.TimeWindowEnd = maxEnd
|
|
|
+ lastTimeWindow.Length = commonConfig.PlatformConfig.TaskMaxTime
|
|
|
+ } else {
|
|
|
+ if commonUtil.TimeCustom1GreaterTimeCustom2(expectEnd, lastTimeWindow.TimeWindowEnd) {
|
|
|
+ lastTimeWindow.TimeWindowEnd = expectEnd
|
|
|
+ lastTimeWindow.Length = commonUtil.CalculateDifferenceOfTimeCustom(lastTimeWindow.TimeWindowBegin, expectEnd)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2-2-2 更新label
|
|
|
+ labels := lastTimeWindow.Labels
|
|
|
+ lastTimeWindow.Labels = commonUtil.AppendIfNotExists(labels, faultLabel)
|
|
|
+ // 2-2-3 更新 topic
|
|
|
+ sourceMasterTopics := lastTimeWindow.MasterTopics
|
|
|
+ lastTimeWindow.MasterTopics = commonUtil.MergeSlice(sourceMasterTopics, masterTopics)
|
|
|
+ sourceSlaveTopics := lastTimeWindow.SlaveTopics
|
|
|
+ lastTimeWindow.SlaveTopics = commonUtil.MergeSlice(sourceSlaveTopics, slaveTopics)
|
|
|
+ c_log.GlobalLogger.Infof("在旧故障窗口内,更新生产者队列最新的窗口,【Lable】=%v,【FaultTime】=%v,【Length】=%v", lastTimeWindow.Labels, lastTimeWindow.FaultTime, lastTimeWindow.Length)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func getTopicsOfNode(faultLabel string) (masterTopics []string, slaveTopics []string) {
|
|
|
+ // 获取所有需要采集的topic
|
|
|
+ var faultCodeTopics []string
|
|
|
+ for _, code := range commonConfig.CloudConfig.Triggers {
|
|
|
+ if code.Label == faultLabel {
|
|
|
+ faultCodeTopics = code.Topics
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return faultCodeTopics, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 判断是否可采集数据
|
|
|
+func canCollect() bool {
|
|
|
+ // 如果开启了采集频率限制,则云端判断采集数量是否超过限额
|
|
|
+ if commonConfig.CloudConfig.CollectLimit.Flag == 1 {
|
|
|
+ c_log.GlobalLogger.Error("当前设备已开启数采频率限制,需判断采集数量是否达到限额。")
|
|
|
+ responseString, err := commonUtil.HttpPostJsonWithHeaders(
|
|
|
+ commonConfig.CloudConfig.CollectLimit.Url,
|
|
|
+ map[string]string{"Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"},
|
|
|
+ map[string]string{
|
|
|
+ "snCode": commonConfig.LocalConfig.SecretKey,
|
|
|
+ "collectLimitDay": util.ToString(commonConfig.CloudConfig.CollectLimit.Day),
|
|
|
+ "collectLimitWeek": util.ToString(commonConfig.CloudConfig.CollectLimit.Week),
|
|
|
+ "collectLimitMonth": util.ToString(commonConfig.CloudConfig.CollectLimit.Month),
|
|
|
+ "collectLimitYear": util.ToString(commonConfig.CloudConfig.CollectLimit.Year),
|
|
|
+ },
|
|
|
+ )
|
|
|
+ if err != nil {
|
|
|
+ c_log.GlobalLogger.Error("发送http请求获取是否允许采集失败:", err)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 解析JSON字符串到Response结构体
|
|
|
+ var resp entity.Response
|
|
|
+ err = json.Unmarshal([]byte(responseString), &resp)
|
|
|
+ if err != nil {
|
|
|
+ c_log.GlobalLogger.Error("解析是否允许采集接口返回结果失败:", err)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if resp.Code != 200 { // 不是200 代表不允许采集
|
|
|
+ c_log.GlobalLogger.Info("采集数量已超过限额,当前周期内不再采集。", resp.Code)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ c_log.GlobalLogger.Error("当前设备未开启数采频率限制,无需判断采集数量是否达到限额。")
|
|
|
+ }
|
|
|
+
|
|
|
+ // 本地判断是否存在正在处理的数据
|
|
|
+ if entity.ProcessingFlag {
|
|
|
+ c_log.GlobalLogger.Info("存在正在处理的数据,此次不再采集。")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ c_log.GlobalLogger.Info("允许采集。")
|
|
|
+ return true
|
|
|
+}
|