From 092d749fef002fcf6141194899bd2faf1f3d4eef Mon Sep 17 00:00:00 2001 From: ykyohei <38639108+ykyohei@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:50:46 +0000 Subject: [PATCH 1/3] Add cpu level packet count --- socs/agents/hwp_encoder/agent.py | 63 +++++++++++++++++++------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/socs/agents/hwp_encoder/agent.py b/socs/agents/hwp_encoder/agent.py index e371e95ba..3d87b7321 100644 --- a/socs/agents/hwp_encoder/agent.py +++ b/socs/agents/hwp_encoder/agent.py @@ -391,13 +391,14 @@ def parse_counter_info(self, data): Note: 'data' structure: - (Please note that '150' below might be replaced by COUNTER_INFO_LENGTH) + (Please note that '120' below might be replaced by COUNTER_INFO_LENGTH) [0] Readout from the quadrature - [1-150] clock counts of 150 data points - [151-300] corresponding clock overflow of the 150 data points (each overflow count + [1] CPU level encoder packet count + [2-121] clock counts of 120 data points + [122-241] corresponding clock overflow of the 120 data points (each overflow count is equal to 2^16 clock counts) - [301-450] corresponding absolute number of the 150 data points ((1, 2, 3, etc ...) - or (150, 151, 152, etc ...) or (301, 302, 303, etc ...) etc ...) + [242-361] corresponding absolute number of the 120 data points ((1, 2, 3, etc ...) + or (120, 121, 122, etc ...) or (241, 242, 243, etc ...) etc ...) counter_queue structure: counter_queue = [[64 bit clock counts], @@ -407,13 +408,13 @@ def parse_counter_info(self, data): """ # Convert the Encoder Packet structure into a numpy array - derter = np.array(struct.unpack('<' + 'I' + 'III' * COUNTER_INFO_LENGTH, data)) + derter = np.array(struct.unpack('<' + 'I' + 'I' + 'III' * COUNTER_INFO_LENGTH, data)) # self.quad_queue.append(derter[0].item()) # merged to counter_queue - self.counter_queue.append((derter[1:COUNTER_INFO_LENGTH + 1] - + (derter[COUNTER_INFO_LENGTH + 1:2 * COUNTER_INFO_LENGTH + 1] << 32), - derter[2 * COUNTER_INFO_LENGTH + 1:3 * COUNTER_INFO_LENGTH + 1], - derter[0].item(), time.time())) + self.counter_queue.append((derter[2:COUNTER_INFO_LENGTH + 2] + + (derter[COUNTER_INFO_LENGTH + 2:2 * COUNTER_INFO_LENGTH + 2] << 32), + derter[2 * COUNTER_INFO_LENGTH + 2:3 * COUNTER_INFO_LENGTH + 2], + derter[0].item(), derter[1].item(), time.time())) def parse_irig_info(self, data): """Method to parse the IRIG Packet and put them to the irig_queue @@ -428,12 +429,13 @@ def parse_irig_info(self, data): 'data' structure: [0] clock count of the IRIG Packet which the UTC time corresponds to [1] overflow count of initial rising edge - [2] binary encoding of the second data - [3] binary encoding of the minute data - [4] binary encoding of the hour data - [5-11] additional IRIG information which we do mot use - [12-21] synchronization pulse clock counts - [22-31] overflow count at each synchronization pulse + [2] CPU level IRIG packet count + [3] binary encoding of the second data + [4] binary encoding of the minute data + [5] binary encoding of the hour data + [6-12] additional IRIG information which we do mot use + [13-22] synchronization pulse clock counts + [23-32] overflow count at each synchronization pulse irig_queue structure: irig_queue = [Packet clock count, @@ -445,7 +447,7 @@ def parse_irig_info(self, data): """ # Convert the IRIG Packet structure into a numpy array - unpacked_data = struct.unpack('= NUM_ENCODER_TO_PUBLISH \ @@ -614,6 +624,7 @@ def acq(self, session, params): data = {'timestamps': [], 'block_name': 'HWPEncoder_quad', 'data': {}} data['timestamps'] = received_time_list data['data']['quad'] = quad_list + data['data']['encoder_packet_count'] = encoder_packet_count_list self.agent.publish_to_feed('HWPEncoder', data) if quad_list: self.last_quad = quad_list[-1] From a2e908c6b94abfbcced3dc2b0fb92a9f986e7020 Mon Sep 17 00:00:00 2001 From: Jack Lashner Date: Sun, 17 Mar 2024 14:48:13 -0400 Subject: [PATCH 2/3] Fix issues with packet counter --- socs/agents/hwp_encoder/agent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/socs/agents/hwp_encoder/agent.py b/socs/agents/hwp_encoder/agent.py index 3d87b7321..401d1d88f 100644 --- a/socs/agents/hwp_encoder/agent.py +++ b/socs/agents/hwp_encoder/agent.py @@ -71,8 +71,9 @@ # The number of datapoints in every encoder packet from the Beaglebone COUNTER_INFO_LENGTH = 120 # The size of the encoder packet from the beaglebone -# (header + 3*COUNTER_INFO_LENGTH datapoint information + 1 quadrature readout) -COUNTER_PACKET_SIZE = 4 + 4 * COUNTER_INFO_LENGTH + 8 * COUNTER_INFO_LENGTH + 4 +# (header + 3*COUNTER_INFO_LENGTH datapoint information +# + 1 quadrature readout + 1 packet counter) +COUNTER_PACKET_SIZE = 4 + 4 + 4 * COUNTER_INFO_LENGTH + 8 * COUNTER_INFO_LENGTH + 4 # The size of the IRIG packet from the Beaglebone IRIG_PACKET_SIZE = 132 @@ -672,6 +673,7 @@ def acq(self, session, params): quad_list = [] quad_counter_list = [] received_time_list = [] + encoder_packet_count_list = [] time_encoder_published = ct From 1a64b58b306757ed6b6bc9f6d21f6f01c3f1cf6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 17 Mar 2024 18:48:36 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- socs/agents/hwp_encoder/agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/socs/agents/hwp_encoder/agent.py b/socs/agents/hwp_encoder/agent.py index 401d1d88f..9e818b3a1 100644 --- a/socs/agents/hwp_encoder/agent.py +++ b/socs/agents/hwp_encoder/agent.py @@ -71,7 +71,7 @@ # The number of datapoints in every encoder packet from the Beaglebone COUNTER_INFO_LENGTH = 120 # The size of the encoder packet from the beaglebone -# (header + 3*COUNTER_INFO_LENGTH datapoint information +# (header + 3*COUNTER_INFO_LENGTH datapoint information # + 1 quadrature readout + 1 packet counter) COUNTER_PACKET_SIZE = 4 + 4 + 4 * COUNTER_INFO_LENGTH + 8 * COUNTER_INFO_LENGTH + 4 # The size of the IRIG packet from the Beaglebone