Architecture / Development workflow / File transfer
If moving an experiment from direct to remote use forces the caller to rewrite device operations around the transport, much of the benefit of an independent DeviceClass is lost. A transparent SUSANOO API keeps control logic independent of transport and preserves the instrument API’s meaning for the caller.
Distributed execution still matters. After a disconnect, the outcome of an instrument operation may be unknown. Several callers may operate the same instrument. Account for both when designing the API.
Use the DeviceClass directly for local operation and the DeviceProxy for remote operation. Matching method names alone cannot preserve a caller’s program if a save destination or return value has different semantics. Transparency applies to the meaning of the DeviceClass API, including how it is called. An operation can be reachable through the frame without yet meeting the remote API contract.
Each instrument defines the operations it needs. If several devices need a common API, decide that in the instrument-control library independently of the transport.
When reviewing transparency, consider not only operation methods but also the requirements for initializing the instrument. The DeviceClass defines its initialization arguments and device settings; DeviceServer and DeviceProxy do not impose a separate device configuration contract.
Using Config is recommended for a DeviceClass, but it is not required. The DeviceClass determines whether to adopt Config, its format, and the device-specific settings it defines. A DeviceClass without Config can also be published remotely.
When a DeviceClass uses Config, a ServerClass or ClientClass may follow that device’s configuration design as needed. This does not require all three classes to share a Config type or configuration file. Server bind addresses and client endpoints are transport settings, distinct from instrument-control settings. Each device implementation defines how the relevant settings are passed.
Before publishing a DeviceClass, identify what must carry over and what constraints remote execution introduces. Defining transparency to hide all network behavior would imply that the result is known even when communication fails.
| Aspect | Contract defined by the DeviceClass | What to check in the DeviceServer and DeviceProxy |
|---|---|---|
| Operation | Purpose, arguments, units, and defaults | Can the caller request the same device operation? |
| Result | Return type, contents, and completion condition | Does the transfer representation become the expected return value? |
| Side effect | Instrument movement, file saves, and configuration updates | Do the effects occur in the expected location and order? |
| State | Ownership and timing of reads and updates | How does the caller observe instrument-side state? |
| Failure | Device errors, interruption, and recoverability | Can the caller distinguish transport failures from device failures? |
| Lifecycle | Connection, initialization, stop, and release semantics | Are instrument resources managed after a disconnect? |
The DeviceClass instance that owns instrument state runs on the DeviceServer. Several proxies of the same DeviceServer work with the same instrument state. Each DeviceProxy represents that instrument to its caller.
For move(position), distinguish request acceptance, submission to the instrument, and physical completion. Define when the DeviceClass returns and preserve that meaning in the DeviceProxy. Receipt of a frame response alone does not establish physical completion.
When communication fails after a request is sent, the DeviceProxy may be unable to tell whether the DeviceServer received it, is executing it, or has already completed it. Automatically retrying move() or start_measurement() can repeat an operation. Select status queries or operation identifiers where instrument behavior and operational requirements call for them. Those mechanisms require their own design.
DeviceServer and DeviceProxy are paired roles. Add a same-name override only on the side where it is needed. The ServerClass inherits the DeviceClass and handles instrument-side work and conversion. The ClientClass inherits the frame client and restores caller-side results or side effects. When the existing implementation suffices, use the DeviceClass and generic frame client.
| Operation | DeviceServer side | DeviceProxy side | When a specialized class is needed |
|---|---|---|---|
read_value() |
Read the value through the DeviceClass | Receive it | Usually neither side |
move(position) |
Move the instrument through the DeviceClass | Receive the call result | Usually neither side. Verify stop and failure semantics separately |
get_image() |
Acquire and encode the image | Reconstruct the image object if needed | Depends on the data representation |
export_data(path) |
Generate the file and return transferable data | Save to the caller’s path |
Both sides for a caller-side save |
| Continuous measurement | Measure and evaluate instrument state | Receive or stop continuous data | Separate the frame’s streams or events from device-specific handling |
For an export_data(path) operation, first determine what path means. If it is solely the caller-side destination, the client can keep it locally while the server returns transferable contents. If the argument also selects a data format or acquisition condition, that information must still reach the instrument side. Removing the entire argument from the remote call would change the API contract. File overwrite behavior, return values, and errors also remain part of that contract.
Assume that the DeviceClass’s export_data(path) promises to save a file on the caller’s computer.
Direct:
Application → DeviceClass.export_data(path) → File on the caller's host
Remote:
Application → ClientClass.export_data(path)
→ Frame → ServerClass.export_data(...)
→ Reuse the inherited export to generate the contents
← Transfer the generated contents
→ Save to path on the caller's host
The server generates the instrument-specific format, and the client interprets the destination. This division of responsibility applies independently of gRPC. The frame implements the transfer. The API determines which host owns the destination. If path is defined as a path on the instrument host, keep the save there. See the code example.
Device-specific failures belong to the DeviceClass or a transport-independent support layer. Disconnection, timeout, and transfer-format mismatches belong to the frame or the distributed execution environment. Preserve the distinction when surfacing errors through the DeviceProxy.
The DeviceServer’s operational responsibilities include handling concurrent callers, ownership of instrument resources, disconnection during measurement, stopping, and releasing resources. Transparent access still has these distributed execution constraints.
Compare the behavior observed for the same inputs through the DeviceClass and the DeviceProxy. For a reading, check the value, type, and errors. For motion or measurement startup, compare acceptance and completion. For a save, compare destination, contents, and return value.
A successful reply to move(position) can acknowledge submission without indicating completion. If the DeviceClass returns when it issues the command, preserve that behavior remotely. If it waits for movement to finish, document the DeviceServer’s completion condition and timeout. If a disconnect leaves the outcome unknown, confirm instrument state independently.
For export_data(path), verify that direct and remote calls save the same contents to the caller’s requested path. Instrument-side temporary names and transfer dictionaries are intermediate values. Return the result defined by the original API.
A ClientClass may provide auxiliary operations for connection, disconnection, or subscription. Document those alongside the instrument API contract, with the purpose of each clear.
First decide what the DeviceClass operation does, when it completes, and what happens on failure. Identify the operations whose meaning would change if they ran remotely. Ordinary reads may need only frame forwarding. Operations such as file saving, where execution location affects the result, require instrument-side or caller-side adaptations.
Then select the communication frame and client construction method. The DeviceProxy() factory simplifies construction where needed. See DeviceServer development for turning these decisions into a class layout.
Author: Kengo NAKADA