[debug] fix idle send instruction & remove deepcopy & close task by device
This commit is contained in:
@@ -165,8 +165,7 @@ class Project(threading.Thread):
|
||||
task_info = task.get_task_info(action)
|
||||
instruction_set = getattr(self._instruction_set, action.type, None)
|
||||
# print('instruction_set',instruction_set)
|
||||
|
||||
if instruction_set != None:
|
||||
if instruction_set != None and task.cycle == 0:
|
||||
for instruction in instruction_set:
|
||||
args = list(map(lambda arg: task_info[arg], instruction['arguments']))
|
||||
threading.Thread(target=getattr(device, instruction['method'])(*args))
|
||||
@@ -219,7 +218,11 @@ class Project(threading.Thread):
|
||||
# if no running task
|
||||
if self._task_manager.running_task == None:
|
||||
return False
|
||||
|
||||
|
||||
for key in self._task_manager.running_task.action:
|
||||
if self._task_manager.running_task.action[key] == 'stop' and self._task_manager.running_task.cycle != 0:
|
||||
return False
|
||||
|
||||
for device in self._task_manager.running_task.device:
|
||||
if self._complete_device[device].status == 1:
|
||||
return False
|
||||
|
||||
@@ -108,7 +108,7 @@ class TaskManager():
|
||||
# print(f'!!@#!set_running_task\n\n\n{task._cycle_count}\n{task._cycle}\n\n\n')
|
||||
if task._cycle_count < task._cycle:
|
||||
task._cycle_count += 1
|
||||
cycle_target = deepcopy(self._task_list[task._cycle_next]) # TODO: not sure deep or shallow
|
||||
cycle_target = self._task_list[task._cycle_next] # TODO: not sure deep or shallow
|
||||
cycle_target.reset()
|
||||
# print('!!@#!status: ', cycle_target.status)
|
||||
# self._task_list[task._cycle_next].status = 0
|
||||
@@ -122,7 +122,7 @@ class TaskManager():
|
||||
_task.reset()
|
||||
# print('!@#WATCH', _task.status)
|
||||
# print('!@#_task._cycle_count: ', _task._cycle_count)
|
||||
_task_copy = deepcopy(_task) # TODO: here fix one bug, and make another, due to the second time "stop" condition will be trigger in this way, while the number of cycle will be reset
|
||||
_task_copy = _task # TODO: here fix one bug, and make another, due to the second time "stop" condition will be trigger in this way, while the number of cycle will be reset
|
||||
self._next_task.append(_task_copy)
|
||||
except RuntimeError as e:
|
||||
print(e)
|
||||
|
||||
Reference in New Issue
Block a user