malcolm.modules.builtin.hooks

class malcolm.modules.builtin.hooks.ControllerHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), **kwargs: Any)[source]

A hook that takes Part and Context for use in controllers

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

class malcolm.modules.builtin.hooks.InitHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), **kwargs: Any)[source]

Called when this controller is told to start by the process

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

class malcolm.modules.builtin.hooks.ResetHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), **kwargs: Any)[source]

Called at reset() to reset all parts to a known good state

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

class malcolm.modules.builtin.hooks.HaltHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), **kwargs: Any)[source]

Called when this controller is told to halt

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

class malcolm.modules.builtin.hooks.DisableHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), **kwargs: Any)[source]

Called at disable() to stop all parts updating their attributes

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

class malcolm.modules.builtin.hooks.LayoutHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), ports: Anno(name='APortMap', typ=(<class 'str'>, annotypes._array.Array[malcolm.modules.builtin.infos.PortInfo]), description='The PortInfos for all the parts'), layout: Anno(name='ALayoutTable', typ=<class 'malcolm.modules.builtin.util.LayoutTable'>, description='A possibly partial set of changes to the layout table that should be acted on'))[source]

Called when layout table set and at init to update child layout

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

  • ports – The PortInfos for all the parts

  • layout (LayoutTable) – A possibly partial set of changes to the layout table that should be acted on

validate_return(ret: Optional[Union[Anno(name='ALayoutInfos', typ=<class 'malcolm.modules.builtin.infos.LayoutInfo'>, description='The current layout information'), Sequence[malcolm.modules.builtin.infos.LayoutInfo], malcolm.modules.builtin.infos.LayoutInfo]]) -> Anno(name='ALayoutInfos', typ=<class 'malcolm.modules.builtin.infos.LayoutInfo'>, description='The current layout information')[source]

Check that all returned infos are LayoutInfos

class malcolm.modules.builtin.hooks.LoadHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), structure: Anno(name='AStructure', typ=(<class 'str'>, typing.Any), description='The serialized structure to load'), init: Anno(name='AInit', typ=<class 'bool'>, description='Whether this operation is taking place at init'))[source]

Called at load() to load child settings from a structure

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

  • structure – The serialized structure to load

  • init (bool) – Whether this operation is taking place at init

class malcolm.modules.builtin.hooks.SaveHook(part: Anno(name='APart', typ=<class 'malcolm.core.part.Part'>, description='The part that has attached to the Hook'), context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks'), **kwargs: Any)[source]

Called at save() to serialize child settings into a dict structure

Parameters
  • part (Part) – The part that has attached to the Hook

  • context (Context) – Context that should be used to perform operations on child blocks

validate_return(ret: Anno(name='AStructure', typ=(<class 'str'>, typing.Any), description='The serialized structure to load')) -> Anno(name='AStructure', typ=(<class 'str'>, typing.Any), description='The serialized structure to load')[source]

Check that a serialized structure is returned