pypdevsbbl.generic.transformers module

Set of PythonPDEVS building blocks for transforming data.

The classes in this file concern themselves with message transformations throughout a system and can come in useful in numerous situations.

class pypdevsbbl.generic.transformers.Transformer(name: str, T=<function Transformer.<lambda>>)[source]

Bases: pypdevs.DEVS.AtomicDEVS

Transforms data w.r.t. a function.

Note

The transformation itself happens upon arrival of a new item. The more expensive the transformation function, the more expensive the usage of this block. Keep this in mind when modeling for real-time simulations.

_images/transformer.svg
Parameters:
  • name (str) – The name of the block.
  • T (def) – Function that defines the transformation. It takes 3 arguments: i (the item), e (the elapsed time) and t (the total time). And it will return the transformed item. Defaults to the item itself.
State:
  • time (numeric) – The total elapsed time.
  • transformed (any) – The transformed item.
  • original (any) – The original item (before transformation).
Input Ports:

input (any) – The item to transform.

Output Ports:
  • transformed (any) – The transformed item.
  • original (any) – The original item (before transformation).
extTransition(inputs)[source]
intTransition()[source]
timeAdvance()[source]
outputFnc()[source]
class pypdevsbbl.generic.transformers.LookupTable(name: str, table: dict, default=None)[source]

Bases: pypdevsbbl.generic.transformers.Transformer

Finds the value in a lookup table.

_images/lookup-table.svg
Parameters:
  • name (str) – The name of the block.
  • table (dict) – The lookup table. Each input is mapped on a key in this table, which is outputted.
  • default (any) – The default value if no mapping exists. Defaults to None.
State:
  • time (numeric) – The total elapsed time.
  • transformed (any) – The transformed item.
  • original (any) – The original item (before transformation).
Input Ports:

input (any) – The item to look up.

Output Ports:
  • transformed (any) – The looked up item.
  • original (any) – The original item (before lookup).
class pypdevsbbl.generic.transformers.Pack(name: str, package=<class 'pypdevsbbl.extra.packaging.Package'>, *args)[source]

Bases: pypdevs.DEVS.AtomicDEVS

Collects all input in a generic package.

A group of items is captured on this block’s input. Based on a predefined package (see pypdevsbbl.extra.packaging submodule), the elapsed time and the simulation time, there can be deduced how the items can be combined.

As soon as a message arrives on the release input, the package is released on the out port and the state is reset. Additionally, if the pypdevsbbl.extra.packaging.Package.finished() function of evaluates True after packing, the package will be released automatically.

_images/pack.svg
Parameters:
  • name (str) – The name of the block.
  • package – The package class in which to combine all input. Defaults to a generic pypdevsbbl.extra.packaging.Package.
  • *args – Additional list of arguments to be passed to the Package class upon construction. This is empty by default.
State:
Input Ports:
  • input (any) – The object to add to the package.
  • release (any) – When the package needs to be released.
Output Ports:

output (Package) – A package.

timeAdvance()[source]
intTransition()[source]
outputFnc()[source]
extTransition(inputs)[source]
class pypdevsbbl.generic.transformers.Unpack(name: str)[source]

Bases: pypdevs.DEVS.AtomicDEVS

Releases the contents of a package.

When a pypdevsbbl.extra.packaging.Package arrives on the input, it is unpacked and the list of contents is afterwards outputted on the out port.

_images/unpack.svg
Parameters:name (str) – The name of the block.
State:contents (list) – The list of contents of the package.
Input Ports:input (Package) – The package to unpack.
Output Ports:output (list) – All contents of the package.
timeAdvance()[source]
intTransition()[source]
outputFnc()[source]
extTransition(inputs)[source]