Browse Source

提交count.py

zx 2 years ago
parent
commit
874bd3ff39
2 changed files with 44 additions and 1 deletions
  1. 43 0
      Count.py
  2. 1 1
      count.json

+ 43 - 0
Count.py

@@ -0,0 +1,43 @@
+import math
+import queue
+import threading
+import time
+from dijkstra.Map import singleton
+import json
+
+@singleton
+class TestCount():
+    conf_file_="./count.json"
+    navCount_={}
+    navTasks_ = queue.Queue()
+    lock_ = threading.Lock()
+    running_ = False
+
+    def __init__(self):
+        self.Loadcfg()
+
+    def Loadcfg(self):
+        with open(self.conf_file_,'r',encoding='utf-8') as fp:
+            self.navCount_=json.load(fp)
+    def singleCount(self):
+        return self.navCount_["single_count"]
+    def loadCount(self):
+        return self.navCount_["load_count"]
+
+    def SaveCount(self):
+        with open(self.conf_file_,'w',encoding='utf-8') as fp:
+            json.dump(self.navCount_,fp)
+            return map
+
+    def Close(self):
+        self.exit_ = True
+    def loadCountAdd(self,ad=1):
+        self.lock_.acquire()
+        self.navCount_["load_count"]+=ad
+        self.SaveCount()
+        self.lock_.release()
+    def singleCountAdd(self,ad=1):
+        self.lock_.acquire()
+        self.navCount_["single_count"]+=ad
+        self.SaveCount()
+        self.lock_.release()

+ 1 - 1
count.json

@@ -1 +1 @@
-{"load_count": 381, "single_count": 493}
+{"load_count": 382, "single_count": 522}