diff --git a/lib/python/qtvcp/lib/qtplasmac/updater.py b/lib/python/qtvcp/lib/qtplasmac/updater.py index 8f055b57d17..5287c45934a 100644 --- a/lib/python/qtvcp/lib/qtplasmac/updater.py +++ b/lib/python/qtvcp/lib/qtplasmac/updater.py @@ -22,7 +22,9 @@ import os from shutil import copy as COPY -# move default material from prefs file to material 0 in materials file (pre V1.236.278 2023/07/07) +########################################################################################################### +# move default material from prefs file to material 0 in materials file (pre V1.236.278 2023/07/07) # +########################################################################################################### def move_default_material(prefs, materials, unitsPerMm): if os.path.isfile(materials): with open(materials, 'r') as f_in: @@ -58,67 +60,83 @@ def move_default_material(prefs, materials, unitsPerMm): f_out.write(line) prefs.remove_section('DEFAULT MATERIAL') prefs.write(open(prefs.fn, 'w')) + return(False, False, 'Updated to V1.236.278') -# move port info from [GUI_OPTIONS] section (if it was moved via V1.227.219 update) to [POWERMAX] section + +########################################################################################################### +# move port info from [GUI_OPTIONS] section (if it was moved via V1.227.219 update) to [POWERMAX] section # +########################################################################################################### def move_port(prefs): if not prefs.has_option('POWERMAX', 'Port'): data = prefs.getpref('Port', '', str, 'GUI_OPTIONS') prefs.putpref('Port', data, str, 'POWERMAX') prefs.removepref('Port', 'GUI_OPTIONS') prefs.write(open(prefs.fn, 'w')) - update_notify('V1.232.240') + return(False, False, 'Updated to V1.232.240') + -# move qtplasmac options from INI file to prefs file (pre V1.227.219 2022/07/14) +########################################################################################################### +# move qtplasmac options from INI file to prefs file (pre V1.227.219 2022/07/14) # +########################################################################################################### def move_options_to_prefs_file(inifile, prefs): - text = prefs.getpref('shutdown_msg_detail', '', str, 'SHUTDOWN_OPTIONS') - prefs.putpref('Exit warning text', text, str, 'GUI_OPTIONS') - prefs.remove_section('SHUTDOWN_OPTIONS') - prefs.write(open(prefs.fn, 'w')) - data = inifile.find('QTPLASMAC', 'MODE') or None - if data: - prefs.putpref('Mode', data, int, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'ESTOP_TYPE') or None - if data: - prefs.putpref('Estop type', data, int, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'DRO_POSITION') or None - if data: - prefs.putpref('DRO position', data, str, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'FLASH_ERROR') or None - if data: - data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False - prefs.putpref('Flash error', data, bool, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'HIDE_RUN') or None - if data: - data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False - prefs.putpref('Hide run', data, bool, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'HIDE_PAUSE') or None + try: + text = prefs.getpref('shutdown_msg_detail', '', str, 'SHUTDOWN_OPTIONS') + prefs.putpref('Exit warning text', text, str, 'GUI_OPTIONS') + prefs.remove_section('SHUTDOWN_OPTIONS') + prefs.write(open(prefs.fn, 'w')) + data = inifile.find('QTPLASMAC', 'MODE') or None + if data: + prefs.putpref('Mode', data, int, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'ESTOP_TYPE') or None + if data: + prefs.putpref('Estop type', data, int, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'DRO_POSITION') or None + if data: + prefs.putpref('DRO position', data, str, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'FLASH_ERROR') or None + if data: + data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False + prefs.putpref('Flash error', data, bool, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'HIDE_RUN') or None + if data: + data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False + prefs.putpref('Hide run', data, bool, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'HIDE_PAUSE') or None + if data: + data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False + prefs.putpref('Hide pause', data, bool, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'HIDE_ABORT') or None + if data: + data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False + prefs.putpref('Hide abort', data, bool, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'CUSTOM_STYLE') or None + if data: + prefs.putpref('Custom style', data, str, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'AUTOREPEAT_ALL') or None + if data: + data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False + prefs.putpref('Autorepeat all', data, bool, 'GUI_OPTIONS') + data = inifile.find('QTPLASMAC', 'LASER_TOUCHOFF') or None + except Exception as e: + return(False, True, e) if data: - data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False - prefs.putpref('Hide pause', data, bool, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'HIDE_ABORT') or None - if data: - data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False - prefs.putpref('Hide abort', data, bool, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'CUSTOM_STYLE') or None - if data: - prefs.putpref('Custom style', data, str, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'AUTOREPEAT_ALL') or None - if data: - data = True if data.lower() in ('yes', 'y', 'true', 't', '1') else False - prefs.putpref('Autorepeat all', data, bool, 'GUI_OPTIONS') - data = inifile.find('QTPLASMAC', 'LASER_TOUCHOFF') or None - if data: - x, y, d = get_offsets(data, 'LASER_OFFSET') + x, y, d, error = get_offsets(data, 'LASER_OFFSET') + if error: + return(False, True, error) prefs.putpref('X axis', x, float, 'LASER_OFFSET') prefs.putpref('Y axis', y, float, 'LASER_OFFSET') data = inifile.find('QTPLASMAC', 'CAMERA_TOUCHOFF') or None if data: - x, y, d = get_offsets(data, 'CAMERA_OFFSET') + x, y, d, error = get_offsets(data, 'CAMERA_OFFSET') + if error: + return(False, True, error) prefs.putpref('X axis', x, float, 'CAMERA_OFFSET') prefs.putpref('Y axis', y, float, 'CAMERA_OFFSET') data = inifile.find('QTPLASMAC', 'OFFSET_PROBING') or None if data: - x, y, d = get_offsets(data, 'OFFSET_PROBING') + x, y, d, error = get_offsets(data, 'OFFSET_PROBING') + if error: + return(False, True, error) prefs.putpref('X axis', x, float, 'OFFSET_PROBING') prefs.putpref('Y axis', y, float, 'OFFSET_PROBING') prefs.putpref('Delay', d, float, 'OFFSET_PROBING') @@ -131,212 +149,36 @@ def move_options_to_prefs_file(inifile, prefs): if bName and bCode: prefs.putpref(f'{bNum} Name', bName, str, 'BUTTONS') prefs.putpref(f'{bNum} Code', bCode, str, 'BUTTONS') + return(False, False, '') -# move qtplasmac options from INI file to prefs file (pre V1.227.219 2022/07/14) def move_options_to_prefs_file_iniwrite(inifile): - tmpFile = f'{inifile}~' - COPY(inifile, tmpFile) - with open(tmpFile, 'r') as inFile: - with open(inifile, 'w') as outFile: - remove = False - for line in inFile: - if not line: - break - elif line.startswith('[QTPLASMAC]'): - remove = True - continue - elif remove: - if line.startswith('['): - remove = False - else: + try: + tmpFile = f'{inifile}~' + COPY(inifile, tmpFile) + with open(tmpFile, 'r') as inFile: + with open(inifile, 'w') as outFile: + remove = False + for line in inFile: + if not line: + break + elif line.startswith('[QTPLASMAC]'): + remove = True continue - outFile.write(line) - if os.path.isfile(tmpFile): - os.remove(tmpFile) - update_notify('V1.227.219') - -# remove the qtplasmac link from the config directory (pre V1.225.208 2022/06/29) -def remove_qtplasmac_link_iniwrite(inifile): - tmpFile = f'{inifile}~' - COPY(inifile, tmpFile) - with open(tmpFile, 'r') as inFile: - with open(inifile, 'w') as outFile: - for line in inFile: - if line.replace(' ','').startswith('ngc='): - line = 'ngc = qtplasmac_gcode\n' - elif line.replace(' ','').startswith('nc='): - line = 'nc = qtplasmac_gcode\n' - elif line.replace(' ','').startswith('tap='): - line = 'tap = qtplasmac_gcode\n' - elif (line.startswith('SUBROUTINE_PATH') or line.startswith('USER_M_PATH')) and ':./qtplasmac' in line: - line = line.replace(':./qtplasmac','') - outFile.write(line) - if os.path.isfile(tmpFile): - os.remove(tmpFile) - update_notify('V1.225.208') - -# change startup parameters from a subroutine (pre V1.224.207 2022/06/22) -def rs274ngc_startup_code_iniwrite(inifile): - tmpFile = f'{inifile}~' - COPY(inifile, tmpFile) - with open(tmpFile, 'r') as inFile: - with open(inifile, 'w') as outFile: - for line in inFile: - if line.startswith('RS274NGC_STARTUP_CODE') and ('metric' in line or 'imperial' in line): - units = 21 if 'metric' in line else 20 - line = f'RS274NGC_STARTUP_CODE = G{units} G40 G49 G80 G90 G92.1 G94 G97 M52P1\n' - outFile.write(line) - if os.path.isfile(tmpFile): - os.remove(tmpFile) - update_notify('V1.225.207') - -# move [CONVERSATIONAL] prefs from qtvcp.prefs to .prefs (pre V1.222.187 2022/05/03) -def move_prefs(qtvcp, machine): - deleteMachineLine = False - moveQtvcpLine = False - with open(machine, 'r') as inFile: - machineData = inFile.readlines() - with open(qtvcp, 'r') as inFile: - qtvcpData = inFile.readlines() - with open(machine, 'w') as machineFile: - with open(qtvcp, 'w') as qtvcpFile: - for line in machineData: - if line.strip() == '[CONVERSATIONAL]': - deleteMachineLine = True - elif line.startswith('['): - deleteMachineLine = False - if not deleteMachineLine: - machineFile.write(line) - for line in qtvcpData: - if line.strip() == '[CONVERSATIONAL]': - moveQtvcpLine = True - elif line.startswith('['): - moveQtvcpLine = False - if moveQtvcpLine: - machineFile.write(line) - else: - qtvcpFile.write(line) - update_notify('V1.222.187') - -# split out qtplasmac.prefs into .prefs and qtvcp.prefs (pre V1.222.170 2022/03/08) -def split_prefs_file(old, new, prefs): - move = False - copy = False - moves = ['[GUI_OPTIONS]','[COLOR_OPTIONS]','[ENABLE_OPTIONS]','[STATISTICS]', \ - '[PLASMA_PARAMETERS]','[DEFAULT MATERIAL]', '[SINGLE CUT]', '[CONVERSATIONAL]'] - copies = ['[SHUTDOWN_OPTIONS]'] - with open(old, 'r') as inFile: - data = inFile.readlines() - with open(new, 'w') as newFile: - with open(prefs, 'w') as prefsFile: - for line in data: - if line.strip() in moves: - move = True - copy = False - elif line.strip() in copies: - move = False - copy = True - elif line.strip().startswith('['): - move = False - copy = False - if move: - prefsFile.write(line) - elif copy: - if line.strip().startswith('['): - prefsFile.write(line) - if 'shutdown_msg_detail' in line: - prefsFile.write(line) - prefsFile.write('\n') - newFile.write(line) - else: - newFile.write(line) - if os.path.isfile(old): - os.remove(old) - update_notify('V1.222.170') - -# use qtplasmac_comp.hal for component connections (pre V1.221.154 2022/01/18) -def add_component_hal_file(path, halfiles): - tmpFile = None - pinsToCheck = ['PLASMAC COMPONENT INPUTS','plasmac.arc-ok-in','plasmac.axis-x-position', - 'plasmac.axis-y-position','plasmac.breakaway','plasmac.current-velocity', - 'plasmac.cutting-start','plasmac.cutting-stop','plasmac.feed-override', - 'plasmac.feed-reduction','plasmac.float-switch','plasmac.feed-upm', - 'plasmac.ignore-arc-ok-0','plasmac.machine-is-on','plasmac.motion-type', - 'plasmac.offsets-active','plasmac.ohmic-probe','plasmac.program-is-idle', - 'plasmac.program-is-paused','plasmac.program-is-running','plasmac.scribe-start', - 'plasmac.spotting-start','plasmac.thc-disable','plasmac.torch-off', - 'plasmac.units-per-mm','plasmac.x-offset-current','plasmac.y-offset-current', - 'plasmac.z-offset-current', - 'PLASMAC COMPONENT OUTPUTS','plasmac.adaptive-feed','plasmac.feed-hold', - 'plasmac.offset-scale','plasmac.program-pause','plasmac.program-resume', - 'plasmac.program-run','plasmac.program-stop','plasmac.torch-on', - 'plasmac.x-offset-counts','plasmac.y-offset-counts','plasmac.xy-offset-enable', - 'plasmac.z-offset-counts','plasmac.z-offset-enable','plasmac.requested-velocity'] - for f in halfiles: - f = os.path.expanduser(f) - if not 'custom' in f: - halfile = os.path.join(path, f) - with open(halfile, 'r') as inFile: - if 'plasmac.cutting-start' in inFile.read(): - inFile.seek(0) - tmpFile = f'{halfile}~' - COPY(halfile, tmpFile) - with open(tmpFile, 'r') as inFile: - with open(f, 'w') as outFile: - for line in inFile: - if any(pin in line for pin in pinsToCheck): - continue - outFile.write(line) - if tmpFile and os.path.isfile(tmpFile): - os.remove(tmpFile) - -def add_component_hal_file_iniwrite(inifile): - written = False - tmpFile = f'{inifile}~' - COPY(inifile, tmpFile) - with open(tmpFile, 'r') as inFile: - with open(inifile, 'w') as outFile: - while 1: - line = inFile.readline() - if not line: - break - elif line.startswith('[HAL]'): - outFile.write(line) - break - else: - outFile.write(line) - while 1: - line = inFile.readline() - if not line: - if not written: - outFile.write('HALFILE = qtplasmac_comp.hal\n') - break - elif line.startswith('['): - if not written: - outFile.write('HALFILE = qtplasmac_comp.hal\n') - outFile.write(line) - break - elif 'custom.hal' in line.lower(): - outFile.write('HALFILE = qtplasmac_comp.hal\n') - outFile.write(line) - written = True - break - else: - outFile.write(line) - while 1: - line = inFile.readline() - if not line: - break - else: + elif remove: + if line.startswith('['): + remove = False + else: + continue outFile.write(line) - if os.path.isfile(tmpFile): - os.remove(tmpFile) - update_notify('V1.221.154') - -# common functions + if os.path.isfile(tmpFile): + os.remove(tmpFile) + except Exception as e: + return(False, True, e) + return(True, False, 'Updated to V1.227.219') def get_offsets(data, oType): x = y = d = 0 + error = False parms = data.lower().split() for parm in parms: if parm.startswith('x'): @@ -346,12 +188,217 @@ def get_offsets(data, oType): elif oType == 'OFFSET_PROBING': d = float(parm) else: - print(f'Parameter error in {oType}. "{data}" is invalid.') - return x, y, d + error = f'Parameter error in {oType}. "{data}" is invalid.' + return x, y, d, error + + +########################################################################################################### +# remove the qtplasmac link from the config directory (pre V1.225.208 2022/06/29) # +########################################################################################################### +def remove_qtplasmac_link_iniwrite(inifile): + try: + tmpFile = f'{inifile}~' + COPY(inifile, tmpFile) + with open(tmpFile, 'r') as inFile: + with open(inifile, 'w') as outFile: + for line in inFile: + if line.replace(' ','').startswith('ngc='): + line = 'ngc = qtplasmac_gcode\n' + elif line.replace(' ','').startswith('nc='): + line = 'nc = qtplasmac_gcode\n' + elif line.replace(' ','').startswith('tap='): + line = 'tap = qtplasmac_gcode\n' + elif (line.startswith('SUBROUTINE_PATH') or line.startswith('USER_M_PATH')) and ':./qtplasmac' in line: + line = line.replace(':./qtplasmac','') + outFile.write(line) + if os.path.isfile(tmpFile): + os.remove(tmpFile) + except Exception as e: + return(False, True, e) + return(True, False, 'Updated to V1.225.208') + + +########################################################################################################### +# change startup parameters from a subroutine (pre V1.224.207 2022/06/22) # +########################################################################################################### +def rs274ngc_startup_code_iniwrite(inifile): + try: + tmpFile = f'{inifile}~' + COPY(inifile, tmpFile) + with open(tmpFile, 'r') as inFile: + with open(inifile, 'w') as outFile: + for line in inFile: + if line.startswith('RS274NGC_STARTUP_CODE') and ('metric' in line or 'imperial' in line): + units = 21 if 'metric' in line else 20 + line = f'RS274NGC_STARTUP_CODE = G{units} G40 G49 G80 G90 G92.1 G94 G97 M52P1\n' + outFile.write(line) + if os.path.isfile(tmpFile): + os.remove(tmpFile) + except Exception as e: + return(False, True, e) + return(True, False, 'Updated to V1.225.207') + + +########################################################################################################### +# move [CONVERSATIONAL] prefs from qtvcp.prefs to .prefs (pre V1.222.187 2022/05/03) # +########################################################################################################### +def move_prefs(qtvcp, machine): + try: + deleteMachineLine = False + moveQtvcpLine = False + with open(machine, 'r') as inFile: + machineData = inFile.readlines() + with open(qtvcp, 'r') as inFile: + qtvcpData = inFile.readlines() + with open(machine, 'w') as machineFile: + with open(qtvcp, 'w') as qtvcpFile: + for line in machineData: + if line.strip() == '[CONVERSATIONAL]': + deleteMachineLine = True + elif line.startswith('['): + deleteMachineLine = False + if not deleteMachineLine: + machineFile.write(line) + for line in qtvcpData: + if line.strip() == '[CONVERSATIONAL]': + moveQtvcpLine = True + elif line.startswith('['): + moveQtvcpLine = False + if moveQtvcpLine: + machineFile.write(line) + else: + qtvcpFile.write(line) + except Exception as e: + return(False, True, e) + return(False, False, 'Updated to V1.222.187') + + +########################################################################################################### +# split out qtplasmac.prefs into .prefs and qtvcp.prefs (pre V1.222.170 2022/03/08) # +########################################################################################################### +def split_prefs_file(old, new, prefs): + try: + move = False + copy = False + moves = ['[GUI_OPTIONS]','[COLOR_OPTIONS]','[ENABLE_OPTIONS]','[STATISTICS]', \ + '[PLASMA_PARAMETERS]','[DEFAULT MATERIAL]', '[SINGLE CUT]', '[CONVERSATIONAL]'] + copies = ['[SHUTDOWN_OPTIONS]'] + with open(old, 'r') as inFile: + data = inFile.readlines() + with open(new, 'w') as newFile: + with open(prefs, 'w') as prefsFile: + for line in data: + if line.strip() in moves: + move = True + copy = False + elif line.strip() in copies: + move = False + copy = True + elif line.strip().startswith('['): + move = False + copy = False + if move: + prefsFile.write(line) + elif copy: + if line.strip().startswith('['): + prefsFile.write(line) + if 'shutdown_msg_detail' in line: + prefsFile.write(line) + prefsFile.write('\n') + newFile.write(line) + else: + newFile.write(line) + if os.path.isfile(old): + os.remove(old) + except Exception as e: + return(False, True, e) + return(False, False, 'Updated to V1.222.170') + -def update_notify(version, restart=False): - print('\n-------------------------------') - print('QtPlasmac updated to', version) - if restart: - print('\n**** A restart is required ****\n') - print('-------------------------------\n') +########################################################################################################### +# use qtplasmac_comp.hal for component connections (pre V1.221.154 2022/01/18) # +########################################################################################################### +def add_component_hal_file(path, halfiles): + try: + tmpFile = None + pinsToCheck = ['PLASMAC COMPONENT INPUTS','plasmac.arc-ok-in','plasmac.axis-x-position', + 'plasmac.axis-y-position','plasmac.breakaway','plasmac.current-velocity', + 'plasmac.cutting-start','plasmac.cutting-stop','plasmac.feed-override', + 'plasmac.feed-reduction','plasmac.float-switch','plasmac.feed-upm', + 'plasmac.ignore-arc-ok-0','plasmac.machine-is-on','plasmac.motion-type', + 'plasmac.offsets-active','plasmac.ohmic-probe','plasmac.program-is-idle', + 'plasmac.program-is-paused','plasmac.program-is-running','plasmac.scribe-start', + 'plasmac.spotting-start','plasmac.thc-disable','plasmac.torch-off', + 'plasmac.units-per-mm','plasmac.x-offset-current','plasmac.y-offset-current', + 'plasmac.z-offset-current', + 'PLASMAC COMPONENT OUTPUTS','plasmac.adaptive-feed','plasmac.feed-hold', + 'plasmac.offset-scale','plasmac.program-pause','plasmac.program-resume', + 'plasmac.program-run','plasmac.program-stop','plasmac.torch-on', + 'plasmac.x-offset-counts','plasmac.y-offset-counts','plasmac.xy-offset-enable', + 'plasmac.z-offset-counts','plasmac.z-offset-enable','plasmac.requested-velocity'] + for f in halfiles: + f = os.path.expanduser(f) + if not 'custom' in f: + halfile = os.path.join(path, f) + with open(halfile, 'r') as inFile: + if 'plasmac.cutting-start' in inFile.read(): + inFile.seek(0) + tmpFile = f'{halfile}~' + COPY(halfile, tmpFile) + with open(tmpFile, 'r') as inFile: + with open(f, 'w') as outFile: + for line in inFile: + if any(pin in line for pin in pinsToCheck): + continue + outFile.write(line) + if tmpFile and os.path.isfile(tmpFile): + os.remove(tmpFile) + except Exception as e: + return(False, True, e) + return(False, False, '') + +def add_component_hal_file_iniwrite(inifile): + try: + written = False + tmpFile = f'{inifile}~' + COPY(inifile, tmpFile) + with open(tmpFile, 'r') as inFile: + with open(inifile, 'w') as outFile: + while 1: + line = inFile.readline() + if not line: + break + elif line.startswith('[HAL]'): + outFile.write(line) + break + else: + outFile.write(line) + while 1: + line = inFile.readline() + if not line: + if not written: + outFile.write('HALFILE = qtplasmac_comp.hal\n') + break + elif line.startswith('['): + if not written: + outFile.write('HALFILE = qtplasmac_comp.hal\n') + outFile.write(line) + break + elif 'custom.hal' in line.lower(): + outFile.write('HALFILE = qtplasmac_comp.hal\n') + outFile.write(line) + written = True + break + else: + outFile.write(line) + while 1: + line = inFile.readline() + if not line: + break + else: + outFile.write(line) + if os.path.isfile(tmpFile): + os.remove(tmpFile) + except Exception as e: + return(False, True, e) + return(True, False, 'Updated to V1.221.154') diff --git a/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py b/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py index 0f4b783be2e..3181db5b639 100644 --- a/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py +++ b/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py @@ -1,4 +1,4 @@ -VERSION = '1.236.289' +VERSION = '1.236.290' ''' qtplasmac_handler.py @@ -144,6 +144,7 @@ def __init__(self, halcomp, widgets, paths): else: self.PREFS = None self.updateIni = [] + self.updateData = [] self.update_check() self.PREFS = Access(self.prefsFile) self.MATS = Access(self.materialFile) @@ -418,6 +419,25 @@ def initialized__(self): self.w.mdihistory.MDILine.spindle_inhibit(True) if self.updateIni: self.update_iniwrite() + updateLog = os.path.join(self.PATHS.CONFIGPATH, 'update_log.txt') + if self.updateData: + restart = False + msgType = linuxcnc.OPERATOR_TEXT + msgText = '' + with open(updateLog, 'a') as f: + for update in self.updateData: + if update[2]: + f.write('{} {}\n'.format(time.strftime('%y-%m-%d'), update[2])) + msgText += '{}\n'.format(update[2]) + if update[0]: restart = True + if update[1]: msgType = linuxcnc.OPERATOR_ERROR + STATUS.emit('error', msgType, msgText) + if restart: + STATUS.emit('error', linuxcnc.OPERATOR_TEXT, 'Due to configuration changes a restart is required') + + if not os.path.isfile(updateLog): + with open(updateLog, 'w') as f: + f.write('{} Initial V{}\n'.format(time.strftime('%y-%m-%d'), VERSION)) self.startupTimer.start(250) # called by qtvcp.py, can override qtvcp settings or qtvcp allowed user options (via INI) @@ -2379,23 +2399,33 @@ def update_check(self): # to be done later in the update_iniwrite function halfiles = self.iniFile.findall('HAL', 'HALFILE') or None qtvcpPrefsFile = os.path.join(self.PATHS.CONFIGPATH, 'qtvcp.prefs') + self.restart = False # use qtplasmac_comp.hal for component connections (pre V1.221.154 2022/01/18) if halfiles and not [f for f in halfiles if 'plasmac.tcl' in f] and not \ [f for f in halfiles if 'qtplasmac_comp.hal' in f]: - UPDATER.add_component_hal_file(self.PATHS.CONFIGPATH, halfiles) + restart, error, text = UPDATER.add_component_hal_file(self.PATHS.CONFIGPATH, halfiles) + self.updateData.append([restart, error, text]) + if error: + return self.updateIni.append(154) # split out qtplasmac specific prefs into a separate file (pre V1.222.170 2022/03/08) if not os.path.isfile(self.prefsFile): old = os.path.join(self.PATHS.CONFIGPATH, 'qtplasmac.prefs') if os.path.isfile(old): - UPDATER.split_prefs_file(old, qtvcpPrefsFile, self.prefsFile) + restart, error, text = UPDATER.split_prefs_file(old, qtvcpPrefsFile, self.prefsFile) + self.updateData.append([restart, error, text]) + if error: + return self.PREFS = Access(self.prefsFile) # move conversational prefs from qtvcp.prefs to .prefs (pre V1.222.187 2022/05/03) if os.path.isfile(qtvcpPrefsFile) and os.path.isfile(self.prefsFile): with open(qtvcpPrefsFile, 'r') as inFile: data = inFile.readlines() if [line for line in data if '[CONVERSATIONAL]' in line]: - UPDATER.move_prefs(qtvcpPrefsFile, self.prefsFile) + restart, error, text = UPDATER.move_prefs(qtvcpPrefsFile, self.prefsFile) + self.updateData.append([restart, error, text]) + if error: + return # change RS274 startup parameters from a subroutine (pre V1.224.207 2022/06/22) startupCode = self.iniFile.find('RS274NGC', 'RS274NGC_STARTUP_CODE') if 'metric_startup' in startupCode or 'imperial_startup' in startupCode: @@ -2410,25 +2440,54 @@ def update_check(self): os.unlink(os.path.join(self.PATHS.CONFIGPATH, 'qtplasmac')) # move qtplasmac options from INI file to prefs file pre V1.227.219 2022/07/14) if not self.PREFS.has_section('BUTTONS'): - UPDATER.move_options_to_prefs_file(self.iniFile, self.PREFS) + restart, error, text = UPDATER.move_options_to_prefs_file(self.iniFile, self.PREFS) + self.updateData.append([restart, error, text]) + if error: + return self.updateIni.append(219) # move port info from [GUI_OPTIONS] section (if it was moved via V1.227.219 update) to [POWERMAX] section if self.PREFS.has_option('GUI_OPTIONS', 'Port'): - UPDATER.move_port(self.PREFS) + restart, error, text = UPDATER.move_port(self.PREFS) + self.updateData.append([restart, error, text]) + if error: + return # move default material from prefs file to material 0 in materials file (pre V1.236.278 2023/07/07) if self.PREFS.has_section('DEFAULT MATERIAL'): - UPDATER.move_default_material(self.PREFS, self.materialFile, self.unitsPerMm) + restart, error, text = UPDATER.move_default_material(self.PREFS, self.materialFile, self.unitsPerMm) + self.updateData.append([restart, error, text]) + if error: + return def update_iniwrite(self): # this is for updates that write to the INI file if 154 in self.updateIni: - UPDATER.add_component_hal_file_iniwrite(INIPATH) + restart, error, text = UPDATER.add_component_hal_file_iniwrite(INIPATH) + if restart: + self.restart = True + self.updateData.append([self.restart, error, text]) + if error: + return if 207 in self.updateIni: - UPDATER.rs274ngc_startup_code_iniwrite(INIPATH) + restart, error, text = UPDATER.rs274ngc_startup_code_iniwrite(INIPATH) + if restart: + self.restart = True + self.updateData.append([self.restart, error, text]) + if error: + return if 208 in self.updateIni: - UPDATER.remove_qtplasmac_link_iniwrite(INIPATH) + restart, error, text = UPDATER.remove_qtplasmac_link_iniwrite(INIPATH) + if restart: + self.restart = True + self.updateData.append([self.restart, error, text]) + if error: + return if 219 in self.updateIni: - UPDATER.move_options_to_prefs_file_iniwrite(INIPATH) + restart, error, text = UPDATER.move_options_to_prefs_file_iniwrite(INIPATH) + if restart: + self.restart = True + self.updateData.append([self.restart, error, text]) + if error: + return def motion_type_changed(self, value): if value == 0 and STATUS.is_mdi_mode(): diff --git a/share/qtvcp/screens/qtplasmac/versions.html b/share/qtvcp/screens/qtplasmac/versions.html index ae2ba434705..36ce3490f41 100644 --- a/share/qtvcp/screens/qtplasmac/versions.html +++ b/share/qtvcp/screens/qtplasmac/versions.html @@ -30,9 +30,14 @@

QtPlasmaC Version History


+
v1.236.290 2023 Aug 30 +
    +
  • log major updates and improve update messages
  • +
+
v1.236.289 2023 Aug 28
    -
  • fix quirks from single cutting before a file was opened
  • +
  • fix quirks from single cutting before a file was opened
Changes submitted by snowgoer540 (Greg Carl)