


xxsimCreateConnection - Create a connection between a port on the
source submodel and a port on the target
submodel.
Syntax:
retval = xxsimCreateConnection(fromSubmodel, fromPort, toSubmodel, toPort)
Inputs:
fromSubmodel = Name of the source submodel where the connection should start.
fromPort = Name of the source port where the connection should start.
toSubmodel = Name of the target submodel where the connection should end.
toPort = Name of the target port where the connection should end.
Outputs:
retval = true on success, false on failure
Examples:
retval = xxsimCreateConnection('SubmodelA', 'output', 'SubmodelB', 'input')
- Creates a signal connection from SubmodelA\output to SubmodelB\input.
Author: Controllab Products B.V.
Email: info@controllab.nl
Website: https://www.20sim.com
January 2021


0001 function retval = xxsimCreateConnection(fromSubmodel, fromPort, toSubmodel, toPort) 0002 % xxsimCreateConnection - Create a connection between a port on the 0003 % source submodel and a port on the target 0004 % submodel. 0005 % 0006 % Syntax: 0007 % retval = xxsimCreateConnection(fromSubmodel, fromPort, toSubmodel, toPort) 0008 % 0009 % Inputs: 0010 % fromSubmodel = Name of the source submodel where the connection should start. 0011 % fromPort = Name of the source port where the connection should start. 0012 % toSubmodel = Name of the target submodel where the connection should end. 0013 % toPort = Name of the target port where the connection should end. 0014 % 0015 % Outputs: 0016 % retval = true on success, false on failure 0017 % 0018 % Examples: 0019 % retval = xxsimCreateConnection('SubmodelA', 'output', 'SubmodelB', 'input') 0020 % 0021 % - Creates a signal connection from SubmodelA\output to SubmodelB\input. 0022 % 0023 % Author: Controllab Products B.V. 0024 % Email: info@controllab.nl 0025 % Website: https://www.20sim.com 0026 % January 2021 0027 0028 %------------- BEGIN CODE -------------- 0029 % Check the obtained amount of input arguments. 0030 if(nargin<4) 0031 error('Not enough input arguments were specified.'); 0032 end; 0033 0034 % Check if the submodelName is a string. 0035 if(~ischar(fromSubmodel)) 0036 error('Please specify a valid fromSubmodel name.'); 0037 end; 0038 if(~ischar(toSubmodel)) 0039 error('Please specify a valid toSubmodel name.'); 0040 end; 0041 0042 % Check if the portName is a string. 0043 if(~ischar(fromPort)) 0044 error('Please specify a valid fromPort name.'); 0045 end; 0046 if(~ischar(toPort)) 0047 error('Please specify a valid toPort name.'); 0048 end; 0049 0050 % invoke 20-sim with the xmlrpc call 0051 input_args = struct('sourceSubmodelName', fromSubmodel, 0052 'sourcePortName', fromPort, 0053 "targetSubmodelName", toSubmodel, 0054 "targetPortName", toPort); 0055 retval = xrlinvoke('xxsim.model.createConnection', input_args); 0056 end