From cd98a14e84fe922ffb01b9c8c7a522d16c2c8d01 Mon Sep 17 00:00:00 2001 From: peterlu14 Date: Tue, 16 Aug 2022 14:25:37 +0800 Subject: [PATCH] [debug] fix idle send instruction & remove deepcopy & close task by device --- python/biopro/project/project.py | 9 ++++++--- python/biopro/project/task_manager.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/python/biopro/project/project.py b/python/biopro/project/project.py index cada67d..b6a43f6 100644 --- a/python/biopro/project/project.py +++ b/python/biopro/project/project.py @@ -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 diff --git a/python/biopro/project/task_manager.py b/python/biopro/project/task_manager.py index 6916365..1d9a8e1 100644 --- a/python/biopro/project/task_manager.py +++ b/python/biopro/project/task_manager.py @@ -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)