src.datasources package

Submodules

src.datasources.models module

class src.datasources.models.UdpDatasource(addr: Tuple[str, int], input_byte_format: str, input_names: List[str], output_refs: List[int], time_index: int, topic: str = None)

Bases: object

Represents a single UDP datasource

class src.datasources.models.UdpReceiver(kafka_addr: str)

Bases: asyncio.protocols.DatagramProtocol

Handles all UDP datasources

connection_lost(exc: Optional[Exception]) → None

Called when the connection is lost or closed.

The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).

connection_made(transport: asyncio.transports.BaseTransport) → None

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

datagram_received(raw_data: bytes, addr: Tuple[str, int]) → None

Filters, transforms and buffers incoming packets before sending it to kafka

error_received(exc: Exception) → None

Called when a send or receive operation raises an OSError.

(Other than BlockingIOError or InterruptedError.)

get_sources()

Returns a list of the current sources

set_source(source_id: str, addr: Tuple[str, int], topic: str, input_byte_format: str, input_names: List[str], output_refs: List[int], time_index: int) → None

Creates a new datasource object and adds it to sources, overwriting if necessary

Parameters
  • source_id – the id to use for the datasource

  • addr – the address the datasource will send from

  • topic – the topic the data will be put on

  • input_byte_format – the byte_format of the data that will be received

  • input_names – the names of the values in the data that will be received

  • output_refs – the indices of the values that will be transmitted to the topic

  • time_index – the index of the value that represents the time of the data

src.datasources.models.generate_catman_outputs(output_names: List[str], output_refs, single: bool = False) → Tuple[List[str], List[int], str]

Generate ouput setup for a datasource that is using the Catman software

Parameters
  • single – true if the data from Catman is single precision (4 bytes each)

  • output_names – a list of the names of the input data

src.datasources.views module

async src.datasources.views.datasource_create(request: aiohttp.web_request.Request)

Create a new datasource from post request.

Post parameters:

  • id: the id to use for the source

  • address: the address to receive data from

  • port: the port to receive data from

  • output_name: the names of the outputs Must be all the outputs and in the same order as in the byte stream.

  • output_ref: the indexes of the outputs that will be used

  • time_index: the index of the time value in the output_name list

  • byte_format: the python struct format string for the data received. Must include byte order (https://docs.python.org/3/library/struct.html?highlight=struct#byte-order-size-and-alignment) Must be in the same order as name. Will not be used if catman is true.

  • catman: set to true to use catman byte format byte_format is not required if set

  • single: set to true if the data is single precision float Only used if catman is set to true

returns redirect to created simulation page

async src.datasources.views.datasource_delete(request: aiohttp.web_request.Request)

Delete the datasource

async src.datasources.views.datasource_detail(request: aiohttp.web_request.Request)

Information about the datasource with the given id. To delete the datasource append /delete To subscribe to the datasource append /subscribe To start the datasource append /start To stop the datasource append /stop

async src.datasources.views.datasource_list(request: aiohttp.web_request.Request)

List all datasources.

Listed datasources will contain true if currently running and false otherwise. Append an id to get more information about a listed datasource. Append /create to create a new datasource

async src.datasources.views.datasource_start(request: aiohttp.web_request.Request)

Start the datasource

async src.datasources.views.datasource_stop(request: aiohttp.web_request.Request)

Stop the server from retrieving data from the datasource with the given id.

async src.datasources.views.datasource_subscribe(request: aiohttp.web_request.Request)

Subscribe to the datasource with the given id

async src.datasources.views.datasource_unsubscribe(request: aiohttp.web_request.Request)

Unsubscribe to the datasource with the given id

src.datasources.views.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=<function make_serializable>, sort_keys=False, **kw)

A version of json.dumps that uses make serializable recursively to make objects serializable

src.datasources.views.try_get_source(app, topic)

Attempt to get the datasource sending to the given topic

Raises an HTTPNotFound error if not found.