def restore_grbl_settings_from_file(self): # first half to system tools, second half to machine module filename = '/home/pi/easycut-smartbench/src/sb_values/saved_grbl_settings_params.txt' success_flag = self.m.restore_grbl_settings_from_file(filename) if success_flag: message = self.l.get_str('GRBL settings restored!') popup_info.PopupMiniInfo(self.sm, self.l, description = message) else: message = self.l.get_str('Could not restore settings, please check file!') popup_info.PopupMiniInfo(self.sm, self.l, description = message)
def get_grbl_settings_from_usb(): if self.usb_stick.is_usb_mounted_flag == True: filename = '/media/usb/saved_grbl_settings_params.txt' success_flag = self.m.restore_grbl_settings_from_file(filename) wait_popup.popup.dismiss() self.usb_stick.disable() if success_flag: message = self.l.get_str('GRBL settings restored!') popup_info.PopupMiniInfo(self.sm, self.l, description = message) else: message = self.l.get_str('Could not restore settings, please check file!') popup_info.PopupMiniInfo(self.sm, self.l, description = message) else: Clock.schedule_once(lambda dt: get_grbl_settings_from_usb(), 0.2)
def save_laser_offset(self): # need to cleverly calculate from movements & saving calibration from maintenance screen self.m.laser_offset_x_value = self.sm.get_screen( 'maintenance').laser_datum_reset_coordinate_x - self.m.mpos_x() self.m.laser_offset_y_value = self.sm.get_screen( 'maintenance').laser_datum_reset_coordinate_y - self.m.mpos_y() if self.m.write_z_head_laser_offset_values( 'True', self.m.laser_offset_x_value, self.m.laser_offset_y_value): saved_success = self.l.get_str("Settings saved!") popup_info.PopupMiniInfo(self.sm, self.l, saved_success) # Save button becomes unavailable self.save_button_image.source = "./asmcnc/apps/maintenance_app/img/save_button_132_greyscale.png" self.save_button.disabled = True else: warning_message = ( self.l.get_str("There was a problem saving your settings.") + \ "\n\n" + \ self.l.get_str("Please check your settings and try again, or if the problem persists please contact the YetiTool support team.") ) popup_info.PopupError(self.sm, self.l, warning_message)
def clear_usb_mountpoint(self): clear_mountpoint_out = (str(os.popen("sudo rm /media/usb/*").read())) # using popen for the block message = ( self.l.get_str("First aid complete.") + \ "\n\n" + \ self.l.get_str("You can now use your USB stick.") ) popup_info.PopupMiniInfo(self.sm, self.l, description = message)
def do_sw_update(): outcome = self.set.get_sw_update_via_usb() if outcome == 2: description = ( self.l.get_str("More than one folder called easycut-smartbench was found on the USB drive.").replace( self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]" ) + \ "\n\n" + \ self.l.get_str("Please make sure that there is only one instance of easycut-smartbench on your USB drive, and try again.").replace( self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]" ) ) popup_info.PopupError(self.sm, self.l, description) elif outcome == 0: description = ( self.l.get_str("There was no folder or zipped folder called easycut-smartbench found on the USB drive.").replace( self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]" ) + \ "\n\n" + \ self.l.get_str("Please make sure that the folder containing the software is called easycut-smartbench, and try again.").replace( self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]" ) ) popup_info.PopupError(self.sm, self.l, description) elif outcome == "update failed": description = ( self.l.get_str("It was not possible to update your software from the USB drive.") + \ "\n\n" + \ self.l.get_str("Please check your easycut-smartbench folder or try again later.").replace( self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]" ) + \ " " + \ self.l.get_str("If this problem persists you may need to connect to the internet to update your software, and repair it if necessary.") ) popup_info.PopupError(self.sm, self.l, description) else: self.usb_stick.disable() update_success = outcome popup_info.PopupSoftwareUpdateSuccess(self.sm, self.l, update_success) self.set.ansible_service_run() message = ( self.l.get_str('Please wait') + \ '...\n\n' + \ self.l.get_str('Console will reboot to finish update.') ) Clock.schedule_once( lambda dt: popup_info.PopupMiniInfo( self.sm, self.l, message), 3)
def get_logs(count): if self.usb_stick.is_usb_mounted_flag == True: os.system("journalctl > smartbench_logs.txt && sudo cp --no-preserve=mode,ownership smartbench_logs.txt /media/usb/ && rm smartbench_logs.txt") wait_popup.popup.dismiss() self.usb_stick.disable() message = self.l.get_str('Logs downloaded') popup_info.PopupMiniInfo(self.sm, self.l, description = message) elif count > 30: message = self.l.get_str('No USB found!') popup_info.PopupMiniInfo(self.sm, self.l, description = message) wait_popup.popup.dismiss() if self.usb_stick.is_available(): self.usb_stick.disable() else: count +=1 Clock.schedule_once(lambda dt: get_logs(count), 0.2) print count
def do_reinstall(): try: os.system('python -m pip uninstall pika -y') os.system('python -m pip install pika==1.2.0') os.system('sudo reboot') wait_popup.popup.dismiss() except: message = self.l.get_str('Issue trying to reinstall pika!') popup_info.PopupMiniInfo(self.sm, self.l, description = message) wait_popup.popup.dismiss()
def get_grbl_settings_onto_usb(): if self.usb_stick.is_usb_mounted_flag == True: os.system("sudo cp --no-preserve=mode,ownership /home/pi/easycut-smartbench/src/sb_values/saved_grbl_settings_params.txt /media/usb/") os.system("rm /home/pi/easycut-smartbench/src/sb_values/saved_grbl_settings_params.txt") wait_popup.popup.dismiss() self.usb_stick.disable() message = self.l.get_str('GRBL settings downloaded') popup_info.PopupMiniInfo(self.sm, self.l, description = message) else: Clock.schedule_once(lambda dt: get_grbl_settings_onto_usb(), 0.2)
def connect_wifi(self): message = self.l.get_str("Please wait") + "...\n\n" + self.l.get_str("Console will reboot to connect to network.") popup_info.PopupMiniInfo(self.sm, self.l, message) # pass credentials to wpa_supplicant file self.wpanetpass = '******' + self.netname + '" "' + self.password + '" 2>/dev/null | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf' self.wpanetpasswlan0 = 'wpa_passphrase "' + self.netname + '" "' + self.password + '" 2>/dev/null | sudo tee /etc/wpa_supplicant/wpa_supplicant-wlan0.conf' # put the credentials and the necessary appendages into the wpa file try: os.system(self.wpanetpass) os.system('echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') os.system('echo "country="' + self.country.text + '| sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') os.system('echo "update_config=1" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') os.system(self.wpanetpasswlan0) os.system('echo "ctrl_interface=run/wpa_supplicant" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') os.system('echo "update_config=1" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') os.system('echo "country="' + self.country.text + '| sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') except: try: self.wpanetpass = '******' + self.netname + '" "invalidPassword" 2>/dev/null | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf' os.system(self.wpanetpass) os.system('echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') os.system('echo "country="' + self.country.text + '| sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') os.system('echo "update_config=1" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') self.wpanetpasswlan0 = 'wpa_passphrase "' + self.netname + '" "invalidPassword" 2>/dev/null | sudo tee /etc/wpa_supplicant/wpa_supplicant-wlan0.conf' os.system(self.wpanetpasswlan0) os.system('echo "ctrl_interface=run/wpa_supplicant" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') os.system('echo "update_config=1" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') os.system('echo "country="' + self.country.text + '| sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') except: self.wpanetpass = '******' os.system(self.wpanetpass) os.system('echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') os.system('echo "country="' + self.country.text + '| sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') os.system('echo "update_config=1" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant.conf') self.wpanetpasswlan0 = 'wpa_passphrase "" "" 2>/dev/null | sudo tee /etc/wpa_supplicant/wpa_supplicant-wlan0.conf' os.system(self.wpanetpasswlan0) os.system('echo "ctrl_interface=run/wpa_supplicant" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') os.system('echo "update_config=1" | sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') os.system('echo "country="' + self.country.text + '| sudo tee --append /etc/wpa_supplicant/wpa_supplicant-wlan0.conf') self.sm.current = 'rebooting'
def save(self): self.show_popup = True if self.save_touchplate_offset() and self.save_z_head_maintenance(): saved_success = self.l.get_str("Settings saved!") popup_info.PopupMiniInfo(self.sm, self.l, saved_success) elif self.show_popup: warning_message = ( self.l.get_str("There was a problem saving your settings.") + \ "\n\n" + \ self.l.get_str("Please check your settings and try again, or if the problem persists please contact the YetiTool support team.") ) popup_info.PopupError(self.sm, self.l, warning_message)
def get_report(count): if self.usb_stick.is_usb_mounted_flag == True: message = 'Downloading report, please wait...' wait_popup = popup_info.PopupWait(self.sm, self.l, description=message) self.write_report_to_file() wait_popup.popup.dismiss() self.usb_stick.disable() message = self.l.get_str('Report downloaded') popup_info.PopupMiniInfo(self.sm, self.l, description=message) elif count > 30: if self.usb_stick.is_available(): self.usb_stick.disable() else: count += 1 Clock.schedule_once(lambda dt: get_report(count), 0.2)
def do_sw_update(): outcome = self.set.get_sw_update_via_wifi() if outcome == False: description = self.l.get_str("There was a problem updating your software.") + \ " \n\n" + \ self.l.get_str("We can try to fix the problem, but you MUST have a stable internet connection and power supply.") + \ "\n\n" + \ self.l.get_str("Would you like to repair your software now?") popup_info.PopupSoftwareRepair(self.sm, self.l, self, description) elif outcome == "Software already up to date!": description = self.l.get_str("Software already up to date!") popup_info.PopupError(self.sm, self.l, description) elif "Could not resolve host: github.com" in outcome: description = self.l.get_str( "Could not connect to github. Please check that your connection is stable, or try again later." ) popup_info.PopupError(self.sm, self.l, description) else: popup_info.PopupSoftwareUpdateSuccess(self.sm, self.l, outcome) self.set.ansible_service_run() message = ( self.l.get_str('Please wait') + \ '...\n\n' + \ self.l.get_str('Console will reboot to finish update.') ) Clock.schedule_once( lambda dt: popup_info.PopupMiniInfo( self.sm, self.l, message), 3) Clock.schedule_once(lambda dt: updating_wait_popup.popup.dismiss(), 0.1)
def save(self): try: [brand, digital, voltage ] = (self.sm.get_screen('maintenance').spindle_settings_widget. spindle_brand.text).rsplit(' ', 2) brand = brand[1:] voltage = voltage.strip('V') if 'digital' in digital: digital = True elif 'manual' in digital: digital = False else: brand_validation_error = ( self.l.get_str("Please select a valid spindle brand from the drop down.") + \ "\n\n" + \ self.l.get_str("If you can't find what you're looking for, please enter the version with a voltage and digital/manual option that matches what you have.") ) popup_info.PopupError(self.sm, self.l, brand_validation_error) return except: brand_validation_error = ( self.l.get_str("Please select a valid spindle brand from the drop down.") + \ "\n\n" + \ self.l.get_str("If you can't find what you're looking for, please enter the version with a voltage and digital/manual option that matches what you have.") ) popup_info.PopupError(self.sm, self.l, brand_validation_error) return try: time = int( self.sm.get_screen('maintenance').spindle_settings_widget. spindle_cooldown_time.text) if (time >= 1 and time <= 60): pass else: time_validation_error = ( self.l.get_str("The spindle cooldown time should be between 1 and 60 seconds.") + \ "\n\n" + \ self.l.get_str("Please enter a new value.") ) popup_info.PopupError(self.sm, self.l, time_validation_error) return except: time_validation_error = ( self.l.get_str("The spindle cooldown time should be a number between 1 and 60 seconds.") + \ "\n\n" + \ self.l.get_str("Please enter a new value.") ) popup_info.PopupError(self.sm, self.l, time_validation_error) return try: speed = int( self.sm.get_screen('maintenance').spindle_settings_widget. spindle_cooldown_speed.text) if (speed >= 10000 and speed <= 20000): pass else: speed_validation_error = ( self.l.get_str("The spindle cooldown speed should be between 10,000 and 20,000 RPM.") + \ "\n\n" + \ self.l.get_str("Please enter a new value.") ) popup_info.PopupError(self.sm, self.l, speed_validation_error) return except: speed_validation_error = ( self.l.get_str("The spindle cooldown speed should be a number between 10,000 and 20,000 RPM.") + \ "\n\n" + \ self.l.get_str("Please enter a new value.") ) popup_info.PopupError(self.sm, self.l, speed_validation_error) return if self.m.write_spindle_cooldown_rpm_override_settings(self.sm.current_screen.spindle_settings_widget.rpm_override) and \ self.m.write_spindle_cooldown_settings(brand, voltage, digital, time, speed) and \ self.m.write_stylus_settings(self.sm.current_screen.spindle_settings_widget.stylus_switch.active): saved_success = self.l.get_str("Settings saved!") popup_info.PopupMiniInfo(self.sm, self.l, saved_success) else: warning_message = ( self.l.get_str("There was a problem saving your settings.") + \ "\n\n" + \ self.l.get_str("Please check your settings and try again, or if the problem persists please contact the YetiTool support team.") ) popup_info.PopupError(self.sm, self.l, warning_message) if voltage == '110': # localize me! spindle_voltage_info = ( self.l.get_str("When using a 110V spindle as part of your SmartBench, please be aware of the following:") + \ "\n\n" + \ self.l.get_str("110V spindles have a minimum speed of ~10,000 RPM.") + \ "\n\n" + \ self.l.get_str("SmartBench electronics are set up to work with a 230V spindle, so our software does a smart conversion to make sure the machine code we send is adjusted to control a 110V spindle.") + \ "\n\n" + \ self.l.get_str("The 5% spindle speed adjustments in the Job Screen cannot be converted for a 110V spindle, so they will not be able to adjust the speed by exactly 5%.") + \ " " + \ self.l.get_str("You will still be able to use the real time spindle speed feedback feature to assist your adjustment.") ) popup_info.PopupInfo(self.sm, self.l, 780, spindle_voltage_info)
def save(self): # TIME FOR DATA VALIDATION # Read from screen use_str = self.sm.get_screen( 'maintenance').brush_use_widget.brush_use.text lifetime_str = self.sm.get_screen( 'maintenance').brush_life_widget.brush_life.text try: # Convert hours into seconds use = float(use_str) * 3600 lifetime = float(lifetime_str) * 3600 # Brush use if use >= 0 and use <= 999 * 3600: pass # all good, carry on else: # throw popup, return without saving brush_use_validation_error = ( self.l.get_str("The number of hours the brushes have been used for should be between 0 and 999.") + \ "\n\n" + \ self.l.get_str("Please enter a new value.") ) popup_info.PopupError(self.sm, self.l, brush_use_validation_error) return # Brush life if lifetime >= 100 * 3600 and lifetime <= 999 * 3600: pass # all good, carry on else: # throw popup, return without saving brush_life_validation_error = ( self.l.get_str("The maximum brush lifetime should be between 100 and 999 hours.") + \ "\n\n" + \ self.l.get_str("Please enter a new value.") ) popup_info.PopupError(self.sm, self.l, brush_life_validation_error) return # Check use <= lifetime if use <= lifetime: pass # all good, carry on else: # throw popup, return without saving brush_both_validation_error = ( self.l.get_str("The brush use hours should be less than or equal to the lifetime!") + \ "\n\n" + \ self.l.get_str("Please check your values.") ) popup_info.PopupError(self.sm, self.l, brush_both_validation_error) return # write new values to file if self.m.write_spindle_brush_values(use, lifetime): saved_success = self.l.get_str("Settings saved!") popup_info.PopupMiniInfo(self.sm, self.l, saved_success) else: warning_message = ( self.l.get_str("There was a problem saving your settings.") + \ "\n\n" + \ self.l.get_str("Please check your settings and try again, or if the problem persists please contact the YetiTool support team.") ) popup_info.PopupError(self.sm, self.l, warning_message) # Update the monitor :) value = 1 - float(self.m.spindle_brush_use_seconds / self.m.spindle_brush_lifetime_seconds) self.sm.get_screen( 'maintenance').brush_monitor_widget.set_percentage(value) except: # throw popup, return without saving warning_message = ( self.l.get_str("There was a problem saving your settings.") + \ "\n\n" + \ self.l.get_str("Please check your settings and try again, or if the problem persists please contact the YetiTool support team.") ) popup_info.PopupError(self.sm, self.l, warning_message) return