def _GetLimits(self, param_limits): return { 'normal': check_range.Interval( [param_limits.low, param_limits.high]), 'warning': check_range.Interval( [param_limits.very_low, param_limits.very_high]), }
def _Check(self, cn0, num_obs, type_bits): """Check the carrier-to-noise ratio.""" if num_obs == 0: return if self._for_log: avg_cn0, max_cn0 = self.GetAvgAndMaxCn0FromTimeSeries( cn0, num_obs, type_bits) else: avg_cn0, max_cn0, _ = self.GetAvgAndMaxCn0(cn0, num_obs, type_bits) avg_ranges = check_range.Interval([40.0, None]) max_ranges = check_range.Interval([45.0, None]) all_inclusive = check_range.AllInclusiveRange() self._CheckByRange('%s (Avg)' % self._name, avg_cn0, avg_ranges, all_inclusive) self._CheckByRange('%s (Max)' % self._name, max_cn0, max_ranges, all_inclusive)
def __init__(self, for_log, message_type, aio_node_label_helper, aio_node_prefix=''): aio_node_labels = [ aio_node_prefix + s for s in aio_node_label_helper.ShortNames() ] self._items_to_check = [ AioMonAnalogChecker(for_log, message_type, node, name='%s.AioMon.AnalogVoltage' % node) for node in aio_node_labels ] + [ AioMonTemperatureChecker( for_log, message_type, node, name='%s.AioMon.Temperature' % node, normal_ranges=check_range.Interval([0, 65]), warning_ranges=check_range.Interval([0, 85])) for node in aio_node_labels ] + [ AioMonHumidityChecker( for_log, message_type, node, name='%s.AioMon.Humidity' % node) for node in aio_node_labels ] + [ AioMonBusVoltageChecker(for_log, message_type, node, name='%s.AioMon.BusVoltage' % node) for node in aio_node_labels ] + [ AioMonBusCurrentChecker(for_log, message_type, node, name='%s.AioMon.BusCurrent' % node) for node in aio_node_labels ]
def __init__(self, mode, **widget_kwargs): super(StarboardPosChart, self).__init__(mode, 'Star Ail Pos [°]', ['A5', 'A7', 'A8'], show_cmd=True, **widget_kwargs) self._SetLimits( { self._ObservationLabel(n): (check_range.Interval(numpy.rad2deg( flap_limits.FlapsToServos( flap_limits.GetControlCrosswindLimits())[n]).tolist(), inclusiveness=(False, False)), check_range.AllInclusiveRange()) for n in ['A7', 'A8'] }, [ control_types.kFlightModeCrosswindNormal, control_types.kFlightModeCrosswindPrepTransOut ])
def __init__(self, mode, **widget_kwargs): nodes = ['E1', 'E2'] super(ElePosChart, self).__init__(mode, 'Ele Pos [°]', nodes, show_cmd=True, **widget_kwargs) limits = flap_limits.FlapsToServos( flap_limits.GetControlCrosswindLimits())['E1'] limits = numpy.rad2deg(limits).tolist() self._SetLimits( { self._ObservationLabel(n): (check_range.Interval(limits, inclusiveness=(False, False)), check_range.AllInclusiveRange()) for n in nodes }, [ control_types.kFlightModeCrosswindNormal, control_types.kFlightModeCrosswindPrepTransOut ])
def testRangeClasses(self): array = numpy.array([0, 1, 2, 3, 4]) crange = check_range.Singleton(1) self.assertIn(1, crange) self.assertNotIn(3, crange) self.assertIn(numpy.array([1, 1]), crange) self.assertNotIn(numpy.array([1, 2]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 1, 0, 0, 0]))) self.assertEqual(str(crange), '1') crange = check_range.Container({1, 'a'}) self.assertIn(1, crange) self.assertIn('a', crange) self.assertNotIn(3, crange) self.assertNotIn('b', crange) self.assertIn(numpy.array([1, 1]), crange) self.assertNotIn(numpy.array([1, 2]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 1, 0, 0, 0]))) self.assertEqual(str(crange), "{1, 'a'}") crange = check_range.Container({1: 2, 'a': 'b'}) self.assertIn(1, crange) self.assertIn('a', crange) self.assertNotIn(3, crange) self.assertNotIn('b', crange) self.assertIn(numpy.array([1, 1]), crange) self.assertNotIn(numpy.array([1, 2]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 1, 0, 0, 0]))) self.assertEqual(str(crange), "{1, 'a'}") crange = check_range.Container([1, 2, 'a', 'b']) self.assertIn(1, crange) self.assertIn('a', crange) self.assertNotIn(3, crange) self.assertNotIn('c', crange) self.assertIn(numpy.array([1, 2]), crange) self.assertNotIn(numpy.array([1, 3]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 1, 1, 0, 0]))) self.assertEqual(str(crange), "{1, 2, 'a', 'b'}") crange = check_range.Interval([1, 3]) self.assertIn(1, crange) self.assertIn(3, crange) self.assertIn(2, crange) self.assertNotIn(5, crange) self.assertNotIn(0, crange) self.assertIn(numpy.array([1, 2, 3]), crange) self.assertNotIn(numpy.array([1, 2, 3, 4]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 1, 1, 1, 0]))) self.assertEqual(str(crange), '[1, 3]') crange = check_range.Interval([1, 3], inclusiveness=[False, False]) self.assertIn(1.1, crange) self.assertIn(2.9, crange) self.assertIn(2, crange) self.assertNotIn(1, crange) self.assertNotIn(3, crange) self.assertIn(numpy.array([2, 2]), crange) self.assertNotIn(numpy.array([1, 2, 3]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 0, 1, 0, 0]))) self.assertEqual(str(crange), '(1, 3)') crange = check_range.Interval([3, None]) self.assertIn(3, crange) self.assertNotIn(2, crange) self.assertIn(numpy.array([3, 4]), crange) self.assertNotIn(numpy.array([1, 2, 3]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 0, 0, 1, 1]))) self.assertEqual(str(crange), '[3, inf]') crange = check_range.Interval([None, 3]) self.assertIn(3, crange) self.assertNotIn(4, crange) self.assertIn(numpy.array([2, 3]), crange) self.assertNotIn(numpy.array([2, 3, 4]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([1, 1, 1, 1, 0]))) self.assertEqual(str(crange), '[-inf, 3]') crange = check_range.Interval([None, None]) self.assertIn(4, crange) self.assertIn(numpy.array([2, 2]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([1, 1, 1, 1, 1]))) self.assertEqual(str(crange), '[-inf, inf]') crange = check_range.Container([]) self.assertNotIn(4, crange) self.assertNotIn(numpy.array([2, 2]), crange) self.assertTrue(numpy.array_equal( crange.Select(array), numpy.array([0, 0, 0, 0, 0]))) self.assertEqual(str(crange), '{}') with self.assertRaises(AssertionError): check_range.Singleton(None)
def __init__(self, for_log): self._items_to_check = [] net_conf = network_config.NetworkConfig() node_messages = { 'batt': 'BatteryStatus', 'drum': 'DrumSensorsMonitor', 'flight_computer': 'FlightComputerSensor', 'gps': 'GpsStatus', 'plc_gs02': 'GroundStationPlcMonitorStatus', 'joystick': 'JoystickMonitorStatus', 'loadcell_node': 'Loadcell', 'mvlv': 'MvlvStatus', 'platform': 'PlatformSensorsMonitor', 'recorder_tms570': 'RecorderStatus', 'servo': 'ServoStatus', 'short_stack': 'ShortStackStatus' } for label, message_type in node_messages.iteritems(): nodes = [ node.camel_name for node in net_conf.GetAioNodesByLabel(label) ] # TODO: Specify thresholds for different boards once thermo # characterization is completed. self._items_to_check += [ avionics_checks.AioMonTemperatureChecker( for_log, message_type, node, name='%s.AioMon.Temperature' % node, normal_ranges=check_range.Interval([0, 75]), warning_ranges=check_range.Interval([0, 85])) for node in nodes ] self._items_to_check += [ avionics_checks.AioMonHumidityChecker( for_log, message_type, node, name='%s.AioMon.Humidity' % node, normal_ranges=check_range.Interval([0, 40]), warning_ranges=check_range.Interval([0, 70])) for node in nodes ] self._items_to_check += [ avionics_checks.AioMonBusVoltageChecker( for_log, message_type, node, name='%s.AioMon.BusVoltage' % node) for node in nodes ] self._items_to_check += [ avionics_checks.AioMonBusCurrentChecker( for_log, message_type, node, name='%s.AioMon.BusCurrent' % node) for node in nodes ] self._items_to_check += [ avionics_checks.AioMonWarningCheck(for_log, message_type, node, name='%s.AioMon.Warnings' % node) for node in nodes ]
def SetByStoplightLimits(value, limits): return SetByRanges( value, check_range.Interval([limits.low, limits.high]), check_range.Interval([limits.very_low, limits.very_high]))
def Initialize(self): with open(_AUTOCHECK_GRADEBOOK, 'r') as fp: json_data = fp.read() try: # Use jsmin to allow comments in the gradebook JSON file. json_data = json.loads(jsmin.jsmin(json_data)) except ValueError: raise ValueError('Invalid JSON format in "%s".' % _AUTOCHECK_GRADEBOOK) gradebook_to_load = gradebook.Gradebook(json_data, settings.NETWORK_YAML) # A dict of field indices to check, grouped by message type, source, and # the first-level attributes. # E.g., gradebook_fields[message_type][source][attribute] = [field_name] gradebook_fields = gradebook_to_load.GetFieldMap( '$message_type.$aio_node.') self._check_dict = collections.defaultdict( lambda: collections.defaultdict( # pylint: disable=g-long-lambda lambda: collections.defaultdict(base_check.ListOfChecks))) for_log = False for message_name, sources in gradebook_fields.iteritems(): for source, attributes in sources.iteritems(): for _, fields in attributes.iteritems(): for field in fields: # Get the referencing ranges to check from the gradebook. segments = field.split('.') criteria = gradebook_to_load.GetCriteria(segments) sub_field_name = '.'.join(segments[2:]) field_checks = gradebook_base_check.GradebookChecks() field_checks.InitializeByField( for_log, message_name, source, sub_field_name, criteria, False) attribute_name = criteria.name if criteria.name else segments[-1] self._check_dict[message_name][source][attribute_name].Concatenate( field_checks) # Add checks for flight computers. default_temperature_limits = _MONITOR_PARAMS.thermal.aiomon_default message_name = 'FlightComputerSensor' for short_name in _FC_LABELS_HELPER.ShortNames(): fc_name = 'Fc' + short_name fc_check_dict = self._check_dict[message_name][fc_name] fc_check_dict['FcMon Analog Voltages [V]'].Append( fc_checks.FcMonAnalogChecker(for_log, short_name)) fc_check_dict['AioMon Analog Voltages [V]'].Append( avionics_checks.AioMonAnalogChecker(for_log, message_name, fc_name)) fc_check_dict['AioMon Board Temperature [C]'].Append( avionics_checks.AioMonTemperatureChecker( for_log, message_name, fc_name, normal_ranges=check_range.Interval( [default_temperature_limits.low, default_temperature_limits.high]), warning_ranges=check_range.Interval( [default_temperature_limits.very_low, default_temperature_limits.very_high]))) fc_check_dict['Bus Voltages [V]'].Append( avionics_checks.AioMonBusVoltageChecker( for_log, message_name, fc_name)) fc_check_dict['Bus Current [A]'].Append( avionics_checks.AioMonBusCurrentChecker( for_log, message_name, fc_name)) # Add checks for servos. message_name = 'ServoStatus' for short_name in _SERVO_LABELS_HELPER.ShortNames(): servo_name = 'Servo' + short_name servo_check_dict = self._check_dict[message_name][servo_name] servo_check_dict['ServoMon Analog Voltages [V]'].Append( servo_checks.ServoMonAnalogChecker(for_log, short_name)) servo_check_dict['ServoMon Temperature [C]'].Append( servo_checks.ServoMonTemperatureChecker( for_log, short_name, normal_ranges=check_range.Interval([0, 65]), warning_ranges=check_range.Interval([0, 80]))) servo_check_dict['AioMon Analog Voltages [V]'].Append( avionics_checks.AioMonAnalogChecker( for_log, message_name, servo_name)) servo_check_dict['AioMon Board Temperature [C]'].Append( avionics_checks.AioMonTemperatureChecker( for_log, message_name, servo_name, normal_ranges=check_range.Interval([0, 65]), warning_ranges=check_range.Interval([0, 80]))) servo_check_dict['Bus Voltages [V]'].Append( avionics_checks.AioMonBusVoltageChecker(for_log, message_name, servo_name)) servo_check_dict['Bus Current [A]'].Append( avionics_checks.AioMonBusCurrentChecker(for_log, message_name, servo_name)) # Add checks for GPSes. gps_check_dict = self._check_dict['GpsSignalStatus']['Gps Receivers'] gps_check_dict['Base NovAtel'].Append( gps_checks.NovAtelCn0Checker(for_log, 'GpsBaseStation', 'GPS Base')) for gps_type, fc_name in gps_util.GpsSelector(): if gps_type == gps_receiver.GpsReceiverType.NOV_ATEL.value: gps_check_dict[fc_name + ' NovAtel'].Append( gps_checks.NovAtelCn0Checker(for_log, fc_name, fc_name)) elif gps_type == gps_receiver.GpsReceiverType.SEPTENTRIO.value: gps_check_dict[fc_name + ' Septentrio'].Append( gps_checks.SeptentrioCn0Checker(for_log, fc_name, fc_name)) else: raise ValueError('Invalid GPS type: %d.' % gps_type) # Add checks for stacked motors. stacking_check_dict = self._check_dict['MotorStatus']['Stacking'] stacking_check_dict['Pbi_Sti'].Append( motor_checks.MotorStackPairVoltageDiff( for_log, ['MotorPbi', 'MotorSti'])) stacking_check_dict['Pbo_Sto'].Append( motor_checks.MotorStackPairVoltageDiff( for_log, ['MotorPbo', 'MotorSto'])) stacking_check_dict['Pti_Sbi'].Append( motor_checks.MotorStackPairVoltageDiff( for_log, ['MotorPti', 'MotorSbi'])) stacking_check_dict['Pto_Sbo'].Append( motor_checks.MotorStackPairVoltageDiff( for_log, ['MotorPto', 'MotorSbo']))
def __init__(self, for_log, source): normal_ranges = check_range.Interval((None, 3)) warning_ranges = check_range.AllInclusiveRange() super(NovAtelDiffCheck, self).__init__(for_log, source, normal_ranges, warning_ranges)
def __init__(self, for_log, source): normal_ranges = check_range.Interval((0, VEL_SIGMA_NORMAL_UPPER)) warning_ranges = check_range.Interval((0, VEL_SIGMA_WARNING_UPPER)) super(SeptentrioVelSigmaCheck, self).__init__(for_log, source, normal_ranges, warning_ranges)
def __init__(self, for_log, source): normal_ranges = check_range.Interval((None, 300)) warning_ranges = check_range.AllExclusiveRange() super(SeptentrioMeanCorrAgeCheck, self).__init__(for_log, source, normal_ranges, warning_ranges)
def __init__(self, for_log, source): normal_ranges = check_range.Interval((0, POS_SIGMA_NORMAL_UPPER)) warning_ranges = check_range.Interval((0, POS_SIGMA_WARNING_UPPER)) super(NovAtelPosSigmaCheck, self).__init__(for_log, source, normal_ranges, warning_ranges)