|
Reactis API V2022.2
API - Reactis (C Bindings): Reactis Info File (Validator Objectives)
rsRsiAddAssertionDiagram
Add a diagram assertion.
Add an assertion of diagram type in a Simulink system.
Syntax
int rsRsiAddAssertionDiagram (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *objSysPath,
int numParams,
const char **paramNames,
const char **paramValues,
int numInputConn,
const char **inputNames,
const char **inputConn
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Specified as a path beginning
with the model name and separating subsystem names with “/”. For example:
“cruise/CruiseMain/CruiseMDL”.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- objSysPath
- Path of referenced objective in Validator library. Must be of form:
val_lib/path/to/objective, where val_lib.mdl|slx is the library file in
which the assertion diagram is located.
- numParams
- Number of mask parameters (int). This must match the number of mask
parameters of the objective subsystem in the val_lib.mdl|slx file.
- paramNames
- Mask parameter names (array of string). Can be NULL if numParams is 0.
- paramValues
- Mask parameter values (array of string). Entries in this array correspond
to the elements in the paramNames array. Can be NULL if numParams is 0.
- numInputConn
- Number of input connections (int). This must match the number of input
ports of the objective subsystem in the val_lib.mdl|slx file.
- inputNames
- Inport names of the assertion diagram (array of string). Can be NULL if
numInputConn is 0.
- inputConn
- Blocks that inports are connected to (array of string). Strings must
be formed as: blockname:portnumber. Entries in this array correspond to the
elements in the inputNames array. Can be NULL if numInputConn is 0.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add the SpdCheck assertion in
the “cruise/CruiseMain/CruiseMDL” subsystem of the cruise.mdl example:
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.mdl");
if( rsi ) {
const char *inputs[] =
{"speed", "dSpeed", "active"};
const char *inputConn[] =
{"speed:1", "DesiredSpeed:1", "Relational Operator1:1"};
if( !rsRsiAddAssertionDiagram(rsi, "cruise/CruiseMain/CruiseMDL", "SpdCheck", 1,
"cruise_validator/Assertion: SpeedMaintenance",
0, NULL, NULL, 3, inputs, inputConn) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiAddAssertionExpression
Add an expression assertion.
Add an assertion of expression type in a Simulink system.
Syntax
int rsRsiAddAssertionExpression (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
int hold,
const char *expression,
int numInputConn,
const char **inputNames,
const char **inputConn
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Specified as a path beginning
with the model name and separating subsystem names with “/”. For example:
“cruise/CruiseMain/CruiseMDL”.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- hold
- Number of (sequential) steps expression must evaluate to false before
assertion is violated (integer).
- expression
- c-like expression that evaluates to zero when the assertion is
violated. See Section
9.3.1 for a description of the expression syntax.
- numInputConn
- Number of input connections (integer).
- inputNames
- Names of variables used in the expression (array of string). Can be NULL if
numInputConn is 0.
- inputConn
- Blocks that inports are connected to (array of string). Strings must be
formed as: blockname:portnumber. Entries in this array correspond to the
elements in the inputNames array. Can be NULL if numInputConn is 0.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add the "Brake" assertion in the
top-level system of the "cruise.mdl" example:
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.mdl");
if( rsi )
{
const char *inputs[] = {"active", "brake"};
const char *inputConn[] = {"CruiseMain:1", "brake:1"};
if( !rsRsiAddAssertionExpression(rsi, "cruise", "Brake", 1, 0,
"!(brake && active)", 2, inputs, inputConn) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiAddAssertionTimer
Add a timer assertion.
Add a timer assertion in a Simulink system. The assertion is counted as
violated if the monitored block output reaches or exceeds the specified
timer end value.
Syntax
int rsRsiAddAssertionTimer (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *connection,
double start,
double step,
double end
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Specified as a path beginning
with the model name and separating subsystem names with “/”. For example:
“cruise/CruiseMain/CruiseMDL”.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- connection
- Name and output port number of block to be monitored as a timer. String must be formed as: blockname:portnumber.
- start
- Timer start value.
- step
- Timer step size.
- end
- Timer end value.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add a timer assertion to a model,
assuming that ’Sum’ is a block which is part of timer circuit that counts
from 0 to 100. The assertion will fail if the timer ever reaches its
maximum value:
RsRsiFile *rsi = rsRsiOpen(h, "testmodel.rsi", "testmodel.mdl");
if( rsi )
{
if( !rsRsiAddAssertionTimer(rsi, "testmodel/subsys", "MyTimer", 1,
"Sum:1", 0, 1, 100) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "testmodel.rsi");
rsRsiClose(rsi);
}
rsRsiAddUserTargetDiagram
Add a diagram-based user-defined target.
Add a user-defined target of diagram type in a Simulink system.
Syntax
int rsRsiAddUserTargetDiagram (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *objSysPath,
int numParams,
const char **paramNames,
const char **paramValues,
int numInputConn,
const char **inputNames,
const char **inputConn
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Specified as a path beginning
with the model name and separating subsystem names with “/”. For example:
“cruise/CruiseMain/CruiseMDL”.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- objSysPath
- Path of referenced objective in Validator library. Must be of form:
val_lib/path/to/objective where val_lib.mdl|slx is the library file in
which the assertion diagram is located.
- numParams
- Number of mask parameters (int). This must match the number of mask
parameters of the objective subsystem in the val_lib.mdl/slx file.
- paramNames
- Mask parameter names (array of string). Can be NULL if numParams is 0.
- paramValues
- Mask parameter values (array of string). Entries in this array correspond to the elements in the paramNames array. Can be NULL if numParams is 0.
- numInputConn
- Number of input connections (int). This must match the number of input ports
of the objective subsystem in the val_lib.mdl/slx file.
- inputNames
- Inport names of the user-defined target diagram (array of string). Can be
NULL if numInputConn is 0.
- inputConn
- Blocks that inports are connected to (array of string). Strings must
be formed as: blockname:portnumber. Entries in this array correspond to the
elements in the inputNames array. Can be NULL if numInputConn is 0.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add the LowSpeedOn
user-defined target in the top-level system of the cruise.mdl example:
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.mdl");
if( rsi ) {
const char *inputs[] = {"onOff", "speed"};
const char *inputConn[] = {"onOff:1", "Plant:1"};
if( !rsRsiAddUserTargetDiagram(
rsi, "cruise", "LowSpeedOn", 1,
"cruise_validator/User-defined target: LowSpeedOn",
0, NULL, NULL, 2, inputs, inputConn) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiAddUserTargetExpression
Add an expression-based user-defined target.
Add a user-defined target of expression type in a Simulink system.
Syntax
int rsRsiAddUserTargetExpression (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
int hold,
const char *expression,
int numInputConn,
const char **inputNames,
const char **inputConn
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Specified as a path beginning
with the model name and separating subsystem names with "/". For example:
"cruise/CruiseMain/CruiseMDL".
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- hold
- Number of (sequential) steps expression must evaluate to true before target
is covered (integer).
- expression
- c-like expression that evaluates to a non-zero value when the target is
covered. See Section
9.3.1 for a description of the expression syntax.
- numInputConn
- Number of input connections (integer).
- inputNames
- Names of variables used in the expression (array of string). Can be NULL if
numInputConn is 0.
- inputConn
- Blocks that inports are connected to (array of string). Strings must
be formed as: blockname:portnumber. Entries in this array correspond to the
elements in the inputNames array. Can be NULL if numInputConn is 0.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add the Active_30 user-defined
target in the top-level system of the cruise.mdl example:
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.mdl");
if( rsi ) {
const char *inputs[] = {"x1"};
const char *inputConn[] = {"CruiseMain:1"};
if( !rsRsiAddUserTargetExpression(rsi, "cruise", "Active_30", 1, 30,
"x1 == 1", 1, inputs, inputConn) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiAddUserTargetTimer
Add a timer-based user-defined target.
Add a timer target in a Simulink system. The target is counted as
covered if the monitored block output reaches or exceeds the specified
timer end value.
Syntax
int rsRsiAddUserTargetTimer (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *connection,
double start,
double step,
double end
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Specified as a path beginning
with the model name and separating subsystem names with “/”. For example:
“cruise/CruiseMain/CruiseMDL”.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- connection
- Name and output port number of block to be monitored as a timer. String
must must be formed as: blockname:portnumber.
- start
- Timer start value.
- step
- Timer step size.
- end
- Timer end value.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add a timer target to a model, assuming
that ’Sum’ is a block which is part of timer circuit that counts from 0 to
100:
RsRsiFile *rsi = rsRsiOpen(h, "testmodel.rsi", "testmodel.mdl");
if( rsi )
{
if( !rsRsiAddUserTargetTimer(rsi, "testmodel/subsys", "MyTimer", 1,
"Sum:1", 0, 1, 100) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "testmodel.rsi");
rsRsiClose(rsi);
}
rsRsiAddStateflowAssertionExpression
Add an expression assertion.
Add an assertion in a Stateflow chart or state.
Syntax
int rsRsiAddStateflowAssertionExpression (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
int hold,
const char *expression,
const char *actionType
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- Chart or state in which objective is to be placed. Specified as a path
beginning with the model name and separating subsystem, chart and state
names with "/". For example: "cruise/CruiseMain/CruiseMDL/Mode/On".
Specifies state "On" within chart "Mode" which is located in system
"cruise/CruiseMain/CruiseMDL".
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- hold
- Number of (sequential) steps expression must evaluate to false before
assertion is violated (integer).
- expression
- c-like expression that evaluates to zero when the assertion is
violated. See Section
9.3.1 for a description of the expression syntax.
- actionType
- Point of execution at which objective is evaluated (string):
- entry
- When entering the state in which objective is located.
- during
- While the state in which objective is located is active.
- exit
- When exiting the state in which objective is located.
- chartentry
- When execution moves to the chart in which objective is located.
- chartexit
- When execution moves away from the chart in which objective is located.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add an assertion in the Mode
chart of the cruise.mdl example to assure that state On/Active is
inactive when deactivate is non-zero:
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.mdl");
if( rsi )
{
if( !rsRsiAddStateflowAssertionExpression(
rsi, "cruise/CruiseMain/CruiseMDL/Mode/On/Active",
"activeExit", 1, 0, "deactivate==0", "during") )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiAddStateflowAssertionTimer
Add a timer assertion.
Add a timer assertion in a Stateflow chart or state. The assertion is
counted as violated if the monitored variable reaches or exceeds the
specified timer end value.
Syntax
int rsRsiAddStateflowAssertionTimer (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *connection,
double start,
double step,
double end
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- Chart or state in which objective is to be placed. Specified as a path
beginning with the model name and separating subsystem, chart and state
names with "/". For example: "cruise/CruiseMain/CruiseMDL/Mode/On".
Specifies state "On" within chart "Mode" which is located in system
"cruise/CruiseMain/CruiseMDL".
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- hold
- Number of (sequential) steps expression must evaluate to false before
assertion is violated (integer).
- connection
- Name of Stateflow variable to be monitored as a timer.
- start
- Timer start value.
- step
- Timer step size.
- end
- Timer end value.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add an assertion in the pump
chart of the gasStation.mdl example. Make sure the ccWait timer
never exceeds its final value of 51:
RsRsiFile *rsi = rsRsiOpen(h, "gasStation.rsi", "gasStation.mdl");
if( rsi )
{
if( !rsRsiAddStateflowAssertionTimer(
rsi, "gasStation/main/pump/On/Enabled/waitCcCheck",
"assertion1", 1, "ccWait", 0, 1, 52) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "gasStation.rsi");
rsRsiClose(rsi);
}
rsRsiQueryObjectives
Query Validator objectives.
Query Validator objectives in the given .rsi file.
Syntax
int rsRsiQueryObjectives(
RsRsiFile *hRsi,
const char *sys,
void *options
);
Parameters
- hRsi
- Pointer to RsRsiFile structure as returned by rsRsiOpen.
- sys
- Specify system from which objectives should be listed. Specified
as a path beginning with the model name and separating subsystem names
with "/". For example: "cruise/CruiseMain/CruiseMDL" Can be NULL, in
that case all objectives from all systems will be listed.
- options
- Reserved for future use, must be NULL.
Return Value
Non-negative integer representing the number of objectives that matched the query.
-1 if an error occurred. In that case, call rsGetLastError to retrieve the error message string.
rsRsiGetQueriedObjectiveId
Returns an identifier for a Validator objective.
Returns an identifier for a Validator objective in the .rsi file.
Syntax
int rsRsiGetQueriedObjectiveId (
RsRsiFile *hRsi,
int index
);
Parameters
- hRsi
- Pointer to RsRsiFile structure as returned by rsRsiOpen.
- index
- Index of the objective. This value must be greater or equal to 0 and less than the return value of the most recent call to rsRsiQueryObjectives.
Return Value
Non-negative integer representing an identifier for the objective.
-1 if an error occurred. In that case, call rsGetLastError to retrieve the error message string.
rsRsiGetObjectiveParameterValue
Get the value of a Validator objective parameter.
Syntax
int rsRsiGetObjectiveParameterValue(
RsRsiFile *hRsi,
int id,
const char *paramName,
char *buffer,
int bufferSize
);
Parameters
- hRsi
- Pointer to RsRsiFile structure as returned by rsRsiOpen.
- id
- Validator objective id returned by rsRsiGetQueriedObjectiveId.
- paramName
- Name of the parameter. Valid names are:
- Name
- Name of the objective.
- Location
- Location of the objective.
- Type
- Type of objective (diagram/expression, assertion/target).
- InputCount
- Number of inputs of the objective.
- OutputCount
- Number of outputs of the objective (virtual sources only).
- InputNameN
- Name of input #N.
- InputConnectionN
- Block:port to which input #N is connected.
- OutputNameN
- Name of output #N (virtual sources only).
- OutputConnectionN
- Block:port to which input #N is connected (virtual sources only).
- buffer
- The buffer that receives the value. The buffer's size must
correspond to the value of the bufferSize parameter. If the buffer
parameter is NULL then the value returned by rsSuiteGetTestName will
be the buffer size required to store the whole name.
- bufferSize
- The size of the buffer passed in as the fourth argument. If the
actual name is longer than this value, it will be truncated to the
length of the buffer. In that case the return value of
rsSuiteGetTestName will be the buffer size that would be required to
receive the whole name.
Return Value
- -1
- If an error occurred. In this case you may call
rsGetLastError to retrieve the error message string.
- 0
- On success.
- A value greater than 0
- If either the buffer parameter is NULL or the bufferSize was not
sufficient to receive the complete name. In that case the value
returned specifies the buffer size required to store the complete
name.
rsRsiRemoveObjective
Remove a Validator objective.
Syntax
int rsRsiRemoveObjective(
RsRsiFile *hRsi,
const char *location,
const char *name
);
Parameters
- hRsi
- Pointer to RsRsiFile structure as returned by rsRsiOpen.
- sys
- System in which the objective is located. Specified as a path
beginning with the model name and separating subsystem names with "/".
For example: "cruise/CruiseMain/CruiseMDL".
- name
- Name of the objective to be removed.
Return Value
- 0
- If an error occurred. In this case call rsGetLastError to get
the error string.
- 1
- If no error occurred.
rsRsiAddStateflowUserTargetExpression
Add an expression-based user-defined target.
Add a user-defined target in a Stateflow chart or state.
Syntax
int rsRsiAddStateflowUserTargetExpression (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
int hold,
const char *expression,
const char *actionType
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- Chart or state in which objective is to be placed. Specified as a path
beginning with the model name and separating subsystem, chart and state
names with “/”. For example: “cruise/CruiseMain/CruiseMDL/Mode/On”.
Specifies state “On” within chart “Mode” which is located in system
“cruise/CruiseMain/CruiseMDL”.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- hold
- Number of (sequential) steps expression must evaluate to true before target
is covered (integer).
- expression
- c-like expression that evaluates to a non-zero value when the target is
covered. See Section
9.3.1 for a description of the expression syntax.
- actionType
- Point of execution at which objective is evaluated (string):
- entry
- When entering the state in which objective is located.
- during
- While the state in which objective is located is active.
- exit
- When exiting the state in which objective is located.
- chartentry
- When execution moves to the chart in which objective is located.
- chartexit
- When execution moves away from the chart in which objective is located.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add a user-defined target in the
Mode chart of the cruise.mdl example to test whether state
On/Active has been exited due to deactivate becoming
non-zero.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.mdl");
if( rsi )
{
if( !rsRsiAddStateflowUserTargetExpression(
rsi, "cruise/CruiseMain/CruiseMDL/Mode/On/Active",
"deactivateExit", 1, 0, "deactivate!=0", "exit") )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiAddStateflowUserTargetTimer
Add a timer-based user-defined target.
Add a timer target in a Stateflow chart or state. The target is counted
as covered if the monitored variable reaches or exceeds the specified timer
end value.
Syntax
int rsRsiAddStateflowUserTargetTimer (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *connection,
double start,
double step,
double end
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- Chart or state in which objective is to be placed. Specified as a path
beginning with the model name and separating subsystem, chart and state
names with “/”. For example: “cruise/CruiseMain/CruiseMDL/Mode/On”.
Specifies state “On” within chart “Mode” which is located in system
“cruise/CruiseMain/CruiseMDL”.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- hold
- Number of (sequential) steps expression must evaluate to true before target
is covered (integer).
- connection
- Name of Stateflow variable to be monitored as a timer.
- start
- Timer start value.
- step
- Timer step size.
- end
- Timer end value.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add a user-defined target in the
pump chart of the gasStation.mdl example to assist in incrementing
the ccWait timer to its maximum value of 51:
RsRsiFile *rsi = rsRsiOpen(h, "gasStation.rsi", "gasStation.mdl");
if( rsi )
{
if( !rsRsiAddStateflowUserTargetTimer(
rsi, "gasStation/main/pump/On/Enabled/waitCcCheck",
"timer1", 1, "ccWait", 0, 1, 51) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "gasStation.rsi");
rsRsiClose(rsi);
}
rsRsiAddVirtualSourceDiagram
Add a diagram-based virtual source.
Add a virtual source of diagram type.
Syntax
int rsRsiAddVirtualSourceDiagram (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *objSysPath,
int numParams,
const char **paramNames,
const char **paramValues,
int numInputConn,
const char **inputNames,
const char **inputConn,
int numOutputConn,
const char **outputNames,
const char **outputConn
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Note: Virtual sources must be
placed in the top-level system of the model.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- objSysPath
- Path of referenced objective in Validator library. Must be of form:
val_lib/path/to/objective where val_lib.mdl|slx is the library file in
which the assertion diagram is located.
- numParams
- Number of mask parameters (int). This must match the number of mask
parameters of the objective subsystem in the val_lib.mdl/slx file.
- paramNames
- Mask parameter names (array of string). Can be NULL if numParams is 0.
- paramValues
- Mask parameter values (array of string). Entries in this array correspond to the elements in the paramNames array. Can be NULL if numParams is 0.
- numInputConn
- Number of input connections (int). This must match the number of input
ports of the virtual source in the val_lib.mdl/slx file.
- inputNames
- Inport names of the virtual source (array of string). Can be
NULL if numInputConn is 0.
- inputConn
- Blocks that inports are connected to (array of string). Strings must
be formed as: blockname:portnumber. Entries in this array correspond to the
elements in the inputNames array. Can be NULL if numInputConn is 0.
- numOutputConn
- Number of output connections (int). This must match the number of output
ports of the virtual source in the val_lib.mdl|slx file.
- outputName
- Outport names (array of string).
- outputConn
- Names of inport blocks in the model that the virtual source outports are
connected to (array of string). Entries in this array correspond to the
elements in the outputName array.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add the ActiveCheckScenario
virtual source in cruise_vs.rsi for the cruise.mdl example:
RsRsiFile *rsi = rsRsiOpen(h, "cruise_vs.rsi", "cruise.mdl");
if( rsi )
{
const char *outputs[] =
{"onOff", "accelResume", "cancel", "decelSet", "brake", "gas"};
const char *outputConn[] =
{"onOff", "accelResume", "cancel", "decelSet", "brake", "gas"};
if( !rsRsiAddVirtualSourceDiagram(
rsi, "cruise", "ActiveCheckScenario", 1,
"cruise_validator/ActiveCheckScenario",
0, NULL, NULL, 0, NULL, NULL,
6, outputs, outputConn) )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise_vs.rsi");
rsRsiClose(rsi);
}
rsRsiAddVirtualSourceExpression
Add an expression-based virtual source.
Add a virtual source of ’expression’ type.
Syntax
int rsRsiAddVirtualSourceExpression (
RsiFile *hRsi,
const char *sys,
const char *name,
int enabled,
const char *expression,
int numInputConn,
const char **inputNames,
const char **inputConn,
const char *outputConn
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- sys
- System in which objective is to be placed. Note: Virtual sources must be
placed in the top-level system of the model.
- name
- Name of the objective.
- enabled
- Objective enabled/disabled (boolean).
- expression
- c-like expression that evaluates to the intended value for the input
port. See Section
9.3.1 for a description of the expression syntax.
- numInputConn
- Number of input connections (integer).
- inputNames
- Names of variables used in the expression (array of string). Can be NULL if
numInputConn is 0.
- inputConn
- Blocks that inports are connected to (array of string). Strings must
be formed as: blockname:portnumber. Entries in this array correspond to the
elements in the inputNames array. Can be NULL if numInputConn is 0.
- outputConn
- Name of input port that the virtual source feeds into.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
Example Code
The following code could be used to add a virtual source to the cruise.mdl
example that maintains the drag input at 1/100 of the current
speed:
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.mdl");
if( rsi )
{
const char *inputs[] = {"speed"};
const char *inputConn[] = {"Plant:1"};
if( !rsRsiAddVirtualSourceExpression(rsi, "cruise", "dragSource", 1,
"speed/100", 1, inputs, inputConn,
"drag") )
{
printf("Error: %s\n", rsGetLastError(h));
}
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
|