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()
def __init__(self, sensor_type, ip, current_config): self.sensor_type = sensor_type self.sensor_type_name = "" self.measurement_type = "" self.ip = ip self.current_config = current_config self.temperature_offset = self.current_config.temperature_offset self.get_commands = app_variables.CreateNetworkGetCommands() self.sql_column_names = app_variables.CreateSQLColumnNames() self.readable_column_names = app_variables.CreateSQLColumnsReadable() self.sensor_measurements = app_variables.CreateMeasurementsTypes() self.first_datetime = str(datetime.time(datetime.now()))[:8] self.fig = pyplot.figure() self.fig.canvas.set_window_title('Live Sensor Graph') self.ax1 = self.fig.add_subplot(1, 1, 1) self.x = [] self.y = [] self.ani = animation.FuncAnimation( self.fig, self._update_graph, interval=float(self.current_config.live_refresh) * 1000) pyplot.show()
def download_sensor_database(address_and_port): """ Returns requested sensor file (based on the provided command data). """ network_commands = app_variables.CreateNetworkGetCommands() url = "https://" + address_and_port + "/" + network_commands.sensor_sql_database try: webbrowser.open_new_tab(url) except Exception as error: app_logger.sensor_logger.warning( "Download Sensor SQL Database Failed on " + str(address_and_port)) app_logger.sensor_logger.debug(str(error))
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)
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. """ import guizero from threading import Thread from tkinter import simpledialog from app_modules import app_logger from app_modules import app_variables from app_modules import app_useful_functions from app_modules import sensor_commands network_commands = app_variables.CreateNetworkSendCommands() get_commands = app_variables.CreateNetworkGetCommands() class CreateSensorDisplayWindow: """ Creates a GUI window for displaying sensor readings on the remote sensor Display. """ def __init__(self, app, ip_selection, current_config): self.ip_selection = ip_selection self.current_config = current_config self.readable_column_names = app_variables.CreateSQLColumnsReadable() self.sql_columns = app_variables.CreateSQLColumnNames() self.window = guizero.Window(app, title="Remote Sensor Display", width=275, height=400, layout="grid",
def __init__(self, app, ip_selection, current_config, database_or_sensor): self.database_or_sensor = database_or_sensor self.current_config = current_config self.ip_selection = ip_selection self.selected_ip = "" self.db_location = "" self.database_notes = [] self.database_notes_dates = [] self.database_user_note_dates = [] self.text_variables_generic = CreateGenericNoteVariables() self.text_variables_sensor = CreateSensorNoteVariables() self.text_variables_database = CreateDatabaseNoteVariables() self.sql_column_names = app_variables.CreateSQLColumnNames() self.network_send_commands = app_variables.CreateNetworkSendCommands() self.sensor_get_commands = app_variables.CreateNetworkGetCommands() self.window = guizero.Window(app, title=self.text_variables_database.window_title, width=580, height=525, layout="grid", visible=False) self.text_connected_to = guizero.Text(self.window, text=self.text_variables_database.text_connected_to, color="red", size=8, grid=[1, 1, 3, 1], align="left") self.checkbox_use_current_datetime = guizero.CheckBox(self.window, text=self.text_variables_generic.checkbox_enable_datetime, command=self._reset_datetime, grid=[4, 1, 5, 1], align="left") self.button_connect = guizero.PushButton(self.window, text=self.text_variables_database.button_connect, command=self._open_database, grid=[1, 5], align="left") self.button_back_note = guizero.PushButton(self.window, text="Back", command=self._back_button, grid=[2, 5], align="left") self.text_note_current = guizero.Text(self.window, text=self.text_variables_generic.text_note_current, color="blue", grid=[3, 5], align="top") self.textbox_on_number_notes = guizero.TextBox(self.window, text="0", width=5, grid=[3, 5], align="bottom") self.text_date_label1 = guizero.Text(self.window, text=self.text_variables_generic.text_date_label1, color="blue", grid=[4, 5], align="top") self.textbox_note_date = guizero.TextBox(self.window, text=self.text_variables_generic.textbox_note_date, grid=[4, 5], width=23, align="bottom") self.text_total_notes_label = guizero.Text(self.window, text=self.text_variables_generic.text_total_notes_label, color="blue", grid=[5, 5], align="top") self.textbox_total_notes = guizero.TextBox(self.window, text="0", width=5, grid=[5, 5], align="bottom") self.button_next_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_next_note, command=self._next_button, grid=[6, 5], align="left") self.textbox_current_note = guizero.TextBox(self.window, text=self.text_variables_database.textbox_current_note, width=70, height=25, grid=[1, 10, 6, 1], multiline=True, scrollbar=True, align="left") self.button_new_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_new_note, command=self._database_add_note_button, grid=[1, 12], align="left") self.button_delete_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_delete_note, command=self._database_delete_button, grid=[4, 12], align="left") self.button_update_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_update_note, command=self._database_update_note_button, grid=[5, 12, 2, 1], align="left") # Window Tweaks self.window.tk.resizable(False, False) self._disable_notes_window_functions() self.checkbox_use_current_datetime.value = True self.textbox_current_note.bg = "black" self.textbox_current_note.text_color = "white" self.textbox_current_note.tk.config(insertbackground="red") if database_or_sensor == self.text_variables_generic.sensor_notes_verification: self._change_for_sensor()
def __init__(self, app, ip_selection, current_config): self.ip_selection = ip_selection self.current_config = current_config self.network_get_commands = app_variables.CreateNetworkGetCommands() self.window = guizero.Window(app, title="Sensor Logs", width=975, height=450, layout="grid", visible=False) self.app_menubar = guizero.MenuBar( self.window, toplevel=[["Download"]], options=[[[ "Download All Selected Sensors Logs", self._download_logs ]]]) self.text_select_ip = guizero.Text( self.window, text="Select Sensor IPs in the main window", color="#CB0000", grid=[1, 1], align="left") self.text_choose = guizero.Text(self.window, text="Last lines of selected log", color="blue", grid=[1, 1], align="top") self.radio_log_type = guizero.ButtonGroup( self.window, options=["Primary Log", "Network Log", "Sensors Log"], horizontal="True", grid=[1, 1], align="right") self.textbox_log = guizero.TextBox( self.window, text="\nPlease select the log type in the top right" + " and press 'Update Sensor Log View' in the bottom right\n\n" + "You may also use the 'Download' menu in the top left to " + "download ALL logs from selected sensors to a chosen folder", grid=[1, 2], width=118, height=22, multiline=True, scrollbar=True, align="left") self.button_get = guizero.PushButton(self.window, text="Update Sensor\nLog View", command=self._get_log, grid=[1, 3], align="right") # Window Tweaks self.window.tk.resizable(False, False) self.textbox_log.bg = "black" self.textbox_log.text_color = "white" self.textbox_log.tk.config(insertbackground="red")