-
Notifications
You must be signed in to change notification settings - Fork 37
Block methods and attributes
Peter Corke edited this page Jun 6, 2021
·
3 revisions
The Block object and its subclasses are key to bdsim.
| Subclass | Purpose |
|---|---|
SourceBlock |
data source, outputs only |
SinkBlock |
data sink, inputs only, but not graphical |
GraphicsBlock |
data sink, inputs only, but graphical |
FunctionBlock |
instantaneous function of inputs, no state |
TransferBlock |
transfer function, has dynamics and state |
SubsystemBlock |
represents a subsystem and its connections |
ClockedBlock |
a discrete time block with states |
| Method name | Called when | Purpose |
|---|---|---|
new |
at construction | adds a reference to the owning block diagram |
__init__ |
at construction | processes common arguments |
| add_outport | connecting | connect wire to block output port |
| add_inport | connecting | connect wire to block input port |
| start | simulation startup | initialise the block ready for simulation, report events |
| check | simulation startup | sanity check block parameters like number of inputs, outputs, states etc. |
| done | end of simulation | clean up, write files, matplotlib block etc. |
| step | every integrator time step | save output/state information |
| output | every integrator iteration | return output of the block based on time, inputs, state |
| setinput | every integrator iteration | set block port input value |
| setinputs | every integrator iteration | set all block port input values |
__getitem__ |
diagram construction | create a plug by wire index or slice |
__getattr__ |
diagram construction | create a plug from block port name |
__setitem__ |
diagram construction | create a wire |
__setattr__ |
diagram construction | create a wire |
| rshift | diagram construction | operator creates wire between operand blocks/plugs |
| _fixname | constructor | turn LaTeX port names to valid Python identifier name |
| inport_names | constructor | set block input port names |
| outport_names | constructor | set block output port names |
| state_names | constructor | set block state names, they are used in output object and plots |
| sourcename | Get the name of output port driving this input port | |
info |
print information about the block |
|
| isclocked | true if the block is clocked |
| Method name | Called when | Purpose |
|---|---|---|
| savefig | end of simulation |
GraphicsBlock only |
| Method name | Called when | Purpose |
|---|---|---|
| reset | start of simulation | copy initial state to current state |
| getstate0 | start of simulation | return initial state vector |
| setstate | every integrator time step | set state vector |
| Attribute name | Purpose |
|---|---|
| nin | number of input ports |
| nout | number of output ports |
| nstates | number of continuous-time states |
| ndstates | number of discrete-time states |
| id | unique sequential integer identifier, starts at 0 |
| _clocked | bool, true if block is clocked |
| _input_names | list of names of input ports, includes LaTeX markup |
| _output_names | list of names of output ports, includes LaTeX markup |
| _state_names | list of names of states, includes LaTeX markup |
| inports | list(nin) of wires connected to input ports |
| outports | list(nout) of wires connected to output ports |
| _x | current state vector |
| _x0 | initial state vector, set at construction time |
Copyright (c) Peter Corke 2020-23
- Home
- FAQ
- Changes
- Adding blocks
- Block path
- Connecting blocks
- Subsystems
- Compiling
- Running
- Runtime options
- Discrete-time blocks
- Figures
- Real time control
- PID control
- Coding patterns