slmsuite.hardware.remote#
Provides a TCPIP client-server interface to control remote hardware.
Interface with a Server using
RemoteSLM and
RemoteCamera.
Under the hood, this uses json formatting with
zlib compression used for any numpy data, including especially
megapixel phase masks and megapixel camera images.
Danger
This interface will operate best in a secure and trusted local network.
Hosting a server on a public IP raises some risk of tampering
(even with an allowlist, as IP addresses can be spoofed).
Communication is locked down to only the few commands that are required
by an abstract camera or SLM to reduce risk.
However, there are no protections against DDOS attack or similar and
communication is not encrypted or authenticated.
In the future, if there is interest, SSH authentication could be added, and the scope of commands offered could be expanded beyond the required abstract commands to also include whatever hardware-specific functionality is implemented. Moreover, CameraSLMs could be hosted on a server such that system calibrations could live in the cloud.
Example
The following is a simple example of a setup communicating between two
threads—for example, two Jupyter notebooks—on the same computer (via localhost:5025).
The server hosts a simulated SLM and camera:
# Server notebook
from slmsuite.hardware.slms.simulated import SimulatedSLM
from slmsuite.hardware.cameras.simulated import SimulatedCamera
from slmsuite.hardware.remote import Server
slm = SimulatedSLM((1600, 1200), pitch_um=(8,8), name="remote_slm")
cam = SimulatedCamera(slm, (1440, 1100), pitch_um=(4,4), gain=50, name="remote_camera")
server = Server(
hardware=[slm, cam],
port=5025,
)
The client connects to this hardware:
# Client notebook
from slmsuite.hardware.slms.remote import RemoteSLM
from slmsuite.hardware.cameras.remote import RemoteCamera
slm = RemoteSLM(
name="remote_slm"
host="localhost",
port=5025,
)
cam = RemoteCamera(
name="remote_camera"
host="localhost",
port=5025,
)
slm.set_phase(None)
cam.get_image()
cam.plot()
Classes
Server for handling client commands and interfacing with hardware. |