@@ -64,7 +64,6 @@ def update(self, parent, iniFile):
64
64
65
65
# test for axis letter(s) changed
66
66
if len (tool_joints ) == len (ini_joints ): # this has problems if many axes are changed
67
- #print('Same number of joints, checking Axis Letters')
68
67
for key , value in tool_joints .items ():
69
68
if tool_joints [key ] != ini_joints [key ]:
70
69
new_axis = f'[AXIS_{ tool_joints [key ]} ]'
@@ -74,7 +73,6 @@ def update(self, parent, iniFile):
74
73
if line .strip () == f'[AXIS_{ ini_joints [key ]} ]' :
75
74
for index , line in enumerate (self .content ):
76
75
if line .strip () == old_axis :
77
- #print(f'Index: {index} Old: {old_axis} New: {new_axis}')
78
76
self .content [index ] = f'{ new_axis } \n '
79
77
self .get_sections ()
80
78
for line in self .content :
@@ -89,7 +87,6 @@ def update(self, parent, iniFile):
89
87
del self .content [start :end ]
90
88
self .get_sections ()
91
89
if value not in tool_joints .values ():
92
- #print(f'Remvoing [AXIS_{value}]')
93
90
axis = f'[AXIS_{ value } ]'
94
91
start = self .sections [axis ][0 ]
95
92
end = self .sections [axis ][1 ] + 1
@@ -104,15 +101,12 @@ def update(self, parent, iniFile):
104
101
elif len (tool_joints ) > len (ini_joints ):
105
102
for key , value in tool_joints .items ():
106
103
if key not in ini_joints :
107
- #print(f'Adding {key} after {last_key}')
108
104
last_end = self .sections [last_key ][1 ] + 1
109
- #print(f'Insert {key} at {last_end}')
110
105
self .content .insert (last_end , f'{ key } \n ' )
111
106
self .content .insert (last_end + 1 , '\n ' )
112
107
self .get_sections ()
113
108
# need to check to see if the axis has been create
114
109
if f'[AXIS_{ value } ]' not in self .sections :
115
- #print(f'Adding [AXIS_{value}] after {last_axis}')
116
110
last_end = self .sections [last_key ][1 ] + 1
117
111
self .content .insert (last_end , f'[AXIS_{ value } ]\n ' )
118
112
self .content .insert (last_end + 1 , '\n ' )
@@ -350,73 +344,6 @@ def update(self, parent, iniFile):
350
344
# coordinatesLB contains all the axes XYYZ
351
345
# [AXIS_x] section
352
346
353
- '''
354
- # build axis joint(s) dictionaries
355
- tool_ja = {}
356
- joint = 0
357
- for i in range(4):
358
- for j in range(6):
359
- if getattr(parent, f'c{i}_axis_{j}').currentData():
360
- tool_ja[f'[JOINT_{joint}]'] = f'[AXIS_{getattr(parent, f"c{i}_axis_{j}").currentData()}]'
361
- joint += 1
362
- #for key, value in tool_ja.items():
363
- # print(f'key: {key} value: {value}')
364
-
365
- ini_ja = {}
366
- for key, value in self.sections.items():
367
- if key.startswith('[JOINT'):
368
- for i in range(value[0], value[1]):
369
- if self.content[i].startswith('AXIS'):
370
- axis = self.content[i].strip()
371
- axis = axis.split()
372
- axis = f'[AXIS_{axis[-1]}]'
373
- ini_ja[key] = axis
374
-
375
- if len(tool_ja) == len(ini_ja):
376
- if tool_ja != ini_ja:
377
- for key in tool_ja.keys():
378
- if tool_ja[key] != ini_ja[key]:
379
- index = self.content.index(f'{ini_ja[key]}\n ')
380
- if index:
381
- self.content[index] = f'{tool_ja[key]}\n '
382
- self.get_sections() # update section start/end
383
-
384
- elif len(tool_ja) > len(ini_ja):
385
- for key in ini_ja.keys(): # check for axis letter changed
386
- if tool_ja[key] != ini_ja[key]:
387
- index = self.content.index(f'{ini_ja[key]}\n ')
388
- if index:
389
- self.content[index] = f'{tool_ja[key]}\n '
390
- self.get_sections() # update section start/end
391
-
392
- ini_axes = []
393
- for key, value in ini_ja.items(): # get a list of axes
394
- if value not in ini_axes:
395
- ini_axes.append(value)
396
-
397
- last_axis = ''
398
- last_joint = ''
399
- # this fails if more than one joint is added !!!!!!!!!!!
400
- for key, value in tool_ja.items(): # add missing axis
401
- if tool_ja[key] not in ini_axes:
402
- print(f'key: {key}')
403
- index = self.sections[last_joint][1]
404
- if index:
405
- self.insert_section(index, f'{tool_ja[key]}')
406
- last_joint = key
407
-
408
- for key, value in tool_ja.items(): # add missing joint after last axis
409
- if key not in ini_ja.keys():
410
- index = self.sections[value][1]
411
- self.insert_section(index, f'{key}')
412
-
413
- elif len(tool_ja) < len(ini_ja): # joint removed
414
- for joint, axis in ini_ja.items():
415
- if joint not in tool_ja:
416
- self.delete_section(joint)
417
- self.delete_section(axis)
418
- '''
419
-
420
347
# finally update the [AXIS_n] and [JOINT_n] sections
421
348
axes = []
422
349
n = 0 # joint number
@@ -426,18 +353,15 @@ def update(self, parent, iniFile):
426
353
axis = getattr (parent , f'c{ i } _axis_{ j } ' ).currentData ()
427
354
if axis not in axes :
428
355
axes .append (axis )
429
- #print(f'AXIS_{axis} MIN_LIMIT {getattr(parent, f"c{i}_min_limit_{j}").text()}')
356
+
430
357
self .update_key (f'AXIS_{ axis } ' , 'MIN_LIMIT' , getattr (parent , f'c{ i } _min_limit_{ j } ' ).text ())
431
358
self .update_key (f'AXIS_{ axis } ' , 'MAX_LIMIT' , getattr (parent , f'c{ i } _max_limit_{ j } ' ).text ())
432
359
self .update_key (f'AXIS_{ axis } ' , 'MAX_VELOCITY' , getattr (parent , f'c{ i } _max_vel_{ j } ' ).text ())
433
360
self .update_key (f'AXIS_{ axis } ' , 'MAX_ACCELERATION' , getattr (parent , f'c{ i } _max_accel_{ j } ' ).text ())
434
- #iniContents.append(f'CARD = {i}\n')
435
- #iniContents.append(f'TAB = {j}\n')
436
361
437
362
self .update_key (f'JOINT_{ n } ' , 'CARD' , f'{ i } ' )
438
363
self .update_key (f'JOINT_{ n } ' , 'TAB' , f'{ j } ' )
439
364
self .update_key (f'JOINT_{ n } ' , 'AXIS' , getattr (parent , f'c{ i } _axis_{ j } ' ).currentData ())
440
- #print(f'JOINT_{n} MIN_LIMIT {getattr(parent, f"c{i}_min_limit_{j}").text()}')
441
365
self .update_key (f'JOINT_{ n } ' , 'MIN_LIMIT' , getattr (parent , f'c{ i } _min_limit_{ j } ' ).text ())
442
366
self .update_key (f'JOINT_{ n } ' , 'MAX_LIMIT' , getattr (parent , f'c{ i } _max_limit_{ j } ' ).text ())
443
367
self .update_key (f'JOINT_{ n } ' , 'MAX_VELOCITY' , getattr (parent , f'c{ i } _max_vel_{ j } ' ).text ())
@@ -730,19 +654,15 @@ def get_sections(self):
730
654
previous = key
731
655
732
656
def update_key (self , section , key , value ):
733
- #if key == 'HOME_IGNORE_LIMITS':
734
- # print(section, key, value)
735
657
found = False
736
658
start = self .sections [f'[{ section } ]' ][0 ]
737
659
end = self .sections [f'[{ section } ]' ][1 ]
738
660
for item in self .content [start :end ]:
739
661
if item .split ('=' )[0 ].strip () == key :
740
- index = self .content .index (item )
662
+ index = self .content .index (item , start )
741
663
self .content [index ] = f'{ key } = { value } \n '
742
664
found = True
743
665
break
744
- #else:
745
- # found = False
746
666
if not found :
747
667
self .content .insert (end , f'{ key } = { value } \n ' )
748
668
self .get_sections () # update section start/end
0 commit comments