Using the editor¶
Window layout¶
| Area | What it does |
|---|---|
| Library (left) | All blocks, grouped by category. Type in the search box to filter. Drag a block onto the canvas or double-click it. Hover for a short description. |
| Canvas (centre) | The diagram. |
| Properties (right) | Parameters of the selected block. Press ? for the block's help. |
| Model Workspace (bottom, tab) | Named parameters that blocks can use. See Workspace and calibrations. |
| Diagnostics (bottom) | Problems in the model, such as unconnected inputs or algebraic loops. Click an entry to select the blocks involved. |
Panels can be moved, closed and reopened from the View menu.
Blocks¶
- Select: click, or drag a rectangle on empty canvas. Shift-click adds to the selection.
- Move: drag. Blocks snap to a 10-pixel grid.
- Rename: edit Name in the Properties panel, or right-click → Rename…. Names must be unique.
- Delete: Delete or Backspace.
- Copy / cut / paste: ⌘C / ⌘X / ⌘V (Ctrl on Windows and Linux). Lines between copied blocks are copied too.
- Double-click: opens a subsystem, the plot window of a Scope, or the Properties panel for other blocks.
- Flip: Ctrl+Shift+F swaps the input and output sides (see below).
Lines (signals)¶
- Drag from an output port (right side, ▸) to an input port (left side). You can also start from an input and drag backwards to an output.
- An output can feed many inputs (a dot marks the branch). An input has exactly one source. Connecting a new line to an input that is already used replaces the old line.
- Click a line to select it; Delete (or right-click → Delete Wire) removes it.
- Lines are routed automatically with right angles. When the direct route would pass through a block, the line goes around the blocks (the shortest route with the fewest bends).
- Drag a line segment to place it yourself: the middle segments move sideways; the short segments at the ports follow the blocks. Lines from the same output move together at a shared segment, so dragging the segment at a branch moves the branch point. Manually placed lines keep their corners when blocks move (the ends follow the ports) and are saved with the model. Right-click → Reset Route returns to automatic routing.
- Hover over a port to see which input it is, e.g. input 2: reset (rising) on a Discrete-Time Integrator with an external reset, or k1, f1 on an Interpolation block.
Right-click menus¶
Right-click a block, a wire or the empty canvas for the actions that fit it:
| On | Actions |
|---|---|
| a block | Rename, help, cut / copy / delete, create a subsystem from the selection; Open Scope for scopes |
| a subsystem | also Open Subsystem, Edit Mask…, Variants…, Save Subsystem to Library…, Generate C Code… (or Break Library Link when it is linked) |
| a wire | Delete Wire |
| the canvas | paste, select all, auto layout, fit to window, up to the parent system |
Right-clicking a block that is part of a selection keeps the selection, so Delete or Create Subsystem act on all selected blocks.
Flipping blocks for feedback paths¶
Feedback paths, such as a sensor signal going back to the controller, are easier to read when they run from right to left. Select blocks and press Ctrl+Shift+F (Edit → Flip Block, or right-click → Flip Block): their inputs move to the right side and their outputs to the left. Flipping only changes the drawing, and it is saved with the model.
In Python, set block.meta["flipped"] = True.
Rotating, resizing and nudging blocks¶
Ctrl+Shift+R (Edit → Rotate Block, or right-click → Rotate Block) turns the selected blocks a quarter turn clockwise: the signal then flows down (inputs on top, outputs at the bottom), then to the left, then up, then right again. Use it for signal chains drawn top to bottom, like a sensor path. Flipping a rotated block swaps top and bottom.
To make a block bigger, select it and drag the grip in its lower right corner; blocks never get smaller than their natural size. Edit → Reset Block Size undoes it. The arrow keys move the selected blocks by one grid step, Shift+arrow by five. All of these can be undone and are saved with the model.
In Python: block.meta["vertical"] = True (with flipped for upwards), block.meta["size"] = [140, 80].
Sample times, widths and data types on the canvas¶
The View menu can annotate the diagram with what the compiler found out:
| View → | Shows |
|---|---|
| Show Data Types | the data type on every wire that is not double (int16, fixdt(1,16,8), ...) |
| Show Signal Widths | [3] on vector wires, which are also drawn thicker |
| Sample Time Colours | blocks and wires coloured by their sample time, with a legend in the status bar |
The discrete rates get colours from fastest to slowest (orange, green, blue, amber, ...); continuous blocks keep the normal colour and constant blocks are pink. A subsystem whose blocks all run at one rate takes that colour. Use it to check that every block of an ECU task really runs in that task, and to find where a Rate Transition is needed. The annotations update while you edit, once the model compiles.
Editing parameters¶
Numeric fields accept:
| You type | Meaning |
|---|---|
0.5, -1e-3 |
numbers |
2*pi, 1/0.05, sqrt(2) |
arithmetic; pi, e, inf are known |
[1 2 3] or [1, 2, 3] |
vectors |
[1 2; 3 4] |
matrices (rows separated by ;, as in MATLAB) |
Kp, 1/tau, 2*Kp |
workspace variables and expressions of them |
Kp * (MODE == 2), A > 1 && B ~= 0 |
comparisons and logic give 1 or 0 (MATLAB ~=, &&, \|\|, ~ work too) |
Press Enter or leave the field to apply. If a value is invalid the field turns red and the old value is kept.
Tidying up¶
Edit → Auto Layout (⇧⌘L / Ctrl+Shift+L) arranges the blocks of the shown diagram from left to right in signal-flow order. It can be undone like any other edit.
Scripting console¶
View ▸ Console (a tab next to the Model Workspace) runs Python with the open model and its results in scope:
| Name | What it is |
|---|---|
model |
the open model (a Diagram): model.block("pid").params, model.workspace["Kp"] |
res, runs |
the last result and all runs in the Data Inspector: res["speed"].max() |
simulate, load, save |
run, open and save models |
block classes, blocks |
model.add(Gain(gain=2), name="k") |
np, plt |
NumPy and Matplotlib |
window |
the main window, for scripting the app itself |
Statements over several lines work as in the Python prompt (finish with an empty line); ↑ and ↓ recall
earlier lines. Errors are printed in the console. Changes a statement makes to the model appear in the
editor at once and are one undo step (Edit ▸ Undo reverts them). Assigning another model to model
(e.g. model = load("examples/drive_cycle.nervus")) opens it.
Undo¶
Every change, including moves, can be undone with ⌘Z and redone with ⇧⌘Z (Ctrl+Z / Ctrl+Y).
Zoom and pan¶
- Zoom: ⌘/Ctrl + mouse wheel, trackpad pinch, or ⌘+ / ⌘−. Fit to window: ⌘0.
- Pan: two-finger scroll on a trackpad, the middle mouse button, or hold Space and drag.
Themes¶
View → Theme switches between light and dark, or follows the system setting.