Skip to content

Commit 6760143

Browse files
committed
gstat -add status-message description
1 parent e9117cc commit 6760143

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

docs/src/gui/gstat.adoc

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,62 @@ This depends on the widget/libraries used.
487487
intended to be sent when requesting LinuxCNC to shutdown. +
488488
This depends on the widget/libraries used.
489489

490+
*status-message* :: 'returns python dict (message), python dict (options)'
491+
Intended for a screen/panel to get status/log messages from widgets, but can be used generally. +
492+
The listening object is expected to look for and handle at least these entries: +
493+
494+
The message dict would include: +
495+
496+
* TITLE: (string)
497+
* SHORTTEXT: (string)
498+
* DETAILS: (string)
499+
500+
The options dict would include: +
501+
502+
* LEVEL: (integer)
503+
* LOG: (bool)
504+
505+
The listening object could use this to display information on a text line or message dialog. +
506+
The LEVEL would indicate urgency 0 = DEFAULT 1 = WARNING 2 = CRITICAL +
507+
LOG indicates whether the message should be logged to a file/page if available. +
508+
LOG messages would be assumed to use the DETAILS entry. +
509+
510+
An example of how to send a message:
511+
512+
[source,python]
513+
----
514+
mess = {'SHORTTEXT':'File Copy Failed',
515+
'TITLE':'FileManager',
516+
'DETAILS':'There is not enough room on disk to copy the file'}
517+
opt = {'LOG':True,'LEVEL':2}
518+
STATUS.emit('status-message',mess,opt)
519+
----
520+
521+
An example of the listening object:
522+
523+
[source,python]
524+
----
525+
# tell STATUS we want to respond to any sent 'status-message' messages.
526+
STATUS.connect('status-message', lambda w, d, o: self.add_external_status(m,o))
527+
528+
def add_external_status(self, message, option):
529+
530+
# extract and trap errors for expected entries
531+
level = option.get('LEVEL', STATUS.DEFAULT)
532+
log = option.get("LOG", True)
533+
title = message.get('TITLE', '')
534+
mess = message.get('SHORTTEXT', '')
535+
logtext = message.get('DETAILS', '')
536+
537+
# call a function to print the message on a statusbar:
538+
self.add_status(mess, level, noLog=True)
539+
540+
# request a log file update
541+
if log:
542+
STATUS.emit('update-machine-log', "{}\n{}".format(title, logtext), 'TIME')
543+
544+
----
545+
490546
*error* :: '(returns integer, string)' -
491547
intended to be sent when an error has been reported . +
492548
integer represents the kind of error. ERROR, TEXT or DISPLAY +
@@ -623,4 +679,4 @@ returns string representing the internal selected axis letter.
623679
Some status points are reported wrongly during a running program because the interpreter runs ahead of the current position of a running program.
624680
This will hopefully be resolved with the merge of state-tags branch.
625681

626-
// vim: set syntax=asciidoc:
682+
// vim: set syntax=asciidoc:

0 commit comments

Comments
 (0)