Skip to content

Commit bf6a8b2

Browse files
committed
qtplasmac: move options from ini file to prefs file
1 parent fc1f29b commit bf6a8b2

File tree

15 files changed

+538
-597
lines changed

15 files changed

+538
-597
lines changed

configs/by_machine/qtplasmac/machine.tcl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ loadrt hypot names=sim:hyp_xy,sim:hyp_xyz
1919
# ---THREAD LINKS---
2020
addf motion-command-handler servo-thread
2121
addf motion-controller servo-thread
22-
addf plasmac servo-thread
22+
# don't add the plasmac component if it already exists
23+
if {[hal list pin plasmac.mode] == {}} {
24+
addf plasmac servo-thread
25+
}
2326
for {set jnum 0} {$jnum < $numJoints} {incr jnum} {
2427
addf sim:${jnum}_pid.do-pid-calcs servo-thread
2528
addf sim:${jnum}_mux servo-thread

configs/by_machine/qtplasmac/sim_no_stepgen.tcl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,9 @@ net sim:tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepa
6868

6969
# ---ESTOP HANDLING---
7070
loadrt or2 names=estop_or
71-
loadrt not names=estop_not
72-
addf estop_or servo-thread
73-
addf estop_not servo-thread
74-
net sim:estop-raw estop_or.out estop_not.in
75-
net sim:estop-out estop_not.out iocontrol.0.emc-enable-in
76-
if {$::QTPLASMAC(ESTOP_TYPE) == 2} {
77-
loadrt not names=estop_not_1
78-
addf estop_not_1 servo-thread
79-
net sim:estop-1-raw iocontrol.0.user-enable-out => estop_not_1.in
80-
net sim:estop-1-in estop_not_1.out => estop_or.in1
81-
}
71+
loadrt not names=estop_not,estop_not_1
72+
addf estop_or servo-thread
73+
addf estop_not servo-thread
74+
addf estop_not_1 servo-thread
75+
net sim:estop-raw estop_or.out => estop_not.in
76+
net sim:estop-out estop_not.out => iocontrol.0.emc-enable-in

configs/by_machine/qtplasmac/sim_stepgen.tcl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,18 @@ addf db_breakaway servo-thread
5050
addf db_arc-ok servo-thread
5151

5252
# ---Z JOINT CONNECTION---
53-
net plasmac:axis-position joint.${z-axis}.pos-fb => plasmac.axis-z-position
53+
net plasmac:axis-position joint.${z-axis}.pos-fb => plasmac.axis-z-position
5454

5555
# ---TOOL CHANGE PASSTHROUGH
5656
net sim:tool-number <= iocontrol.0.tool-prep-number
57-
net sim:tool-change-loopback iocontrol.0.tool-change => iocontrol.0.tool-changed
57+
net sim:tool-change-loopback iocontrol.0.tool-change => iocontrol.0.tool-changed
5858
net sim:tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
5959

6060
# ---ESTOP HANDLING---
6161
loadrt or2 names=estop_or
62-
loadrt not names=estop_not
63-
addf estop_or servo-thread
64-
addf estop_not servo-thread
62+
loadrt not names=estop_not,estop_not_1
63+
addf estop_or servo-thread
64+
addf estop_not servo-thread
65+
addf estop_not_1 servo-thread
6566
net sim:estop-raw estop_or.out => estop_not.in
6667
net sim:estop-out estop_not.out => iocontrol.0.emc-enable-in
67-
if {$::QTPLASMAC(ESTOP_TYPE) == 2} {
68-
loadrt not names=estop_not_1
69-
addf estop_not_1 servo-thread
70-
net sim:estop-1-raw iocontrol.0.user-enable-out => estop_not_1.in
71-
net sim:estop-1-in estop_not_1.out => estop_or.in1
72-
}

docs/src/plasma/qtplasmac.adoc

Lines changed: 82 additions & 130 deletions
Large diffs are not rendered by default.

lib/python/qtvcp/lib/qtplasmac/set_offsets.py

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
_translate = QCoreApplication.translate
2929

30-
def dialog_show(P, W, iniPath, STATUS, ACTION, TOOL, foreColor, backColor):
30+
def dialog_show(P, W, prefs, iniPath, STATUS, ACTION, TOOL, foreColor, backColor):
3131
msg = QMessageBox()
3232
msg.setWindowIcon(QIcon(os.path.join(P.IMAGES, 'linuxcncicon.png')))
3333
msg.setWindowTitle(_translate('Offsets', 'SET PERIPHERAL OFFSET'))
@@ -50,7 +50,8 @@ def dialog_show(P, W, iniPath, STATUS, ACTION, TOOL, foreColor, backColor):
5050
if get_reply(P, STATUS, P.laserOffsetX, P.laserOffsetY):
5151
P.laserOffsetX = round(STATUS.get_position()[1][0], 4) + 0
5252
P.laserOffsetY = round(STATUS.get_position()[1][1], 4) + 0
53-
do_ini_file(P, W, iniPath, P.laserOffsetX, P.laserOffsetY, '', 'LASER_TOUCHOFF', '# laser touchoff')
53+
prefs.putpref('X axis', P.laserOffsetX, float, 'LASER_OFFSET')
54+
prefs.putpref('Y axis', P.laserOffsetY, float, 'LASER_OFFSET')
5455
if P.laserOffsetX or P.laserOffsetY:
5556
W.laser.show()
5657
else:
@@ -59,7 +60,8 @@ def dialog_show(P, W, iniPath, STATUS, ACTION, TOOL, foreColor, backColor):
5960
if get_reply(P, STATUS, P.camOffsetX, P.camOffsetY):
6061
P.camOffsetX = round(STATUS.get_position()[1][0], 4) + 0
6162
P.camOffsetY = round(STATUS.get_position()[1][1], 4) + 0
62-
do_ini_file(P, W, iniPath, P.camOffsetX, P.camOffsetY, '', 'CAMERA_TOUCHOFF', '# camera touchoff')
63+
prefs.putpref('X axis', P.camOffsetX, float, 'CAMERA_OFFSET')
64+
prefs.putpref('Y axis', P.camOffsetY, float, 'CAMERA_OFFSET')
6365
if P.camOffsetX or P.camOffsetY:
6466
W.camera.show()
6567
else:
@@ -110,7 +112,9 @@ def dialog_show(P, W, iniPath, STATUS, ACTION, TOOL, foreColor, backColor):
110112
P.probeOffsetX = round(STATUS.get_position()[1][0], 4) + 0
111113
P.probeOffsetY = round(STATUS.get_position()[1][1], 4) + 0
112114
P.probeDelay = new
113-
do_ini_file(P, W, iniPath, P.probeOffsetX, P.probeOffsetY, P.probeDelay, 'OFFSET_PROBING', '# offset probing')
115+
prefs.putpref('X axis', P.probeOffsetX, float, 'OFFSET_PROBING')
116+
prefs.putpref('Y axis', P.probeOffsetY, float, 'OFFSET_PROBING')
117+
prefs.putpref('Delay', P.probeDelay, float, 'OFFSET_PROBING')
114118
P.set_probe_offset_pins()
115119

116120
def get_reply(P, STATUS, xOffset, yOffset, probe=False, delay=0.0, new=0.0):
@@ -140,58 +144,6 @@ def get_reply(P, STATUS, xOffset, yOffset, probe=False, delay=0.0, new=0.0):
140144
else:
141145
return False
142146

143-
def do_ini_file(P, W, iniPath, xOffset, yOffset, pDelay, param, comment):
144-
written = False
145-
COPY(iniPath, '{}~'.format(iniPath))
146-
inFile = open('{}~'.format(iniPath), 'r')
147-
outFile = open(iniPath, 'w')
148-
while 1:
149-
line = inFile.readline()
150-
if not line:
151-
break
152-
elif line.startswith('[QTPLASMAC]'):
153-
outFile.write(line)
154-
break
155-
else:
156-
outFile.write(line)
157-
while 1:
158-
line = inFile.readline()
159-
if not line:
160-
if not written:
161-
outFile.write('{}\n'.format(comment))
162-
if xOffset or yOffset:
163-
outFile.write('{} = X{:0.3f} Y{:0.3f} {}\n\n'.format(param, xOffset, yOffset, pDelay))
164-
else:
165-
outFile.write('#{} = X0.000 Y0.000\n\n'.format(param))
166-
break
167-
elif line.startswith('['):
168-
if not written:
169-
outFile.write('{}\n'.format(comment))
170-
if xOffset or yOffset:
171-
outFile.write('{} = X{:0.3f} Y{:0.3f} {}\n\n'.format(param, xOffset, yOffset, pDelay))
172-
else:
173-
outFile.write('#{} = X0.000 Y0.000\n\n'.format(param))
174-
outFile.write(line)
175-
break
176-
elif line.startswith('{}'.format(param)) or line.startswith('#{}'.format(param)):
177-
if xOffset or yOffset:
178-
outFile.write('{} = X{:0.3f} Y{:0.3f} {}\n'.format(param, xOffset, yOffset, pDelay))
179-
else:
180-
outFile.write('#{} = X0.000 Y0.000\n'.format(param))
181-
written = True
182-
break
183-
else:
184-
outFile.write(line)
185-
while 1:
186-
line = inFile.readline()
187-
if not line:
188-
break
189-
else:
190-
outFile.write(line)
191-
inFile.close()
192-
outFile.close()
193-
os.remove('{}~'.format(iniPath))
194-
195147
def do_tool_file(P, W, toolFile, xOffset, yOffset):
196148
written = False
197149
COPY(toolFile, '{}~'.format(toolFile))

lib/python/qtvcp/lib/qtplasmac/updater.py

Lines changed: 134 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,89 @@
2222
import os
2323
from shutil import copy as COPY
2424

25+
# move qtplasmac options from ini file to prefs file pre V1.227.219 2022/07/14)
26+
def move_options_to_prefs_file(inifile, prefs):
27+
text = prefs.getpref('shutdown_msg_detail', '', str, 'SHUTDOWN_OPTIONS')
28+
prefs.putpref('Exit warning text', text, str, 'GUI_OPTIONS')
29+
prefs.remove_section('SHUTDOWN_OPTIONS')
30+
prefs.write(open(prefs.fn, "w"))
31+
data = inifile.find('QTPLASMAC', 'MODE') or None
32+
if data:
33+
prefs.putpref('Mode', data, int, 'GUI_OPTIONS')
34+
data = inifile.find('QTPLASMAC', 'ESTOP_TYPE') or None
35+
if data:
36+
prefs.putpref('Estop type', data, int, 'GUI_OPTIONS')
37+
data = inifile.find('QTPLASMAC', 'DRO_POSITION') or None
38+
if data:
39+
prefs.putpref('DRO position', data, str, 'GUI_OPTIONS')
40+
data = inifile.find('QTPLASMAC', 'FLASH_ERROR') or None
41+
if data:
42+
prefs.putpref('Flash error', data, bool, 'GUI_OPTIONS')
43+
data = inifile.find('QTPLASMAC', 'HIDE_RUN') or None
44+
if data:
45+
prefs.putpref('Hide run', data, bool, 'GUI_OPTIONS')
46+
data = inifile.find('QTPLASMAC', 'HIDE_PAUSE') or None
47+
if data:
48+
prefs.putpref('Hide pause', data, bool, 'GUI_OPTIONS')
49+
data = inifile.find('QTPLASMAC', 'HIDE_ABORT') or None
50+
if data:
51+
prefs.putpref('Hide abort', data, bool, 'GUI_OPTIONS')
52+
data = inifile.find('QTPLASMAC', 'CUSTOM_STYLE') or None
53+
if data:
54+
prefs.putpref('Custom style', data, str, 'GUI_OPTIONS')
55+
data = inifile.find('QTPLASMAC', 'AUTOREPEAT_ALL') or None
56+
if data:
57+
prefs.putpref('Autorepeat all', data, bool, 'GUI_OPTIONS')
58+
data = inifile.find('QTPLASMAC', 'LASER_TOUCHOFF') or None
59+
if data:
60+
x, y, d = get_offsets(data)
61+
prefs.putpref('X axis', x, float, 'LASER_OFFSET')
62+
prefs.putpref('Y axis', y, float, 'LASER_OFFSET')
63+
data = inifile.find('QTPLASMAC', 'CAMERA_TOUCHOFF') or None
64+
if data:
65+
x, y, d = get_offsets(data)
66+
prefs.putpref('X axis', x, float, 'CAMERA_OFFSET')
67+
prefs.putpref('Y axis', y, float, 'CAMERA_OFFSET')
68+
data = inifile.find('QTPLASMAC', 'OFFSET_PROBING') or None
69+
if data:
70+
x, y, d = get_offsets(data)
71+
prefs.putpref('X axis', x, float, 'OFFSET_PROBING')
72+
prefs.putpref('Y axis', y, float, 'OFFSET_PROBING')
73+
prefs.putpref('Delay', d, float, 'OFFSET_PROBING')
74+
data = inifile.find('QTPLASMAC', 'PM_PORT') or None
75+
if data:
76+
prefs.putpref('Port', data, str, 'GUI_OPTIONS')
77+
for bNum in range(1,21):
78+
bName = inifile.find('QTPLASMAC', 'BUTTON_{}_NAME'.format(bNum)) or None
79+
bCode = inifile.find('QTPLASMAC', 'BUTTON_{}_CODE'.format(bNum)) or None
80+
if bName and bCode:
81+
prefs.putpref('{} Name'.format(bNum), bName, str, 'BUTTONS')
82+
prefs.putpref('{} Code'.format(bNum), bCode, str, 'BUTTONS')
83+
84+
def move_options_to_prefs_file_iniwrite(inifile):
85+
tmpFile = '{}~'.format(inifile)
86+
COPY(inifile, tmpFile)
87+
with open(tmpFile, 'r') as inFile:
88+
with open(inifile, 'w') as outFile:
89+
remove = False
90+
for line in inFile:
91+
if not line:
92+
break
93+
elif line.startswith('[QTPLASMAC]'):
94+
remove = True
95+
continue
96+
elif remove:
97+
if line.startswith('['):
98+
remove = False
99+
else:
100+
continue
101+
outFile.write(line)
102+
if os.path.isfile(tmpFile):
103+
os.remove(tmpFile)
104+
update_notify('V1.227.219')
105+
25106
# remove the qtplasmac link from the config directory (pre V1.225.208 2022/06/29)
26-
def remove_qtplasmac_link(inifile):
107+
def remove_qtplasmac_link_iniwrite(inifile):
27108
tmpFile = '{}~'.format(inifile)
28109
COPY(inifile, tmpFile)
29110
with open(tmpFile, 'r') as inFile:
@@ -43,7 +124,7 @@ def remove_qtplasmac_link(inifile):
43124
update_notify('V1.225.208')
44125

45126
# change startup parameters from a subroutine (pre V1.224.207 2022/06/22)
46-
def rs274ngc_startup_code(inifile): #, unitsCode):
127+
def rs274ngc_startup_code_iniwrite(inifile):
47128
tmpFile = '{}~'.format(inifile)
48129
COPY(inifile, tmpFile)
49130
with open(tmpFile, 'r') as inFile:
@@ -122,7 +203,41 @@ def split_prefs_file(old, new, prefs):
122203
update_notify('V1.222.170')
123204

124205
# use qtplasmac_comp.hal for component connections (pre V1.221.154 2022/01/18)
125-
def add_component_hal_file(path, inifile, halfiles):
206+
def add_component_hal_file(path, halfiles):
207+
pinsToCheck = ['PLASMAC COMPONENT INPUTS','plasmac.arc-ok-in','plasmac.axis-x-position',
208+
'plasmac.axis-y-position','plasmac.breakaway','plasmac.current-velocity',
209+
'plasmac.cutting-start','plasmac.cutting-stop','plasmac.feed-override',
210+
'plasmac.feed-reduction','plasmac.float-switch','plasmac.feed-upm',
211+
'plasmac.ignore-arc-ok-0','plasmac.machine-is-on','plasmac.motion-type',
212+
'plasmac.offsets-active','plasmac.ohmic-probe','plasmac.program-is-idle',
213+
'plasmac.program-is-paused','plasmac.program-is-running','plasmac.scribe-start',
214+
'plasmac.spotting-start','plasmac.thc-disable','plasmac.torch-off',
215+
'plasmac.units-per-mm','plasmac.x-offset-current','plasmac.y-offset-current',
216+
'plasmac.z-offset-current',
217+
'PLASMAC COMPONENT OUTPUTS','plasmac.adaptive-feed','plasmac.feed-hold',
218+
'plasmac.offset-scale','plasmac.program-pause','plasmac.program-resume',
219+
'plasmac.program-run','plasmac.program-stop','plasmac.torch-on',
220+
'plasmac.x-offset-counts','plasmac.y-offset-counts','plasmac.xy-offset-enable',
221+
'plasmac.z-offset-counts','plasmac.z-offset-enable','plasmac.requested-velocity']
222+
for f in halfiles:
223+
f = os.path.expanduser(f)
224+
if not 'custom' in f:
225+
halfile = os.path.join(path, f)
226+
with open(halfile, 'r') as inFile:
227+
if 'plasmac.cutting-start' in inFile.read():
228+
inFile.seek(0)
229+
tmpFile = '{}~'.format(halfile)
230+
COPY(halfile, tmpFile)
231+
with open(tmpFile, 'r') as inFile:
232+
with open(f, 'w') as outFile:
233+
for line in inFile:
234+
if any(pin in line for pin in pinsToCheck):
235+
continue
236+
outFile.write(line)
237+
if os.path.isfile(tmpFile):
238+
os.remove(tmpFile)
239+
240+
def add_component_hal_file_iniwrite(inifile):
126241
written = False
127242
tmpFile = '{}~'.format(inifile)
128243
COPY(inifile, tmpFile)
@@ -163,44 +278,25 @@ def add_component_hal_file(path, inifile, halfiles):
163278
outFile.write(line)
164279
if os.path.isfile(tmpFile):
165280
os.remove(tmpFile)
166-
#'plasmac.axis-z-position',
167-
pinsToCheck = ['PLASMAC COMPONENT INPUTS','plasmac.arc-ok-in','plasmac.axis-x-position',
168-
'plasmac.axis-y-position','plasmac.breakaway','plasmac.current-velocity',
169-
'plasmac.cutting-start','plasmac.cutting-stop','plasmac.feed-override',
170-
'plasmac.feed-reduction','plasmac.float-switch','plasmac.feed-upm',
171-
'plasmac.ignore-arc-ok-0','plasmac.machine-is-on','plasmac.motion-type',
172-
'plasmac.offsets-active','plasmac.ohmic-probe','plasmac.program-is-idle',
173-
'plasmac.program-is-paused','plasmac.program-is-running','plasmac.scribe-start',
174-
'plasmac.spotting-start','plasmac.thc-disable','plasmac.torch-off',
175-
'plasmac.units-per-mm','plasmac.x-offset-current','plasmac.y-offset-current',
176-
'plasmac.z-offset-current',
177-
'PLASMAC COMPONENT OUTPUTS','plasmac.adaptive-feed','plasmac.feed-hold',
178-
'plasmac.offset-scale','plasmac.program-pause','plasmac.program-resume',
179-
'plasmac.program-run','plasmac.program-stop','plasmac.torch-on',
180-
'plasmac.x-offset-counts','plasmac.y-offset-counts','plasmac.xy-offset-enable',
181-
'plasmac.z-offset-counts','plasmac.z-offset-enable','plasmac.requested-velocity']
182-
for f in halfiles:
183-
f = os.path.expanduser(f)
184-
if not 'custom' in f:
185-
halfile = os.path.join(path, f)
186-
with open(halfile, 'r') as inFile:
187-
if 'plasmac.cutting-start' in inFile.read():
188-
inFile.seek(0)
189-
tmpFile = '{}~'.format(halfile)
190-
COPY(halfile, tmpFile)
191-
with open(tmpFile, 'r') as inFile:
192-
with open(f, 'w') as outFile:
193-
for line in inFile:
194-
if any(pin in line for pin in pinsToCheck):
195-
continue
196-
outFile.write(line)
197-
if os.path.isfile(tmpFile):
198-
os.remove(tmpFile)
199281
update_notify('V1.221.154')
200282

283+
# common functions
284+
285+
def get_offsets(data):
286+
x = y = d = 0
287+
parms = data.lower().split()
288+
for parm in parms:
289+
if parm.startswith('x'):
290+
x = float(parm.replace('x', ''))
291+
elif parm.startswith('y'):
292+
y = float(parm.replace('y', ''))
293+
else:
294+
d = float(parm)
295+
return x, y, d
296+
201297
def update_notify(version, restart=False):
202-
print('-------------------------------')
298+
print('\n-------------------------------')
203299
print('QtPlasmac updated to', version)
204300
if restart:
205301
print('\n**** A restart is required ****\n')
206-
print('-------------------------------')
302+
print('-------------------------------\n')

lib/python/qtvcp/qt_istat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def update(self):
109109
self.MACRO_PATH = None
110110
self.INI_MACROS = self.INI.findall("DISPLAY", "MACRO")
111111
self.MACHINE_IS_LATHE = bool(self.INI.find("DISPLAY", "LATHE"))
112-
self.MACHINE_IS_QTPLASMAC = (self.INI.find("QTPLASMAC", "MODE")) or None
112+
self.MACHINE_IS_QTPLASMAC = 'qtplasmac' in self.INI.find("DISPLAY", "DISPLAY")
113113

114114
extensions = self.INI.findall("FILTER", "PROGRAM_EXTENSION")
115115
self.PROGRAM_FILTERS = ([e.split(None, 1) for e in extensions]) or None

0 commit comments

Comments
 (0)