Libraries are prebuilt Python modules that give added features to QtVCP. In this way you can select what features you want - yet don’t have to build common ones yourself.

1. Status

Status is a library that sends GObject messages based on LinuxCNC’s current state. It is an extension of GladeVCP’s GStat object.

It also has some functions to report status on such things as internal jog rate.

You connect a function call to the STATUS message you are interested in, and QtVCP will call this function when the message is sent from STATUS.

1.1. Anwendung

  • Import Status modules
    Add this Python code to your import section:

    ############################
    # **** IMPORT SECTION **** #
    ############################
    
    from qtvcp.core import Status
  • Instantiate Status module
    Add this Python code to your instantiate section:

    STATUS = Status()
  • Connect to STATUS messages
    Use GObject syntax.

1.2. Beispiel

So können Sie z. B. Ein- und Ausschaltmeldungen der Maschine auffangen.

Anmerkung
The example below shows the two common ways of connecting signals, one of them using lambda. lambda is used to strip off or manipulate arguments from the status message before calling the function. You can see the difference in the called function signature: The one that uses lambda does not accept the status object - lambda did not pass it to the function.
  • Place these commands into the [INITIALIZE] section of the Python handler file:

    STATUS.connect('state-on', self.on_state_on)
    STATUS.connect('state-off', lambda: w, self.on_state_off())

    Wenn sich LinuxCNC in Zustand "machine on" befindet, wird in diesem Beispielcode state die Funktion self.on_state_on aufgerufen.
    Wenn LinuxCNC in Zustand "machine off" ist, wird die Funktion self.on_state_off aufgerufen.

  • These would call functions that looks like these:

    def on_state_on(self, status_object):
        print('LinuxCNC machine is on')
    def on_state_off(self):
        print('LinuxCNC machine is off')

2. Info

Info is a library to collect and filter data from the INI file.

2.1. Verfügbare Daten und Voreinstellungen

LINUXCNC_IS_RUNNING
LINUXCNC_VERSION
INIPATH
INI = linuxcnc.ini(INIPATH)
MDI_HISTORY_PATH = '~/.axis_mdi_history'
QTVCP_LOG_HISTORY_PATH = '~/qtvcp.log'
MACHINE_LOG_HISTORY_PATH = '~/.machine_log_history'
PREFERENCE_PATH = '~/.Preferences'
SUB_PATH = None
SUB_PATH_LIST = []
self.MACRO_PATH = None
MACRO_PATH_LIST = []
INI_MACROS = self.INI.findall("DISPLAY", "MACRO")

IMAGE_PATH = IMAGEDIR
LIB_PATH = os.path.join(HOME, "share","qtvcp")

PROGRAM_FILTERS = None
PARAMETER_FILE = None
MACHINE_IS_LATHE = False
MACHINE_IS_METRIC = False
MACHINE_UNIT_CONVERSION = 1
MACHINE_UNIT_CONVERSION_9 = [1]*9
TRAJ_COORDINATES =
JOINT_COUNT = int(self.INI.find("KINS","JOINTS")or 0)
AVAILABLE_AXES = ['X','Y','Z']
AVAILABLE_JOINTS = [0,1,2]
GET_NAME_FROM_JOINT = {0:'X',1:'Y',2:'Z'}
GET_JOG_FROM_NAME = {'X':0,'Y':1,'Z':2}
NO_HOME_REQUIRED = False
HOME_ALL_FLAG
JOINT_TYPE = self.INI.find(section, "TYPE") or "LINEAR"
JOINT_SEQUENCE_LIST
JOINT_SYNC_LIST

JOG_INCREMENTS = None
ANGULAR_INCREMENTS = None
GRID_INCREMENTS

DEFAULT_LINEAR_JOG_VEL = 15 Einheiten pro Minute
MIN_LINEAR_JOG_VEL = 60 Einheiten pro Minute
Länge_LINEAR_JOG_VEL = 300 Einheiten pro Minute

DEFAULT_ANGULAR_JOG_VEL =
MIN_ANGULAR_JOG_VEL =
MAX_ANGULAR_JOG_VEL =

MAX_FEED_OVERRIDE =
MAX_TRAJ_VELOCITY =

AVAILABLE_SPINDLES = int(self.INI.find("TRAJ", "SPINDLES") or 1)
DEFAULT_SPINDLE_0_SPEED = 200
MAX_SPINDLE_0_SPEED = 2500
MAX_SPINDLE_0_OVERRIDE = 100
MIN_SPINDLE_0_OVERRIDE = 50

MAX_FEED_OVERRIDE = 1.5
MAX_TRAJ_VELOCITY

2.2. User message dialog info

USRMESS_BOLDTEXT = self.INI.findall("DISPLAY", "MESSAGE_BOLDTEXT")
USRMESS_TEXT = self.INI.findall("DISPLAY", "MESSAGE_TEXT")
USRMESS_TYPE = self.INI.findall("DISPLAY", "MESSAGE_TYPE")
USRMESS_PINNAME = self.INI.findall("DISPLAY", "MESSAGE_PINNAME")
USRMESS_DETAILS = self.INI.findall("DISPLAY", "MESSAGE_DETAILS")
USRMESS_ICON = self.INI.findall("DISPLAY", "MESSAGE_ICON")
ZIPPED_USRMESS =

self.GLADEVCP = (self.INI.find("DISPLAY", "GLADEVCP")) or None

2.3. Embedded program info

TAB_NAMES = (self.INI.findall("DISPLAY", "EMBED_TAB_NAME")) or None
TAB_LOCATION = (self.INI.findall("DISPLAY", "EMBED_TAB_LOCATION")) or []
TAB_CMD = (self.INI.findall("DISPLAY", "EMBED_TAB_COMMAND")) or None
ZIPPED_TABS =

MDI_COMMAND_LIST =      (heading: [MDI_COMMAND_LIST], title: MDI_COMMAND")
TOOL_FILE_PATH =        (heading: [EMCIO], title:TOOL_TABLE)
POSTGUI_HALFILE_PATH =  (heading: [HAL], title: POSTGUI_HALFILE)

2.4. Helpers

There are some helper functions - mostly used for widget support:

get_error_safe_setting(_self_, _heading_, _detail_, default=_None_)
convert_metric_to_machine(_data_)
convert_imperial_to_machine(_data_)
convert_9_metric_to_machine(_data_)
convert_9_imperial_to_machine(_data_)
convert_units(_data_)
convert_units_9(_data_)
get_filter_program(_fname_)
get_qt_filter_extensions()

Get filter extensions in Qt format.

2.5. Anwendung

  • Import Info module
    Add this Python code to your import section:

    ############################
    # **** IMPORT SECTION **** #
    ############################
    
    from qtvcp.core import Info
  • Instantiate Info module.
    Add this Python code to your instantiate section:

    ###########################################
    # **** BIBLIOTHEKEN INSTANZIIEREN **** #
    ###########################################
    
    INFO = Info()
  • Access INFO data Use this general syntax:

    home_state = INFO.NO_HOME_REQUIRED
    if INFO.MACHINE_IS_METRIC is True:
        print('Metric based')

3. Action

Action library is used to command LinuxCNC’s motion controller.

It tries to hide incidental details and add convenience methods for developers.

3.1. Helpers

Es gibt einige Hilfsfunktionen, die hauptsächlich für die Unterstützung dieser Bibliothek verwendet werden:

get_jog_info (_num_)
jnum_check(_num_)
ensure_mode(_modes_)
open_filter_program(_filename_, _filter_)

Öffnen Sie das G-Code-Filterprogramm.

3.2. Anwendung

  • Import Action module
    Add this Python code to your import section:

    ############################
    # **** IMPORT SECTION **** #
    ############################
    
    from qtvcp.core import Action
  • Instantiate Action module
    Add this Python code to your instantiate section:

    ###########################################
    # **** BIBLIOTHEKEN INSTANZIIEREN **** #
    ###########################################
    
    ACTION = Action()
  • Access ACTION commands
    Use general syntax such as these:

    ACTION.SET_ESTOP_STATE(state)
    ACTION.SET_MACHINE_STATE(state)
    
    ACTION.SET_MACHINE_HOMING(joint)
    ACTION.SET_MACHINE_UNHOMED(joint)
    
    ACTION.SET_LIMITS_OVERRIDE()
    
    ACTION.SET_MDI_MODE()
    ACTION.SET_MANUAL_MODE()
    ACTION.SET_AUTO_MODE()
    
    ACTION.SET_LIMITS_OVERRIDE()
    
    ACTION.CALL_MDI(code)
    ACTION.CALL_MDI_WAIT(code)
    ACTION.CALL_INI_MDI(number)
    
    ACTION.CALL_OWORD()
    
    ACTION.OPEN_PROGRAM(filename)
    ACTION.SAVE_PROGRAM(text_source, fname):
    
    ACTION.SET_AXIS_ORIGIN(axis,value)
    ACTION.SET_TOOL_OFFSET(axis,value,fixture = False)
    
    ACTION.RUN()
    ACTION.ABORT()
    ACTION.PAUSE()
    
    ACTION.SET_MAX_VELOCITY_RATE(rate)
    ACTION.SET_RAPID_RATE(rate)
    ACTION.SET_FEED_RATE(rate)
    ACTION.SET_SPINDLE_RATE(rate)
    
    ACTION.SET_JOG_RATE(rate)
    ACTION.SET_JOG_INCR(incr)
    ACTION.SET_JOG_RATE_ANGULAR(rate)
    ACTION.SET_JOG_INCR_ANGULAR(incr, text)
    
    ACTION.SET_SPINDLE_ROTATION(direction = 1, rpm = 100, number = 0)
    ACTION.SET_SPINDLE_FASTER(number = 0)
    ACTION.SET_SPINDLE_SLOWER(number = 0)
    ACTION.SET_SPINDLE_STOP(number = 0)
    
    ACTION.SET_USER_SYSTEM(system)
    
    ACTION.ZERO_G92_OFFSET()
    ACTION.ZERO_ROTATIONAL_OFFSET()
    ACTION.ZERO_G5X_OFFSET(num)
    
    ACTION.RECORD_CURRENT_MODE()
    ACTION.RESTORE_RECORDED_MODE()
    
    ACTION.SET_SELECTED_AXIS(jointnum)
    
    ACTION.DO_JOG(jointnum, direction)
    ACTION.JOG(jointnum, direction, rate, distance=0)
    
    ACTION.TOGGLE_FLOOD()
    ACTION.SET_FLOOD_ON()
    ACTION.SET_FLOOD_OFF()
    
    ACTION.TOGGLE_MIST()
    ACTION.SET_MIST_ON()
    ACTION.SET_MIST_OFF()
    
    ACTION.RELOAD_TOOLTABLE()
    ACTION.UPDATE_VAR_FILE()
    
    ACTION.TOGGLE_OPTIONAL_STOP()
    ACTION.SET_OPTIONAL_STOP_ON()
    ACTION.SET_OPTIONAL_STOP_OFF()
    
    ACTION.TOGGLE_BLOCK_DELETE()
    ACTION.SET_BLOCK_DELETE_ON()
    ACTION.SET_BLOCK_DELETE_OFF()
    
    ACTION.RELOAD_DISPLAY()
    ACTION.SET_GRAPHICS_VIEW(view)
    
    ACTION.UPDATE_MACHINE_LOG(text, option=None):
    
    ACTION.CALL_DIALOG(command):
    
    ACTION.HIDE_POINTER(state):
    
    ACTION.PLAY_SOUND(path):
    ACTION.PLAY_ERROR():
    ACTION.PLAY_DONE():
    ACTION.PLAY_READY():
    ACTION.PLAY_ATTENTION():
    ACTION.PLAY_LOGIN():
    ACTION.PLAY_LOGOUT():
    ACTION.SPEAK(speech):
    
    ACTION.BEEP():
    ACTION.BEEP_RING():
    ACTION.BEEP_START():
    
    ACTION.SET_DISPLAY_MESSAGE(string)
    ACTION.SET_ERROR_MESSAGE(string)

4. Tool

This library handles tool offset file changes.

Warnung
LinuxCNC doesn’t handle third party manipulation of the tool file well.

4.1. Helpers

GET_TOOL_INFO(_toolnumber_)

This will return a Python list of information on the requested tool number.

GET_TOOL_ARRAY()

This return a single Python list of Python lists of tool information.

This is a raw list formed from the system tool file.

ADD_TOOL(_newtool_ = [_-99, 0,'0','0','0','0','0','0','0','0','0','0','0','0', 0,'New Tool'_])

This will return a Python tuple of two Python lists of Python lists of tool information:

  • [0] will be real tools information

  • [1] will be wear tools information (tool numbers will be over 10000; Fanuc style tool wear)

By default, adds a blank tool entry with tool number -99.
You can preload the newtool array with tool information.

DELETE_TOOLS(_toolnumber_)

Delete the numbered tool.

SAVE_TOOLFILE(_toolarray_)

This will parse the toolarray and save it to the tool file specified in the INI file as the tool path.

This tool array must contain all the available tools information.

This array is expected to use the LinuxCNC raw tool array, i.e. it does not feature tool wear entries.

It will return True if there was an error.

CONVERT_TO_WEAR_TYPE(_toolarray_)

This function converts a LinuxCNC raw tool array to a QtVCP tool array.

QtVCP’s tool array includes entries for X and Z axis tool wear.

LinuxCNC supports tool wear by adding tool wear information into tool entries above 10000.

Anmerkung
This also requires remap code to add the wear offsets at tool change time.
CONVERT_TO_STANDARD_TYPE(_toolarray_)

This function converts QtVCP’s tool array into a LinuxCNC raw tool array.

QtVCP’s array includes entries for X and Z axis tool wear.

LinuxCNC supports tool wear by adding tool wear information into tool entries above 10000.

Anmerkung
This also requires remap code to add the wear offsets t tool change time.

5. Path

Path module gives reference to important files paths.

5.1. Referenzierte Pfade

PATH.PREFS_FILENAME

The preference file path.

PATH.WORKINGDIR

The directory QtVCP was launched from.

PATH.IS_SCREEN

Is this a screen or a VCP?

PATH.CONFIGPATH

Launched configuration folder.

PATH.RIPCONFIGDIR

The Run-in-place config folder for QtVCP screens.

PATH.BASEDIR

Base folder for LinuxCNC.

PATH.BASENAME

The Qt Designer files name (no ending).

PATH.IMAGEDIR

The QtVCP image folder.

PATH.SCREENDIR

The QtVCP builtin Screen folder.

PATH.PANELDIR

The QtVCP builtin VCP folder.

PATH.HANDLER

Handler-Datei Pfad.

PATH.HANDLERDIR

Directory where the Python handler file was found.

PATH.XML

QtVCP UI file path.

PATH.HANDLERDIR

Directory where the UI file was found.

PATH.QSS

QtVCP QSS file path.

PATH.PYDIR

LinuxCNCs Python-Bibliothek.

PATH.LIBDIR

Der Ordner der QtVCP-Bibliothek.

PATH.WIDGET

Der QtVCP-Widget-Ordner.

PATH.PLUGIN

Der QtVCP-Widget-Plugin-Ordner.

PATH.VISMACHDIR

Verzeichnis, in dem sich die vorgefertigten Vismach-Dateien befinden.

Derzeit nicht verwendet:

PATH.LOCALEDIR

Ordner für Übersetzungen.

PATH.DOMAIN

Translation domain.

5.2. Helpers

Es sind einige Hilfsfunktionen verfügbar:

file_list = PATH.find_vismach_files()
directory_list = PATH.find_screen_dirs()
directory_list = PATH.find_panel_dirs()

5.3. Anwendung

  • Import Path module
    Add this Python code to your import section:

    ############################
    # **** IMPORT SECTION **** #
    ############################
    
    from qtvcp.core import Path
  • Instantiate Path module
    Add this Python code to your instantiate section:

    ###########################################
    # **** BIBLIOTHEKEN INSTANZIIEREN **** #
    ###########################################
    
    PATH = Path()

6. VCPWindow

VCPWindow module gives reference to the MainWindow and widgets.

Typically this would be used for a library (e.g., the toolbar library uses it) as the widgets get a reference to the MainWindow from the _hal_init() function.

6.1. Anwendung

  • Import VCPWindow module
    Add this Python code to your import section:

    ############################
    # **** IMPORT SECTION **** #
    ############################
    
    from qtvcp.qt_makegui import VCPWindow
  • Instantiate VCPWindow module+ Add this Python code to your instantiate section:

    ###########################################
    # **** BIBLIOTHEKEN INSTANZIIEREN **** #
    ###########################################
    
    WIDGETS = VCPWindow()

7. Aux_program_loader

Aux_program_loader module allows an easy way to load auxiliary programs LinuxCNC often uses.

7.1. Helpers

load_halmeter()

Halmeter wird zur Anzeige von Daten eines HAL-Pins verwendet.
Laden Sie ein Halmeter mit:

AUX_PRGM.load_halmeter()
load_ladder()

SPS-Programm ClassicLadder laden:

AUX_PRGM.load_ladder()
load_status()

Laden des LinuxCNC status Programms:

AUX_PRGM.load_status()
load_halshow()

HALshow laden, Anzeigeprogramm konfigurieren:

AUX_PRGM.load_halshow()
load_halscope()

Laden des HALscope Programms:

AUX_PRGM.load_halscope()
load_tooledit()

Programm Tooledit laden:

AUX_PRGM.load_tooledit(<TOOLEFILE_PATH>)
load_calibration()

Programm zur Kalibrierung laden:

AUX_PRGM.load_calibration()
keyboard_onboard()

Load onboard/Matchbox keyboard

AUX_PRGM.keyboard_onboard(<ARGS>)

7.2. Anwendung

  • Import Aux_program_loader module
    Add this Python code to your import section:

############################
# **** IMPORT SECTION **** #
############################

from qtvcp.lib.aux_program_loader import Aux_program_loader
  • Instantiate Aux_program_loader module
    Add this Python code to your instantiate section:

###########################################
# **** BIBLIOTHEKEN INSTANZIIEREN **** #
###########################################

AUX_PRGM = Aux_program_loader()

8. Keylookup

Keylookup module is used to allow keypresses to control behaviors such as jogging.

It’s used inside the handler file to facilitate creation of key bindings such as keyboard jogging, etc.

8.1. Anwendung

Import Keylookup module

Um diese Module zu importieren, fügen Sie diesen Python-Code in Ihren Import-Abschnitt ein:

############################
# **** IMPORT SECTION **** #
############################

from qtvcp.lib.keybindings import Keylookup
Instanziieren des Moduls Keylookup

To instantiate Keylookup module* so you can use it, add this Python code to your instantiate section:

###########################################
# **** BIBLIOTHEKEN INSTANZIIEREN **** #
###########################################

KEYBIND = Keylookup()
Anmerkung
Add Key Bindings
Keylookup requires code under the processed_key_event function to call KEYBIND.call().
Most handler files already have this code.

In der Handler-Datei, unter der initialisierten Funktion verwenden Sie diese allgemeine Syntax, um Tastenbindungen zu erstellen:

KEYBIND.add_call("DEFINED_KEY","FUNCTION TO CALL", USER DATA)

Hier fügen wir eine Tastenbindung für F10, F11 und F12 hinzu:

##########################################
# Spezielle Funktionen, die von QtVCP aufgerufen werden
##########################################

# zu diesem Zeitpunkt:
# sind die Widgets instanziiert.
# die HAL-Pins sind gebaut, aber HAL ist nicht bereit
def initialized__(self):
    KEYBIND.add_call('Key_F10','on_keycall_F10',None)
    KEYBIND.add_call('Key_F11','on_keycall_override',10)
    KEYBIND.add_call('Key_F12','on_keycall_override',20)

Und dann müssen wir die Funktionen hinzufügen, die aufgerufen werden.
Fügen Sie in der Handler-Datei unter dem Abschnitt KEY BINDING CALLS Folgendes hinzu:

#####################
# KEY BINDING CALLS #
#####################

def on_keycall_F12(self,event,state,shift,cntrl,value):
    if state:
        print('F12 pressed')

def on_keycall_override(self,event,state,shift,cntrl,value):
    if state:
        print('value = {}'.format(value))

8.2. Key Defines

Here is a list of recognized key words. Use the quoted text.
Letter keys use Key_ with the upper or lower letter added.
e.g., Key_a and Key_A.

keys = {
    Qt.Key_Escape: "Key_Escape",
    Qt.Key_Tab: "Key_Tab",
    Qt.Key_Backtab: "Key_Backtab",
    Qt.Key_Backspace: "Key_Backspace",
    Qt.Key_Return: "Key_Return",
    Qt.Key_Enter: "Key_Enter",
    Qt.Key_Insert: "Key_Insert",
    Qt.Key_Delete: "Key_Delete",
    Qt.Key_Pause: "Key_Pause",
    Qt.Key_Print: "Key_Print",
    Qt.Key_SysReq: "Key_SysReq",
    Qt.Key_Clear: "Key_Clear",
    Qt.Key_Home: "Key_Home",
    Qt.Key_End: "Key_End",
    Qt.Key_Left: "Key_Left",
    Qt.Key_Up: "Key_Up",
    Qt.Key_Right: "Key_Right",
    Qt.Key_Down: "Key_Down",
    Qt.Key_PageUp: "Key_PageUp",
    Qt.Key_PageDown: "Key_PageDown",
    Qt.Key_Shift: "Key_Shift",
    Qt.Key_Control: "Key_Control",
    Qt.Key_Meta: "Key_Meta",
    # Qt.Key_Alt: "Key_Alt",
    Qt.Key_AltGr: "Key_AltGr",
    Qt.Key_CapsLock: "Key_CapsLock",
    Qt.Key_NumLock: "Key_NumLock",
    Qt.Key_ScrollLock: "Key_ScrollLock",
    Qt.Key_F1: "Key_F1",
    Qt.Key_F2: "Key_F2",
    Qt.Key_F3: "Key_F3",
    Qt.Key_F4: "Key_F4",
    Qt.Key_F5: "Key_F5",
    Qt.Key_F6: "Key_F6",
    Qt.Key_F7: "Key_F7",
    Qt.Key_F8: "Key_F8",
    Qt.Key_F9: "Key_F9",
    Qt.Key_F10: "Key_F10",
    Qt.Key_F11: "Key_F11",
    Qt.Key_F12: "Key_F12",
    Qt.Key_F13: "Key_F13",
    Qt.Key_F14: "Key_F14",
    Qt.Key_F15: "Key_F15",
    Qt.Key_F16: "Key_F16",
    Qt.Key_F17: "Key_F17",
    Qt.Key_F18: "Key_F18",
    Qt.Key_F19: "Key_F19",
    Qt.Key_F20: "Key_F20",
    Qt.Key_F21: "Key_F21",
    Qt.Key_F22: "Key_F22",
    Qt.Key_F23: "Key_F23",
    Qt.Key_F24: "Key_F24",
    Qt.Key_F25: "Key_F25",
    Qt.Key_F26: "Key_F26",
    Qt.Key_F27: "Key_F27",
    Qt.Key_F28: "Key_F28",
    Qt.Key_F29: "Key_F29",
    Qt.Key_F30: "Key_F30",
    Qt.Key_F31: "Key_F31",
    Qt.Key_F32: "Key_F32",
    Qt.Key_F33: "Key_F33",
    Qt.Key_F34: "Key_F34",
    Qt.Key_F35: "Key_F35",
    Qt.Key_Super_L: "Key_Super_L",
    Qt.Key_Super_R: "Key_Super_R",
    Qt.Key_Menu: "Key_Menu",
    Qt.Key_Hyper_L: "Key_HYPER_L",
    Qt.Key_Hyper_R: "Key_Hyper_R",
    Qt.Key_Help: "Key_Help",
    Qt.Key_Direction_L: "Key_Direction_L",
    Qt.Key_Direction_R: "Key_Direction_R",
    Qt.Key_Space: "Key_Space",
    Qt.Key_Any: "Key_Any",
    Qt.Key_Exclam: "Key_Exclam",
    Qt.Key_QuoteDbl: "Key_QuoteDdl",
    Qt.Key_NumberSign: "Key_NumberSign",
    Qt.Key_Dollar: "Key_Dollar",
    Qt.Key_Percent: "Key_Percent",
    Qt.Key_Ampersand: "Key_Ampersand",
    Qt.Key_Apostrophe: "Key_Apostrophe",
    Qt.Key_ParenLeft: "Key_ParenLeft",
    Qt.Key_ParenRight: "Key_ParenRight",
    Qt.Key_Asterisk: "Key_Asterisk",
    Qt.Key_Plus: "Key_Plus",
    Qt.Key_Comma: "Key_Comma",
    Qt.Key_Minus: "Key_Minus",
    Qt.Key_Period: "Key_Period",
    Qt.Key_Slash: "Key_Slash",
    Qt.Key_0: "Key_0",
    Qt.Key_1: "Key_1",
    Qt.Key_2: "Key_2",
    Qt.Key_3: "Key_3",
    Qt.Key_4: "Key_4",
    Qt.Key_5: "Key_5",
    Qt.Key_6: "Key_6",
    Qt.Key_7: "Key_7",
    Qt.Key_8: "Key_8",
    Qt.Key_9: "Key_9",
    Qt.Key_Colon: "Key_Colon",
    Qt.Key_Semicolon: "Key_Semicolon",
    Qt.Key_Less: "Key_Less",
    Qt.Key_Equal: "Key_Equal",
    Qt.Key_Greater: "Key_Greater",
    Qt.Key_Question: "Key_Question",
    Qt.Key_At: "Key_At",
    Qt.Key_BracketLeft: "Key_BracketLeft",
    Qt.Key_Backslash: "Key_Backslash",
    Qt.Key_BracketRight: "Key_BracketRight",
    Qt.Key_AsciiCircum: "Key_AsciiCircum",
    Qt.Key_Underscore: "Key_Underscore",
    Qt.Key_QuoteLeft: "Key_QuoteLeft",
    Qt.Key_BraceLeft: "Key_BraceLeft",
    Qt.Key_Bar: "Key_Bar",
    Qt.Key_BraceRight: "Key_BraceRight",
    Qt.Key_AsciiTilde: "Key_AsciiTilde",

}

9. Messages

Messages module is used to display pop up dialog messages on the screen.

These messages are:

  • definiert in der INI-Datei unter der Überschrift [DISPLAY], und

  • gesteuert durch HAL-Pins.

9.1. Eigenschaften

_BOLDTEXT

Generally is a title.

_TEXT

Text below title, and usually longer.

_DETAIL

Text hidden unless clicked on.

_PINNAME

Basename of the HAL pin(s).

_TYPE

Gibt an, ob es sich um Folgendes handelt: Status message - shown in the status bar and the notify dialog.
Requires no user intervention. OK message - requiring the user to click OK to close the dialog.
OK messages have two HAL pins:

  • One HAL pin to launch the dialog, and

  • One to signify it’s waiting for response. Yes/No message - requiring the user to select yes or no buttons to close the dialog.
    Yes/No messages have three HAL pins:

  • One to show the dialog,

  • One for waiting, and

  • eine für die Antwort.

By default it will send STATUS messages for focus_overlay and alert sound.

9.2. Beispiele

Hier sind Beispiele für Codeblöcke zur Definition von INI-Nachrichten, die unter der Überschrift ‚[DISPLAY]‘ zu finden sind:

  • Statusleiste und Desktop-Benachrichtigungs-Pop-up-Meldung:

    MESSAGE_BOLDTEXT = NONE
    MESSAGE_TEXT = This is a statusbar test
    MESSAGE_DETAILS = STATUS DETAILS
    MESSAGE_TYPE = status
    MESSAGE_PINNAME = statustest
  • Pop-up-Dialog mit einer Ja/Nein-Frage:

    MESSAGE_BOLDTEXT = NONE
    MESSAGE_TEXT = This is a yes no dialog test
    MESSAGE_DETAILS = Y/N DETAILS
    MESSAGE_TYPE = yesnodialog
    MESSAGE_PINNAME = yndialogtest
  • Pop-up-Dialog, der eine OK-Antwort verlangt + Statusleiste und Desktop-Benachrichtigung:

    [DISPLAY]
    MESSAGE_BOLDTEXT = Dies ist der kurze Text
    MESSAGE_TEXT = Dies ist der längere Text des Tests der beiden Typen. Er kann länger sein als der Text der Statusleiste
    MESSAGE_DETAILS = BOTH DETAILS
    MESSAGE_TYPE = okdialog status
    MESSAGE_PINNAME = bothtest

Das Widget ScreenOptions kann das Nachrichtensystem automatisch einrichten.

10. Notify

Notify module is used to send messages that are integrated into the desktop.

Es verwendet die pynotify Bibliothek.

Ubuntu/Mint folgt nicht dem Standard, so dass man nicht einstellen kann, wie lange die Meldung angezeigt wird.
Ich schlage vor, dies mit dem Paket notify-osd zu beheben, das unter dieses PPA verfügbar ist (DISCONTINUED aufgrund der Umstellung von Ubuntu auf Gnome).

Notify erhält eine Liste aller Alarmmeldungen seit dem Start in self.alarmpage.
Wenn Sie im Notify-Popup auf 'Show all messages' klicken, werden sie auf dem Terminal ausgegeben.

Das Widget ScreenOptions kann das Benachrichtigungssystem automatisch einrichten.

Typischerweise werden STATUS messages verwendet, um Benachrichtigungen zu senden.

10.1. Eigenschaften

Sie können Folgendes festlegen:

title

Titeltext der Benachrichtigung.

message

Inhalt der Benachrichtigungsnachricht.

icon

Symbol für eine Benachrichtigung.

timeout

Wie lange die Nachricht angezeigt wird.

11. Preferences

Preferences module allows one to load and save preference data permanently to storage media.

Das Widget ScreenOptions kann das Einstellungssystem automatisch einrichten.

QtVCP searches for the ScreenOptions widget first and, if found, calls _pref_init().
This will create the preferences object and return it to QtVCP to pass to all the widgets and add it to the window object attributes.
In this case the preferences object would be accessible from the handler file’s initialized_ method as self.w.PREFS_.

Außerdem können alle Widgets bei der Initialisierung Zugriff auf eine bestimmte Einstellungsdatei haben.

Das Widget ScreenOptions kann die Einstellungsdatei automatisch einrichten.

12. Player

Dieses Modul ermöglicht das Abspielen von Sounds mit Gstreamer, Beep und Espeak.

Es kann:

  • play sound/music files using Gstreamer (non blocking),

  • play sounds using the beep library (currently blocks while beeping),

  • speak words using the espeak library (non blocking while speaking).

Es gibt Standard-Warntöne, die Mint oder FreeDesktop-Standardsounds verwenden.

Sie können beliebige Sounds oder sogar Songs abspielen, indem Sie den Pfad angeben.

STATUS hat Nachrichten zur Steuerung des Player-Moduls.

Das Widget ScreenOptions kann automatisch das Audiosystem einrichten.

12.1. Töne (engl. sounds)

Alarmsignale

Es gibt Standard-Warnungen zur Auswahl:

  • ERROR

  • READY

  • ATTENTION

  • RING

  • DONE

  • LOGIN

  • LOGOUT

Pieptöne

Es gibt drei Pieptöne:

  • BEEP_RING

  • BEEP_START

  • BEEP

12.2. Anwendung

  • Import Player module
    Add this Python code to your import section:

    ############################
    # **** IMPORT SECTION **** #
    ############################
    
    from qtvcp.lib.audio_player import Player
  • Instantiate Player module
    Add this Python code to your instantiated section:

    ###########################################
    # **** BIBLIOTHEKEN INSTANZIIEREN **** #
    ###########################################
    
    SOUND = Player()
    SOUND._register_messages()

    Die Funktion _register_messages() verbindet den Audioplayer mit der STATUS-Bibliothek, so dass Klänge mit dem STATUS-Meldungssystem abgespielt werden können.

12.3. Beispiel

To play sounds upon STATUS messages, use these general syntaxes:

STATUS.emit('play-alert','LOGOUT')
STATUS.emit('play-alert','BEEP')
STATUS.emit('play-alert','SPEAK This is a test screen for Q t V C P')
STATUS.emit('play-sound', 'PATH TO SOUND')

13. Virtuelle Tastatur

Diese Bibliothek ermöglicht es Ihnen, mit STATUS-Nachrichten eine virtuelle Tastatur zu starten.

It uses Onboard or Matchbox libraries for the keyboard.

14. Toolbar Actions

Diese Bibliothek liefert vorgefertigte Untermenüs und Aktionen für Symbolleistenmenüs und Symbolleistenschaltflächen.

Toolbuttons, menu and toolbar menus are:

  • built in Qt Designer, and

  • zugewiesene Aktionen/Untermenüs in der Handler-Datei.

14.1. Aktionen

estop
power
load
reload
gcode_properties
run
pause
abort
block_delete
optional_stop
touchoffworkplace
touchofffixture
runfromline
load_calibration
load_halmeter
load_halshow
load_status
load_halscope
about
zoom_in
zoom_out
view_x
view_y
view_y2
view_z
view_z2
view_p
view_clear
show_offsets
quit
system_shutdown
tooloffsetdialog
originoffsetdialog
calculatordialog
alphamode
inhibit_selection
show_dimensions

Schaltet die Anzeige der Dimensionen um.

14.2. Untermenüs

recent_submenu
home_submenu
unhome_submenu
zero_systems_submenu
grid_size_submenu

Menu to set graphic grid size

14.3. Anwendung

Hier ist der typische Code, der zu den entsprechenden Abschnitten der Handler-Datei hinzuzufügen ist:

############################
# **** IMPORT SECTION **** #
############################

from qtvcp.lib.toolbar_actions import ToolBarActions

###########################################
**** Bibliotheken instanziieren Abschnitt **** #
###########################################

TOOLBAR = ToolBarActions()

14.4. Beispiele

  • Assigning Tool Actions To Toolbar Buttons

    ##########################################
    # Spezielle Funktionen, die von QtVCP aufgerufen werden
    ##########################################
    
    # At this point:
    #   * the widgets are instantiated,
    #   * the HAL pins are built but HAL is not set ready.
    def initialized__(self):
        TOOLBAR.configure_submenu(self.w.menuHoming, 'home_submenu')
        TOOLBAR.configure_action(self.w.actionEstop, 'estop')
        TOOLBAR.configure_action(self.w.actionQuit, 'quit', lambda d:self.w.close())
        TOOLBAR.configure_action(self.w.actionEdit, 'edit', self.edit)
        # Add a custom function
        TOOLBAR.configure_action(self.w.actionMyFunction, 'my_Function', self.my_function)
  • Hinzufügen einer benutzerdefinierten Symbolleistenfunktion:

    #####################
    # GENERAL FUNCTIONS #
    #####################
    
    def my_function(self, widget, state):
        print('My function State = ()'.format(state))

15. Qt Vismach Machine Graphics library

Qt_vismach is a set of Python functions that can be used to create and animate models of machines.

Vismach:

  • displays the model in a 3D viewport

  • animates the model parts as the values of associated HAL pins change.

This is the Qt based version of the library, there is also a tkinter version available in LinuxCNC.

The Qt version allows embedding the simulation in other screens.

15.1. Integrierte Beispiele

There are included sample panels in QtVCP for:

  • a 3-Axis XYZ mill,

  • a 5-Axis gantry mill,

  • a 3-Axis mill with an A axis/spindle, and

  • a scara mill.

Most of these samples, if loaded after a running LinuxCNC configuration (including non-QtVCP based screens), will react to machine movement.
Some require HAL pins to be connected for movement.

From a terminal (pick one):

qtvcp vismach_mill_xyz
qtvcp vismach_scara
qtvcp vismach_millturn
qtvcp vismach_5axis_gantry

15.2. Primitives-Bibliothek

Provides the basic building blocks of a simulated machine.

Collection

A collection is an object of individual machine parts.

Diese enthält eine hierarchische Liste von primitiven Formen oder STL-Objekten, auf die Operationen angewendet werden können.

Translate

This object will perform an OpenGL translation calculation on a Collection object.

Translation refers to moving an object in straight line to a different position on screen.

Scale

This object will perform an OpenGL scale function on a collection object.

HalTranslate

This object will perform an OpenGL translation calculation on a Collection object, offset by the HAL pin value.

Translation refers to moving an object in straight line to a different position on screen.

You can either:

  • read a pin from a component owned by the Vismach object, or

  • direktes Lesen eines HAL-Systempins, wenn das Komponentenargument auf None gesetzt ist.

Rotate

This object will perform an OpenGL rotation calculation on a Collection object.

HalRotate

This object will perform an OpenGL rotation calculation on a Collection object, offset by the HAL pin value.

You can either:

  • read a pin from a component owned by the vismach object, or

  • direktes Lesen eines HAL-Systempins, wenn das Komponentenargument auf None gesetzt ist.

HalToolCylinder

Dieses Objekt erstellt eine CylinderZ object, die Größe und Länge basierend auf der geladenen Werkzeugdefinition (aus der Werkzeugtabelle) ändert

It reads the halui.tool.diameter and motion.tooloffset.z HAL pins.

Beispiel aus dem mill_xyz-Beispiel:

toolshape = CylinderZ(0)
toolshape = Color([1, .5, .5, .5], [toolshape])
tool = Collection([
    Translate([HalTranslate([tooltip], None, "motion.tooloffset.z", 0, 0, -MODEL_SCALING)], 0, 0, 0),
    HalToolCylinder(toolshape)
])
Track

Move and rotate an object to point from one capture() 'd coordinate system to another.

Base object to hold coordinates for primitive shapes.

CylinderX, CylinderY, CylinderZ

Build a cylinder on the X, Y or Z axis by giving endpoint (X, Y, or Z) and radii coordinates.

Sphere

Build a sphere from center and radius coordinates.

TriangleXY, TriangleXZ, TriangleYZ

Build a triangle in the specified plane by giving the corners Z coordinates for each side.

ArcX

Build an arc by specifying

Box

Build a box specified by the 6 vertex coordinates.

BoxCentered

Build a box centered on origin by specifying the width in X and Y, and the height in Z.

BoxCenteredXY

Build a box centered in X and Y, and running from Z=0, by specifying the width in X and Y, and running up or down to the specified height in Z.

Capture

Capture current transformation matrix of a collection.

Anmerkung
This transforms from the current coordinate system to the viewport system, NOT to the world system.
Hud

Heads up display draws a semi-transparent text box.

Use:

  • HUD.strs for things that must be updated constantly,

  • HUD.show("stuff") for one-shot things like error messages.

Color

Applies a color to the parts of a collection.

AsciiSTL, AsciiOBJ

Loads a STL or OBJ data file as a Vismach part.

15.3. Anwendung

Import a simulation

Here is how one might import the XYZ_mill simulation in a QtVCP panel or screen handler file.

############################
# **** IMPORT SECTION **** #
############################

import mill_xyz as MILL
Instantiate and use the simulation widget

Instanziieren Sie das Simulations-Widget und fügen Sie es dem Hauptlayout des Bildschirms hinzu:

##########################################
# Spezielle Funktionen, die von QtVCP aufgerufen werden
##########################################

# At this point:
#   * the widgets are instantiated,
#   * the HAL pins are built but HAL is not set ready.
def initialized__(self):
    machine = MILL.Window()
    self.w.mainLayout.addWidget(machine)

15.4. Mehr zum Thema

Weitere Informationen über die Erstellung einer benutzerdefinierten Maschinensimulation finden Sie im Kapitel zu Qt Vismach.