|
39 | 39 |
|
40 | 40 | # set up parsing of the inifile |
41 | 41 | import os |
42 | | -import configparser |
| 42 | +import linuxcnc |
43 | 43 | # get the path for the ini file used to start this config |
44 | 44 | inifile = os.environ.get("INI_FILE_NAME") |
45 | | -# instantiate a parser in non-strict mode because we have multiple entries for |
46 | | -# some sections in the ini |
47 | | -config = configparser.ConfigParser(strict=False) |
48 | | -# ingest the ini file |
49 | | -config.read(inifile) |
| 45 | +# instantiate the LinuxCNC ini-parser |
| 46 | +config = linuxcnc.ini(inifile) |
50 | 47 |
|
51 | 48 | ## SPINDLE ROTARY JOINT LETTERS |
52 | 49 | # spindle primary joint |
53 | | -joint_letter_primary = (config['TWP']['PRIMARY']).capitalize() |
| 50 | +joint_letter_primary = config.getstring('TWP', 'PRIMARY', fallback="").capitalize() |
54 | 51 | # spindle secondary joint (ie the one closer to the tool) |
55 | | -joint_letter_secondary = (config['TWP']['SECONDARY']).capitalize() |
| 52 | +joint_letter_secondary = config.getstring('TWP', 'SECONDARY', fallback="").capitalize() |
56 | 53 |
|
57 | 54 | if not joint_letter_primary in ('A','B','C') or not joint_letter_secondary in ('A','B','C'): |
58 | 55 | log.error("Unable to parse joint letters given in INI [TWP].") |
|
61 | 58 | else: |
62 | 59 | # get the MIN/MAX limits of the respective rotary joint letters |
63 | 60 | category = 'AXIS_' + joint_letter_primary |
64 | | - primary_min_limit = float(config[category]['MIN_LIMIT']) |
65 | | - primary_max_limit = float(config[category]['MAX_LIMIT']) |
| 61 | + primary_min_limit = config.getreal(category, 'MIN_LIMIT', fallback=0.0) |
| 62 | + primary_max_limit = config.getreal(category, 'MAX_LIMIT', fallback=0.0) |
66 | 63 | log.info('Joint letter for primary is %s with MIN/MAX limits: %s,%s', joint_letter_primary, primary_min_limit, primary_max_limit) |
67 | 64 | category = 'AXIS_' + joint_letter_secondary |
68 | | - secondary_min_limit = float(config[category]['MIN_LIMIT']) |
69 | | - secondary_max_limit = float(config[category]['MAX_LIMIT']) |
| 65 | + secondary_min_limit = config.getreal(category, 'MIN_LIMIT', fallback=0.0) |
| 66 | + secondary_max_limit = config.gerreal(category, 'MAX_LIMIT', fallback=0.0) |
70 | 67 | log.info('Joint letter for secondary is %s with MIN/MAX Limits: %s,%s', joint_letter_secondary, secondary_min_limit, secondary_max_limit) |
71 | 68 |
|
72 | 69 |
|
73 | 70 | ## CONNECTIONS TO THE KINEMATIC COMPONENT |
74 | | -# get the name of the kinematic component (this seems to ingest also the next line) |
75 | | -kins_comp = (config['KINS']['KINEMATICS']).partition('\n')[0] |
| 71 | +# get the name of the kinematic component |
| 72 | +kins_comp = config.getstring('KINS', 'KINEMATICS', fallback="") |
76 | 73 | # name of the hal pin that represents the nutation-angle |
77 | 74 | kins_nutation_angle = kins_comp + '_kins.nut-angle' |
78 | 75 | # name of the hal pin that represents the pre-rotation |
|
0 commit comments