-
Notifications
You must be signed in to change notification settings - Fork 8
Remote Control
Instruments using the Instrument Framework are controlled externally by messages formatted using JSON-RPC 2.0. The message contains a "method" to invoke and optional "params" needed to execute the method. For example:
{"jsonrpc": "2.0", "method": "setMagnetField", "params": [9], "id": 1}
An example of an instrument API is "Set Magnet.vi":

The PPMS and Oxford 18T magnets use different method names, Set Magnet and setMagnetField, respectively. (It is not critical that they're the same, they just have to be self-consistent within an instrument type. Making them the same would be better for general lab-wide organization.)


Set Magnet.vi uses 4 parameters (params): Field (T), Rate (T/min), Axis [z,x,y], Mode [persistent, driven]
An example JSON-RPC request:
{"jsonrpc":"2.0","method":"setMagnetField","params":{"Field":0,"Rate":0,"Axis":"Z","Mode":"Persistent"},"id":"ac3caf5f75f9d4ed9b1bf5cd8a3812d2"}

PPMS:Set Magnet.vi combines the first 3 using a typedef cluster, and ignores Axis:

The subVI "Remote Client.vi" handles formatting the message and sending over the appropriate communication channel (most often ZMQ over TCP).
This class is used to handle formatting and parsing JSON-RPC objects, of which there are two types: **Request ** and Response. There are four main methods of the JSON-RPC.lvclass:
- Create Request
- Parse Request (also Parse Params)
- Create Response
- Parse Response

Here "Command" = "Method" and "Data" = "Params" Create Request.vi converts Command and Data into a JSON-RPC Request Object simply a text string. That string is sent using zmq_send_multi.vi.