MCPcopy Create free account
hub / github.com/ARM-software/AVH / __getInterval

Method __getInterval

interface/sensor/python/vsi_sensor.py:127–146  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

125
126 # Calculate average interval based on number of samples/blocks in current time window
127 def __getInterval(self):
128 logger.info("Calculate new Interval")
129 if (CONTROL & CONTROL_DMA_Msk) != 0:
130 size = FIFO_SIZE
131 else:
132 size = SAMPLE_SIZE
133
134 num = int(sum(self.data_size[self.cnt:-1])/size)
135
136 if num > 0:
137 self.interval = round((self.window * 1000)/num)
138 logger.debug(f"Number of Samples/Blocks: {num}")
139
140 # Compensate for time drift
141 record_elapsed_time = (self.timestamp[self.cnt] - self.timestamp[0]) * 1000
142 if self.elapsed_time != record_elapsed_time:
143 interval_correction = round((self.elapsed_time - record_elapsed_time)/num)
144 self.interval -= interval_correction #us
145 else:
146 self.interval = 0
147
148 # Calculate new average timer interval when current record timestamp is at least
149 # SLIDE_INTERVAL ahead of last timestamp used for updating the timer

Callers 1

updateTimerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected