Config: idempotent macro file rename W -> A
The auxiliary stepper used to be exposed as a W axis. After the gplan integration it is exposed as A. Migrate persisted macro config on every load: w_down.nc -> a_down.nc w_up.nc -> a_up.nc 'W Down' -> 'A Down' 'W Up' -> 'A Up' Idempotent so a stale in-memory copy can never reintroduce the old names.
This commit is contained in:
@@ -216,6 +216,32 @@ class Config(object):
|
|||||||
defaults = json.load(f)
|
defaults = json.load(f)
|
||||||
config['selected-tool-settings'] = defaults['selected-tool-settings'];
|
config['selected-tool-settings'] = defaults['selected-tool-settings'];
|
||||||
|
|
||||||
|
# Auxiliary axis nomenclature: rename W -> A in macro names and
|
||||||
|
# filenames. The auxcnc-driven stepper has been integrated into
|
||||||
|
# gplan as A since the option-b migration; old configs may
|
||||||
|
# still carry W Down/W Up macro entries pointing at
|
||||||
|
# w_down.nc/w_up.nc which were renamed on disk to a_down.nc /
|
||||||
|
# a_up.nc. Migrate idempotently on every load so a stale
|
||||||
|
# in-memory copy can never reintroduce the old names.
|
||||||
|
macros = config.get('macros') if isinstance(config, dict) else None
|
||||||
|
if isinstance(macros, list):
|
||||||
|
renames = {
|
||||||
|
'w_down.nc': 'a_down.nc',
|
||||||
|
'w_up.nc': 'a_up.nc',
|
||||||
|
}
|
||||||
|
display_renames = {
|
||||||
|
'W Down': 'A Down',
|
||||||
|
'W Up': 'A Up',
|
||||||
|
}
|
||||||
|
for m in macros:
|
||||||
|
if not isinstance(m, dict): continue
|
||||||
|
fn = m.get('file_name')
|
||||||
|
if isinstance(fn, str) and fn in renames:
|
||||||
|
m['file_name'] = renames[fn]
|
||||||
|
nm = m.get('name')
|
||||||
|
if isinstance(nm, str) and nm in display_renames:
|
||||||
|
m['name'] = display_renames[nm]
|
||||||
|
|
||||||
config['version'] = self.version.split('b')[0]
|
config['version'] = self.version.split('b')[0]
|
||||||
config['full_version'] = self.version
|
config['full_version'] = self.version
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user