# HG changeset patch # User Daniel O'Connor # Date 1513944623 -3600 # Node ID 30e7adf283ca0c4286cf19f70ffae07c213746d1 # Parent 40a3b403a096b10fceef4d829dea518fa9ef5fe8 Add depth of discharge annotation when plotting state_of_charge diff -r 40a3b403a096 -r 30e7adf283ca graph.py --- a/graph.py Fri Dec 22 13:05:05 2017 +0100 +++ b/graph.py Fri Dec 22 13:10:23 2017 +0100 @@ -13,20 +13,21 @@ import tzlocal class Column(object): - def __init__(self, rowname, title, table, units, limits = (None, None), conv = None): + def __init__(self, rowname, title, table, units, limits = (None, None), conv = None, annofn = None): self.rowname = rowname self.title = title self.table = table self.units = units self.limits = limits - self.conv = None + self.conv = conv + self.annofn = annofn columns = [ Column('main_voltage', 'Battery Voltage', 'eprolog', 'Vdc'), Column('aux_voltage', 'Aux Voltage', 'eprolog', 'Vdc'), Column('battery_curr', 'Battery Current', 'eprolog', 'A'), Column('amp_hours', 'Battery Amp Hours', 'eprolog', 'Ah'), - Column('state_of_charge', 'State of Charge', 'eprolog', '%', (0, 100)), + Column('state_of_charge', 'State of Charge', 'eprolog', '%', (0, 100), annofn = lambda xdata, ydata: 'DoD: %.1f' % (100 - ydata.min())), Column('time_remaining', 'Time Remaining', 'eprolog', 'min'), Column('battery_temp', 'Battery Temperature', 'eprolog', 'C'), @@ -165,7 +166,10 @@ scale_min, scale_max = c.limits # DoD? - c.annotation = None + if c.annofn != None: + c.annotation = c.annofn(c.xdata, c.ydata) + else: + c.annotation = None # Work out which axis to plot on if c.units == yaxisunits1: