Skip to content

Commit 619faee

Browse files
committed
Test for update_ini
1 parent c007641 commit 619faee

File tree

3 files changed

+65
-16
lines changed

3 files changed

+65
-16
lines changed

configs/sim/gmoccapy/gmoccapy.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ CYCLE_TIME = 100
2222

2323
# Values that will be allowed for override, 1.0 = 100%
2424
MAX_FEED_OVERRIDE = 1.5
25-
MIN_SPINDLE_0_OVERRIDE = 0.5
26-
MAX_SPINDLE_0_OVERRIDE = 1.2
25+
MIN_SPINDLE_OVERRIDE = 0.5
26+
MAX_SPINDLE_OVERRIDE = 1.2
2727

2828
# Spindle start speed
29-
DEFAULT_SPINDLE_0_SPEED = 450
29+
DEFAULT_SPINDLE_SPEED = 450
3030
# Scaling of spindle speed bar
31-
MIN_SPINDLE_0_SPEED = 0
32-
MAX_SPINDLE_0_SPEED = 3000
31+
MIN_SPINDLE_SPEED = 0
32+
MAX_SPINDLE_SPEED = 3000
3333

3434
# The following are not used, added here to suppress warnings (from qt_istat/logger).
3535
DEFAULT_LINEAR_VELOCITY = 35

scripts/linuxcnc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ function GetFromIniEx {
519519

520520
# 2.1.5 check version
521521
GetFromIni VERSION EMC
522-
if [ "$retval" != "1.1" ]; then
522+
if [ "$retval" != "1.2" ]; then
523523
if [ -z "$DISPLAY" ]; then
524524
echo "INI file [EMC]VERSION indicates update is needed, but the update GUI can't run without an X display"
525525
exit 1

src/emc/ini/update_ini.py

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
THIS_VERSION = "1.1"
3+
THIS_VERSION = "1.2"
44

55
import sys
66
import os
@@ -165,16 +165,11 @@ def writeifexists(file, section, src_item, dest_item = "None"):
165165

166166
print("halpaths = ", halpaths)
167167

168-
if version == "1.0":
169-
#Just update the version in the INI
170-
inistring = open(filename,'r').read()
171-
newini = open(filename, 'w')
172-
inistring = re.sub("VERSION *= *(.*)", "VERSION = %s" % THIS_VERSION, inistring)
173-
newini.write(inistring)
174-
newini.close()
175168

176-
if version == "$Revision$" or version < "1.0":
177-
169+
def ini_preamble():
170+
"""
171+
The part which is equal for the conversions up from version 1.1
172+
"""
178173
inistring = open(filename,'r').read()
179174
newini = open(filename, 'w')
180175
# Get a list of all sections
@@ -209,6 +204,18 @@ def writeifexists(file, section, src_item, dest_item = "None"):
209204
else:
210205
newini.write("VERSION = %s\n" % THIS_VERSION)
211206

207+
return inistring, newini, all_sections
208+
209+
if version == "1.0":
210+
#Just update the version in the INI
211+
inistring = open(filename,'r').read()
212+
newini = open(filename, 'w')
213+
inistring = re.sub("VERSION *= *(.*)", "VERSION = %s" % THIS_VERSION, inistring)
214+
newini.write(inistring)
215+
newini.close()
216+
217+
if version == "$Revision$" or version < "1.0":
218+
inistring, newini, all_sections = ini_preamble()
212219
#These sections don't need any work.
213220
copysection("DISPLAY")
214221
copysection("FILTER")
@@ -416,6 +423,48 @@ def writeifexists(file, section, src_item, dest_item = "None"):
416423
#That's the INI file done:
417424
newini.close()
418425

426+
if version < "1.2":
427+
inistring, newini, all_sections = ini_preamble()
428+
429+
all_sections.remove("DISPLAY")
430+
section = re.search(r"\[DISPLAY\](.+?)\n\[", inistring, re.DOTALL)
431+
if section: section = section.group(1)
432+
newini.write("\n[DISPLAY]\n")
433+
# if section != None:
434+
# if not re.search("DEFAULT_SPINDLE_0_SPEED", section):
435+
# if re.search("DEFAULT_SPINDLE_SPEED", section):
436+
# section = re.sub("DEFAULT_SPINDLE_SPEED", "DEFAULT_SPINDLE_0_SPEED", section)
437+
# else:
438+
# mv = re.findall(r"DEFAULT_SPINDLE_SPEED[\s=]+(\d*(\.\d+)?)", inistring, re.MULTILINE)
439+
# section = ("\n# start value for spindle speed " +
440+
# "\nDEFAULT_SPINDLE_0_SPEED = %s" % max(mv)[0] + section)
441+
# # if not re.search("DEFAULT_LINEAR_VELOCITY", section):
442+
# # section = re.sub("DEFAULT_VELOCITY", "DEFAULT_LINEAR_VELOCITY", section)
443+
# # if not re.search("MAX_LINEAR_ACCELERATION", section):
444+
# # section = re.sub("MAX_ACCELERATION", "MAX_LINEAR_ACCELERATION", section)
445+
# # if not re.search("DEFAULT_ACCELERATION", section):
446+
# # section = re.sub("DEFAULT_ACCELERATION", "DEFAULT_LINEAR_ACCELERATION", section)
447+
# # print("COORDINATES = %s\n" % ''.join(coordinates))
448+
# # section = re.sub("COORDINATES.*", "COORDINATES = %s" % ''.join(coordinates[: joints]), section)
449+
# # section = re.sub("CYCLE_TIME.*?\n", "", section)
450+
# # section = re.sub("AXES *=.*\n", "", section)
451+
# newini.write(section)
452+
453+
# # 'DEFAULT_SPINDLE_SPEED' : 'DEFAULT_SPINDLE_0_SPEED',
454+
# # 'MIN_SPINDLE_OVERRIDE' : 'MIN_SPINDLE_0_OVERRIDE',
455+
# # 'MAX_SPINDLE_OVERRIDE' : 'MAX_SPINDLE_0_OVERRIDE',
456+
457+
458+
#These sections don't need any work.
459+
copysection("FILTER")
460+
copysection("RS274NGC")
461+
copysection("PYTHON")
462+
copysection("EMCMOT")
463+
copysection("TASK")
464+
copysection("HAL")
465+
copysection("HALUI")
466+
copysection("TRAJ")
467+
copysection("EMCIO")
419468

420469

421470
# Now change all the pin names etc in the linked HAL files.

0 commit comments

Comments
 (0)