Kernel

class kernel.Kernel

The Kernel class is the core of the system.

It is instantiated once at the beginning of the program and then gathers every handleable object in different lists, in order to make them accessible by other parts of the program (such as the User Interface):

Variables:
  • plugins – (python modules list) The list of plugins that have been loaded
  • protocols – (models.Protocol list) the list of protocols currently handled by the kernel
  • drivers – (models.Driver list) the list of hardware parts that may work with the system
  • interfaces – (models.Interface list) the list of available interfaces (http...)
  • devices – (models.Device list) the list of devices currently connected to the system
  • actions – (models.Action list) the list of actions made available
  • infos – (models.Information list) the list of informations available
  • block_models – (models.BlockModel list) the list of block models that may be used in the creation of a new scenario
  • scenarios – (scenario.Scenario list) the scenarios creates by the user (some may not be active)
add_to_kernel(element)

Adds the element given as argument to the corresponding objects list of the kernel.

It auto-detects the type of the argument given and automatically appends to one of the lists of the kernel.

Parameters:element (models.Information or models.Action or models.Device or models.Interface or models.Protocol or models.Driver or scenario.Scenario or models.BlockModel) – The element to add to the kernel
Raises TypeError:
 if the element given as argument is of none of the types given above.
get_by_id(searched_id)

Get an element previously added to the kernel by providing its id.

Parameters:searched_id (int) – The ID of the element which is searched.
Returns:the searched object or False if it has not been found
Return type:int or bool
get_new_id()

(Internal) Get an identifier that we know being unique. It is used by the add_to_kernel() so that any object added to the kernel gets its own identifier.

It is particularly useful when it comes to user interfaces.

Returns:A unique identifier
Return type:int
load_plugins()

Loads all plugins available in the plugin package/subdirectory. If a plugin has already been loaded, it is ignored.

remove_by_id(searched_id)

Remove the element whose ID has been given as argument from the kernel and returns it.

Parameters:searched_id (int) – The ID of the element to remove
Returns:The removed element or false
Return type:models.Information or models.Action or models.Device or models.Interface or models.Protocol or models.Driver or scenario.Scenario or models.BlockModel or boolean

Previous topic

API

Next topic

Models

This Page