moved core functions in tasks.py to class Tasker

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2020-06-10 18:19:58 +00:00
parent 236c28c3be
commit 8a212a21df

View File

@ -6,30 +6,23 @@ __author__ = (
"Arthur Lu <learthurgo@gmail.com>", "Arthur Lu <learthurgo@gmail.com>",
) )
match_ = False class Tasker():
metric_ = False
pit_ = False
match_enable = True match_ = False
metric_enable = True metric_ = False
pit_enable = True pit_ = False
config = {} match_enable = True
metric_enable = True
pit_enable = True
def init(): config = {}
global match_ def __init__():
global metric_
global pit_
global match_enable
global metric_enable
global pit_enable
global config
config = su.load_config("config.json") config = su.load_config("config.json")
def match(): def match():
match_ = True match_ = True
@ -47,7 +40,7 @@ def match():
task = threading.Thread(name = "match", target = match) task = threading.Thread(name = "match", target = match)
task.start() task.start()
def metric(): def metric():
metric_ = True metric_ = True
@ -67,7 +60,7 @@ def metric():
task = threading.Thread(name = "match", target = metric) task = threading.Thread(name = "match", target = metric)
task.start() task.start()
def pit(): def pit():
pit_ = True pit_ = True
@ -85,26 +78,44 @@ def pit():
task = threading.Thread(name = "pit", target = pit) task = threading.Thread(name = "pit", target = pit)
task.start() task.start()
def start_match(): def start_match():
task = threading.Thread(name = "match", target = match) task = threading.Thread(name = "match", target = match)
task.start() task.start()
def start_metric(): def start_metric():
task = threading.Thread(name = "match", target = metric) task = threading.Thread(name = "match", target = metric)
task.start() task.start()
def start_pit(): def start_pit():
task = threading.Thread(name = "pit", target = pit) task = threading.Thread(name = "pit", target = pit)
task.start() task.start()
def stop_match(): def stop_match():
match_enable = False match_enable = False
def stop_metric(): def stop_metric():
metric_enable = False metric_enable = False
def stop_pit(): def stop_pit():
pit_enable = False pit_enable = False
def get_match():
return match_
def get_metric():
return metric_
def get_pit():
return pit_
def get_match_enable():
return match_enable
def get_metric_enable():
return metric_enable
def get_pit_enable():
return pit_enable
""" """
def main(): def main():