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.
Table of Contents
Table of Contents | ||
---|---|---|
|
1 Advanced Use Cases
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".1.1 poweradvantage.py from Python
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) |
1.2 Customized Output from poweradvantage.py
printpower prints the power but can also be copied and modified to make a custom printout.
...
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() |
1.3 Porting poweradvantage.py
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"] |