malcolm.modules.builtin.parts

class malcolm.modules.builtin.parts.BlockPart(name: Anno(name='APartName', typ=<class 'str'>, description='The name of the Part within the Controller'), description: Anno(name='AMetaDescription', typ=<class 'str'>, description='Description of what this element represents'), writeable: Anno(name='AWriteable', typ=<class 'bool'>, description='Is the attribute writeable?') = True, config: Anno(name='AConfig', typ=<class 'int'>, description='If writeable, which iteration should this field be loaded/saved in? 0 means do not restore') = 1, group: Optional[Anno(name='AGroup', typ=<class 'str'>, description='If given, which GUI group should we attach to')] = None, widget: Optional[Anno(name='AWidget', typ=<enum 'Widget'>, description='If given, use this widget instead of the default')] = None, value: Anno(name='AValue', typ=<class 'str'>, description='Initial value of the created attribute') = '')[source]

Create a single string SinkPort for connecting to another Block

Parameters
  • name (str) – The name of the Part within the Controller

  • description (str) – Description of what this element represents

  • writeable (bool) – Is the attribute writeable?

  • config (int) – If writeable, which iteration should this field be loaded/saved in? 0 means do not restore

  • group (str) – If given, which GUI group should we attach to

  • widget (Widget) – If given, use this widget instead of the default

  • value (str) – Initial value of the created attribute

class malcolm.modules.builtin.parts.ChildPart(name: Anno(name='APartName', typ=<class 'str'>, description='The name of the Part within the Controller'), mri: Anno(name='AMri', typ=<class 'str'>, description='Malcolm resource id of child object'), initial_visibility: Optional[Anno(name='AInitialVisibility', typ=<class 'bool'>, description='Whether the part is initially visible with no config loaded, None means only if child Source/Sink Ports connect to another Block')] = None, stateful: Anno(name='AStateful', typ=<class 'bool'>, description='If the child is a StatefulController then this should be True') = True)[source]
Parameters
  • name (str) – The name of the Part within the Controller

  • mri (str) – Malcolm resource id of child object

  • initial_visibility (bool) – Whether the part is initially visible with no config loaded, None means only if child Source/Sink Ports connect to another Block

  • stateful (bool) – If the child is a StatefulController then this should be True

no_save_attribute_names: Set[str] = {}

A set containing all the Attribute names of our child Block that we will put to, so shouldn’t be saved. Set this in subclasses using no_save

notify_dispatch_request(request: malcolm.core.request.Request) None[source]

Will be called when a context passed to a hooked function is about to dispatch a request

on_init(context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks')) None[source]
Parameters

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

on_disable(context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks')) None[source]
Parameters

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

on_reset(context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks')) None[source]
Parameters

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

on_halt() None[source]
on_layout(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')) 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]][source]
Parameters
  • 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

Returns

The current layout information

Return type

LayoutInfo

on_load(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') = False) None[source]
Parameters
  • 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

on_save(context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks')) -> Anno(name='AStructure', typ=(<class 'str'>, typing.Any), description='The serialized structure to load')[source]
Parameters

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

reload(context: Anno(name='AContext', typ=<class 'malcolm.core.context.Context'>, description='Context that should be used to perform operations on child blocks')) None[source]

If we have done a save or load with the child having a particular design then make sure the child now has that design.

Parameters

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

sever_sink_ports(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'), connected_to: Optional[str] = None) None[source]

Conditionally sever Sink Ports of the child. If connected_to is then None then sever all, otherwise restrict to connected_to’s Source Ports

Parameters
  • context (Context) – The context to use

  • ports (dict) – {part_name: [PortInfo]}

  • connected_to (str) – Restrict severing to this part

calculate_part_visibility(ports: Anno(name='APortMap', typ=(<class 'str'>, annotypes._array.Array[malcolm.modules.builtin.infos.PortInfo]), description='The PortInfos for all the parts')) None[source]

Calculate what is connected to what

Parameters

ports – {part_name: [PortInfo]} from other ports

class malcolm.modules.builtin.parts.ChoicePart(name: Anno(name='APartName', typ=<class 'str'>, description='The name of the Part within the Controller'), description: Anno(name='AMetaDescription', typ=<class 'str'>, description='Description of what this element represents'), choices: Union[Anno(name='AChoices', typ=<class 'str'>, description='Possible choices for this attribute'), Sequence[enum.Enum], Sequence[str], str], value: Anno(name='AValue', typ=<class 'str'>, description='Initial value of the created attribute'), writeable: Anno(name='AWriteable', typ=<class 'bool'>, description='Is the attribute writeable?') = False, config: Anno(name='AConfig', typ=<class 'int'>, description='If writeable, which iteration should this field be loaded/saved in? 0 means do not restore') = 1, group: Optional[Anno(name='AGroup', typ=<class 'str'>, description='If given, which GUI group should we attach to')] = None, widget: Optional[Anno(name='AWidget', typ=<enum 'Widget'>, description='If given, use this widget instead of the default')] = None)[source]

Create a single choice Attribute on the Block

Parameters
  • name (str) – The name of the Part within the Controller

  • description (str) – Description of what this element represents

  • choices (str) – Possible choices for this attribute

  • value (str) – Initial value of the created attribute

  • writeable (bool) – Is the attribute writeable?

  • config (int) – If writeable, which iteration should this field be loaded/saved in? 0 means do not restore

  • group (str) – If given, which GUI group should we attach to

  • widget (Widget) – If given, use this widget instead of the default

class malcolm.modules.builtin.parts.Float64Part(name: Anno(name='APartName', typ=<class 'str'>, description='The name of the Part within the Controller'), description: Anno(name='AMetaDescription', typ=<class 'str'>, description='Description of what this element represents'), writeable: Anno(name='AWriteable', typ=<class 'bool'>, description='Is the attribute writeable?') = False, config: Anno(name='AConfig', typ=<class 'int'>, description='If writeable, which iteration should this field be loaded/saved in? 0 means do not restore') = 1, group: Optional[Anno(name='AGroup', typ=<class 'str'>, description='If given, which GUI group should we attach to')] = None, widget: Optional[Anno(name='AWidget', typ=<enum 'Widget'>, description='If given, use this widget instead of the default')] = None, value: Anno(name='AValue', typ=<class 'float'>, description='Initial value of the created attribute') = 0.0, limit_low: Union[Anno(name='ALimitLow', typ=<class 'numpy.float64'>, description='The lower bound of range within which the value must be set'), float] = 0, limit_high: Union[Anno(name='ALimitHigh', typ=<class 'numpy.float64'>, description='The upper bound of range within which the value must be set'), float] = 0, precision: Union[Anno(name='APrecision', typ=<class 'numpy.int32'>, description='Number of significant figures to display'), int] = 8, units: Anno(name='AUnits', typ=<class 'str'>, description='The units for the value') = '')[source]

Create a single float64 Attribute on the Block

Parameters
  • name (str) – The name of the Part within the Controller

  • description (str) – Description of what this element represents

  • writeable (bool) – Is the attribute writeable?

  • config (int) – If writeable, which iteration should this field be loaded/saved in? 0 means do not restore

  • group (str) – If given, which GUI group should we attach to

  • widget (Widget) – If given, use this widget instead of the default

  • value (float) – Initial value of the created attribute

  • limit_low (float64) – The lower bound of range within which the value must be set

  • limit_high (float64) – The upper bound of range within which the value must be set

  • precision (int32) – Number of significant figures to display

  • units (str) – The units for the value

class malcolm.modules.builtin.parts.GroupPart(name: Anno(name='APartName', typ=<class 'str'>, description='The name of the Part within the Controller'), description: Anno(name='AMetaDescription', typ=<class 'str'>, description='Description of what this element represents'))[source]

Part representing a GUI group other Attributes attach to

Parameters
  • name (str) – The name of the Part within the Controller

  • description (str) – Description of what this element represents

class malcolm.modules.builtin.parts.HelpPart(help_url: Anno(name='AHelpUrl', typ=<class 'str'>, description='The URL that gives some help documentation for this Block'), name: Anno(name='APartName', typ=<class 'str'>, description='The name of the Part within the Controller') = 'help', description: Anno(name='ADesc', typ=<class 'str'>, description='The description of what the help documentation is about') = 'Help documentation for the Block')[source]

Part representing a link to some help documentation for the GUI

Parameters
  • help_url (str) – The URL that gives some help documentation for this Block

  • name (str) – The name of the Part within the Controller

  • description (str) – The description of what the help documentation is about

class malcolm.modules.builtin.parts.IconPart(svg: Anno(name='ASvg', typ=<class 'str'>, description='If given, path to svg for initial value') = '')[source]

Part representing a the icon a GUI should display

Parameters

svg (str) – If given, path to svg for initial value

class malcolm.modules.builtin.parts.LabelPart(value: Optional[Anno(name='ALabelValue', typ=<class 'str'>, description='Initial value of Block label')] = None)[source]

Part representing a the title of the Block a GUI should display

Parameters

value (str) – Initial value of Block label

class malcolm.modules.builtin.parts.StringPart(name: Anno(name='APartName', typ=<class 'str'>, description='The name of the Part within the Controller'), description: Anno(name='AMetaDescription', typ=<class 'str'>, description='Description of what this element represents'), writeable: Anno(name='AWriteable', typ=<class 'bool'>, description='Is the attribute writeable?') = False, config: Anno(name='AConfig', typ=<class 'int'>, description='If writeable, which iteration should this field be loaded/saved in? 0 means do not restore') = 1, group: Optional[Anno(name='AGroup', typ=<class 'str'>, description='If given, which GUI group should we attach to')] = None, widget: Optional[Anno(name='AWidget', typ=<enum 'Widget'>, description='If given, use this widget instead of the default')] = None, value: Anno(name='AValue', typ=<class 'str'>, description='Initial value of the created attribute') = '')[source]

Create a single string Attribute on the Block

Parameters
  • name (str) – The name of the Part within the Controller

  • description (str) – Description of what this element represents

  • writeable (bool) – Is the attribute writeable?

  • config (int) – If writeable, which iteration should this field be loaded/saved in? 0 means do not restore

  • group (str) – If given, which GUI group should we attach to

  • widget (Widget) – If given, use this widget instead of the default

  • value (str) – Initial value of the created attribute