crestdsl.model.api package

API Functions for Entities

crestdsl.model.api.get_name(entity)

Returns the name of a given entity.

Parameters

entity (Entity) – The entity whose name should be returned.

Returns

The entity’s name or the empty string if there is no name defined (usually the root).

Return type

str

crestdsl.model.api.get_current(entity)

Returns the current automaton state of a given entity.

Parameters

entity (Entity) – The entity whose current state should be accessed.

Returns

The entity’s current automaton state.

Return type

State

crestdsl.model.api.get_root(entity)

Returns the root entity of a system.

Parameters

entity (Entity) – Any entity within the system.

Returns

The system’s root entity.

Return type

Entity

crestdsl.model.api.get_parent(entity)

Returns the parent of a given entity.

Parameters

entity (Entity) – The entity whose parent should be returned.

Returns

The entity’s parent entity (or None).

Return type

Entity

crestdsl.model.api.get_children(entity)

Returns the child entities of a given entity.

Parameters

entity (Entity) – The entity whose children should be returned.

Returns

A list of the entity’s subentities.

Return type

list of Entity

crestdsl.model.api.get_sources(entity)

The “sources” ports of an entity. The sources ports are all ports that can be read by updates/transitions/influences. These are an entity’s inputs, locals and all subentities’ output ports.

Parameters

entity (Entity) – The entity whose sources should be returned.

Returns

The list of ports that can be read by modifiers.

Return type

list of Port

crestdsl.model.api.get_targets(entity)

The “targets” ports of an entity. The targets ports are all ports that can be written by updates and influences. These are an entity’s outputs, locals and all subentities’ input ports.

Parameters

entity (Entity) – The entity whose targets should be returned.

Returns

The list of ports that can be written by modifiers.

Return type

list of Port

Convenience API for Entities Creation

Warning

Only use these functions once the object has been created. (You can use them for example in the constructor.)

crestdsl.model.api.add(entity, name, obj)

Adds the object to the entity and register it as the name. This function is similar to setattr, but does some string resolving beforehand. That means you can e.g. pass a Transition object where source/target are passed by their string identifiers.

Note

This method requires an entity to be initialised aleady. Call this method e.g. from within __init__ and be careful of what you are doing.

Warning

You cannot use this function to override objects that are already linked before. I.e. You cannot reassign a state that is used in a transition/update or a port that is already used in an influence. Be especially be careful when overriding transitions that are used in actions! We cannot currently detect these issues.

Parameters
  • entity (Entity) – The entity that should be extended.

  • name (str) – The attribute name under which you want to save the object.

  • obj (CrestObject) – The object that you want to set.

crestdsl.model.api.pullup(*ports, **kwargs)

This method takes a subentity input or output ports, creates equivalent ports in their parent’s parent entity and connects them using influences.

Use kwargs to assign a specific name.

Note

This method requires an entity to be initialised aleady. Call this method e.g. from within __init__ and be careful of what you are doing.

Parameters
  • ports (list of Port) – A list of subentity ports that you want to pull up.

  • kwargs (list of str=Port) – A list of name=Port pairs, so that name will be the pulled up port’s name in this entity.

crestdsl.model.api.relay(*port_pairs, **kwargs)

A convenience function to quickly create many influences in an entity.

The method takes a port pairs and connects them using influences.

Use kwargs to assign a specific name.

Note

This method requires an entity to be initialised aleady. Call this method e.g. from within __init__ and be careful of what you are doing.

Parameters
  • ports (list of (Port,Port)-pairs) – A list of source and target ports between which an influence should be created.

  • kwargs (list of str=(Port,Port)) – A list of name=Port pairs, so that string will be used as the influence’s name.

crestdsl.model.api.dependencies(*port_pairs)

An alternative way to define dependencies for an entity.

Note

This method requires an entity to be initialised aleady. Call this method e.g. from within __init__ and be careful of what you are doing.

Parameters

ports (list of (Output,Input)-pairs) – A list of dependency source (output) and target (input) ports between which a dependency should be declared.