Browse Source

Fix for sensor data jumps due to non-synchronised threads.

master
Carlos Reding 1 year ago
parent
commit
05cc7469a0
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      puppeteer/_core.py

+ 8
- 2
puppeteer/_core.py View File

@@ -420,7 +420,7 @@ class SetupDevice:
report : list
Updated list of temperatures.
"""
return report.append(self._sensors[sensor_id].get_temperature())
return report.append([sensor_id, self._sensors[sensor_id].get_temperature()])

def report_temperature(self):
"""
@@ -445,7 +445,13 @@ class SetupDevice:
# Once data retrieved, halt threads.
for process in thread_list:
process.join()
return np.array(report)
# Sort report to ensure temperatures _always_ have same order.
# This avoids `jumps' in the temperature reported by each sensor
# that are really caused by threads not finishing exactly in the
# same order.
report.sort()
sorted_report = [temperature[1] for temperature in report]
return np.array(sorted_report)

def _init_device(self, dev, OUTPUT, imdev):
"""

Loading…
Cancel
Save