mpacts.core. command

In order to be able to use this module import it like this:

import mpacts.core.command
#or assign it to a shorter name
import mpacts.core.command as com

AndGates

class mpacts.core.command.AndGates

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that AND combines two other gates.
Has no default location.
  • Required keywords:
    • gate1 — First gate to be AND combined.
    • gate2 — Second gate to be AND combined (if gate1 was true).
object __init__(tuple args, dict kwds) :
args: name, parent kwds: gate1, gate2
AndGates(name, parent, **kwargs)

Command

class mpacts.core.command.Command

Bases: mpacts.core.baseobject.BaseObject

Abstract Base Class for all commands. Cannot be instatiated directly

Raises an exception This class cannot be instantiated from Python

Command(name, parent, **kwargs)
execute((Command)self) → None :

Execute the command.

CommandGateBase

class mpacts.core.command.CommandGateBase

Bases: mpacts.core.baseobject.BaseObject

Abstract Base Class for all command gates. Cannot be instatiated directly. If the check member is true, the command will be executed in its command-list.

Raises an exception This class cannot be instantiated from Python

CommandGateBase(name, parent, **kwargs)
check_gate((CommandGateBase)self, (BaseObject)command) → bool :

Check if the command will get executed – careful, this can/will change the internal state!

copy((CommandGateBase)self) → BaseObject :

Explicitely copy the command gate: since python would otherwise use the same object, you could get unexpected results if you use the same gate in several locations!

CommandList

class mpacts.core.command.CommandList

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Collection (list) of commands, executed in the order they are added. Is also a command itself, where execute() executes all children
Has no default location.
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [gate]
CommandList(name, parent, **kwargs)
execute((CommandList)self) → None :

Execute all commands in the commandlist.

first((CommandList)self) → Command :

Retrieves first command in list.

last((CommandList)self) → Command :

Retrieves last command in list.

ExecuteAlways

class mpacts.core.command.ExecuteAlways

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is always executed in its commandlist. This is the default gate.
Has no default location.
object __init__(tuple args, dict kwds) :
args: name, parent kwds:
ExecuteAlways(name, parent, **kwargs)

ExecuteAtGivenTimes

class mpacts.core.command.ExecuteAtGivenTimes

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed (approximately) at the specified times (maximaly once per time step) in its commandlist.
Has no default location.
  • Required keywords:
    • time_list — List of times after which the command will be executed. If the granularity is higher then the timestep it will be executed just once per timestep.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: time_list
ExecuteAtGivenTimes(name, parent, **kwargs)

ExecuteEveryNTimes

class mpacts.core.command.ExecuteEveryNTimes

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed every N-times in its commandlist.
Has no default location.
  • Optional keywords:
    • N (default value = 1) — Get/Set the amount of steps after which the command will be executed in its command list.
    • counter (default value = 0) — Get/Set the counter since which the command has been executed in its command list.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [counter, N]
ExecuteEveryNTimes(name, parent, **kwargs)

ExecuteEveryPCSizeChange

class mpacts.core.command.ExecuteEveryPCSizeChange

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure that a command is executed whenever the size of a given array manger has changed
Has no default location.
  • Required keywords:
    • mgr — Array Manager (particle container) to be monitored for size changes
  • Optional keywords:
    • last_size (default value = -1) — Last size of the provided array manager. Usually, this property should not be user-specified!
object __init__(tuple args, dict kwds) :
args: name, parent kwds: mgr, [last_size]
ExecuteEveryPCSizeChange(name, parent, **kwargs)

ExecuteEveryWallTimeInterval

class mpacts.core.command.ExecuteEveryWallTimeInterval

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed (approximately) every wall-time interval in its commandlist.
Has no default location.
  • Required keywords:
    • interval — The ‘interval’ in ‘the command is executed every interval seconds.’
object __init__(tuple args, dict kwds) :
args: name, parent kwds: interval
ExecuteEveryWallTimeInterval(name, parent, **kwargs)

ExecuteExceptFirstStep

class mpacts.core.command.ExecuteExceptFirstStep

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed after first step.
Has no default location.
object __init__(tuple args, dict kwds) :
args: name, parent kwds:
ExecuteExceptFirstStep(name, parent, **kwargs)

ExecuteFromTime

class mpacts.core.command.ExecuteFromTime

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed only from a given simulation time.
Has no default location.
  • Required keywords:
    • time (s) — Execute every time step from a given ‘time’.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: time
ExecuteFromTime(name, parent, **kwargs)

ExecuteNever

class mpacts.core.command.ExecuteNever

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is never executed in its commandlist. Usefull for debuging.
Has no default location.
object __init__(tuple args, dict kwds) :
args: name, parent kwds:
ExecuteNever(name, parent, **kwargs)

ExecuteOnce

class mpacts.core.command.ExecuteOnce

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is only executed once in its commandlist.
Has no default location.
  • Optional keywords:
    • executed (default value = 0) — Get/Set if the command has been executed in its command list.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [executed]
ExecuteOnce(name, parent, **kwargs)

ExecuteOncePerStep

class mpacts.core.command.ExecuteOncePerStep

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed only once per simulation time-step in its commandlist.
Has no default location.
object __init__(tuple args, dict kwds) :
args: name, parent kwds:
ExecuteOncePerStep(name, parent, **kwargs)

ExecuteTimeInterval

class mpacts.core.command.ExecuteTimeInterval

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed (approximately) every simulation-time interval or at the specified times in its commandlist.
Has no default location.
  • Optional keywords:
    • count (s) (default value = -1) — Current (in units of time) counter of the TimeIntervalGate.
    • interval (s) (default value = -1) — Execute after how many seconds (simulation-time)
    • time_list (default value = times) — List of times after which the command will be executed.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [interval, time_list, count]
ExecuteTimeInterval(name, parent, **kwargs)

ExecuteUntilTime

class mpacts.core.command.ExecuteUntilTime

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that makes sure its command is executed only up to a given simulation time.
Has no default location.
  • Required keywords:
    • time (s) — Execute every time step until a fiven ‘time’.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: time
ExecuteUntilTime(name, parent, **kwargs)

NotGate

class mpacts.core.command.NotGate

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that inverts another gate, usefull to execute for instance always BUT at certain intervals.
Has no default location.
  • Required keywords:
    • gate — Gate that will be inverted by this gate
object __init__(tuple args, dict kwds) :
args: name, parent kwds: gate
NotGate(name, parent, **kwargs)

OrGates

class mpacts.core.command.OrGates

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that AND combines two other gates.
Has no default location.
  • Required keywords:
    • gate1 — First gate to be OR combined.
    • gate2 — Second gate to be OR combined (if gate1 was false).
object __init__(tuple args, dict kwds) :
args: name, parent kwds: gate1, gate2
OrGates(name, parent, **kwargs)

ParallelCommandList

class mpacts.core.command.ParallelCommandList

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Collection (list) of commands, possibly executed in parallel. Is also a command itself, where execute() executes all children
Has no default location.
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [gate]
ParallelCommandList(name, parent, **kwargs)
execute((ParallelCommandList)self) → None :

Execute all commands in the commandlist.

first((ParallelCommandList)self) → Command :

Retrieves first command in list.

last((ParallelCommandList)self) → Command :

Retrieves last command in list.

PythonCommand

class mpacts.core.command.PythonCommand((object)arg1[, (str)name[, (object)parent]]) → None

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

A Command that can be overriden in python and where execute() will execute the python code from within C++. Example:

from mpacts.core.command import PythonCommand 

class ExampleCmd( PythonCommand ): 

        def __init__( self, name, parent, **kwargs): #parent typically is the simulation object 'mysim'
                PythonCommand.__init__( self, name, parent( 'loop_cmds/pre_body_force_cmds') )
                if 'gate' in kwargs.keys(): 
                        self.set( gate=kwargs['gate'] )
                #do other init stuff

        def execute( self ):
                print 'Command', self.name(), 'is being called from C++, yay!'
PythonCommand(name, parent, **kwargs)
python_object((PythonCommand)arg1) → object :

Get the original python object back, containing the overridden execute function

PythonFunctionCommand

class mpacts.core.command.PythonFunctionCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

A command that executes a python function (or function object) from within the simulation loop.
def example():
print mysim

PythonFunctionCommand(‘aname’, mysim, function=example) | Default location: ‘loop_cmds/pre_body_force_cmds’

  • Required keywords:
    • function — The python function to be executed. Needs to be callable (i.e. either be a function, or a class with a __call__ function)
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
object __init__(tuple args, dict kwds) :
args: name, parent kwds: function, [gate]
PythonFunctionCommand(name, parent, **kwargs)

TimedCommandList

class mpacts.core.command.TimedCommandList

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Collection (list) of commands, executed with timers in the order they are added. Is also a command itself, where execute() executes all children, using print all timing information can be obtained.
Has no default location.
  • Optional keywords:
    • executionTime (default value = Uninitialized) — Get/set the total execution time of the TimedCommandList.
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • timer_time (default value = 0) —
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [gate, executionTime, timer_time]
TimedCommandList(name, parent, **kwargs)
execute((TimedCommandList)self) → None :

Execute all commands in the commandlist whilst timing the results.

first((TimedCommandList)self) → Command :

Retrieves first command in list.

last((TimedCommandList)self) → Command :

Retrieves last command in list.

ToggleGate

class mpacts.core.command.ToggleGate

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate with a bool member deciding directly on execution or not.
Has no default location.
  • Required keywords:
    • execute — Determines whether or not the command will be executed directly. The value of execute is not modified by gate itself only read.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: execute
ToggleGate(name, parent, **kwargs)

VerboseCommandList

class mpacts.core.command.VerboseCommandList

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Collection (list) of commands, executed vebosely in the order they are added. Is also a command itself, where execute() executes all children
Has no default location.
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
object __init__(tuple args, dict kwds) :
args: name, parent kwds: [gate]
VerboseCommandList(name, parent, **kwargs)
execute((VerboseCommandList)self) → None :

Verbosely execute all commands in the commandlist.

first((VerboseCommandList)self) → Command :

Retrieves first command in list.

last((VerboseCommandList)self) → Command :

Retrieves last command in list.

VerboseExecute

class mpacts.core.command.VerboseExecute

Bases: mpacts.core.command.CommandGateBase, mpacts.core.baseobject.BaseObject

A gate that prints the command that is being executed in its commandlist.
Has no default location.
object __init__(tuple args, dict kwds) :
args: name, parent kwds:
VerboseExecute(name, parent, **kwargs)