2022-07-18 10:52:56 -03:00
|
|
|
# AP_FLAKE8_CLEAN
|
2014-01-27 02:38:57 -04:00
|
|
|
|
2022-07-18 11:09:04 -03:00
|
|
|
from LogAnalyzer import Test, TestResult
|
|
|
|
|
2014-01-27 02:38:57 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
2022-07-18 10:52:56 -03:00
|
|
|
if "CURR" not in logdata.channels:
|
2014-08-12 12:54:15 -03:00
|
|
|
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
|
2016-09-07 19:36:06 -03:00
|
|
|
try:
|
2022-07-18 11:09:04 -03:00
|
|
|
vccMin = logdata.channels["CURR"]["Vcc"].min()
|
|
|
|
vccMax = logdata.channels["CURR"]["Vcc"].max()
|
2022-07-18 10:52:56 -03:00
|
|
|
except KeyError:
|
2022-07-18 11:09:04 -03:00
|
|
|
vccMin = logdata.channels["POWR"]["Vcc"].min()
|
|
|
|
vccMax = logdata.channels["POWR"]["Vcc"].max()
|
2016-09-07 19:36:06 -03:00
|
|
|
vccMin *= 1000
|
|
|
|
vccMax *= 1000
|
|
|
|
|
2022-07-18 11:09:04 -03:00
|
|
|
vccDiff = vccMax - vccMin
|
|
|
|
vccMinThreshold = 4.6 * 1000
|
|
|
|
vccMaxDiff = 0.3 * 1000
|
2014-08-12 12:54:15 -03:00
|
|
|
if vccDiff > vccMaxDiff:
|
|
|
|
self.result.status = TestResult.StatusType.WARN
|
2022-07-18 11:09:04 -03:00
|
|
|
self.result.statusMessage = "VCC min/max diff %sv, should be <%sv" % (vccDiff / 1000.0, vccMaxDiff / 1000.0)
|
2014-08-12 12:54:15 -03:00
|
|
|
elif vccMin < vccMinThreshold:
|
|
|
|
self.result.status = TestResult.StatusType.FAIL
|
2022-07-18 11:09:04 -03:00
|
|
|
self.result.statusMessage = "VCC below minimum of %sv (%sv)" % (
|
|
|
|
repr(vccMinThreshold / 1000.0),
|
|
|
|
repr(vccMin / 1000.0),
|
|
|
|
)
|