📄 untitled_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.
*/
/*
* untitled_acc.c
*
* Real-Time Workshop code generation for Simulink model "untitled_acc.mdl".
*
* Model Version : 1.0
* Real-Time Workshop version : 6.6 (R2007a) 01-Feb-2007
* C source code generated on : Sun Aug 31 03:55:50 2008
*/
#include <math.h>
#include "untitled_acc.h"
#include "untitled_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)
{
/* Integrator: '<Root>/Integrator1' */
((BlockIO *) _ssGetBlockIO(S))->B_0_0_0 = ((ContinuousStates *)
ssGetContStates(S))->Integrator1_CSTATE;
/* Scope: '<Root>/Scope' */
/* Call into Simulink for Scope */
ssCallAccelRunBlock(S, 0, 1, SS_CALL_MDL_OUTPUTS);
/* Integrator: '<Root>/Integrator' */
((BlockIO *) _ssGetBlockIO(S))->B_0_2_0 = ((ContinuousStates *)
ssGetContStates(S))->Integrator_CSTATE;
{
real_T currentTime;
if (ssIsSampleHit(S, 1, 0)) {
currentTime = ssGetTaskTime(S,0);
if (ssIsMajorTimeStep(S)) {
if (currentTime >= ((Parameters *) ssGetDefaultParam(S))->P_4) {
((D_Work *) ssGetRootDWork(S))->Step_MODE = 1;
} else {
((D_Work *) ssGetRootDWork(S))->Step_MODE = 0;
}
}
((BlockIO *) _ssGetBlockIO(S))->B_0_5_0 = ((D_Work *) ssGetRootDWork(S))
->Step_MODE == 1 ? ((Parameters *) ssGetDefaultParam(S))->P_6 :
((Parameters *) ssGetDefaultParam(S))->P_5;
}
((BlockIO *) _ssGetBlockIO(S))->B_0_6_0 = (((Parameters *) ssGetDefaultParam
(S))->P_3 * ((BlockIO *) _ssGetBlockIO(S))->B_0_0_0 + ((BlockIO *)
_ssGetBlockIO(S))->B_0_5_0) + ((Parameters *) ssGetDefaultParam(S))->P_2 *
((BlockIO *) _ssGetBlockIO(S))->B_0_2_0;
}
/* tid is required for a uniform function interface. This system
* is single rate, and in this case, tid is not accessed. */
UNUSED_PARAMETER(tid);
}
/* Update for root system: '<Root>' */
#define MDL_UPDATE
static void mdlUpdate(SimStruct *S, int_T tid)
{
if (ssIsSampleHit(S, 1, 0)) {
}
/* 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)
{
/* Integrator Block: '<Root>/B_0_0' */
{
((StateDerivatives *) ssGetdX(S))->Integrator1_CSTATE = ((BlockIO *)
_ssGetBlockIO(S))->B_0_2_0;
}
/* Integrator Block: '<Root>/B_0_2' */
{
((StateDerivatives *) ssGetdX(S))->Integrator_CSTATE = ((BlockIO *)
_ssGetBlockIO(S))->B_0_6_0;
}
}
/* ZeroCrossings for root system: '<Root>' */
#define MDL_ZERO_CROSSINGS
static void mdlZeroCrossings(SimStruct *S)
{
((NonsampledZCs *) ssGetNonsampledZCs(S))->Step_NSZC = ssGetT(S) -
((Parameters *) ssGetDefaultParam(S))->P_4;
}
/* Function to initialize sizes */
static void mdlInitializeSizes(SimStruct *S)
{
/* checksum */
ssSetChecksumVal(S, 0, 1725355873U);
ssSetChecksumVal(S, 1, 3336736872U);
ssSetChecksumVal(S, 2, 761204266U);
ssSetChecksumVal(S, 3, 1381143870U);
/* options */
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
/* Accelerator check memory map size match for DWork */
if (ssGetSizeofDWork(S) != sizeof(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(BlockIO)) {
ssSetErrorStatus(S,"Unexpected error: Internal BlockIO sizes do "
"not match for accelerator mex file.");
}
/* model parameters */
_ssSetDefaultParam(S, (real_T *) &rtDefaultParameters);
}
/* 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 + -