2014-01-27 02:38:57 -04:00
|
|
|
from LogAnalyzer import Test,TestResult
|
|
|
|
import DataflashLog
|
|
|
|
|
|
|
|
import collections
|
|
|
|
|
|
|
|
|
|
|
|
class TestVCC(Test):
|
2014-08-12 12:54:15 -03:00
|
|
|
'''test for VCC within recommendations, or abrupt end to log in flight'''
|
2014-01-27 02:38:57 -04:00
|
|
|
|
2014-08-12 12:54:15 -03:00
|
|
|
def __init__(self):
|
|
|
|
Test.__init__(self)
|
|
|
|
self.name = "VCC"
|
2014-01-27 02:38:57 -04:00
|
|
|
|
2014-08-12 12:54:15 -03:00
|
|
|
def run(self, logdata, verbose):
|
|
|
|
self.result = TestResult()
|
|
|
|
self.result.status = TestResult.StatusType.GOOD
|
2014-01-27 02:38:57 -04:00
|
|
|
|
2014-08-12 12:54:15 -03:00
|
|
|
if not "CURR" in logdata.channels:
|
|
|
|
self.result.status = TestResult.StatusType.UNKNOWN
|
|
|
|
self.result.statusMessage = "No CURR log data"
|
|
|
|
return
|
2014-01-27 02:38:57 -04:00
|
|
|
|
2014-08-12 12:54:15 -03:00
|
|
|
# just a naive min/max test for now
|
|
|
|
vccMin = logdata.channels["CURR"]["Vcc"].min()
|
|
|
|
vccMax = logdata.channels["CURR"]["Vcc"].max()
|
|
|
|
vccDiff = vccMax - vccMin;
|
|
|
|
vccMinThreshold = 4.6 * 1000;
|
|
|
|
vccMaxDiff = 0.3 * 1000;
|
|
|
|
if vccDiff > vccMaxDiff:
|
|
|
|
self.result.status = TestResult.StatusType.WARN
|
|
|
|
self.result.statusMessage = "VCC min/max diff %sv, should be <%sv" % (vccDiff/1000.0, vccMaxDiff/1000.0)
|
|
|
|
elif vccMin < vccMinThreshold:
|
|
|
|
self.result.status = TestResult.StatusType.FAIL
|
|
|
|
self.result.statusMessage = "VCC below minimum of %sv (%sv)" % (`vccMinThreshold/1000.0`,`vccMin/1000.0`)
|
|
|
|
|