From a198a018e59dec641d09a935ef968ae693675d9c Mon Sep 17 00:00:00 2001 From: antcsny <131650489+antcsny@users.noreply.github.com> Date: Fri, 24 May 2024 11:02:46 +0200 Subject: [PATCH] WIP Trace stop during execution Adding a new state to read_done to stop the kuka trace if collector is done --- kuka/reader.py | 8 ++++---- robot/KRL/Data_collector.sub | 7 +++++-- ui/measure_robot.py | 7 +++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/kuka/reader.py b/kuka/reader.py index e791f30..95bcd00 100644 --- a/kuka/reader.py +++ b/kuka/reader.py @@ -273,7 +273,7 @@ class KUKA_DataReader: # Flag indicating the state of the collection self._read_done = False - while not self._read_done: + while self._read_done != 1 : # Getting our sample data, self._data_available, self._read_done = self.read(now, load) @@ -309,7 +309,9 @@ class KUKA_DataReader: sleep(self.rate/2) else: - # Sleeping to wait for the next data to be sampled + # Sleeping to wait for the next data to be sampled, stop de trace if robot movement done + if self._read_done == 2: + self.trace.Trace_Stop() sleep(self.rate/2) # Creating a data frame @@ -397,7 +399,6 @@ class KUKA_DataReader: trace_sampling = int(trace_config.split("_")[0]) ## ---- Run for a single speed ---- ## - if type(speed) == str or type(speed) == int: # Sync with other robots @@ -429,7 +430,6 @@ class KUKA_DataReader: # Returning the two collected DataFrames return data_vars, data_trace - ## -------------------------------- ## ## ---- Run for multiple speeds ---- ## diff --git a/robot/KRL/Data_collector.sub b/robot/KRL/Data_collector.sub index 4729910..b5638c7 100644 --- a/robot/KRL/Data_collector.sub +++ b/robot/KRL/Data_collector.sub @@ -205,8 +205,11 @@ DEF COMMUNICATION_ROUTINE () __TAB_1[35] = 1 ; __PYTHON_DATA_AVAILABLE = TRUE ENDIF - IF (NOT ColRUN) AND (SAMPLE_NUMBER == SAMPLE_READ) THEN - __TAB_1[36] = 1 ; __READ_DONE + IF (NOT ColRUN) AND THEN + IF SAMPLE_NUMBER == SAMPLE_READ THEN + __TAB_1[36] = 1 ; __READ_DONE + ELSE + __TAB_1[36] = 2 ; TRACE_STOP ELSE __TAB_1[36] = 0 ENDIF diff --git a/ui/measure_robot.py b/ui/measure_robot.py index fac6951..10b6909 100644 --- a/ui/measure_robot.py +++ b/ui/measure_robot.py @@ -13,6 +13,7 @@ class Measure_robot (CollectionGraphWindow): # Flag used to close the window when done collecting_data_done = False + storing_data_done = False # Collected data data = None @@ -130,9 +131,11 @@ class Measure_robot (CollectionGraphWindow): if self.collecting_data_done : self.collecting_data_done = False - self._status.update("Collection Done !",text_color="#0c2") + self._status.update("Collection Done",text_color="#00f") + elif self.storing_data_done : + self.storing_data_done = False + self._status.update("Successfully stored data", text_color='#0c2') else: self.redraw() - return True -- GitLab