📄 scomdemohecgen.c
字号:
/*
* File: scomdemohecgen.c
*
*
*
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: BASIC, 1.0 ---
*
* This file is an S-function produced by the Basic S-Function
* Builder which only recognizes certain fields. Changes made
* outside these fields will be lost the next time the block is
* used to load, edit, and resave this file. This file will be overwritten
* by the S-function Builder block. If you want to edit this file by hand,
* you must change it only in the area defined as:
*
* %%%-SFUNWIZ_defines_Changes_BEGIN
* #define NAME 'replacement text'
* %%% SFUNWIZ_defines_Changes_END
*
* DO NOT change NAME--Change the 'replacement text' only.
*
* For better compatibility with the Real-Time Workshop, the
* "wrapper" S-function technique is used. This is discussed
* in the Real-Time Workshop User's Manual in the Chapter titled,
* "Wrapper S-functions".
*
* -------------------------------------------------------------------------
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
* -------------------------------------------------------------------------
* Created: Mon Aug 20 15:23:09 2001
*
*
*/
#define S_FUNCTION_NAME scomdemohecgen
#define S_FUNCTION_LEVEL 2
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
#define NUM_INPUTS 1
#define INPUT_0_WIDTH DYNAMICALLY_SIZED
#define INPUT_0_FEEDTHROUGH 1
#define NUM_OUTPUTS 1
#define OUTPUT_0_WIDTH 8
#define NPARAMS 1
#define SAMPLE_TIME_0 INHERITED_SAMPLE_TIME
#define NUM_DISC_STATES 0
#define DISC_STATES_IC [0]
#define NUM_CONT_STATES 0
#define CONT_STATES_IC [0]
#define SFUNWIZ_GENERATE_TLC 0
#define SOURCEFILES ""
#define PANELINDEX 5
#define SFUNWIZ_REVISION 1.0
/* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
#include "simstruc.h"
#define PARAM_DEF0(S) ssGetSFcnParam(S, 0)
extern void scomdemohecgen_Outputs_wrapper(const real_T *u,
real_T *y,
const real_T *param0, const int_T p_width0,
const int_T y_width, const int_T u_width);
extern void scomdemohecgen_Update_wrapper(const real_T *u,
const real_T *y,
const real_T *param0, const int_T p_width0,
const int_T y_width, const int_T u_width);
extern void scomdemohecgen_Derivatives_wrapper(const real_T *u,
const real_T *y, real_T *dx,
const real_T *param0, const int_T p_width0,
const int_T y_width, const int_T u_width);
/*====================*
* S-function methods *
*====================*/
#define MDL_CHECK_PARAMETERS
#if defined(MDL_CHECK_PARAMETERS) && defined(MATLAB_MEX_FILE)
/* Function: mdlCheckParameters =============================================
* Abstract:
* Validate our parameters to verify they are okay.
*/
static void mdlCheckParameters(SimStruct *S)
{
int i;
bool validParam = false;
/* All parameters must be scalar */
for (i = 0; i < ssGetSFcnParamsCount(S); i++) {
const mxArray *pVal = ssGetSFcnParam(S,i);
if ( !mxIsNumeric(pVal) || !mxIsDouble(pVal) || mxIsLogical(pVal) ||
mxIsComplex(pVal) || mxIsSparse(pVal) || !mxIsFinite(mxGetPr(pVal)[0])) {
validParam = true;
break;
}
}
if (validParam) {
ssSetErrorStatus(S,"All parameters must be a scalar or vectors");
return;
}
}
#endif /* MDL_CHECK_PARAMETERS */
/* Function: mdlInitializeSizes ===============================================
* Abstract:
* Setup sizes of the various vectors.
*/
static void mdlInitializeSizes(SimStruct *S)
{
ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */
#if defined(MATLAB_MEX_FILE)
if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) {
mdlCheckParameters(S);
if (ssGetErrorStatus(S) != NULL) {
return;
}
} else {
return; /* Parameter mismatch will be reported by Simulink */
}
#endif
ssSetNumContStates(S, NUM_CONT_STATES);
ssSetNumDiscStates(S, NUM_DISC_STATES);
if (!ssSetNumInputPorts(S, 1)) return;
ssSetInputPortWidth(S, 0, INPUT_0_WIDTH);
ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/
if (!ssSetNumOutputPorts(S,1)) return;
ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
ssSetNumSampleTimes(S, 1);
ssSetNumRWork(S, 0);
ssSetNumIWork(S, 0);
ssSetNumPWork(S, 0);
ssSetNumModes(S, 0);
ssSetNumNonsampledZCs(S, 0);
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE |
SS_OPTION_USE_TLC_WITH_ACCELERATOR);
}
#if defined(MATLAB_MEX_FILE)
# define MDL_SET_INPUT_PORT_WIDTH
static void mdlSetInputPortWidth(SimStruct *S, int_T port,
int_T inputPortWidth)
{
ssSetInputPortWidth(S,port,inputPortWidth);
}
# define MDL_SET_OUTPUT_PORT_WIDTH
static void mdlSetOutputPortWidth(SimStruct *S, int_T port,
int_T outputPortWidth)
{
ssSetOutputPortWidth(S,port,ssGetInputPortWidth(S,0));
}
#endif
/* Function: mdlInitializeSampleTimes =========================================
* Abstract:
* Specifiy the sample time.
*/
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, SAMPLE_TIME_0);
ssSetOffsetTime(S, 0, 0.0);
}
/* Function: mdlOutputs =======================================================
*
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);
real_T *y = ssGetOutputPortRealSignal(S,0);
const real_T *param0 = mxGetPr(PARAM_DEF0(S));
const int_T p_width0 = mxGetNumberOfElements(PARAM_DEF0(S));
const int_T y_width = ssGetOutputPortWidth(S,0);
const int_T u_width = ssGetInputPortWidth(S,0);
scomdemohecgen_Outputs_wrapper(u, y, param0, p_width0, y_width, u_width);
}
#undef MDL_UPDATE /* Change to #define to use the function */
#if defined(MDL_UPDATE)
/* Function: mdlUpdate ======================================================
* Abstract:
* This function is called once for every major integration time step.
* Discrete states are typically updated here, but this function is useful
* for performing any tasks that should only take place once per
* integration step.
*/
static void mdlUpdate(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T *) ssGetInputPortSignal(S,0);
real_T *xD = ssGetDiscStates(S);
const real_T *y = ssGetOutputPortSignal(S,0);
const real_T *param0 = mxGetPr(PARAM_DEF0(S));
const int_T p_width0 = mxGetNumberOfElements(PARAM_DEF0(S));
const int_T y_width = ssGetOutputPortWidth(S,0);
const int_T u_width = ssGetInputPortWidth(S,0);
scomdemohecgen_Update_wrapper(u, y, param0, p_width0, y_width, u_width);
}
#endif /* MDL_UPDATE */
#undef MDL_DERIVATIVES /* Change to #define to use function */
#if defined(MDL_DERIVATIVES)
/* Function: mdlDerivatives =================================================
* Abstract:
* In this function, you compute the S-function block's derivatives.
* The derivatives are placed in the derivative vector, ssGetdX(S).
*/
static void mdlDerivatives(SimStruct *S)
{
const real_T *u = (const real_T *) ssGetInputPortSignal(S,0);
real_T *dx = ssGetdX(S);
real_T *xC = ssGetContStates(S);
const real_T *y = ssGetOutputPortSignal(S,0);
const real_T *param0 = mxGetPr(PARAM_DEF0(S));
const int_T p_width0 = mxGetNumberOfElements(PARAM_DEF0(S));
const int_T y_width = ssGetOutputPortWidth(S,0);
const int_T u_width = ssGetInputPortWidth(S,0);
scomdemohecgen_Derivatives_wrapper(u, y, dx, param0, p_width0, y_width, u_width);
}
#endif /* MDL_DERIVATIVES */
/* Function: mdlTerminate =====================================================
* Abstract:
* No termination needed, but we are required to have this routine.
*/
static void mdlTerminate(SimStruct *S)
{
}
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#else
#include "cg_sfun.h" /* Code generation registration function */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -