pylab_ml.gui.instruments.regs.registermaster.Gui
- class Gui(parent=None, name='reg', parentwindow=None, channel=None)[source]
Bases:
GuiSimple basic GUI for the Registermaster.
- Inherited from base_instrument
status
- __init__(parent=None, name='reg', parentwindow=None, channel=None)[source]
Initialize the GUI for the registermaster.
- Parameters:
parent (QWidget, optional) – The parent widget of the GUI.
name (str, optional) – The name of the GUI instance.
parentwindow (QWidget, optional) – The parent window of the GUI.
channel (int, optional) – The channel number for the registermaster.
Methods
__init__([parent, name, parentwindow, channel])Initialize the GUI for the registermaster.
add_menue(menue, connect, enabled[, ...])Add a menue item to Setup
add_menuicon(typ[, connect])Add icon and action to the menu.
adjustUI()Adjust the UI, set the title and icons and connect the quit action.
close([event])Handle the close event for the GUI by publishing an 'off' command and then calling the base class's close method.
dprint(msg)Print a debug message if debugging is enabled.
filtersubtopic(value)Filter the subtopic from the value, if the value starts with the topinstname.
gui2mqtt(widget)Function connect a Gui-widget to mqtt, it sends a mqtt set command with the value from the Gui-widget.
Disconnect the GUI, set the MQTT status to "disconnect" and disable the frame.
hide()Hide the GUI.
Return whether the GUI is currently visible.
memoryframe(adr, value)Update the memory frame in the GUI with the given address and value.
mqttConnectSVGWidget(filename, name[, channel])Create an InteractiveSvgWidget and load the filname.
Connect all object which start with MQTT_ to the function gui2mqtt().
mqttreceive(instName, msg)Common MQTT receive messages, get raw MQTT data for more information.
Adjust the GUI elements for the registermaster.
objectName2mqttName(name)Filter from the object name the right MQTT name.
Open the current Excel file.
publish(cmd[, value, instName])Publish a command and value over MQTT.
readreg(regname)Read the value of a register.
registerframe(register, value)Update the register frame in the GUI with the given register and value.
regstatus(msg)Update the status label in the GUI with the given message.
retranslateUi(Form)Retranslate the UI, set the text of the widgets.
setLabel(Label, value[, ext])Set the text of a label.
set_Geometry(geometry)Set the geometry of the GUI, check if the geometry is on the actual screen.
show()Show the GUI.
showdoc(action, label)Show or hide the documentation for a given label based on the state of the corresponding action.
Show or hide the documentation for all registers based on the state of the corresponding actions.
svg2mqtt(name, value)Publish the name and value over mqtt.
toggleBhold(hold)Toggle the state of the hold button and update its icon accordingly.
unitOfMeasurement(value[, unit])Convert a value with a unit to its numerical representation.
Attributes
Get the current filename.
Return the id of the instrument, which is used for MQTT topics.
Return the MQTT status of the instrument, which is either "connect" or "disconnect".
Return the current status message from the status bar.
Return the subtopic of the instrument, which is the part after the topinstname.
Add a menue item to Setup
- Parameters:
menue (string) – The text of the menu item.
connect (function) – The function to be called when the menu item is triggered.
enabled (bool) – Whether the menu item is enabled.
checkable (bool, optional) – Whether the menu item is checkable. The default is False.
checked (bool, optional) – Whether the menu item is checked. The default is False.
Add icon and action to the menu.
- Parameters:
typ (string) – The type of the menu item.
connect (function, optional) – The function to be called when the menu item is triggered. The default is None.W
“onoff” : on/off
- close(event=None)[source]
Handle the close event for the GUI by publishing an ‘off’ command and then calling the base class’s close method.
- property filename
Get the current filename.
- filtersubtopic(value)[source]
Filter the subtopic from the value, if the value starts with the topinstname.
- gui2mqtt(widget)[source]
Function connect a Gui-widget to mqtt, it sends a mqtt set command with the value from the Gui-widget.
- Parameters:
widget (QtWidgets.QWidget) – The GUI widget that triggered the MQTT command, expected to have an objectName that follows the
- Return type:
None.
- gui_disconnect()[source]
Disconnect the GUI, set the MQTT status to “disconnect” and disable the frame.
- property id
Return the id of the instrument, which is used for MQTT topics.
- memoryframe(adr, value)[source]
Update the memory frame in the GUI with the given address and value.
- Parameters:
adr (int) – The address of the memory location.
value (int) – The value to set for the memory location.
- mqttConnectSVGWidget(filename, name, channel=None)[source]
Create an InteractiveSvgWidget and load the filname. Connect all clicks to the text id’s to the function svg2mqtt().
- Parameters:
filename (string) – The path to the SVG file to be loaded into the widget.
name (string) – The base name for the widget, used for MQTT topic construction.
channel (string, optional) – An optional channel identifier to be appended to the name for MQTT topic construction. The default is None.
- Returns:
svgWidget – The created InteractiveSvgWidget with the loaded SVG file and connected signals.
- Return type:
- mqttConnectWidgets()[source]
Connect all object which start with MQTT_ to the function gui2mqtt().
Create a list with all commands in self.mqtt_cmds
- property mqtt_status
Return the MQTT status of the instrument, which is either “connect” or “disconnect”.
- mqttreceive(instName, msg)[source]
Common MQTT receive messages, get raw MQTT data for more information.
- Parameters:
instName (str) – The name of the instrument instance.
msg (dict) – The MQTT message received.
- objectName2mqttName(name)[source]
Filter from the object name the right MQTT name.
- eg. objectname = MQTT_voltage -> Voltage listen on get and set
= MQTT_set_I_limit -> I_limit listen only on set = MQTT_get_I_limit -> I_limit listen only on get = TAB_ch -> Name for a tab-name
- Parameters:
name (string) – The object name to be filtered.
- Returns:
listen (string) – The type of MQTT command to listen for (“set”, “get”, or “”).
result (string) – The filtered MQTT name extracted from the object name.
- publish(cmd, value='', instName=None)[source]
Publish a command and value over MQTT.
- Parameters:
cmd (string) – The command to be published.
value (string, optional) – The value associated with the command. The default is an empty string.
instName (string, optional) – The name of the instrument. If None, the instance’s name is used. The default is None.
- registerframe(register, value)[source]
Update the register frame in the GUI with the given register and value.
- Parameters:
register (Register) – The register object to update.
value (int) – The value to set for the register.
- setLabel(Label, value, ext=None)[source]
Set the text of a label.
- Parameters:
Label (object) – the label object.
value (string) – this text will be displayed.
ext (string, optional) – extention, The default is None.
- Return type:
None.
- set_Geometry(geometry)[source]
Set the geometry of the GUI, check if the geometry is on the actual screen.
- Parameters:
geometry (tuple) – A tuple of the form (x, y, width, height) representing the geometry of the GUI.
- showdoc(action, label)[source]
Show or hide the documentation for a given label based on the state of the corresponding action.
- showregdoc()[source]
Show or hide the documentation for all registers based on the state of the corresponding actions.
- property status
Return the current status message from the status bar.
- property subtopic
Return the subtopic of the instrument, which is the part after the topinstname.
- svg2mqtt(name, value)[source]
Publish the name and value over mqtt. Overwrite this function if you need a more complex form.
- Parameters:
name (string) – The name of the SVG element that was changed.
value (string) – The new value of the SVG element.
- unitOfMeasurement(value, unit=None)[source]
Convert a value with a unit to its numerical representation.
- Parameters:
value (string) – The value with a unit (e.g., “10 k”).
unit (string, optional) – The unit to use for conversion. If None, the unit is inferred from the value.
- Returns:
The numerical representation of the value.
- Return type:
float