Device Models#

Every device supported by Samna has a corresponding device model. The device model has two main functions. It allows you to send and receive events to/from the device via the filter system, and to apply a new configuration to the device. After obtaining a development kit object using the device controller the chip model can be retrieved.

samna.init_samna()
# Obtain the device model for the device on the development kit we obtained from the device controller
model = my_board.get_device_model()

# Devices can also be closed via the device controller.
samna.device.close_device(my_board)

Configuration#

Device models all have an apply_configuration() function that accepts a configuration object. Such a configuration object can be created in Python, for example to create and apply a DYNAP-CNN configuration

# Create a default configuration
config = samna.dynapcnn.configuration.DynapcnnConfiguration()

# Modify some parameter of the configuration if desired
config.cnn_layers[0].monitor_enable = true

# Apply the configuration to a device via its device model
# This will generate errors if the configuration is illegal
model.apply_configuration(config)

Event streams#

All models can hook into the event filtering system using their source and sink nodes. All events written to the sink node of a device model will be transmitted to the physical device and all events produced by the physical device will be broadcast from the model source node.

All device models provide the get_source_node() and get_sink_node() functions.

Common model functions#

class Model#
get_source_node()#

Returns a reference to the source event node which will broadcast all events produced by the device.

get_sink_node()#

Returns a reference to the sink event node which will transmit all events it receives to the device.

get_configuration()#

Returns a copy of the current configuration of the device. Note that this is simply a copy of configuration provided to the last successful call to apply_configuration(). This function does not read physical device state.

apply_configuration(configuration)#

Attempts to apply a configuration for the device. The configuration will first be validated and the configuration will only be applied if validation is successful. If validation does not succeed this method will throw an exception containing a validation error message.

Parameters:

configuration (DeviceConfiguration) – The configuration specific to the type of device.

Supported device models#