[update] temp push
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
|
||||
class Condition ():
|
||||
def __init__(self, type, comparsion, value):
|
||||
self._type = type
|
||||
self._comparsion = comparsion
|
||||
self._value = value
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
@property
|
||||
def comparsion(self):
|
||||
return self._comparsion
|
||||
@property
|
||||
def value(self):
|
||||
return self._value
|
||||
|
||||
def set_comparsion(self, comparsion):
|
||||
self._comparsion = comparsion
|
||||
|
||||
def set_type(self, type):
|
||||
self._type = type
|
||||
|
||||
def set_value(self, value):
|
||||
self._value = value
|
||||
|
||||
def check(self, value):
|
||||
|
||||
@@ -12,7 +12,7 @@ class Project(threading.Thread):
|
||||
self._mqtt_thread = mqttThread
|
||||
self._time_interval = 1
|
||||
|
||||
self._task_manager = TaskManager(self._project['taskObj'])
|
||||
self._task_manager = TaskManager(self._project['taskList'])
|
||||
|
||||
@property
|
||||
def desc(self) -> str:
|
||||
@@ -48,6 +48,7 @@ class Project(threading.Thread):
|
||||
while True:
|
||||
print('run')
|
||||
time.sleep( self._time_interval)
|
||||
self._task_manager.check_match_condition()
|
||||
# for task in self.tasks:
|
||||
# print('task', task.name)
|
||||
# check time
|
||||
|
||||
@@ -65,7 +65,6 @@ class Task:
|
||||
def match_condition_actions(self, condition_id) -> list:
|
||||
return [action_id for action_id in self.actions if condition_id in self.actions[action_id]['condition']]
|
||||
|
||||
|
||||
def conditions_meet(self, specify_type:str = None):
|
||||
match_conditions = []
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from json import loads as json_parse, dumps as _json_stringify
|
||||
from typing import Dict, Optional, Any
|
||||
from xml.dom.expatbuilder import parseString
|
||||
import paho.mqtt.client as mqtt
|
||||
from .task import Task
|
||||
|
||||
@@ -9,11 +10,9 @@ def json_stringify(o: Any) -> str:
|
||||
return _json_stringify(o, separators=(',', ':'))
|
||||
|
||||
class TaskManager():
|
||||
def __init__(self, all_task):
|
||||
self.task_graph = {}
|
||||
self.my_list = []
|
||||
self._all_task = all_task
|
||||
self.create_task_list(all_task)
|
||||
def __init__(self, task_list):
|
||||
self._task_list = task_list
|
||||
self._current_task = self._task_list[0]
|
||||
|
||||
def remove(self, index):
|
||||
pass
|
||||
@@ -21,26 +20,29 @@ class TaskManager():
|
||||
def get(self):
|
||||
pass
|
||||
|
||||
def create_task_list(self, all_task):
|
||||
for key, task in all_task.items():
|
||||
print(key, task)
|
||||
def get_current_task(self):
|
||||
pass
|
||||
|
||||
def add_task(self, node):
|
||||
if node not in self.my_list:
|
||||
self.my_list.append(node)
|
||||
else:
|
||||
print("Node ",node," already exists!")
|
||||
def check_match_condition(self):
|
||||
self._current_task.condition
|
||||
pass
|
||||
|
||||
def add_edge(self, node1, node2):
|
||||
temp = []
|
||||
if node1 in self.my_list and node2 in self.my_list:
|
||||
if node1 not in self.task_graph:
|
||||
temp.append(node2)
|
||||
self.task_graph[node1] = temp
|
||||
# def add_task(self, node):
|
||||
# if node not in self.my_list:
|
||||
# self.my_list.append(node)
|
||||
# else:
|
||||
# print("Node ",node," already exists!")
|
||||
|
||||
# def add_edge(self, node1, node2):
|
||||
# temp = []
|
||||
# if node1 in self.my_list and node2 in self.my_list:
|
||||
# if node1 not in self.task_graph:
|
||||
# temp.append(node2)
|
||||
# self.task_graph[node1] = temp
|
||||
|
||||
elif node1 in self.task_graph:
|
||||
temp.extend(self.task_graph[node1])
|
||||
temp.append(node2)
|
||||
self.task_graph[node1] = temp
|
||||
else:
|
||||
print("Nodes don't exist!")
|
||||
# elif node1 in self.task_graph:
|
||||
# temp.extend(self.task_graph[node1])
|
||||
# temp.append(node2)
|
||||
# self.task_graph[node1] = temp
|
||||
# else:
|
||||
# print("Nodes don't exist!")
|
||||
Reference in New Issue
Block a user