Count.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import math
  2. import queue
  3. import threading
  4. import time
  5. from dijkstra.Map import singleton
  6. import json
  7. @singleton
  8. class TestCount():
  9. conf_file_="./count.json"
  10. navCount_={}
  11. navTasks_ = queue.Queue()
  12. lock_ = threading.Lock()
  13. running_ = False
  14. def __init__(self):
  15. self.Loadcfg()
  16. def Loadcfg(self):
  17. with open(self.conf_file_,'r',encoding='utf-8') as fp:
  18. self.navCount_=json.load(fp)
  19. def singleCount(self):
  20. return self.navCount_["single_count"]
  21. def loadCount(self):
  22. return self.navCount_["load_count"]
  23. def SaveCount(self):
  24. with open(self.conf_file_,'w',encoding='utf-8') as fp:
  25. json.dump(self.navCount_,fp)
  26. return map
  27. def Close(self):
  28. self.exit_ = True
  29. def loadCountAdd(self,ad=1):
  30. self.lock_.acquire()
  31. self.navCount_["load_count"]+=ad
  32. self.SaveCount()
  33. self.lock_.release()
  34. def singleCountAdd(self,ad=1):
  35. self.lock_.acquire()
  36. self.navCount_["single_count"]+=ad
  37. self.SaveCount()
  38. self.lock_.release()