Reactis API V2020
API - Reactis: C Bindings - Reactis Info File (Configuration Variables)
rsRsiAddConfigVar
Add a configuration variable to the .rsi file.
Adds the variable specified by the ’name’ parameter as a new
configuration variable. If that variable was already a configuration
variable, then rsRsiAddConfigVar behaves the same as
rsRsiSetConfigVarType. For a description of the syntax of types in
.rsi files, see
Section 5.3.2 in the Reactis User’s guide.
Syntax
int rsRsiAddConfigVar (
RsiFile *hRsi,
const char *name,
const char *type,
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- name
- Name of the configuration variable.
- type
- Type of the configuration variable.
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 configuration variable named
“InitialSpeed”.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
rsRsiAddConfigVar(rsi, "InitialSpeed", "double{10.0, 30.0, 40.0}");
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiRemoveConfigVar
Remove configuration variable from .rsi file.
Syntax
int rsRsiRemoveConfigVar ( RsiFile * h, const char *Name);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
- Name
- Name of the configuration variable 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.
Example Code
The following code could be used to remove an existing configuration
variable.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
rsRsiRemoveConfigVar(rsi, "InitialSpeed");
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiGetNumConfigVars
Number of configuration variables in an .rsi file.
Return the number of configuration variables currently set in the .rsi
file.
Syntax
int rsRsiGetNumConfigVars (RsiFile *h);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
Return Value
Returns the number of configuration variables in the .rsi file
specified by the h parameter or -1 if an error occurred. In
that case, you may call rsGetLastError to retrieve the error message
string.
Example Code
The following code could be used to get the quantity of configuration
variables already assigned from the cruise.rsi file.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
int num_cvs;
num_cvs = rsRsiGetNumConfigVars(rsi);
rsRsiClose(rsi);
}
rsRsiGetConfigVarName
Return name of a configuration variable with the given index.
Return the name of a configuration variable.
Syntax
int rsRsiGetConfigVarName (
RsiFile *h,
int index,
char *buffer,
int bufferSize
);
Parameters
- h
- Pointer to an RsiFile structure as returned by rsRsiOpen.
- index
- The index of the configuration variable. This value must be greater or
equal to 0 and less than the return value of rsRsiGetNumConfigVars.
- buffer
- The buffer that receives the name of the configuration variable. The
buffer’s size must correspond to the value of the bufferSize
parameter. If the buffer parameter is NULL then the value returned by
rsRsiGetConfigVarName will be the buffer size required to store the whole
name.
- bufferSize
- The size of the buffer passed in as the third 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 rsRsiGetConfigVarName will
be the buffer size that would be required to receive the whole name.
Return Value
- -1
- If an error occurred (the index parameter is
outside the valid range).
- 0
- On success.
- A value greater than 0
- If either the buffer parameter is NULL
or the bufferSize parameter was not sufficient to receive the
complete name. In that case, the value returned specifies the buffer size
required to store the complete name.
Example Code
The following code could be used to get the names of the variables
already assigned as configuration variables from the cruise.rsi file.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
int cvn_index;
int num_cvs;
char buffer[100];
num_cvs = rsRsiGetNumConfigVars(rsi);
for ( cvn_index = 0; cvn_index < num_cvs; cvn_index++ ) {
rsRsiGetConfigVarName(rsi, cvn_index, buffer, bufferSize);
printf("Configuration variable %u has name %s\n", cvn_index, buffer);
}
rsRsiClose(rsi);
}
rsRsiGetConfigVarType
Return the type of a configuration variable.
Return the data type of a configuration variable in the .rsi file. For
a description of the syntax of types in .rsi files, see
Section 5.3.2 in the Reactis User's Guide.
Syntax
int rsRsiGetConfigVarType (
RsiFile *h,
const char *name,
char *buffer,
int bufferSize
);
Parameters
- h
- Pointer to an RsiFile structure as returned by rsRsiOpen.
- name
- The name of the configuration variable for which the type string should be
returned.
- buffer
- The buffer that receives the input type string. The buffer’s size must
correspond to the value of the bufferSize parameter. If the
buffer parameter is NULL, then the value returned by
rsRsiGetConfigVarType will be the buffer size required to store the
whole name.
- bufferSize
- The size of the buffer passed in as the third argument. If the
actual type string is longer than this value, it will be truncated to the
length of the buffer. In that case, the return value of
rsRsiGetConfigVarType will be the buffer size that would be required
to receive the whole type string.
Return Value
- -1
- If an error occurred (either the index parameter is
outside the valid range or neither rsTester or rsSimRunSuite
have been called before).
- 0
- On success.
- A value greater than 0
- If either the buffer parameter is NULL or
the bufferSize parameter was not sufficient to receive the
complete type string. In that case, the value returned specifies the buffer
size required to store the complete type string.
Example Code
The following code could be used to get the type of the named configuration
variable from the cruise.rsi file.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
char buffer[100];
rsRsiGetConfigVarType(rsi, "InitialSpeed", buffer, 100);
printf("Type of InitialSpeed: %s\n", buffer);
rsRsiClose(rsi);
}
rsRsiSetConfigVarType
Set the type of a configuration variable.
Set the data type of a configuration variable in the .rsi file. For a
description of the syntax of types in .rsi files see
Section 5.3.2 .
Syntax
int rsRsiSetConfigVarType (RsiFile *h, const char *Name, char *Type);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
- Name
- Name of the configuration variable for which the type string should be
changed.
- Type
- New type string for the configuration variable.
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 set the type of an existing
configuration variable.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
rsRsiSetConfigVarType(rsi, "InitialSpeed", "double{10.0, 30.0, 40.0}");
rsRsiSave(rsi, "cruise.rsi");
rsRsiClose(rsi);
}
rsRsiGetNumPotentialConfigVars
Number of workspace vars that could be configuration vars.
Return the number of workspace variables defined by the model that can
be used as configuration variables.
Syntax
int rsRsiGetNumPotentialConfigVars (RsiFile *h);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
Return Value
Returns the number of potential configuration variables or -1 if an
error occurred. In that case, you may call rsGetLastError to retrieve
the error message string.
Example Code
The following code could be used to get the quantity and also the names
of the variables available for assignment as configuration variables.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
int pcvn_index;
int num_pcvs;
char buffer[100];
num_pcvs = rsRsiGetNumPotentialConfigVars(rsi);
for ( pcvn_index = 0; pcvn_index < num_pcvs; pcvn_index++ )
{
rsRsiGetPotentialConfigVarName(rsi, pcvn_index, buffer, bufferSize);
printf("Potential Configuration variable %u has name %s\n", pcvn_index, buffer);
}
rsRsiClose(rsi);
}
rsRsiGetPotentialConfigVarName
Retrieve name of potential configuration variable.
Return the name of a configuration variable.
Syntax
int rsRsiGetPotentialConfigVarName (
RsiFile *h,
int index,
char *buffer,
int bufferSize
);
Parameters
- h
- Pointer to an RsiFile structure as returned by rsRsiOpen.
- index
- The index of the configuration variable. This value must be greater or
equal to 0 and less than the return value of rsRsiGetNumConfigVars.
- buffer
- The buffer that receives the name of the configuration variable. The
buffer’s size must correspond to the value of the bufferSize
parameter. If the buffer parameter is NULL, then the value returned
by rsRsiGetPotentialConfigVarName will be the buffer size required to store
the whole name.
- bufferSize
- The size of the buffer passed in as the third 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
rsRsiGetPotentialConfigVarName will be the buffer size that would be
required to receive the whole name.
Return Value
- -1
- If an error occurred (either the index parameter is
outside the valid range or neither rsTester or rsSimRunSuite
have been called before).
- 0
- On success.
- A value greater than 0
- If either the buffer parameter is NULL
or the bufferSize parameter was not sufficient to receive the
complete name. In that case, the value returned specifies the buffer size
required to store the complete name.
Example Code
The following code could be used to get the names of the variables
available for assignment as configuration variables.
RsRsiFile *rsi = rsRsiOpen(h, "cruise.rsi", "cruise.slx");
if ( rsi ) {
int pcvn_index;
int num_pcvs;
char buffer[100];
num_pcvs = rsRsiGetNumPotentialConfigVars(rsi);
for ( pcvn_index = 0; pcvn_index < num_pcvs; pcvn_index++ )
{
rsRsiGetPotentialConfigVarName(rsi, pcvn_index, buffer, bufferSize);
printf("Potential Configuration variable %u has name %s\n", pcvn_index, buffer);
}
rsRsiClose(rsi);
}
rsRsiAddConfigVarSet
Add a new configuration variable set to the .rsi file.
Adds a new configuration set to the .rsi file. If the copyFrom
parameter is NULL, then no constraints will be set initially for variables
in the new configuration set, otherwise the constraints will be copied from
the corresponding variables in the configuration set named by the copyFrom
parameter.
Syntax
int rsRsiAddConfigVarSet (
RsiFile *hRsi,
const char *name,
const char *copyFrom,
);
Parameters
- hRsi
- Pointer to RsiFile structure as returned by rsRsiOpen.
- name
- Name of the configuration variable set.
- copyFrom
- Name of an existing configuration variable set from which to copy the type
constraints. If NULL, then no type constraints will be set initially.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
rsRsiRemoveConfigVarSet
Delete a configuration variable set from .rsi file.
Remove a configuration variable set from the .rsi file.
Syntax
int rsRsiRemoveConfigVarSet (RsiFile * h, const char *Name);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
- Name
- Name of the configuration variable set 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.
rsRsiGetNumConfigVarSets
Number of configuration variable sets in an .rsi file.
Return the number of configuration variable sets currently set in the
.rsi file.
Syntax
int rsRsiGetNumConfigVarSets (RsiFile *h);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
Return Value
Returns the number of configuration variable sets in the .rsi file
specified by the h parameter or -1 if an error occurred. In
that case, you may call rsGetLastError to retrieve the error message
string.
rsRsiGetConfigVarSetEnabled
Get enabled/disabled status of a configuration variable set.
Query the enabled/disabled status of a configuration set in the .rsi
file.
Syntax
int rsRsiGetConfigVarSetEnabled (
RsiFile *h,
const char *name
);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
- name
- Name of the configuration variable set.
Return Value
- -1
- If an error occurred. In this case, you may call
rsGetLastError to retrieve the error message string.
- 0
- If the configuration set is currently disabled.
- >0
- If the configuration set is currently enabled.
rsRsiSetConfigVarSetEnabled
Set enabled/disabled status of a configuration variable set.
Set the enabled/disabled status of a configuration variable set in the
.rsi file.
Syntax
int rsRsiSetConfigVarSetEnabled (RsiFile *h, const char
*Name, int Enable );
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
- Name
- Name of the configuration variable set.
- Enable
- 0 to disable set, 1 to enable.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
rsRsiGetActiveConfigVarSet
Return name of currently active configuration variable set.
Return the name of the currently active configuration variable
set. Calls to rsRsiSetConfigVarType and rsRsiGetConfigVarType to
modify and return the setting for the configuration variable in the
currently active set.
Syntax
int rsRsiGetActiveConfigVarSet (RsiFile *h,
char *buffer,
int bufferSize
);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
- buffer
- The buffer that receives the name of the active configuration variable
set. The buffer’s size must correspond to the value of the
bufferSize parameter. If the buffer parameter is NULL, then the
value returned by rsRsiGetActiveConfigVarSet will be the buffer size
required to store the whole name.
- bufferSize
- The size of the buffer passed in as the third 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
rsRsiGetActiveConfigVarSet will be the buffer size that would be
required to receive the whole name.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
rsRsiSetActiveConfigVarSet
Sets the active configuration variable set.
Change the currently active configuration variable set. Calls to
rsRsiSetConfigVarType and rsRsiGetConfigVarType to modify and
return the setting for the configuration variable in the currently active
set.
Syntax
int rsRsiSetActiveConfigVarSet (RsiFile *h, const char *Name);
Parameters
- h
- Pointer to RsiFile structure as returned by rsRsiOpen.
- Name
- Name of the configuration variable set.
Return Value
- 0
- If an error occurred. In this case, call rsGetLastError to get the
error string.
- 1
- If no error occurred.
rsRsiGetConfigVarSetName
Return name of a configuration variable set with the given index.
Return the name of a configuration variable set.
Syntax
int rsRsiGetConfigVarSetName (
RsiFile *h,
int index,
char *buffer,
int bufferSize
);
Parameters
- h
- Pointer to an RsiFile structure as returned by rsRsiOpen.
- index
- The index of the configuration variable set. This value must be greater or
equal to 0 and less than the return value of
rsRsiGetNumConfigVarSets.
- buffer
- The buffer that receives the name of the configuration variable set. The
buffer’s size must correspond to the value of the bufferSize
parameter. If the buffer parameter is NULL then the value returned by
rsRsiGetConfigVarSetName will be the buffer size required to store the whole
name.
- bufferSize
- The size of the buffer passed in as the third 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 rsRsiGetConfigVarSetName
will be the buffer size that would be required to receive the whole name.
Return Value
- -1
- If an error occurred (the index parameter is outside
the valid range).
- 0
- On success.
- A value greater than 0
- If either the buffer parameter is NULL
or the bufferSize parameter was not sufficient to receive the
complete name. In that case, the value returned specifies the buffer size
required to store the complete name.