From 6bc7833cd5e47bf60805125a2cbb71ee6097ec28 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期一, 16 十二月 2019 17:04:47 +0800
Subject: [PATCH] ---
---
ruleserver/timeTicker.go | 70 +++++++++++++++++++---------------
1 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/ruleserver/timeTicker.go b/ruleserver/timeTicker.go
index 3d258e8..b957670 100644
--- a/ruleserver/timeTicker.go
+++ b/ruleserver/timeTicker.go
@@ -1,8 +1,7 @@
package ruleserver
import (
- "fmt"
- "ruleprocess/logger"
+ "basic.com/valib/logger.git"
"ruleprocess/structure"
"strings"
"time"
@@ -34,35 +33,44 @@
func TimeTicker() {
ticker := time.NewTicker(1 * time.Second)
- go func(ticker *time.Ticker) {
- defer ticker.Stop()
- for {
- select {
- case <-ticker.C:
- logger.Info("瀹氭椂鍣ㄦ墽琛屽崟鍏�", time.Now().Unix())
- fmt.Println("瀹氭椂鍣ㄦ墽琛屽崟鍏�", time.Now().Unix())
- // 姣忕閽熻鏁板櫒姹犲瓙閲屾墍鏈夌殑璁℃暟鍣ㄥ厓绱犻兘鍑忎竴锛屽噺鍒�0鐨勬槸璇ユ姤璀︾殑
- rw.Lock()
- for k, timeEle := range TimeEleList {
- if timeEle.N > 0 {
- timeEle.N = timeEle.N - 1
- logger.Error("-------------------------------------鎵撳嵃瀹氭椂鍣ㄨ鏁板厓绱犲綋鍓嶅��-----------------------------------------锛�", timeEle.N)
- }
- if timeEle.GroupId != "" && timeEle.N == 0 {
- // 璇存槑鏄仈鍔ㄤ换鍔$殑鏃堕棿绐楀彛 鍒扮偣鍎夸簡璇ラ攢姣佷簡,鍐嶆潵浜嗗啀鍒涘缓
- delete(TimeEleList, k)
- }
+ //go func(ticker *time.Ticker) {
+ defer ticker.Stop()
+ for {
+ select {
+ case <-ticker.C:
+ //logger.Info("瀹氭椂鍣ㄦ墽琛屽崟鍏�", time.Now().Unix())
+ //fmt.Println("瀹氭椂鍣ㄦ墽琛屽崟鍏�", time.Now().Unix())
+ // 姣忕閽熻鏁板櫒姹犲瓙閲屾墍鏈夌殑璁℃暟鍣ㄥ厓绱犻兘鍑忎竴锛屽噺鍒�0鐨勬槸璇ユ姤璀︾殑
+ // 鍥剧墖瀹氭椂鍣ㄧ郴鍒�
+ rw.Lock()
+ for k, timeEle := range TimeEleList {
+ if timeEle.N > 0 {
+ timeEle.N = timeEle.N - 1
+ //logger.Debug("-------------------------------------鎵撳嵃瀹氭椂鍣ㄨ鏁板厓绱犲綋鍓嶅��-----------------------------------------锛�", timeEle.N)
}
- rw.Unlock()
- case stop := <-stopChan:
- if stop {
- logger.Info("瀹氭椂鍣ㄧ粨鏉�")
- return
- //os.Exit(0)
+ if timeEle.GroupId != "" && timeEle.N == 0 {
+ // 璇存槑鏄仈鍔ㄤ换鍔$殑鏃堕棿绐楀彛 鍒扮偣鍎夸簡璇ラ攢姣佷簡,鍐嶆潵浜嗗啀鍒涘缓
+ delete(TimeEleList, k)
}
}
+ rw.Unlock()
+ // 鐩爣瀹氭椂鍣ㄧ郴鍒�
+ for _,cameraArea := range structure.StaticMap {
+ for _,obj := range cameraArea.Targets {
+ if obj.N > 0 {
+ obj.N = obj.N - 1
+ }
+ }
+ }
+ case stop := <-stopChan:
+ if stop {
+ logger.Info("瀹氭椂鍣ㄧ粨鏉�")
+ return
+ //os.Exit(0)
+ }
}
- }(ticker)
+ }
+ //}(ticker)
}
func StopTimeTicker() {
stopChan <- true
@@ -148,8 +156,8 @@
func (p SubList) Less(i, j int) bool { return p[i].Sort < p[j].Sort }
// 缁撴瀯浣撴牴鎹煇瀛楁鎺掑簭
-type resultList []*structure.LittleRuleResult
+type ResultList []*structure.LittleRuleResult
-func (p resultList) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-func (p resultList) Len() int { return len(p) }
-func (p resultList) Less(i, j int) bool { return p[i].Sort < p[j].Sort }
+func (p ResultList) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+func (p ResultList) Len() int { return len(p) }
+func (p ResultList) Less(i, j int) bool { return p[i].Sort < p[j].Sort }
--
Gitblit v1.8.0