Skip to main content

Federations

With SA VSCode you can connect to federations to interact with edge devices. For more information about federations we refer to the Federations section of the System description chapter in the SA Engine manual.

Connect to federation

To connect to a federation you need a connection blob for the specific federation. SA Studio comes with a preconfigured federation, so if you have signed up for SA Studio you have a federation you can use to interact with your edge devices. How to get the connection blob for your SA Studio federation is described in the Connecting edge devices chapter of the SA Studio manual.

When you have the connection blob for your federation you can use the function federation:save() to save the connection blob to a file. This will save the connection blob in SA_HOME/federations/<file>.

Save a federation connection blob with the federation:save() function.

Your stored federations are listed in the Federations drop down on the SA tab. If your saved federation is not present in the list you can refresh the list with the rotating arrows button and your saved federation will appear.

Federations are listed in the Federations drop down list on the SA tab.

To connect to one of your stored federations you can click the connection button next to the federation name in the list. It will say "connected" next to the federation when you are connected to it.

Connect to federation with the connect button next to the federation name.

Setup a local federation

VS Code also contains a local federation that is always listed in the Federations drop down on the SA tab. This can be used to communicate with edges available locally.

To enable the local federation, click the connection button next to the federation name in the list. This will start a local Nameserver and connect your VS Code instance to it as ME.

A local federation.

Read more about local federations in CLI Local federations

Interact with edge devices

In the federations drop down you can see the peers connected to the federation. In the figure below we see that we have a connected edge called "ANDROID-EDGE".

Connected peers are listed in the Federations drop down list.

Running individual queries on peers

You can run queries on peers connected to the federation by specifying //peer: <peer-id> at the top of the query (similar to how you specify visualization format, see Visualization). In the figure below we run signal_stream() on the Android device connected to the federation by specifying //peer: android-edge at the top of the query. Notice that if you expand the peer in the Federations drop down you can see the query running on the device (you might have to refresh the Federations list for the running query to show).

Run a query on a peer connected to the federation by specifying //peer: <peer-id>.

You can stop the query by clicking the stop icon check_box_outline_blank next to the query in the drop down list, or with the stop icon in the top right corner of the query (shown when hovering with the mouse over the query) in the interactive window as described in the Code execution section.

Setting default peer

In the bottom right corner of the status bar, default peer can be selected. Queries that do not have a peer-id specified at the top will be executed on the default peer.

Default peer is shown in the bottom right corner of the status bar.

Click the default peer name to change it. A dropdown menu with peers available in your federation will appear at the top of the window.

Select default peer in the dropdown menu.