Skip to content
Snippets Groups Projects
Commit 568769cd authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Adapt to new pmt interface and fix invalid read

parent 827327c3
Branches
No related tags found
No related merge requests found
from argparse import ArgumentParser from argparse import ArgumentParser
import pmt import pypmt
import time import time
from bokeh.plotting import figure from bokeh.plotting import figure
from bokeh.io import show from bokeh.io import show
...@@ -7,6 +7,7 @@ from bokeh.embed import file_html ...@@ -7,6 +7,7 @@ from bokeh.embed import file_html
from bokeh.io import curdoc from bokeh.io import curdoc
from bokeh.models import ColumnDataSource from bokeh.models import ColumnDataSource
import config import config
import pmt
def parse_args(): def parse_args():
...@@ -78,20 +79,22 @@ class Display: ...@@ -78,20 +79,22 @@ class Display:
def callback(self): def callback(self):
if self.state is None: if self.state is None:
#first read is garbage
self.state = self.sensor.read()
self.state = self.sensor.read() self.state = self.sensor.read()
time.sleep(1) time.sleep(1)
n_state = self.sensor.read() 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 = { row = {
"Joules": [ "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": [ "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": [ "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], "Seconds": [self.cur_second],
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment