API

This page contains the auto-generated documentation for the sisock package.

sisock.base module

Sisock: serve Simons data over secure sockets (sisock)

Classes

sisock.base.DataNodeServer([config]) Parent class for all data node servers.

Functions

sisock.base.uri(s) Compose a full URI for pub/sub or RPC calls.
sisock.base.sisock_to_unix_time(t) Convert a sisock timestamp to a UNIX timestamp.

Constants

WAMP_USER
Username for servers/hub to connect to WAMP router.
WAMP_SECRET
Password for servers/hub to connect to WAMP router.
WAMP_URI
Address of WAMP router.
REALM
Realm in WAMP router to connect to.
BASE_URI
The lowest level URI for all pub/sub topics and RPC registrations.
class sisock.base.DataNodeServer(config=None)

Bases: autobahn.twisted.wamp.ApplicationSession

Parent class for all data node servers.

Variables:
  • name (string) – Each data node server inheriting this class must set its own name. The hub will reject duplicate names.
  • description (string) – Each data node server inheriting this class must provide its own, human- readable description for consumers.
after_onJoin(details)

This method is called after onJoin() has finished.

This method can be overridden by child classes that need to run more code after the parent onJoin method has run.

Parameters:details (autobahn.wamp.types.SessionDetails) – Details about the session, as passed to onJoin.
description = None
get_data(field, start, end, min_stride=None)

Request data.

This method can overridden by child classes if a get_data runs in the main reactor thread, otherwise it’s the get_data_blocking method that needs to be overridden

Parameters:
  • field (list of strings) – The list of fields you want data from.
  • start (float) – The start time for the data: if positive, interpret as a UNIX time; if 0 or negative, begin start seconds ago.
  • end (float) – The end time for the data, using the same format as start.
  • min_stride (float or None) – If not None then, if necessary, downsample data such that successive samples are separated by at least min_stride seconds.
Returns:

On success, a dictionary is returned with two entries.

  • data : A dictionary with one entry per field:
    • field_name : array containing the timestream of data.
  • timeline : A dictionary with one entry per timeline:
    • timeline_name : An dictionary with the following entries.
    • t : an array containing the timestamps
    • finalized_until : the timestamp prior to which the presently requested data are guaranteed not to change; None may be returned if all requested data are finalized

If data are not available during the whole length requested, all available data will be returend; if no data are available for a field, or the field does not exist, its timestream will be an empty array. Timelines will only be included if there is at least one field to which it corresponds with available data. If no data are available for any of the fields, all arrays will be empty.

If the amount of data exceeds the data node server’s pipeline allowance, False will be returned.

Return type:

dictionary

get_fields(start, end)

Get a list of available fields and associated timelines available within a time interval.

Any field that has at least one available sample in the interval [start, stop) must be included in the reply; however, be aware that the data server is allowed to include fields with zero samples available in the interval.

This method should be overridden by child classes if the fields are obtained in a non-blocking way (running in the reactor thread).

Parameters:
  • start (float) – The start time for the field list. If positive, interpret as a UNIX time; if 0 or negative, get field list t seconds ago.
  • end (float) – The end time for the field list, using the same format as start.
Returns:

Two dictionaries of dictionaries, as defined below.

  • field : the field name is the key, and the value is:
    • description : information about the field; can be None.
    • timeline : the name of the timeline this field follows.
    • type : one of “number”, “string”, “bool”
    • units : the physical units; can be None
  • timeline : the field name is the key, and the value is:
    • interval : the average interval, in seconds, between readings; if the readings are aperiodic, None.
    • field : a list of field names associated with this timeline

The field dictionary can be empty, indicating that no fields are available during the requested interval.

Return type:

dictionary

name = None
onChallenge(challenge)

Fired when the WAMP router requests authentication.

Parameters:challenge (autobahn.wamp.types.Challenge) – The authentication request to be responded to.
Returns:signature – The authentication response.
Return type:string
onConnect()

Fired when session first connects to WAMP router.

onJoin(details)

Fired when the session joins WAMP (after successful authentication).

After registering procedures, the hub is requested to add this data node server.

Parameters:details (autobahn.wamp.types.SessionDetails) – Details about the session.
sisock.base.sisock_to_unix_time(t)

Convert a sisock timestamp to a UNIX timestamp.

Parameters:t (float) – A sisock timestamp.
Returns:unix_time – If t is positive, return t. If t is zero or negative, return \(time.time() - t\).
Return type:float
sisock.base.uri(s)

Compose a full URI for pub/sub or RPC calls.

Parameters:s (The final part of the URI to compose.) –
Returns:uri – The string returned is “%s.%s” % (BASE_URI, s).
Return type:string