|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | | -THIS_VERSION = "1.1" |
| 3 | +THIS_VERSION = "1.2" |
4 | 4 |
|
5 | 5 | import sys |
6 | 6 | import os |
@@ -165,16 +165,11 @@ def writeifexists(file, section, src_item, dest_item = "None"): |
165 | 165 |
|
166 | 166 | print("halpaths = ", halpaths) |
167 | 167 |
|
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() |
175 | 168 |
|
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 | + """ |
178 | 173 | inistring = open(filename,'r').read() |
179 | 174 | newini = open(filename, 'w') |
180 | 175 | # Get a list of all sections |
@@ -209,6 +204,18 @@ def writeifexists(file, section, src_item, dest_item = "None"): |
209 | 204 | else: |
210 | 205 | newini.write("VERSION = %s\n" % THIS_VERSION) |
211 | 206 |
|
| 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() |
212 | 219 | #These sections don't need any work. |
213 | 220 | copysection("DISPLAY") |
214 | 221 | copysection("FILTER") |
@@ -416,6 +423,48 @@ def writeifexists(file, section, src_item, dest_item = "None"): |
416 | 423 | #That's the INI file done: |
417 | 424 | newini.close() |
418 | 425 |
|
| 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") |
419 | 468 |
|
420 | 469 |
|
421 | 470 | # Now change all the pin names etc in the linked HAL files. |
|
0 commit comments