System
Provides access to the system in hardware interfaces that have access to cameras.
Exceptions:
An exception that represents an error raised from the Spinnaker API. |
Classes:
Base class for all event handlers. |
|
A system log event handler that is returned by |
|
A system interface arrival/removal handler that is returned by |
|
A system/interface camera arrival/removal handler that is returned by |
|
A |
|
Provides access to a list of the interface devices to which cameras can be attached e.g. |
|
A hardware interface to which cameras such as GigE, USB2/3 can be attached. |
- exception SpinnakerAPIException(*args, spin_what='', spin_full_msg='', spin_msg='', spin_file_name='', spin_func_name='', spin_build_date='', spin_build_time='', spin_line_num=0, spin_error_code=0)
Bases:
ExceptionAn exception that represents an error raised from the Spinnaker API.
- class LoggingEventHandler
Bases:
EventHandlerBaseA system log event handler that is returned by
attach_log_event_handler()that handles callbacks for internal Spinnaker logging events.This represents a callback function that is called on each log event with 3 positional arguments: this instance, the
SpinSysteminstance that created this, and a dict with the log data.Some dict keys are the error
category, the errormessage, thendc(Nested Diagnostic Context), thethreadin which it happened, thetimestampstring, thepriorityname, and thepriority_num.
- class SystemEventHandler
Bases:
EventHandlerBaseA system interface arrival/removal handler that is returned by
attach_event_handler()that handles callbacks for when a new hardware interface to which cameras may be attached (e.g. USB port) is added or removed from the system.This represents an arrival and removal callback function that is each called respectively (if provided when it’s created), on each arrival/removal event with 3 positional arguments: this instance, the
SpinSysteminstance that created this, and a string representing the interface name.
- class InterfaceEventHandler
Bases:
EventHandlerBaseA system/interface camera arrival/removal handler that is returned by
attach_interface_event_handler()andattach_event_handler()that handles callbacks for when a camera is added or removed from the system or specific interface.This represents an arrival and removal callback function that is each called respectively (if provided when it’s created), on each arrival/removal event with 3 positional arguments: this instance, the
SpinSystemorInterfaceDeviceinstance that created this, and an integer representing the camera serial number.
- class SpinSystem
Bases:
objectA
SpinSystemprovides access to interfaces and cameras attached to these interfaces across the system.Methods:
Registers the system callbacks to get interface arrival/removal events.
Registers device arrival and removal events for all interfaces that are found on the system.
Registers the callback to get logging events from system.
Creates and returns a new
InterfaceDeviceListfor accessing interfaces on the system.Detaches all the attached log event handlers that have been previously attached.
Detaches the event handler returned by
attach_event_handler().Detaches the event handler previously returned by
attach_interface_event_handler().Detaches an event handler returned by
attach_log_event_handler().Checks if the system is in use by any interface or camera objects.
Gets the current Spinnaker library version as a 4 tuple of
(major, minor, type, build).Gets the logging level (as listed in
log_level_names) for all logging events on the system.Gets the transport layer nodemap from the system.
Broadcast an Action Command to all devices on the system.
Sets the logging level for all logging events on the system.
Updates the internal list of cameras on the system, returning a bool indicating whether there has been any changes and cameras have arrived or been removed.
Updates the internal list of interfaces on the system.
Attributes:
system_nodes: rotpy.system_nodes.SystemNodes The pre-listed system nodes from
SystemNodes.- attach_event_handler(self, callback_arrival=None, callback_removal=None)
Registers the system callbacks to get interface arrival/removal events.
- Parameters
callback_arrival – A function that will be called upon interface arrival events. If it’s
None, arrival events will be ignored. SeeSystemEventHandlerfor the function signature.callback_removal – A function that will be called upon interface removal events. If it’s
None, removal events will be ignored. SeeSystemEventHandlerfor the function signature.
- Returns
A
SystemEventHandlerinstance representing the callbacks.
The callbacks will receive the system events while they are registered, possibly even before this function returns(?) and could potentially be called by external threads. It’s best not to do any work in it.
- attach_interface_event_handler(self, callback_arrival=None, callback_removal=None, bool update=True)
Registers device arrival and removal events for all interfaces that are found on the system. If new interfaces are detected by the system after this call, those interfaces will be automatically registered with this event.
- Parameters
callback_arrival – A function that will be called upon device arrival events. If it’s
None, arrival events will be ignored. SeeInterfaceEventHandlerfor the function signature.callback_removal – A function that will be called upon device removal events. If it’s
None, removal events will be ignored. SeeInterfaceEventHandlerfor the function signature.update – Whether to update the interface list before attaching event for the available interfaces on the system.
- Returns
A
InterfaceEventHandlerinstance representing the callbacks.
Note
Only GEV interface arrivals and removals are currently handled.
The callbacks will receive the interface events while they are registered, possibly even before this function returns(?) and could potentially be called by external threads. It’s best not to do any work in it.
- attach_log_event_handler(self, callback)
Registers the callback to get logging events from system.
- Parameters
callback – A function that will be called upon logging events. See
LoggingEventHandlerfor the function signature.- Returns
A
LoggingEventHandlerinstance representing the callback.
The
callbackwill receive the events while it is registered, possibly even before this function returns(?) and could potentially be called by external threads. It’s best not to do any work in it.
- create_interface_list(self, bool update_interfaces=True)
Creates and returns a new
InterfaceDeviceListfor accessing interfaces on the system.This returns GigE and USB2 and USB3 interfaces. Note that on MacOS only active GigE interfaces will be stored in the returned interface list.
- Parameters
update_interfaces – Whether to update the internal interface list before getting the available interfaces list.
- Returns
- detach_all_log_handlers(self)
Detaches all the attached log event handlers that have been previously attached.
- detach_event_handler(self, SystemEventHandler handler)
Detaches the event handler returned by
attach_event_handler().- Parameters
handler – The
SystemEventHandlerthat handled the events.
- detach_interface_event_handler(self, InterfaceEventHandler handler)
Detaches the event handler previously returned by
attach_interface_event_handler().- Parameters
handler – The
InterfaceEventHandlerthat handled the events.
- detach_log_event_handler(self, LoggingEventHandler handler)
Detaches an event handler returned by
attach_log_event_handler().- Parameters
handler – The
LoggingEventHandlerthat handled the events.
- get_in_use(self)
Checks if the system is in use by any interface or camera objects.
- get_library_version(self)
Gets the current Spinnaker library version as a 4 tuple of
(major, minor, type, build).
- get_logging_level(self)
Gets the logging level (as listed in
log_level_names) for all logging events on the system.
- send_command(self, unsigned int device_key, unsigned int group_key, unsigned int group_mask, unsigned long long action_time=0, unsigned int num_results=0)
Broadcast an Action Command to all devices on the system.
- Parameters
device_key – The action command’s device key.
group_key – The action command’s group key.
group_mask – The action command’s group mask.
action_time – Time when to assert a future action. Zero (default) means immediate action.
num_results – The number of results expected in the return list. The value passed should be equal to the expected number of devices that acknowledge the command. The returned list will be the actual number of received results. If this is 0, the function will return as soon as the command has been broadcasted.
- Returns
A list of tuples, one tuple for each item in the result. Each tuple is
(address, status), whereaddressis the device address andstatusis the status string fromcmd_status_names.
- set_logging_level(self, unicode level)
Sets the logging level for all logging events on the system. Logging events below such level will not trigger callbacks
- Parameters
level – The name of the level as listed in
log_level_names.
- system_nodes
system_nodes: rotpy.system_nodes.SystemNodes The pre-listed system nodes from
SystemNodes.Use this property to get a pre-instantiated
SystemNodesbecauseSystemNodesis not user instantiable.Note
Remember to check whether each of the pre-listed nodes are
is_available(),is_readable(),is_writable()etc.
- update_camera_list(self, bool update_interfaces=True)
Updates the internal list of cameras on the system, returning a bool indicating whether there has been any changes and cameras have arrived or been removed.
- Parameters
update_interfaces – If True, the interface lists will also be updated.
- Returns
True if cameras changed on interface and False otherwise.
If desired to get the new interfaces or cameras, call
create_interface_list()orcreate_from_system(), respectively because existingCameraListwill not reflect the updates.
- update_interface_list(self)
Updates the internal list of interfaces on the system.
If desired to get the new interfaces, call
create_interface_list(), existingInterfaceDeviceListwill not reflect the updates.
- class InterfaceDeviceList
Bases:
objectProvides access to a list of the interface devices to which cameras can be attached e.g. GigE and USB2 and USB3 interfaces.
Warning
Do not create a
InterfaceDeviceListmanually, rather get it fromcreate_interface_list().Once a
InterfaceDeviceListis created from the system, updating the system so it detects new interface will not be reflected in existingInterfaceDeviceList. Instead, create new one to access those new interfaces.Note
On MacOS only active GigE interfaces will be stored in the returned
InterfaceDeviceList.Methods:
Retrieves an interface device from this interface device list using using a zero-based index that is less than
get_size().Extends this interface list with a copy of the other interface list.
Retrieves the number of detected interface devices in the list.
- create_interface(self, unsigned int index)
Retrieves an interface device from this interface device list using using a zero-based index that is less than
get_size().- Parameters
index – The index of the interface device.
- Returns
- extend(self, InterfaceDeviceList other)
Extends this interface list with a copy of the other interface list.
- Parameters
other – The other
InterfaceDeviceListto add to us.
- get_size(self)
Retrieves the number of detected interface devices in the list.
- class InterfaceDevice
Bases:
objectA hardware interface to which cameras such as GigE, USB2/3 can be attached.
Warning
Do not create a
InterfaceDevicemanually, rather get it fromInterfaceDeviceList.create_interface().Methods:
Registers device arrival and removal events for this interface.
Detaches the event handler previously returned by
attach_event_handler().Returns whether this interface is in use by any camera objects.
Returns whether this interface is still valid for use.
Gets the transport layer nodemap from this interface.
Releases the interface's resources, including its nodes.
Broadcast an Action Command to all devices on this interface.
Updates the internal list of cameras on this interface, returning a bool indicating whether there has been any changes and cameras have arrived or been removed.
Attributes:
interface_nodes: rotpy.system_nodes.InterfaceNodes The pre-listed interface nodes from
InterfaceNodes.- attach_event_handler(self, callback_arrival=None, callback_removal=None)
Registers device arrival and removal events for this interface.
- Parameters
callback_arrival – A function that will be called upon device arrival events. If it’s
None, arrival events will be ignored. SeeInterfaceEventHandlerfor the function signature.callback_removal – A function that will be called upon device removal events. If it’s
None, removal events will be ignored. SeeInterfaceEventHandlerfor the function signature.
- Returns
A
InterfaceEventHandlerinstance representing the callbacks.
The callbacks will receive the interface events while they are registered, possibly even before this function returns(?) and could potentially be called by external threads. It’s best not to do any work in it.
Event handlers are automatically cleaned up when an interface is removed, and must be registered to interfaces as they arrive. Note that GEV interfaces experience arrival/removal events when the IP information changes, similar to GEV cameras.
- detach_event_handler(self, InterfaceEventHandler handler)
Detaches the event handler previously returned by
attach_event_handler().- Parameters
handler – The
InterfaceEventHandlerthat handled the events.
- get_in_use(self)
Returns whether this interface is in use by any camera objects.
- get_is_valid(self)
Returns whether this interface is still valid for use.
- interface_nodes
interface_nodes: rotpy.system_nodes.InterfaceNodes The pre-listed interface nodes from
InterfaceNodes.Use this property to get a pre-instantiated
InterfaceNodesbecauseInterfaceNodesis not user instantiable.Note
Remember to check whether each of the pre-listed nodes are
is_available(),is_readable(),is_writable()etc.
- release(self)
Releases the interface’s resources, including its nodes.
Once called, non of the pre-listed node are valid and other interface methods should not be called.
- send_command(self, unsigned int device_key, unsigned int group_key, unsigned int group_mask, unsigned long long action_time=0, unsigned int num_results=0)
Broadcast an Action Command to all devices on this interface.
- Parameters
device_key – The action command’s device key.
group_key – The action command’s group key.
group_mask – The action command’s group mask.
action_time – Time when to assert a future action. Zero (default) means immediate action.
num_results – The number of results expected in the return list. The value passed should be equal to the expected number of devices that acknowledge the command. The returned list will be the actual number of received results. If this is 0, the function will return as soon as the command has been broadcasted.
- Returns
A list of tuples, one tuple for each item in the result. Each tuple is
(address, status), whereaddressis the device address andstatusis the status string fromcmd_status_names.
- update_camera_list(self)
Updates the internal list of cameras on this interface, returning a bool indicating whether there has been any changes and cameras have arrived or been removed.
- Returns
True if cameras changed on interface and False otherwise.
If desired to get the new cameras, call
create_from_interface()because existingCameraListwill not reflect the updates.