From 568769cd8848dbd62ff801db5421e777077f709c Mon Sep 17 00:00:00 2001 From: mancini <mancini@astron.nl> Date: Wed, 2 Aug 2023 10:50:33 +0200 Subject: [PATCH] Adapt to new pmt interface and fix invalid read --- pmt-view/main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pmt-view/main.py b/pmt-view/main.py index 79d1622..bbfecc6 100644 --- a/pmt-view/main.py +++ b/pmt-view/main.py @@ -1,5 +1,5 @@ from argparse import ArgumentParser -import pmt +import pypmt import time from bokeh.plotting import figure from bokeh.io import show @@ -7,6 +7,7 @@ from bokeh.embed import file_html from bokeh.io import curdoc from bokeh.models import ColumnDataSource import config +import pmt def parse_args(): @@ -78,20 +79,22 @@ class Display: def callback(self): if self.state is None: + #first read is garbage + self.state = self.sensor.read() self.state = self.sensor.read() time.sleep(1) n_state = self.sensor.read() - self.cur_second += pmt.seconds(self.state, n_state) + self.cur_second += pypmt.PMT.seconds(self.state, n_state) row = { "Joules": [ - pmt.joules(self.state, n_state), + pypmt.PMT.joules(self.state, n_state), ], - "Watts": [pmt.joules(self.state, n_state)], + "Watts": [pypmt.PMT.joules(self.state, n_state)], "Average watts": [ - pmt.joules(self.state, n_state) / pmt.seconds(self.state, n_state) + pypmt.PMT.joules(self.state, n_state) / pypmt.PMT.seconds(self.state, n_state) ], "Average joules": [ - pmt.watts(self.state, n_state) / pmt.seconds(self.state, n_state) + pypmt.PMT.watts(self.state, n_state) / pypmt.PMT.seconds(self.state, n_state) ], "Seconds": [self.cur_second], } -- GitLab