LingxinMeng 10 mesiacov pred
rodič
commit
46d801223e

+ 1 - 1
aarch64/pjisuv/common/config/c_platform.go

@@ -62,7 +62,7 @@ func InitPlatformConfig() {
 			break
 		}
 	}
-	c_log.GlobalLogger.Info("获取数据闭环平台配置 - 成功。")
+	c_log.GlobalLogger.Infof("获取数据闭环平台配置 - 成功。【触发前】=【%v 秒】,触发后=【%v 秒】,【最大窗口】=【%v 秒】。", PlatformConfig.TaskBeforeTime, PlatformConfig.TaskAfterTime, PlatformConfig.TaskMaxTime)
 }
 
 /*

+ 5 - 6
aarch64/pjisuv/common/service/rosbag_upload.go

@@ -70,7 +70,7 @@ outLoop:
 		//}
 
 		// 5 upload,必须顺序执行
-		c_log.GlobalLogger.Info("发送bag数据包,故障时间为:", currentTimeWindow.FaultTime)
+		//c_log.GlobalLogger.Info("发送bag数据包,故障时间为:", currentTimeWindow.FaultTime)
 		//start := time.Now()
 		//objectKey1 := commonConfig.OssEquBasePrefix + "data/" + nodeName + "_" + currentTimeWindow.FaultTime + "_" + strings.Join(currentTimeWindow.Labels, "_") + "_" + fmt.Sprintf("%d", bagNumber) + "/"
 		objectKey2 := commonConfig.OssEquBasePrefix + "data_merge/" + currentTimeWindow.FaultTime + "_" + strings.Join(currentTimeWindow.Labels, "_") + "_" + fmt.Sprintf("%d", currentTimeWindow.Length) + ".bag"
@@ -101,11 +101,11 @@ outLoop:
 				if triggerId, ok := masterConfig.LabelMapTriggerId.Load(label); !ok {
 					c_log.GlobalLogger.Errorf("【label】=%v 没有对应的【triggerId】", label)
 				} else {
-					c_log.GlobalLogger.Info("添加一个【triggerId】=", triggerId)
+					//c_log.GlobalLogger.Info("添加一个【triggerId】=", triggerId)
 					triggerIds = append(triggerIds, commonUtil.ToString(triggerId))
 				}
 			}
-			c_log.GlobalLogger.Info("json 中添加【triggerIds】=", triggerIds)
+			//c_log.GlobalLogger.Info("json 中添加【triggerIds】=", triggerIds)
 			callBackJsonBytes, _ := json.MarshalIndent(&entity.CallBack{
 				DataName:    currentTimeWindow.FaultTime,
 				DataSize:    "", // 由合并程序补充
@@ -132,9 +132,8 @@ outLoop:
 				//}
 				commonUtil.WriteStringToFile(callBackJson, dir+"callback.json")
 			}
-			c_log.GlobalLogger.Infof("结束处理窗口,【Label】=%v,【FaultTime】=%v,【Length】=%v", currentTimeWindow.Labels, currentTimeWindow.FaultTime, currentTimeWindow.Length)
-			c_log.GlobalLogger.Infof("待处理窗口个数为:%v", len(entity.TimeWindowConsumerQueue))
 		}
-
+		c_log.GlobalLogger.Infof("结束处理窗口,【Label】=%v,【FaultTime】=%v,【Length】=%v", currentTimeWindow.Labels, currentTimeWindow.FaultTime, currentTimeWindow.Length)
+		c_log.GlobalLogger.Infof("待处理窗口个数为:%v", len(entity.TimeWindowConsumerQueue))
 	}
 }

+ 6 - 7
aarch64/pjisuv/master/service/produce_window.go

@@ -27,7 +27,10 @@ var (
 		ObjDicOfTpperception:      make(map[uint32][]float32),
 		ObjTypeDicOfTpperception:  make(map[uint32]uint8),
 		ObjSpeedDicOfTpperception: make(map[uint32]float64),
-	} // /cicv_location
+	}
+	// 保存时间窗口需要锁,防止数据竟态
+	saveTimeWindowMutex sync.Mutex
+	// /cicv_location
 	mutexOfCicvLocation sync.RWMutex
 	// /tpperception
 	mutexOfTpperception sync.RWMutex
@@ -1807,6 +1810,8 @@ func PrepareTimeWindowProducerQueue() {
 }
 
 func saveTimeWindow(faultLabel string, faultHappenTime string, lastTimeWindow *commonEntity.TimeWindow) {
+	saveTimeWindowMutex.Lock()
+	defer saveTimeWindowMutex.Unlock()
 	masterTopics, slaveTopics := getTopicsOfNode(faultLabel)
 	if lastTimeWindow == nil || util.TimeCustom1GreaterTimeCustom2(faultHappenTime, lastTimeWindow.TimeWindowEnd) { // 如果是不在旧故障窗口内,添加一个新窗口
 		exceptBegin := util.TimeCustomChange(faultHappenTime, -commonConfig.PlatformConfig.TaskBeforeTime)
@@ -1839,12 +1844,6 @@ func saveTimeWindow(faultLabel string, faultHappenTime string, lastTimeWindow *c
 			latestTimeWindowEnd = latestEnd
 			lastTimeWindow.TimeWindowEnd = latestTimeWindowEnd
 			lastTimeWindow.Length = util.CalculateDifferenceOfTimeCustom(lastTimeWindow.TimeWindowBegin, lastTimeWindow.TimeWindowEnd)
-		} else {
-			if util.TimeCustom1GreaterTimeCustom2(expectEnd, lastTimeWindow.TimeWindowEnd) {
-				latestTimeWindowEnd = expectEnd
-				lastTimeWindow.TimeWindowEnd = latestTimeWindowEnd
-				lastTimeWindow.Length = util.CalculateDifferenceOfTimeCustom(lastTimeWindow.TimeWindowBegin, lastTimeWindow.TimeWindowEnd)
-			}
 		}
 		// 更新label
 		labels := lastTimeWindow.Labels

+ 12 - 0
test/time_custom_test.go

@@ -0,0 +1,12 @@
+package test
+
+import (
+	"cicv-data-closedloop/common/util"
+	"fmt"
+	"testing"
+)
+
+func TestTimeCustom(t *testing.T) {
+	begin := util.TimeCustomChange("2024-07-26-07-25-38", -10)
+	fmt.Println(begin)
+}