📄 vdp_acc.c
字号:
/*
* This file is not available for use in any application other than as a
* MATLAB(R) MEX file for use with the Simulink(R) Accelerator product.
*/
/*
* vdp_acc.c
*
* Real-Time Workshop code generation for Simulink model "vdp_acc.mdl".
*
* Model Version : 1.2
* Real-Time Workshop version : 6.0 (R14) 05-May-2004
* C source code generated on : Sun May 04 10:34:30 2008
*/
#include <math.h>
#include <string.h>
#include "vdp_acc.h"
#include "vdp_acc_private.h"
#include <stdio.h>
#include "simstruc.h"
#include "fixedpoint.h"
#define CodeFormat S-Function
#define AccDefine1 Accelerator_S-Function
/* Outputs for root system: '<Root>' */
static void mdlOutputs(SimStruct *S, int_T tid)
{
/* simstruct variables */
vdp_BlockIO *vdp_B = (vdp_BlockIO *) _ssGetBlockIO(S);
vdp_ContinuousStates *vdp_X = (vdp_ContinuousStates*) ssGetContStates(S);
vdp_Parameters *vdp_P = (vdp_Parameters *) ssGetDefaultParam(S);
/* local block i/o variables */
/* tid is required for a uniform function interface. This system
* is single rate, and in this case, tid is not accessed. */
UNUSED_PARAMETER(tid);
/* Integrator: '<Root>/x1' */
vdp_B->x1 = vdp_X->x1_CSTATE;
ssCallAccelRunBlock(S, 0, 1, SS_CALL_MDL_OUTPUTS);
/* Integrator: '<Root>/x2' */
vdp_B->x2 = vdp_X->x2_CSTATE;
ssCallAccelRunBlock(S, 0, 3, SS_CALL_MDL_OUTPUTS);
/* Scope: '<Root>/Scope' */
/* Call into Simulink for Scope */
ssCallAccelRunBlock(S, 0, 4, SS_CALL_MDL_OUTPUTS);
vdp_B->Sum = (1.0 - vdp_B->x1 * vdp_B->x1) * vdp_B->x2 * vdp_P->Mu_Gain -
vdp_B->x1;
}
/* Update for root system: '<Root>' */
#define MDL_UPDATE
static void mdlUpdate(SimStruct *S, int_T tid)
{
/* tid is required for a uniform function interface. This system
* is single rate, and in this case, tid is not accessed. */
UNUSED_PARAMETER(tid);
}
/* Derivatives for root system: '<Root>' */
#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
/* simstruct variables */
vdp_BlockIO *vdp_B = (vdp_BlockIO *) _ssGetBlockIO(S);
vdp_StateDerivatives *vdp_Xdot = (vdp_StateDerivatives*) ssGetdX(S);
/* Integrator Block: <Root>/x1 */
{
vdp_Xdot->x1_CSTATE = vdp_B->x2;
}
/* Integrator Block: <Root>/x2 */
{
vdp_Xdot->x2_CSTATE = vdp_B->Sum;
}
}
/* Function to initialize sizes */
static void mdlInitializeSizes(SimStruct *S)
{
/* checksum */
ssSetChecksumVal(S, 0, 1134516754U);
ssSetChecksumVal(S, 1, 1868759922U);
ssSetChecksumVal(S, 2, 2765682047U);
ssSetChecksumVal(S, 3, 694015886U);
/* options */
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
/* Accelerator check memory map size match for DWork */
if (ssGetSizeofDWork(S) != sizeof(vdp_D_Work)) {
ssSetErrorStatus(S,"Unexpected error: Internal DWork sizes do "
"not match for accelerator mex file.");
}
/* Accelerator check memory map size match for BlockIO */
if (ssGetSizeofGlobalBlockIO(S) != sizeof(vdp_BlockIO)) {
ssSetErrorStatus(S,"Unexpected error: Internal BlockIO sizes do "
"not match for accelerator mex file.");
}
/* model parameters */
_ssSetDefaultParam(S, (real_T *) &vdp_DefaultParameters);
}
/* Empty mdlInitializeSampleTimes function (never called) */
static void mdlInitializeSampleTimes(SimStruct *S) { }
/* Empty mdlTerminate function (never called) */
static void mdlTerminate(SimStruct *S) { }
/* MATLAB MEX Glue */
#include "simulink.c"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -