If you are an advanced user and you want to take advantage of the poweradvantage.py, this Wiki page describes some things you can do.
If you would like to use poweradvantage.py directly from Python instead of Jupyter Notebook we have section 1.1 "poweradvantage.py From Python". If you wish to customize the output format of poweradvantage.py please check section 1.2 "Customized output from poweradvantage.py". If you would like to port to an additional platform, proceed to section 1.3 "Porting poweradvantage.py".
The poweradvantage.py library is accessible directly from Python 3. It can be found at /usr/lib/python<version>/site-packages/poweradvantage.
Code Block |
---|
from poweradvantage import poweradvantage
import time
pa = poweradvantage("VMK180", "SC")
while 1:
pa.printpower()
time.sleep(1) |
printpower prints the power but can also be copied and modified to make a custom printout.
...
For example, if you wanted to only print a subset of the data, you could code this snippet:
Code Block |
---|
|
from poweradvantage import poweradvantage
import time
from IPython import display
pa = poweradvantage("VCK190", "SC")
while 1:
display.clear_output(wait=True)
power = pa.getpower()
domain = ""
dtotal = 0
total = 0
print("%18s Volts Amps Watts" % "")
for (n, d, p) in zip(pa.name, pa.domain, power):
if (d == "LPD") or (d == "FPD"):
if (domain != "") and (d != domain):
print("%18s ----- ------- %7.4f" % (domain, dtotal))
dtotal = 0
domain = d
print("%18s %5.3f %7.4f %7.4f" % (n, p[0], p[1], p[2]))
dtotal += p[2]
total += p[2]
print("%18s ----- ------- %7.4f" % (domain, dtotal))
time.sleep(5) |
...
Code Block |
---|
|
from poweradvantage import poweradvantage
import time
from IPython import display
from datetime import datetime
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
pa = poweradvantage("VCK190", "SC")
name = pa.getname()
import numpy as np
data = {'PS_FPD_Power': []}
#create dataframe
df = pd.DataFrame(data)
while 1:
dt_object = datetime.fromtimestamp(datetime.timestamp(datetime.now()))
power = pa.getpower()
for (n, d, p) in zip(pa.name, pa.domain, power):
if (n == 'VCC_PSFP'):
print("PS FPD %7.4f (watts)" % (p[2]))
#append row to the dataframe
new_data = {'PS_FPD_Power': p[2]}
df = df.append(new_data, ignore_index=True)
plt.plot(df.tail(1000)) # plotting by columns
display.clear_output(wait=True)
plt.show() |
If you wish to support another board type that is not currently supported, poweradvantage.py was coded to be flat and modular.
...
Code Block |
---|
|
# Create some members
if name == "ZCU111":
self.bus = [
3,3,3,3,
3,3,3,3,
3,3,3,3,
3,3]
self.address = [
0x40,0x45,0x46,0x49,
0x4a,0x4b,0x4c,0x4d,
0x4e,0x43,0x47,0x48,
0x41,0x42]
self.name = [
"VCCINT","VADJ_FMC","MGTAVCC","VCCINT_AMS",
"DAC_AVTT","DAC_AVCCAUX","ADC_AVCC","ADC_AVCCAUX",
"DAC_AVCC","VCC1V2","MGT1V2","MGT1V8",
"VCCPSINT","VCC1V8"] |