SENSUB/SEVSUB

ModelingUsed to compute/evaluate the value for a sensor element. SENSUB can detect an event, while SEVSUB is used to return the scalar value computed when the event defined by the sensor occurs.

Use

User-defined request calling a SENSUB/SEVSUB for the calculation of output quantities:

<Sensor_Evaluate
     id                  = "100"
     type                = "USERSUB"
     usrsub_param_string = "USER(2,22,11)"
     usrsub_dll_name     = "NULL"
  />
  <Sensor_Event
     label               = "Sensor/100"
     id                  = "100"
     type                = "USERSUB"
     usrsub_param_string = "USER(22,11)"
     usrsub_dll_name     = "NULL"
     compare             = "GE"
     value               = "0."
     evaluate_id         = "100"
     error_tol           = "0.0001"
  />

The sensor event element calls a SENSUB subroutine, while the sensor evaluate element returns the value computed in the SEVSUB when the event detected by the sensor occurs.

Format

Fortran Calling Syntax
SUBROUTINE SENSUB (ID, TIME, PAR, NPAR, IFLAG, VALUE)
SUBROUTINE SEVSUB (ID, TIME, PAR, NPAR, IFLAG, VALUE)
C/C++ Calling Syntax
void STDCALL SENSUB (int *id, double *time, double *par, int *npar, int *iflag, double *value)
void STDCALL SEVSUB (int *id, double *time, double *par, int *npar, int *iflag, double *value)
Python Calling Syntax
def SENSUB(id, time, par, npar, iflag):
    return value 
def SEVSUB(id, time, par, npar, iflag)
    return value
MATLAB Calling Syntax
function value = SENSUB(id, time, par, npar, iflag)
function value = SEVSUB(id, time, par, npar, iflag)

Attributes

ID
[integer]
The user-defined sensor element identifier.
TIME
[double precision]
The current simulation time.
PAR
[double precision]
An array that contains the constant arguments from the list provided in the user-defined statement.
NPAR
[integer]
The number of entries in the PAR array.
IFLAG
[logical]
Initialization flag.

Output

VALUE
[double precision]
The output value that contains the value of the function that the sensor event returns (for SENSUB).
VALUE
[double precision]
The output value that contains the value of the function that the sensor evaluate entity computes (for SEVSUB).

Example

def SENSUB(id, time, par, npar, iflag):

    ipar =2*[0]
    twopi =2.0*pi
    
    ipar[0] = int(par[0])
    ipar[1] = int(par[1])
    [AZ, errflg] = py_sysfnc("AZ", ipar)
    value = fmod(AZ,twopi) - (pi/2.0)
    return value

def SEVSUB(id, time, par, npar, iflag):

    itype =int(par[0])
        ipar =1*[0]
        ipar[0] =int(par[1]) 
        [senval, errflg] = py_sysfnc("SENVAL", ipar)
        value = senval+1.0

    return value