instrumentserver.client.proxy#
Created on Sat Apr 18 16:13:40 2020
@author: Chao
Classes
|
Client with common server requests as convenience functions. |
|
|
alias of |
|
|
Construct a proxy module using the given blueprint. |
|
A simple mixin class for proxy objects. |
|
Proxy for parameters. |
|
|
|
Specific subscription client used for real-time parameter updates. |
- class instrumentserver.client.proxy.Client(host='localhost', port=5555, connect=True, timeout=20, raise_exceptions=True)[source]#
Bases:
BaseClientClient with common server requests as convenience functions.
- find_or_create_instrument(name: str, instrument_class: str | None = None, *args: Any, **kwargs: Any) ProxyInstrumentModule[source]#
Looks for an instrument in the server. If it cannot find it, create a new instrument on the server. Returns a proxy for either the found or the new instrument.
- Parameters:
name – Name of the new instrument.
instrument_class – Class of the instrument to create or a string of of the class.
args – Positional arguments for new instrument instantiation.
kwargs – Keyword arguments for new instrument instantiation.
- Returns:
A new virtual instrument.
- class instrumentserver.client.proxy.ClientStation(host='localhost', port=5555, connect=True, timeout=20, raise_exceptions=True, config_path: str | None = None, param_path: str | None = None)[source]#
Bases:
object- find_or_create_instrument(name: str, instrument_class: str | None = None, *args: Any, **kwargs: Any) ProxyInstrumentModule[source]#
Looks for an instrument in the server. If it cannot find it, create a new instrument on the server. Returns a proxy for either the found or the new instrument.
- Parameters:
name – Name of the new instrument.
instrument_class – Class of the instrument to create or a string of of the class.
args – Positional arguments for new instrument instantiation.
kwargs – Keyword arguments for new instrument instantiation.
- Returns:
A new virtual instrument.
- get_instrument(name: str) ProxyInstrumentModule[source]#
- instrumentserver.client.proxy.ProxyInstrument#
alias of
ProxyInstrumentModule
- class instrumentserver.client.proxy.ProxyInstrumentModule(name: str, *args, cli: Client | None = None, host: str | None = 'localhost', port: int | None = 5555, remotePath: str | None = None, bluePrint: InstrumentModuleBluePrint | None = None, **kwargs)[source]#
Bases:
ProxyMixin,InstrumentBaseConstruct a proxy module using the given blueprint. Each proxy instantiation represents a virtual module (instrument of submodule of instrument).
- Parameters:
bluePrint – The blueprint that the describes the module.
host – The name of the host where the server lives.
port – The port number of the server.
- add_parameter(name: str, *arg, **kw)[source]#
Add a parameter to the proxy instrument.
If a parameter of that name already exists in the server-side instrument, we only add the proxy parameter. If not, we first add the parameter to the server-side instrument, and then the proxy here.
- remove_parameter(name: str, *arg, **kw)[source]#
Removes parameter from the proxy instrument.
Checking whether the paremeter exists or not is left to the instrument in the server. This is to avoid having to check on every submodule for the parameter manager.
- class instrumentserver.client.proxy.ProxyMixin(*args, cli: Client | None = None, host: str | None = 'localhost', port: int | None = 5555, remotePath: str | None = None, bluePrint: ParameterBluePrint | InstrumentModuleBluePrint | MethodBluePrint | None = None, **kwargs)[source]#
Bases:
objectA simple mixin class for proxy objects.
- askServer(message: ServerInstruction)[source]#
- class instrumentserver.client.proxy.ProxyParameter(name: str, *args, cli: Client | None = None, host: str | None = 'localhost', port: int | None = 5555, remotePath: str | None = None, bluePrint: ParameterBluePrint | None = None, setpoints_instrument: Instrument | None = None, **kwargs)[source]#
Bases:
ProxyMixin,ParameterProxy for parameters.
- Parameters:
cli – Instance of Client.
name – The parameter name.
host – The name of the host where the server lives.
port – The port number of the server.
remotePath – Path of the remote object on the server.
bluePrint – The blue print to construct the proxy parameter. If remotePath and bluePrint are both supplied, the blue print takes priority.
- class instrumentserver.client.proxy.QtClient(parent=None, host='localhost', port=5555, connect=True, timeout=5, raise_exceptions=True)[source]#
Bases:
_QtAdapter,Client
- class instrumentserver.client.proxy.SubClient(instruments: List[str] | None = None, sub_host: str = 'localhost', sub_port: int = 5556)[source]#
Bases:
QObjectSpecific subscription client used for real-time parameter updates.
- connect()[source]#
Connects the subscription client with the broadcast and runs an infinite loop to check for updates.
It should always be run on a separate thread or the program will get stuck in the loop.
- finished#
Signal emitted when the listener finishes (for proper cleanup)
- update#
Signal(ParameterBroadcastBluePrint) – emitted when the server broadcast either a new parameter or an update to an existing one.