read value by property name
This commit is contained in:
Binary file not shown.
Binary file not shown.
+289
@@ -0,0 +1,289 @@
|
|||||||
|
/*
|
||||||
|
* File: hal_sen_read.c
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 3.0 ---
|
||||||
|
*
|
||||||
|
* This file is an S-function produced by the 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 Simulink Coder, the
|
||||||
|
* "wrapper" S-function technique is used. This is discussed
|
||||||
|
* in the Simulink Coder's Manual in the Chapter titled,
|
||||||
|
* "Wrapper S-functions".
|
||||||
|
*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Created: Fri Mar 20 16:10:56 2020
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define S_FUNCTION_LEVEL 2
|
||||||
|
#define S_FUNCTION_NAME hal_sen_read
|
||||||
|
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||||
|
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
|
||||||
|
#define NUM_INPUTS 0
|
||||||
|
|
||||||
|
#define NUM_OUTPUTS 2
|
||||||
|
/* Output Port 0 */
|
||||||
|
#define OUT_PORT_0_NAME value
|
||||||
|
#define OUTPUT_0_WIDTH DYNAMICALLY_SIZED
|
||||||
|
#define OUTPUT_DIMS_0_COL 1
|
||||||
|
#define OUTPUT_0_DTYPE real32_T
|
||||||
|
#define OUTPUT_0_COMPLEX COMPLEX_NO
|
||||||
|
#define OUT_0_FRAME_BASED FRAME_NO
|
||||||
|
#define OUT_0_BUS_BASED 0
|
||||||
|
#define OUT_0_BUS_NAME
|
||||||
|
#define OUT_0_DIMS 1-D
|
||||||
|
#define OUT_0_ISSIGNED 1
|
||||||
|
#define OUT_0_WORDLENGTH 8
|
||||||
|
#define OUT_0_FIXPOINTSCALING 1
|
||||||
|
#define OUT_0_FRACTIONLENGTH 3
|
||||||
|
#define OUT_0_BIAS 0
|
||||||
|
#define OUT_0_SLOPE 0.125
|
||||||
|
/* Output Port 1 */
|
||||||
|
#define OUT_PORT_1_NAME ErrorCode
|
||||||
|
#define OUTPUT_1_WIDTH 1
|
||||||
|
#define OUTPUT_DIMS_1_COL 1
|
||||||
|
#define OUTPUT_1_DTYPE int32_T
|
||||||
|
#define OUTPUT_1_COMPLEX COMPLEX_NO
|
||||||
|
#define OUT_1_FRAME_BASED FRAME_NO
|
||||||
|
#define OUT_1_BUS_BASED 0
|
||||||
|
#define OUT_1_BUS_NAME
|
||||||
|
#define OUT_1_DIMS 1-D
|
||||||
|
#define OUT_1_ISSIGNED 1
|
||||||
|
#define OUT_1_WORDLENGTH 8
|
||||||
|
#define OUT_1_FIXPOINTSCALING 1
|
||||||
|
#define OUT_1_FRACTIONLENGTH 3
|
||||||
|
#define OUT_1_BIAS 0
|
||||||
|
#define OUT_1_SLOPE 0.125
|
||||||
|
|
||||||
|
#define NPARAMS 1
|
||||||
|
/* Parameter 0 */
|
||||||
|
#define PARAMETER_0_NAME name
|
||||||
|
#define PARAMETER_0_DTYPE uint8_T
|
||||||
|
#define PARAMETER_0_COMPLEX COMPLEX_NO
|
||||||
|
|
||||||
|
#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 1
|
||||||
|
#define SOURCEFILES "__SFB__"
|
||||||
|
#define PANELINDEX 8
|
||||||
|
#define USE_SIMSTRUCT 0
|
||||||
|
#define SHOW_COMPILE_STEPS 0
|
||||||
|
#define CREATE_DEBUG_MEXFILE 0
|
||||||
|
#define SAVE_CODE_ONLY 0
|
||||||
|
#define SFUNWIZ_REVISION 3.0
|
||||||
|
/* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
|
||||||
|
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||||
|
#include "simstruc.h"
|
||||||
|
|
||||||
|
#define PARAM_DEF0(S) ssGetSFcnParam(S, 0)
|
||||||
|
|
||||||
|
#define IS_PARAM_UINT8(pVal) (mxIsNumeric(pVal) && !mxIsLogical(pVal) &&\
|
||||||
|
!mxIsEmpty(pVal) && !mxIsSparse(pVal) && !mxIsComplex(pVal) && mxIsUint8(pVal))
|
||||||
|
|
||||||
|
extern void hal_sen_read_Start_wrapper(void **pW,
|
||||||
|
const uint8_T *name, const int_T p_width0);
|
||||||
|
extern void hal_sen_read_Outputs_wrapper(real32_T *value,
|
||||||
|
int32_T *ErrorCode,
|
||||||
|
void **pW,
|
||||||
|
const uint8_T *name, const int_T p_width0,
|
||||||
|
const int_T y_width);
|
||||||
|
/*====================*
|
||||||
|
* S-function methods *
|
||||||
|
*====================*/
|
||||||
|
#define MDL_CHECK_PARAMETERS
|
||||||
|
#if defined(MDL_CHECK_PARAMETERS) && defined(MATLAB_MEX_FILE)
|
||||||
|
/* Function: mdlCheckParameters =============================================
|
||||||
|
* Abstract:
|
||||||
|
* Verify parameter definitions and types.
|
||||||
|
*/
|
||||||
|
static void mdlCheckParameters(SimStruct *S)
|
||||||
|
{
|
||||||
|
int paramIndex = 0;
|
||||||
|
bool invalidParam = false;
|
||||||
|
/* All parameters must match the S-function Builder Dialog */
|
||||||
|
|
||||||
|
{
|
||||||
|
const mxArray *pVal0 = ssGetSFcnParam(S, 0);
|
||||||
|
if (!IS_PARAM_UINT8(pVal0)) {
|
||||||
|
invalidParam = true;
|
||||||
|
paramIndex = 0;
|
||||||
|
goto EXIT_POINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXIT_POINT:
|
||||||
|
if (invalidParam) {
|
||||||
|
char parameterErrorMsg[1024];
|
||||||
|
sprintf(parameterErrorMsg, "The data type and or complexity of parameter %d does not match the "
|
||||||
|
"information specified in the S-function Builder dialog. "
|
||||||
|
"For non-double parameters you will need to cast them using int8, int16, "
|
||||||
|
"int32, uint8, uint16, uint32 or boolean.", paramIndex + 1);
|
||||||
|
ssSetErrorStatus(S, parameterErrorMsg);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif /* MDL_CHECK_PARAMETERS */
|
||||||
|
/* Function: mdlInitializeSizes ===============================================
|
||||||
|
* Abstract:
|
||||||
|
* Setup sizes of the various vectors.
|
||||||
|
*/
|
||||||
|
static void mdlInitializeSizes(SimStruct *S)
|
||||||
|
{
|
||||||
|
|
||||||
|
DECL_AND_INIT_DIMSINFO(outputDimsInfo);
|
||||||
|
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
|
||||||
|
|
||||||
|
ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);
|
||||||
|
|
||||||
|
ssSetSimStateCompliance(S, DISALLOW_SIM_STATE);
|
||||||
|
|
||||||
|
ssSetNumContStates(S, NUM_CONT_STATES);
|
||||||
|
ssSetNumDiscStates(S, NUM_DISC_STATES);
|
||||||
|
|
||||||
|
|
||||||
|
if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
|
||||||
|
|
||||||
|
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
|
||||||
|
/* Output Port 0 */
|
||||||
|
ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
|
||||||
|
ssSetOutputPortDataType(S, 0, SS_SINGLE);
|
||||||
|
ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
|
||||||
|
/* Output Port 1 */
|
||||||
|
ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH);
|
||||||
|
ssSetOutputPortDataType(S, 1, SS_INT32);
|
||||||
|
ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX);
|
||||||
|
ssSetNumPWork(S, 8);
|
||||||
|
|
||||||
|
ssSetNumSampleTimes(S, 1);
|
||||||
|
ssSetNumRWork(S, 0);
|
||||||
|
ssSetNumIWork(S, 0);
|
||||||
|
ssSetNumModes(S, 0);
|
||||||
|
ssSetNumNonsampledZCs(S, 0);
|
||||||
|
|
||||||
|
ssSetSimulinkVersionGeneratedIn(S, "9.2");
|
||||||
|
|
||||||
|
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
|
||||||
|
ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
|
||||||
|
SS_OPTION_USE_TLC_WITH_ACCELERATOR |
|
||||||
|
SS_OPTION_WORKS_WITH_CODE_REUSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function: mdlInitializeSampleTimes =========================================
|
||||||
|
* Abstract:
|
||||||
|
* Specifiy the sample time.
|
||||||
|
*/
|
||||||
|
static void mdlInitializeSampleTimes(SimStruct *S)
|
||||||
|
{
|
||||||
|
ssSetSampleTime(S, 0, SAMPLE_TIME_0);
|
||||||
|
ssSetModelReferenceSampleTimeDefaultInheritance(S);
|
||||||
|
ssSetOffsetTime(S, 0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MDL_SET_OUTPUT_PORT_DATA_TYPE
|
||||||
|
static void mdlSetOutputPortDataType(SimStruct *S, int port, DTypeId dType)
|
||||||
|
{
|
||||||
|
ssSetOutputPortDataType(S, 0, dType);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MDL_SET_DEFAULT_PORT_DATA_TYPES
|
||||||
|
static void mdlSetDefaultPortDataTypes(SimStruct *S)
|
||||||
|
{
|
||||||
|
ssSetOutputPortDataType(S, 0, SS_DOUBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MDL_SET_WORK_WIDTHS
|
||||||
|
#if defined(MDL_SET_WORK_WIDTHS) && defined(MATLAB_MEX_FILE)
|
||||||
|
|
||||||
|
static void mdlSetWorkWidths(SimStruct *S)
|
||||||
|
{
|
||||||
|
|
||||||
|
const char_T *rtParamNames[] = {"P1"};
|
||||||
|
ssRegAllTunableParamsAsRunTimeParams(S, rtParamNames);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MDL_START /* Change to #undef to remove function */
|
||||||
|
#if defined(MDL_START)
|
||||||
|
/* Function: mdlStart =======================================================
|
||||||
|
* Abstract:
|
||||||
|
* This function is called once at start of model execution. If you
|
||||||
|
* have states that should be initialized once, this is the place
|
||||||
|
* to do it.
|
||||||
|
*/
|
||||||
|
static void mdlStart(SimStruct *S)
|
||||||
|
{
|
||||||
|
void **pW = ssGetPWork(S);
|
||||||
|
const int_T p_width0 = mxGetNumberOfElements(PARAM_DEF0(S));
|
||||||
|
const uint8_T *name = (const uint8_T *) mxGetData(PARAM_DEF0(S));
|
||||||
|
|
||||||
|
hal_sen_read_Start_wrapper(pW, name, p_width0);
|
||||||
|
}
|
||||||
|
#endif /* MDL_START */
|
||||||
|
|
||||||
|
/* Function: mdlOutputs =======================================================
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void mdlOutputs(SimStruct *S, int_T tid)
|
||||||
|
{
|
||||||
|
void **pW = ssGetPWork(S);
|
||||||
|
real32_T *value = (real32_T *) ssGetOutputPortRealSignal(S, 0);
|
||||||
|
int32_T *ErrorCode = (int32_T *) ssGetOutputPortRealSignal(S, 1);
|
||||||
|
const int_T p_width0 = mxGetNumberOfElements(PARAM_DEF0(S));
|
||||||
|
const uint8_T *name = (const uint8_T *) mxGetData(PARAM_DEF0(S));
|
||||||
|
const int_T y_width = ssGetOutputPortWidth(S, 0);
|
||||||
|
|
||||||
|
hal_sen_read_Outputs_wrapper(value, ErrorCode, pW, name, p_width0, y_width);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function: mdlTerminate =====================================================
|
||||||
|
* Abstract:
|
||||||
|
* In this function, you should perform any actions that are necessary
|
||||||
|
* at the termination of a simulation. For example, if memory was
|
||||||
|
* allocated in mdlStart, this is the place to free it.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,90 @@
|
|||||||
|
%% File : hal_sen_read.tlc
|
||||||
|
%% Created : Fri Mar 20 16:10:56 2020
|
||||||
|
%%
|
||||||
|
%% Description:
|
||||||
|
%% Simulink Coder wrapper functions interface generated for
|
||||||
|
%% S-function "hal_sen_read.c".
|
||||||
|
%%
|
||||||
|
%% File generated by S-function Builder Block
|
||||||
|
%%
|
||||||
|
%% For more information on using the Target Language with the
|
||||||
|
%% Simulink Coder, see the Target Language Compiler manual
|
||||||
|
%% (under Simulink Coder) in the "Inlining S-Functions"
|
||||||
|
%% chapter under the section and subsection:
|
||||||
|
%% "Writing Block Target Files to Inline S-Functions",
|
||||||
|
%% "Function-Based or Wrappered Code".
|
||||||
|
%%
|
||||||
|
%implements hal_sen_read "C"
|
||||||
|
%% Function: BlockTypeSetup ===================================================
|
||||||
|
%%
|
||||||
|
%% Purpose:
|
||||||
|
%% Set up external references for wrapper functions in the
|
||||||
|
%% generated code.
|
||||||
|
%%
|
||||||
|
%function BlockTypeSetup(block, system) Output
|
||||||
|
%openfile externs
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void hal_sen_read_Start_wrapper(void **pW,
|
||||||
|
const uint8_T *name, const int_T p_width0);
|
||||||
|
|
||||||
|
extern void hal_sen_read_Outputs_wrapper(real32_T *value,
|
||||||
|
int32_T *ErrorCode,
|
||||||
|
void **pW,
|
||||||
|
const uint8_T *name, const int_T p_width0,
|
||||||
|
const int_T y_width);
|
||||||
|
|
||||||
|
extern void hal_sen_read_Terminate_wrapper(void **pW,
|
||||||
|
const uint8_T *name, const int_T p_width0);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
%closefile externs
|
||||||
|
%<LibCacheExtern(externs)>
|
||||||
|
%%
|
||||||
|
%endfunction
|
||||||
|
|
||||||
|
|
||||||
|
%% Function: Start ============================================================
|
||||||
|
%%
|
||||||
|
%function Start(block, system) Output
|
||||||
|
/* %<Type> Block: %<Name> */
|
||||||
|
%assign ppw = LibBlockDWorkAddr(PWORK, "", "", 0)
|
||||||
|
%assign nelements1 = LibBlockParameterSize(P1)
|
||||||
|
%assign param_width1 = nelements1[0] * nelements1[1]
|
||||||
|
%if (param_width1) > 1
|
||||||
|
%assign pp1 = LibBlockMatrixParameterBaseAddr(P1)
|
||||||
|
%else
|
||||||
|
%assign pp1 = LibBlockParameterAddr(P1, "", "", 0)
|
||||||
|
%endif
|
||||||
|
hal_sen_read_Start_wrapper(%<ppw>, %<pp1>, %<param_width1>);
|
||||||
|
%endfunction
|
||||||
|
%% Function: Outputs ==========================================================
|
||||||
|
%%
|
||||||
|
%% Purpose:
|
||||||
|
%% Code generation rules for mdlOutputs function.
|
||||||
|
%%
|
||||||
|
%function Outputs(block, system) Output
|
||||||
|
%%
|
||||||
|
%assign ppw = LibBlockDWorkAddr(PWORK, "", "", 0)
|
||||||
|
%assign py0 = LibBlockOutputSignalAddr(0, "", "", 0)
|
||||||
|
%assign py1 = LibBlockOutputSignalAddr(1, "", "", 0)
|
||||||
|
%assign py_width = LibBlockOutputSignalWidth(0)
|
||||||
|
%assign nelements1 = LibBlockParameterSize(P1)
|
||||||
|
%assign param_width1 = nelements1[0] * nelements1[1]
|
||||||
|
%if (param_width1) > 1
|
||||||
|
%assign pp1 = LibBlockMatrixParameterBaseAddr(P1)
|
||||||
|
%else
|
||||||
|
%assign pp1 = LibBlockParameterAddr(P1, "", "", 0)
|
||||||
|
%endif
|
||||||
|
hal_sen_read_Outputs_wrapper(%<py0>, %<py1>, %<ppw>, %<pp1>, %<param_width1>, %<py_width>);
|
||||||
|
%%
|
||||||
|
%endfunction
|
||||||
|
|
||||||
|
|
||||||
|
%% [EOF] hal_sen_read.tlc
|
||||||
|
|
||||||
@@ -0,0 +1,272 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Include Files
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#if defined(MATLAB_MEX_FILE)
|
||||||
|
#include "tmwtypes.h"
|
||||||
|
#include "simstruc_types.h"
|
||||||
|
#else
|
||||||
|
#include "rtwtypes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create external references here.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||||
|
typedef enum PROP_TYPE
|
||||||
|
{
|
||||||
|
PROP_ARRAY_UINT8=1, /* 8-bit unsigned integer | */
|
||||||
|
PROP_ARRAY_INT8=2, /* 8-bit signed integer | */
|
||||||
|
PROP_ARRAY_UINT16=3, /* 16-bit unsigned integer | */
|
||||||
|
PROP_ARRAY_INT16=4, /* 16-bit signed integer | */
|
||||||
|
PROP_ARRAY_UINT32=5, /* 32-bit unsigned integer | */
|
||||||
|
PROP_ARRAY_INT32=6, /* 32-bit signed integer | */
|
||||||
|
PROP_ARRAY_REAL32=7, /* 32-bit floating-point | */
|
||||||
|
PROP_FUNC_UINT8=8, /* 8-bit unsigned integer | */
|
||||||
|
PROP_FUNC_INT8=9, /* 8-bit signed integer | */
|
||||||
|
PROP_FUNC_UINT16=10, /* 16-bit unsigned integer | */
|
||||||
|
PROP_FUNC_INT16=11, /* 16-bit signed integer | */
|
||||||
|
PROP_FUNC_UINT32=12, /* 32-bit unsigned integer | */
|
||||||
|
PROP_FUNC_INT32=13, /* 32-bit signed integer | */
|
||||||
|
PROP_FUNC_REAL32=14, /* 32-bit floating-point | */
|
||||||
|
} PROP_TYPE;
|
||||||
|
|
||||||
|
typedef int8_t (*get_prop_b_func_ptr)(int index, void *paramter);
|
||||||
|
typedef uint8_t (*get_prop_B_func_ptr)(int index, void *paramter);
|
||||||
|
typedef int16_t (*get_prop_h_func_ptr)(int index, void *paramter);
|
||||||
|
typedef uint16_t (*get_prop_H_func_ptr)(int index, void *paramter);
|
||||||
|
typedef int32_t (*get_prop_i_func_ptr)(int index, void *paramter);
|
||||||
|
typedef uint32_t (*get_prop_I_func_ptr)(int index, void *paramter);
|
||||||
|
typedef float (*get_prop_f_func_ptr)(int index, void *paramter);
|
||||||
|
|
||||||
|
float RPM0[4];
|
||||||
|
|
||||||
|
float RPM1(int index, void * paramter)
|
||||||
|
{
|
||||||
|
(void *)paramter;
|
||||||
|
|
||||||
|
return RPM0[index];
|
||||||
|
}
|
||||||
|
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start function
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void hal_sen_read_Start_wrapper(void **pW,
|
||||||
|
const uint8_T *name, const int_T p_width0)
|
||||||
|
{
|
||||||
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_BEGIN --- EDIT HERE TO _END */
|
||||||
|
/* initialize code to bind property; */
|
||||||
|
int *valid = (int *)&pW[0]; /* 0-invalid; 1-valid; */
|
||||||
|
PROP_TYPE *type = (PROP_TYPE *)&pW[1];
|
||||||
|
int *len = (int *)&pW[2]; /* parameter length; */
|
||||||
|
void **val_ptr = &pW[3]; /* pointer to value array */
|
||||||
|
void **parameter = &pW[4]; /* parameter for function */
|
||||||
|
|
||||||
|
/* set default pW values */
|
||||||
|
*valid = 0;
|
||||||
|
*type = 0;
|
||||||
|
*val_ptr = NULL;
|
||||||
|
*parameter = NULL;
|
||||||
|
*len = 0;
|
||||||
|
if (strncmp(name, "RPM0", p_width0))
|
||||||
|
{
|
||||||
|
*valid = 1;
|
||||||
|
*type = PROP_ARRAY_REAL32;
|
||||||
|
*len = 4;
|
||||||
|
*val_ptr = &RPM0;
|
||||||
|
}
|
||||||
|
else if (strncmp(name, "RPM1", p_width0))
|
||||||
|
{
|
||||||
|
*valid = 1;
|
||||||
|
*type = PROP_FUNC_REAL32;
|
||||||
|
*len = 4;
|
||||||
|
*val_ptr = &RPM1;
|
||||||
|
}
|
||||||
|
/* %%%-SFUNWIZ_wrapper_Start_Changes_END --- EDIT HERE TO _BEGIN */
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Output function
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void hal_sen_read_Outputs_wrapper(real32_T *value,
|
||||||
|
int32_T *ErrorCode,
|
||||||
|
void **pW,
|
||||||
|
const uint8_T *name, const int_T p_width0,
|
||||||
|
const int_T y_width)
|
||||||
|
{
|
||||||
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||||
|
/* get binded property value; */
|
||||||
|
ErrorCode[0] = -1;
|
||||||
|
|
||||||
|
int *valid = (int *)&pW[0];
|
||||||
|
if (*valid)
|
||||||
|
{
|
||||||
|
int *len = (int *)&pW[2];
|
||||||
|
if (y_width > *len)
|
||||||
|
{
|
||||||
|
ErrorCode[0] = -2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
PROP_TYPE *type = (PROP_TYPE *)&pW[1];
|
||||||
|
switch(*type)
|
||||||
|
{
|
||||||
|
case PROP_ARRAY_UINT8:
|
||||||
|
{
|
||||||
|
uint8_t *val = *(uint8_t **)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)val[i];
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_ARRAY_INT8:
|
||||||
|
{
|
||||||
|
int8_t *val = *(int8_t **)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)val[i];
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_ARRAY_UINT16:
|
||||||
|
{
|
||||||
|
uint16_t *val = *(uint16_t **)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)val[i];
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_ARRAY_INT16:
|
||||||
|
{
|
||||||
|
int16_t *val = *(int16_t **)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)val[i];
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_ARRAY_UINT32:
|
||||||
|
{
|
||||||
|
uint32_t *val = *(uint32_t **)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)val[i];
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_ARRAY_INT32:
|
||||||
|
{
|
||||||
|
int32_t *val = *(int32_t **)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)val[i];
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_ARRAY_REAL32:
|
||||||
|
{
|
||||||
|
float *val = *(float **)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = val[i];
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_FUNC_UINT8:
|
||||||
|
{
|
||||||
|
get_prop_B_func_ptr func = *(get_prop_B_func_ptr *)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)(*func)(i,pW[4]);
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_FUNC_INT8:
|
||||||
|
{
|
||||||
|
get_prop_b_func_ptr func = *(get_prop_b_func_ptr *)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)(*func)(i,pW[4]);
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_FUNC_UINT16:
|
||||||
|
{
|
||||||
|
get_prop_H_func_ptr func = *(get_prop_H_func_ptr *)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)(*func)(i,pW[4]);
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_FUNC_INT16:
|
||||||
|
{
|
||||||
|
get_prop_h_func_ptr func = *(get_prop_h_func_ptr *)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)(*func)(i,pW[4]);
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_FUNC_UINT32:
|
||||||
|
{
|
||||||
|
get_prop_I_func_ptr func = *(get_prop_I_func_ptr *)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)(*func)(i,pW[4]);
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_FUNC_INT32:
|
||||||
|
{
|
||||||
|
get_prop_i_func_ptr func = *(get_prop_i_func_ptr *)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (float)(*func)(i,pW[4]);
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_FUNC_REAL32:
|
||||||
|
{
|
||||||
|
get_prop_f_func_ptr func = *(get_prop_f_func_ptr *)&pW[3];
|
||||||
|
for (i=0; i<y_width; ++i)
|
||||||
|
{
|
||||||
|
value[i] = (*func)(i,pW[4]);
|
||||||
|
}
|
||||||
|
ErrorCode[0] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user