Beispiel #1
0
    def get_sensor_data(self, ip):
        """ Gets configuration report data from the provided sensor IP and puts it in the instance que. """
        command_data = sensor_commands.CreateSensorNetworkCommand(
            ip, self.network_timeout, network_get_commands.system_data)
        sensor_system = sensor_commands.get_data(command_data).split(",")
        try:
            sensor_system[3] = app_useful_functions.convert_minutes_string(
                sensor_system[3])
        except Exception as error:
            app_logger.app_logger.error("Sensor Config Report: " + str(error))

        command_data.command = network_get_commands.sensor_configuration
        sensor_config = sensor_commands.get_data(command_data).split(",")

        final_sensor_config = [
            str(sensor_system[0]),
            str(sensor_system[1]),
            str(sensor_system[2]),
            str(sensor_config[0]),
            str(sensor_config[1]),
            str(sensor_config[2]),
            str(sensor_config[3]),
            str(sensor_config[4]),
            str(sensor_config[5])
        ]
        self.data_queue.put([ip, final_sensor_config])
    def _connect_to_sensor(self):
        """ Prompts for Database to open and opens it. """
        ip_list = self.ip_selection.get_verified_ip_list()

        if len(ip_list) > 0:
            self.selected_ip = ip_list[0]
            self.text_connected_to.value = self.text_variables_sensor.text_connected_to[:-2] + self.selected_ip
            command = self.sensor_get_commands.database_notes
            network_timeout = self.current_config.network_timeout_data
            sensor_command = sensor_commands.CreateSensorNetworkCommand(self.selected_ip, network_timeout, command)

            test_database_notes = sensor_commands.get_data(sensor_command).split(",")

            if str(test_database_notes)[2:-2] == self.text_variables_generic.sensor_return_no_notes:
                self._no_sql_notes()
            else:
                self.database_notes = test_database_notes

                sensor_command.command = self.sensor_get_commands.database_note_dates
                self.database_notes_dates = sensor_commands.get_data(sensor_command).split(",")
                sensor_command.command = self.sensor_get_commands.database_user_note_dates
                self.database_user_note_dates = sensor_commands.get_data(sensor_command).split(",")

                count = 0
                datetime_offset = self.current_config.datetime_offset
                for date in self.database_user_note_dates:
                    new_date = self.adjust_datetime(date, datetime_offset)
                    self.database_user_note_dates[count] = new_date
                    count += 1

                if len(self.database_notes) > 0:
                    self.database_notes = self.undue_sterilize_notes(self.database_notes)

                    self.textbox_total_notes.value = str(len(self.database_notes))
                    self.checkbox_use_current_datetime.enable()
                    self.textbox_current_note.enable()
                    self.textbox_on_number_notes.enable()
                    self.textbox_current_note.value = self.database_notes[0]
                    self.textbox_note_date.value = self.database_user_note_dates[0]
                    self.textbox_on_number_notes.value = "1"

                    self.button_next_note.enable()
                    self.button_back_note.enable()
                    self.button_delete_note.enable()
                    self.button_new_note.enable()
                    self.button_update_note.enable()
                else:
                    self.textbox_current_note.enable()
                    self.textbox_current_note.value = self.text_variables_generic.no_notes_found
                    self._disable_notes_window_functions()
        else:
            self._disable_notes_window_functions()
            self.text_connected_to.value = self.text_variables_sensor.text_connected_to

            app_useful_functions.no_ip_selected_message()
    def button_get(self):
        """ Displays the selected configuration of the first selected and online sensor. """
        ip_list = self.ip_selection.get_verified_ip_list()
        if len(ip_list) > 0:
            network_commands = app_variables.CreateNetworkGetCommands()
            try:
                if self.combo_dropdown_selection.value == "Installed Sensors":
                    command = sensor_commands.CreateSensorNetworkCommand(
                        ip_list[0], self.current_config.network_timeout_data,
                        network_commands.installed_sensors_file)
                elif self.combo_dropdown_selection.value == "Configuration":
                    command = sensor_commands.CreateSensorNetworkCommand(
                        ip_list[0], self.current_config.network_timeout_data,
                        network_commands.sensor_configuration_file)
                elif self.combo_dropdown_selection.value == "Wifi":
                    command = sensor_commands.CreateSensorNetworkCommand(
                        ip_list[0], self.current_config.network_timeout_data,
                        network_commands.wifi_config_file)
                elif self.combo_dropdown_selection.value == "Trigger Variances":
                    command = sensor_commands.CreateSensorNetworkCommand(
                        ip_list[0], self.current_config.network_timeout_data,
                        network_commands.variance_config)
                else:
                    command = sensor_commands.CreateSensorNetworkCommand(
                        ip_list[0], self.current_config.network_timeout_data,
                        "")
                    command.command = ""

                self.textbox_config.value = str(
                    sensor_commands.get_data(command))

            except Exception as error:
                app_logger.sensor_logger.error(str(error))
        else:
            app_useful_functions.no_ip_selected_message()
Beispiel #4
0
    def test_app_sensor_commands(self):
        print("\nThis REQUIRES an online sensor @ " + sensor_ip)
        get_network_commands = app_variables.CreateNetworkGetCommands()
        send_network_commands = app_variables.CreateNetworkSendCommands()
        network_timeout = config_default.network_timeout_data
        sensor_command = sensor_commands.CreateSensorNetworkCommand(
            sensor_ip, network_timeout, "")

        log_download = sensor_commands.CreateSensorNetworkCommand(
            sensor_ip, 2, get_network_commands.download_zipped_logs)
        zip_log_download_url = "http://" + log_download.ip + ":" + log_download.port + log_download.command
        sensor_commands.download_zipped_logs(zip_log_download_url)

        sensor_status = sensor_commands.check_sensor_status(
            sensor_ip, network_timeout)
        self.assertEqual(sensor_status, "Online")

        sleep(2)
        # self.assertTrue(os.path.isfile(save_to + sensor_ip[-3:].replace(".", "_") + "PrimaryLog.txt"))
        # self.assertTrue(os.path.isfile(save_to + sensor_ip[-3:].replace(".", "_") + "NetworkLog.txt"))
        # self.assertTrue(os.path.isfile(save_to + sensor_ip[-3:].replace(".", "_") + "SensorsLog.txt"))

        sensor_command.command = get_network_commands.sensor_name
        old_hostname = sensor_commands.get_data(sensor_command)

        verified_bad_hostname = sensor_commands.get_validated_hostname(
            "^^$##_###This.is$NOT-Good!**")
        self.assertEqual(verified_bad_hostname, "_________This_is_NOT_Good___")

        sensor_command.command = send_network_commands.set_host_name
        sensor_command.command_data = verified_bad_hostname
        sensor_commands.put_command(sensor_command)
        sensor_command.command = get_network_commands.sensor_name
        verify_hostname = sensor_commands.get_data(sensor_command)
        self.assertEqual(verify_hostname, verified_bad_hostname)

        sensor_command.command = send_network_commands.set_host_name
        sensor_command.command_data = old_hostname
        sensor_commands.put_command(sensor_command)
        sensor_command.command = get_network_commands.sensor_name
        verify_hostname = sensor_commands.get_data(sensor_command)
        self.assertEqual(verify_hostname, old_hostname)
 def _get_log(self):
     """ Displays the chosen remote sensor log. """
     ip_list = self.ip_selection.get_verified_ip_list()
     if len(ip_list) > 0:
         network_timeout = self.current_config.network_timeout_data
         command_data = sensor_commands.CreateSensorNetworkCommand(
             ip_list[0], network_timeout, "GetNetworkLog")
         if self.radio_log_type.value == "Network Log":
             log = sensor_commands.get_data(command_data)
         elif self.radio_log_type.value == "Primary Log":
             command_data.command = "GetPrimaryLog"
             log = sensor_commands.get_data(command_data)
         elif self.radio_log_type.value == "Sensors Log":
             command_data.command = "GetSensorsLog"
             log = sensor_commands.get_data(command_data)
         else:
             app_logger.app_logger.error("Bad Log Request")
             log = "Bad Log Request"
         self.textbox_log.value = log
     else:
         app_useful_functions.no_ip_selected_message()
Beispiel #6
0
    def get_sensor_data(self, ip):
        """ Gets system report data from the provided sensor IP and puts it in the instance que. """
        command_data = sensor_commands.CreateSensorNetworkCommand(
            ip, self.network_timeout, network_get_commands.system_data)
        sensor_system = sensor_commands.get_data(command_data).split(",")

        try:
            sensor_system[3] = app_useful_functions.convert_minutes_string(
                sensor_system[3])
        except Exception as error:
            app_logger.app_logger.error("Sensor System Report: " + str(error))

        self.data_queue.put([ip, sensor_system])
Beispiel #7
0
    def _update_graph(self, x_frame):
        """ Update the Live Graph Instance. """
        current_time = str(datetime.time(datetime.now()))[:8]
        network_timeout = self.current_config.network_timeout_data
        command_data = sensor_commands.CreateSensorNetworkCommand(
            self.ip, network_timeout, "")

        command_data.command = self.get_commands.sensor_name
        sensor_name = sensor_commands.get_data(command_data)

        sensor_reading, sensor_type_name, measurement_type = self._get_sensor_reading_name_unit(
            command_data)
        try:
            self.ax1.clear()
            self.y.append(sensor_reading)
            self.x.append(x_frame)
            self.ax1.plot(self.x, self.y)

            if self.sensor_type is "SensorUpTime":
                sensor_reading = app_useful_functions.convert_minutes_string(
                    sensor_reading)

            pyplot.title(sensor_name + "  ||  " + self.ip + "\n" +
                         sensor_type_name)
            pyplot.xlabel("Start Time: " + self.first_datetime +
                          "  ||  Updated: " + current_time +
                          "\nCurrent Reading: " + str(sensor_reading) +
                          measurement_type)

            if self.sensor_type is "SensorUpTime":
                measurement_type = "Minutes"

            pyplot.ylabel(measurement_type)
            pyplot.xticks([])
        except Exception as error:
            app_logger.app_logger.error("Live Graph - Invalid Sensor Data: " +
                                        str(error))
    def _remote_sensor_display_selection(self):
        network_timeout = self.current_config.network_timeout_data
        ip_list = self.ip_selection.get_verified_ip_list()

        if len(ip_list) > 0:
            command_data = sensor_commands.CreateSensorNetworkCommand(
                ip_list[0], network_timeout, "")
            display_message = ""

            if self.checkbox_custom_text.value:
                add_text = simpledialog.askstring(
                    "Send Text to Sensor Display", "")
                display_message += add_text
            if self.checkbox_up_time.value:
                command_data.command = get_commands.system_uptime
                add_text = sensor_commands.get_data(command_data)
                display_message += " UpTime: " + add_text
            if self.checkbox_cpu_temp.value:
                command_data.command = get_commands.cpu_temp
                add_text = sensor_commands.get_data(command_data)
                display_message += " CPU Temp: " + add_text
            if self.checkbox_temperature.value:
                command_data.command = get_commands.environmental_temp
                add_text = sensor_commands.get_data(command_data)
                display_message += " Env Temp: " + add_text
            if self.checkbox_pressure.value:
                command_data.command = get_commands.pressure
                add_text = sensor_commands.get_data(command_data)
                display_message += " Pressure: " + add_text
            if self.checkbox_altitude.value:
                command_data.command = get_commands.altitude
                add_text = sensor_commands.get_data(command_data)
                display_message += " Altitude: " + add_text
            if self.checkbox_humidity.value:
                command_data.command = get_commands.humidity
                add_text = sensor_commands.get_data(command_data)
                display_message += " Humidity: " + add_text
            if self.checkbox_distance.value:
                command_data.command = get_commands.distance
                add_text = sensor_commands.get_data(command_data)
                display_message += " Distance: " + add_text
            if self.checkbox_gas.value:
                command_data.command = get_commands.gas_reduced
                add_text = sensor_commands.get_data(command_data)
                display_message += " GAS: " + add_text
            if self.checkbox_particulate_matter.value:
                command_data.command = get_commands.pm_1
                add_text = sensor_commands.get_data(command_data)
                display_message += " PM: " + add_text
            if self.checkbox_lumen.value:
                command_data.command = get_commands.lumen
                add_text = sensor_commands.get_data(command_data)
                display_message += " Lumen: " + add_text
            if self.checkbox_colour.value:
                command_data.command = get_commands.rgb
                add_text = sensor_commands.get_data(command_data)
                display_message += " Colour: " + add_text
            if self.checkbox_ultra_violet.value:
                command_data.command = get_commands.ultra_violet_a
                add_text = sensor_commands.get_data(command_data)
                display_message += " UV: " + add_text
            if self.checkbox_acc.value:
                command_data.command = get_commands.accelerometer_xyz
                add_text = sensor_commands.get_data(command_data)
                display_message += " Acc: " + add_text
            if self.checkbox_mag.value:
                command_data.command = get_commands.magnetometer_xyz
                add_text = sensor_commands.get_data(command_data)
                display_message += " Mag: " + add_text
            if self.checkbox_gyro.value:
                command_data.command = get_commands.gyroscope_xyz
                add_text = sensor_commands.get_data(command_data)
                display_message += " Gyro: " + add_text

            if display_message != "":
                self.send_text_message(display_message)
        else:
            app_useful_functions.no_ip_selected_message()
Beispiel #9
0
    def _get_sensor_reading_name_unit(self, command_data):
        """ Returns the sensors reading(s), name and unit type based on the provided command_data object. """
        if self.sensor_type is self.sql_column_names.system_uptime:
            sensor_type_name = self.readable_column_names.system_uptime
            measurement_type = self.sensor_measurements.no_measurement

            command_data.command = self.get_commands.system_uptime
            try:
                sensor_reading = int(
                    round(float(sensor_commands.get_data(command_data)), 0))
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type is self.sql_column_names.cpu_temp:
            sensor_type_name = self.readable_column_names.cpu_temp
            measurement_type = self.sensor_measurements.celsius

            command_data.command = self.get_commands.cpu_temp
            try:
                sensor_reading = round(
                    float(sensor_commands.get_data(command_data)), 3)
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type is self.sql_column_names.environmental_temp:
            sensor_type_name = self.readable_column_names.environmental_temp
            measurement_type = self.sensor_measurements.celsius

            try:
                if self.current_config.enable_custom_temp_offset:
                    # Temp offset is set to programs when initiating Live Graph
                    pass
                else:
                    command_data.command = self.get_commands.env_temp_offset
                    try:
                        self.temperature_offset = float(
                            sensor_commands.get_data(command_data))
                    except Exception as error:
                        app_logger.app_logger.warning(
                            "Live Graph - Invalid Sensor provided temp offset: "
                            + str(error))
                        self.temperature_offset = 0.0

                command_data.command = self.get_commands.environmental_temp
                try:
                    sensor_reading = round(
                        float(sensor_commands.get_data(command_data)) +
                        float(self.temperature_offset), 3)
                except Exception as error:
                    app_logger.app_logger.warning(
                        "Live Graph - Invalid Env Temperature: " + str(error))
                    sensor_reading = self.readable_column_names.no_sensor
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type is self.sql_column_names.pressure:
            sensor_type_name = self.readable_column_names.pressure
            measurement_type = self.sensor_measurements.pressure

            command_data.command = self.get_commands.pressure
            try:
                sensor_reading = int(
                    round(float(sensor_commands.get_data(command_data)), 0))
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type is self.sql_column_names.altitude:
            sensor_type_name = self.readable_column_names.altitude
            measurement_type = self.sensor_measurements.altitude

            command_data.command = self.get_commands.altitude
            try:
                sensor_reading = int(
                    round(float(sensor_commands.get_data(command_data)), 0))
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type is self.sql_column_names.humidity:
            sensor_type_name = self.readable_column_names.humidity
            measurement_type = self.sensor_measurements.humidity

            command_data.command = self.get_commands.humidity
            try:
                sensor_reading = int(
                    round(float(sensor_commands.get_data(command_data)), 0))
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type is self.sql_column_names.distance:
            sensor_type_name = self.readable_column_names.distance
            measurement_type = self.sensor_measurements.distance

            command_data.command = self.get_commands.distance
            try:
                sensor_reading = int(
                    round(float(sensor_commands.get_data(command_data)), 0))
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type == self.sql_column_names.gas[0]:
            sensor_type_name = self.readable_column_names.gas + " - "
            measurement_type = self.sensor_measurements.gas

            try:
                command_data.command = self.get_commands.gas_index
                gas_index_reading = sensor_commands.get_data(command_data)
                command_data.command = self.get_commands.gas_oxidised
                gas_oxidising_reading = sensor_commands.get_data(command_data)
                command_data.command = self.get_commands.gas_reduced
                gas_reducing_reading = sensor_commands.get_data(command_data)
                command_data.command = self.get_commands.gas_nh3
                gas_nh3_reading = sensor_commands.get_data(command_data)

                sensor_reading = []
                count = 0
                if gas_index_reading != "NoSensor":
                    sensor_reading.append(round(float(gas_index_reading), 3))
                    sensor_type_name += "Resistance Index "
                    count += 1
                if gas_oxidising_reading != "NoSensor":
                    sensor_reading.append(
                        round(float(gas_oxidising_reading), 3))
                    if count > 0:
                        sensor_type_name += "||"
                    sensor_type_name += " Oxidising "
                    count += 1
                if gas_reducing_reading != "NoSensor":
                    sensor_reading.append(round(float(gas_reducing_reading),
                                                3))
                    if count > 0:
                        sensor_type_name += "||"
                    sensor_type_name += " Reducing "
                    count += 1
                if gas_nh3_reading != "NoSensor":
                    sensor_reading.append(round(float(gas_nh3_reading), 3))
                    if count > 0:
                        sensor_type_name += "||"
                    sensor_type_name += " NH3"
                    count += 1
                if count == 0:
                    sensor_reading = self.readable_column_names.no_sensor
            except Exception as error:
                app_logger.app_logger.warning(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type == self.sql_column_names.particulate_matter[0]:
            sensor_type_name = self.readable_column_names.particulate_matter
            measurement_type = self.sensor_measurements.particulate_matter

            try:
                command_data.command = self.get_commands.pm_1
                particulate_matter_1_reading = sensor_commands.get_data(
                    command_data)
                command_data.command = self.get_commands.pm_2_5
                particulate_matter_2_5_reading = sensor_commands.get_data(
                    command_data)
                command_data.command = self.get_commands.pm_10
                particulate_matter_10_reading = sensor_commands.get_data(
                    command_data)

                sensor_reading = []
                count = 0
                if particulate_matter_1_reading != "NoSensor":
                    sensor_reading.append(
                        round(float(particulate_matter_1_reading), 3))
                    sensor_type_name += " PM1 "
                    count += 1
                if particulate_matter_2_5_reading != "NoSensor":
                    sensor_reading.append(
                        round(float(particulate_matter_2_5_reading), 3))
                    if count > 0:
                        sensor_type_name += "||"
                    sensor_type_name += " PM2.5 "
                    count += 1
                if particulate_matter_10_reading != "NoSensor":
                    sensor_reading.append(
                        round(float(particulate_matter_10_reading), 3))
                    if count > 0:
                        sensor_type_name += "||"
                    sensor_type_name += " PM10"
                if count == 0:
                    sensor_reading = self.readable_column_names.no_sensor
            except Exception as error:
                app_logger.app_logger.warning(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type is self.sql_column_names.lumen:
            sensor_type_name = self.readable_column_names.lumen
            measurement_type = self.sensor_measurements.lumen

            command_data.command = self.get_commands.lumen
            try:
                sensor_reading = int(
                    round(float(sensor_commands.get_data(command_data)), 0))
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type == self.sql_column_names.six_chan_color[0]:
            sensor_type_name = self.readable_column_names.colours
            measurement_type = self.sensor_measurements.rgb

            command_data.command = self.get_commands.rgb
            try:
                ems_colors = sensor_commands.get_data(
                    command_data)[1:-1].split(",")

                colors = []
                for color in ems_colors:
                    colors.append(color)

                if len(colors) > 3:
                    sensor_reading = [
                        round(float(colors[0]), 3),
                        round(float(colors[1]), 3),
                        round(float(colors[2]), 3),
                        round(float(colors[3]), 3),
                        round(float(colors[4]), 3),
                        round(float(colors[5]), 3)
                    ]
                    measurement_type = self.sensor_measurements.six_chan_color
                else:
                    sensor_reading = [
                        round(float(colors[0]), 3),
                        round(float(colors[1]), 3),
                        round(float(colors[2]), 3)
                    ]
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type == self.sql_column_names.ultra_violet[0]:
            sensor_type_name = self.readable_column_names.ultra_violet
            measurement_type = self.sensor_measurements.ultra_violet

            try:
                command_data.command = self.get_commands.ultra_violet_a
                ultra_violet_a_reading = sensor_commands.get_data(command_data)
                command_data.command = self.get_commands.ultra_violet_b
                ultra_violet_b_reading = sensor_commands.get_data(command_data)

                sensor_reading = []
                count = 0
                if ultra_violet_a_reading != "NoSensor":
                    sensor_reading.append(
                        round(float(ultra_violet_a_reading), 3))
                    sensor_type_name += " UVA "
                    count += 1
                if ultra_violet_b_reading != "NoSensor":
                    sensor_reading.append(
                        round(float(ultra_violet_b_reading), 3))
                    if count > 0:
                        sensor_type_name += "||"
                    sensor_type_name += " UVB"
                if count == 0:
                    sensor_reading = self.readable_column_names.no_sensor
            except Exception as error:
                app_logger.app_logger.warning(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type == self.sql_column_names.accelerometer_xyz[0]:
            sensor_type_name = self.readable_column_names.accelerometer_xyz
            measurement_type = self.sensor_measurements.xyz

            command_data.command = self.get_commands.accelerometer_xyz
            try:
                var_x, var_y, var_z = sensor_commands.get_data(
                    command_data)[1:-1].split(",")
                sensor_reading = [
                    round(float(var_x), 3),
                    round(float(var_y), 3),
                    round(float(var_z), 3)
                ]
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type == self.sql_column_names.magnetometer_xyz[0]:
            sensor_type_name = self.readable_column_names.magnetometer_xyz
            measurement_type = self.sensor_measurements.xyz

            command_data.command = self.get_commands.magnetometer_xyz
            try:
                var_x, var_y, var_z = sensor_commands.get_data(
                    command_data)[1:-1].split(",")
                sensor_reading = [
                    round(float(var_x), 3),
                    round(float(var_y), 3),
                    round(float(var_z), 3)
                ]
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        elif self.sensor_type == self.sql_column_names.gyroscope_xyz[0]:
            sensor_type_name = self.readable_column_names.gyroscope_xyz
            measurement_type = self.sensor_measurements.xyz

            command_data.command = self.get_commands.gyroscope_xyz
            try:
                var_x, var_y, var_z = sensor_commands.get_data(
                    command_data)[1:-1].split(",")
                sensor_reading = [
                    round(float(var_x), 3),
                    round(float(var_y), 3),
                    round(float(var_z), 3)
                ]
            except Exception as error:
                app_logger.app_logger.debug(
                    "Live Graph - Invalid Sensor Data: " + str(error))
                sensor_reading = self.readable_column_names.no_sensor
        else:
            sensor_reading = "N/A"
            sensor_type_name = "Invalid Sensor"
            measurement_type = " Missing Program Support"

        return sensor_reading, sensor_type_name, measurement_type
Beispiel #10
0
 def get_sensor_data(self, ip):
     """ Gets readings report data from the provided sensor IP and puts it in the instance que. """
     command_data = sensor_commands.CreateSensorNetworkCommand(
         ip, self.network_timeout, network_get_commands.sensor_readings)
     sensor_data = sensor_commands.get_data(command_data).split(",")
     self.data_queue.put([ip, sensor_data])