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()