Overview

We build a more interesting system still by linking processes together so that they can pass data to one another. We can add a link to any system, from any single output port (of a process) to any single input port (of a process). We're going to need a second process, before we try this.

Procedure

  • Add a second process to the system.
  • Link an output port to an input port.
  • Call brahms to execute the system.
Notes
  • The call link() will not object if the source and destination of the link do not exist in the System (you may intend to add them later, and in any case the name of any output Ports of Processes in the System are not generally known until run-time).
    • If the source of a link does not exist at run-time, E_DEADLOCK will be raised.
    • If the destination of a link does not exist at run-time, E_SYSTEM_FILE will be raised.

Example

Script

This example, along with the others in this section, can be found in the script developing_systems.m in the support/tutorial/system/matlab folder.

M Source Code (against 995)
% section header disp([10 '=== Add Link ===' 10]) % choose the class of a new process cls = 'std/2009/resample/numeric'; % design the parameters of the new process state = []; state.order = 1; % choose its sample rate (Hz) fS = 7; % add process to the system using these parameters sys = sys.addprocess('dst', cls, fS, state); % view the two process system sys % add link from src to dst sys = sys.link('src>out', 'dst'); % view the linked system sys % execute the system out = brahms(sys, exe); % view the system outputs out out.src out.dst

Expected Output

Matlab Console
=== Add Link === -------------------------------- SystemML System -------------------------------- ['untitled'] "src" (std/2009/source/numeric) "dst" (std/2009/resample/numeric) -------------------------------- -------------------------------- SystemML System -------------------------------- ['untitled'] "src" (std/2009/source/numeric) "dst" (std/2009/resample/numeric) ==> src>out ==> dst -------------------------------- out = src: [1x1 struct] dst: [1x1 struct] ans = out: [1 2 3 4 5 6 7 8 9 10] ans = out: [0 0.42857 1.8571 3.2857 4.7143 6.1429 7.5714]