Example #1
0
 def validate_orientation(self) -> bool:
     """
     Checks if there are no errors with the orientation sensor and it contains at least 1 data entry
     :return: True if no errors
     """
     # noinspection PyTypeChecker
     return (
         len(xyz.validate_xyz(self._orientation, common.Unit.RADIANS)) < 1
         and self._orientation.get_x_samples().get_values_count() > 0)
Example #2
0
 def validate_magnetometer(self) -> bool:
     """
     Checks if there are no errors with the magnetometer and it contains at least 1 data entry
     :return: True if no errors
     """
     # noinspection PyTypeChecker
     return (len(
         xyz.validate_xyz(self._magnetometer, common.Unit.MICROTESLA)) < 1
             and self._magnetometer.get_x_samples().get_values_count() > 0)
Example #3
0
 def validate_gyroscope(self) -> bool:
     """
     Checks if there are no errors with the gyroscope and it contains at least 1 data entry
     :return: True if no errors
     """
     # noinspection PyTypeChecker
     return (len(
         xyz.validate_xyz(self._gyroscope, common.Unit.RADIANS_PER_SECOND))
             < 1 and self._gyroscope.get_x_samples().get_values_count() > 0)
Example #4
0
 def validate_rotation_vector(self) -> bool:
     """
     Checks if there are no errors with the rotation vector sensor and it contains at least 1 data entry
     :return: True if no errors
     """
     # noinspection PyTypeChecker
     return (len(
         xyz.validate_xyz(self._rotation_vector, common.Unit.UNITLESS)) < 1
             and
             self._rotation_vector.get_x_samples().get_values_count() > 0)
Example #5
0
 def validate_gravity(self) -> bool:
     """
     Checks if there are no errors with the gravity sensor and it contains at least 1 data entry
     :return: True if no errors
     """
     # noinspection PyTypeChecker
     return (len(
         xyz.validate_xyz(self._gravity,
                          common.Unit.METERS_PER_SECOND_SQUARED)) < 1
             and self._gravity.get_x_samples().get_values_count() > 0)
Example #6
0
def validate_sensors(sensors_list: Sensors) -> List[str]:
    """
    Validates sensors.
    :param sensors_list: Sensors to validate
    :return: A list of validated errors
    """
    # audio is the only sensor that every packet must have
    errors_list = []
    if not sensors_list.has_audio() and not sensors_list.has_compressed_audio(
    ):
        errors_list.append("Sensors list missing audio sensor")
    else:
        if sensors_list.has_audio():
            errors_list.extend(audio.validate_audio(sensors_list.get_audio()))
        if sensors_list.has_compressed_audio():
            errors_list.extend(
                audio.validate_compressed_audio(
                    sensors_list.get_compressed_audio()))
    if sensors_list.has_accelerometer():
        errors_list.extend(
            xyz.validate_xyz(sensors_list.get_accelerometer(),
                             common.Unit.METERS_PER_SECOND_SQUARED))
    if sensors_list.has_ambient_temperature():
        errors_list.extend(
            single.validate_single(sensors_list.get_ambient_temperature(),
                                   common.Unit.DEGREES_CELSIUS))
    if sensors_list.has_gravity():
        errors_list.extend(
            xyz.validate_xyz(sensors_list.get_gravity(),
                             common.Unit.METERS_PER_SECOND_SQUARED))
    if sensors_list.has_gyroscope():
        errors_list.extend(
            xyz.validate_xyz(sensors_list.get_gyroscope(),
                             common.Unit.RADIANS_PER_SECOND))
    if sensors_list.has_image():
        errors_list.extend(image.validate_image(sensors_list.get_image()))
    if sensors_list.has_light():
        errors_list.extend(
            single.validate_single(sensors_list.get_light(), common.Unit.LUX))
    if sensors_list.has_linear_acceleration():
        errors_list.extend(
            xyz.validate_xyz(
                sensors_list.get_linear_acceleration(),
                common.Unit.METERS_PER_SECOND_SQUARED,
            ))
    if sensors_list.has_location():
        errors_list.extend(
            location.validate_location(sensors_list.get_location()))
    if sensors_list.has_magnetometer():
        errors_list.extend(
            xyz.validate_xyz(sensors_list.get_magnetometer(),
                             common.Unit.MICROTESLA))
    if sensors_list.has_orientation():
        errors_list.extend(
            xyz.validate_xyz(sensors_list.get_orientation(),
                             common.Unit.RADIANS))
    if sensors_list.has_pressure():
        errors_list.extend(
            single.validate_single(sensors_list.get_pressure(),
                                   common.Unit.KILOPASCAL))
    if sensors_list.has_proximity():
        errors_list.extend(
            single.validate_single(sensors_list.get_proximity(),
                                   common.Unit.CENTIMETERS))
    if sensors_list.has_relative_humidity():
        errors_list.extend(
            single.validate_single(sensors_list.get_relative_humidity(),
                                   common.Unit.PERCENTAGE))
    if sensors_list.has_rotation_vector():
        errors_list.extend(
            xyz.validate_xyz(sensors_list.get_rotation_vector(),
                             common.Unit.UNITLESS))
    if sensors_list.has_velocity():
        errors_list.extend(
            xyz.validate_xyz(sensors_list.get_velocity(),
                             common.Unit.METERS_PER_SECOND))
    return errors_list
Example #7
0
 def test_validate_xyz(self):
     error_list = xyz.validate_xyz(self.non_empty_xyz_sensor)
     self.assertEqual(error_list, [])
     error_list = xyz.validate_xyz(self.empty_xyz_sensor)
     self.assertNotEqual(error_list, [])