Skip to content

Commit fd3437c

Browse files
committed
qtvcp: add "unlinkp" and "net" commands to mdi_line widget
1 parent c1609e4 commit fd3437c

2 files changed

Lines changed: 52 additions & 39 deletions

File tree

docs/src/gui/qtvcp-widgets.adoc

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ It is a comma separated list of keyword and data.
18731873

18741874
=== MDILine Widget
18751875

1876-
One can enter MDI commands here. A popup keyboard is available
1876+
One can enter MDI commands here. A popup keyboard is available.
18771877
There are also embedded commands available from this Widget.
18781878
Enter any of these case sensitive commands to load the respective
18791879
program or access the feature:
@@ -1892,11 +1892,23 @@ program or access the feature:
18921892
link:http://linuxcnc.org/docs/devel/html/ladder/classic-ladder.html[ClassicLadder GUI] if the ClassicLadder realtime HAL component was loaded by the machine's config files
18931893
* `PREFERENCE` - Loads the preference file onto the gcodeEditor
18941894
* `CLEAR HISTORY` - Clears the MDI History
1895+
* `net` - Connects a pin to a signal. An error will result if
1896+
the command is unsuccessful. Running LinuxCNC from terminal
1897+
may help determine the root cause as error messages from hal_lib.c
1898+
will be displayed there.
1899+
** _Syntax_: `net <pin name> <signal name>`
1900+
** __Example__: `net motion.jog-stop plasmac:jog-inhibit`
18951901
* `setp` - Sets the value of a pin or a parameter. Valid values depend
18961902
on the object type of the pin or parameter. An error will result if
18971903
the data types do not match or the pin is connected to a signal.
18981904
** _Syntax_: `setp <pin/parameter-name> <value>`
18991905
** __Example__: `setp plasmac.resolution 100`
1906+
* `unlinkp` - Disconnects a pin from a signal. An error will result
1907+
if the pin does not exist. Running LinuxCNC from terminal
1908+
may help determine the root cause as error messages from hal_lib.c
1909+
will be displayed there.
1910+
** _Syntax_: `unlinkp <pin name>`
1911+
** __Example__: `unlinkp motion.jog-stop`
19001912

19011913
Note that the MDILine function "spindle_inhibit" can be used by a GUI's
19021914
handler file to inhibit M3, M4, and M5 spindle commands if necessary.
@@ -1907,34 +1919,9 @@ It is based on pyQT's QLineEdit.
19071919

19081920
Displays a scrollable list of past MDI command.
19091921
A edit line is embedded for MDI commands.
1910-
There are also embedded commands available from this Widget.
1911-
Enter any of these case sensitive commands to load the respective
1912-
program or access the feature:
1913-
1914-
* `HALMETER` - Starts LinuxCNC utility
1915-
link:http://linuxcnc.org/docs/devel/html/hal/tutorial.html#sec:tutorial-halmeter[`halmeter`]
1916-
* `HALSHOW` - Starts LinuxCNC utility
1917-
link:http://linuxcnc.org/docs/devel/html/hal/halshow.html#cha:halshow[`halshow`]
1918-
* `HALSCOPE` - Starts LinuxCNC utility
1919-
link:http://linuxcnc.org/docs/devel/html/hal/tutorial.html#sec:tutorial-halscope[`halscope`]
1920-
* `STATUS` - Starts LinuxCNC utility
1921-
link:https://linuxcnc.org/docs//html/man/man1/linuxcnctop.1.html[`status`]
1922-
* `CALIBRATION` - Starts LinuxCNC utility
1923-
link:http://linuxcnc.org/docs/devel/html/getting-started/updating-linuxcnc.html#_calibration_emccalib_tcl[`calibration`]
1924-
* `CLASSICLADDER` - Starts the
1925-
link:http://linuxcnc.org/docs/devel/html/ladder/classic-ladder.html[ClassicLadder GUI] if the ClassicLadder realtime HAL component was loaded by the machine's config files
1926-
* `PREFERENCE` - Loads the preference file onto the gcodeEditor
1927-
* `CLEAR HISTORY` - Clears the MDI History
1928-
* `setp` - Sets the value of a pin or a parameter. Valid values depend
1929-
on the object type of the pin or parameter. An error will result if
1930-
the data types do not match or the pin is connected to a signal.
1931-
** _Syntax_: `setp <pin/parameter-name> <value>`
1932-
** _Example_: `setp plasmac.resolution 100`
1933-
1934-
Note that the MDILine function "spindle_inhibit" can be used by a GUI's
1935-
handler file to inhibit M3, M4, and M5 spindle commands if necessary.
1922+
The same MDILine embedded commands may be accessed from this Widget.
19361923

1937-
The history is recorded on a file defined in the INI.
1924+
The history is recorded in a file defined in the INI.
19381925
under the heading [DISPLAY] (this shows the default)
19391926

19401927
[source,{ini}]

lib/python/qtvcp/widgets/mdi_line.py

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ def submit(self):
100100
fp.close()
101101
elif text.lower().startswith('setp'):
102102
self.setp(text)
103+
elif text.lower().startswith('unlinkp'):
104+
self.unlinkp(text)
105+
elif text.lower().startswith('net'):
106+
self.net(text)
103107
elif self.spindleInhibit and self.inhibit_spindle_commands(text):
104108
return
105109
else:
@@ -141,52 +145,74 @@ def line_down(self):
141145
STATUS.emit('move-text-linedown')
142146

143147
def setp(self, setpString):
144-
arguments = len(setpString.lower().replace('setp ','').split(' '))
148+
arguments = len(setpString.lower().replace('setp',' ').split())
145149
if arguments == 2:
146-
halpin, value = setpString.lower().replace('setp ','').split(' ')
150+
halpin, value = setpString.lower().replace('setp',' ').split()
147151
else:
148-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\nsetp requires 2 arguments, {} given\n'.format(arguments))
152+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\nsetp requires 2 arguments, {} given\n'.format(arguments))
149153
return
150154
try:
151155
hal.get_value(halpin)
152156
except Exception as err:
153-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\n{}\n'.format(err))
157+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\n{}\n'.format(err))
154158
return
155159
try:
156160
hal.set_p(halpin, value)
157161
except Exception as err:
158-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\n"{}" {}\n'.format(halpin, err))
162+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\n"{}" {}\n'.format(halpin, err))
159163
return
160164
if type(hal.get_value(halpin)) == bool:
161165
if value.lower() in ['true', '1']:
162166
value = True
163167
elif value.lower() in ['false', '0']:
164168
value = False
165169
else:
166-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\nValue "{}" invalid for a BIT pin/parameter\n'.format(value))
170+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\nValue "{}" invalid for a BIT pin/parameter\n'.format(value))
167171
return
168172
if hal.get_value(halpin) != value:
169-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\nBIT value comparison error\n')
173+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\nBIT value comparison error\n')
170174
return
171175
elif type(hal.get_value(halpin)) == float:
172176
try:
173177
value = float(value)
174178
except:
175-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\nValue "{}" invalid for a Float pin/parameter\n'.format(value))
179+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\nValue "{}" invalid for a Float pin/parameter\n'.format(value))
176180
return
177181
if hal.get_value(halpin) != value:
178-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\nFloat value comparison error\n')
182+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\nFloat value comparison error\n')
179183
return
180184
else:
181185
try:
182186
value = int(value)
183187
except:
184-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\nValue "{}" invalid for S32 or U32 pin/parameter\n'.format(value))
188+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\nValue "{}" invalid for S32 or U32 pin/parameter\n'.format(value))
185189
return
186190
if hal.get_value(halpin) != value:
187-
ACTION.SET_ERROR_MESSAGE('SETP UNSUCCESSFUL:\nS32 or U32 value comparison error\n')
191+
ACTION.SET_ERROR_MESSAGE('SETP ERROR:\nS32 or U32 value comparison error\n')
188192
return
189193

194+
def unlinkp(self, unlinkpString):
195+
arguments = len(unlinkpString.lower().replace('unlinkp',' ').split())
196+
if arguments == 1:
197+
halpin = unlinkpString.lower().replace('unlinkp',' ').strip()
198+
else:
199+
ACTION.SET_ERROR_MESSAGE('UNLINKP ERROR:\nunlinkp requires 1 argument, {} given\n'.format(arguments))
200+
return
201+
reply = hal.disconnect(halpin)
202+
if reply:
203+
ACTION.SET_ERROR_MESSAGE('UNLINKP ERROR:\nPin "{}" not found\n'.format(halpin))
204+
205+
def net(self, netString):
206+
arguments = len(netString.lower().replace('net',' ').split())
207+
if arguments == 2:
208+
halpin, signal = netString.lower().replace('net',' ').split()
209+
else:
210+
ACTION.SET_ERROR_MESSAGE('NET ERROR:\nnet requires 2 arguments, {} given\n'.format(arguments))
211+
return
212+
reply = hal.connect(halpin, signal)
213+
if reply:
214+
ACTION.SET_ERROR_MESSAGE('NET ERROR:\nFailed to link pin "{}" to signal "{}"\n'.format(halpin, signal))
215+
190216
def spindle_inhibit(self, state):
191217
self.spindleInhibit = state
192218

0 commit comments

Comments
 (0)