/* Include files */ #include "edificio3stanze_feedforward_sfun.h" #include "c12_edificio3stanze_feedforward.h" #define CHARTINSTANCE_CHARTNUMBER (chartInstance.chartNumber) #define CHARTINSTANCE_INSTANCENUMBER (chartInstance.instanceNumber) #include "edificio3stanze_feedforward_sfun_debug_macros.h" /* Type Definitions */ /* Named Constants */ #define c12_IN_NO_ACTIVE_CHILD (0) /* Variable Declarations */ /* Variable Definitions */ static SFc12_edificio3stanze_feedforwardInstanceStruct chartInstance; /* Function Declarations */ static void initialize_c12_edificio3stanze_feedforward(void); static void enable_c12_edificio3stanze_feedforward(void); static void disable_c12_edificio3stanze_feedforward(void); static void finalize_c12_edificio3stanze_feedforward(void); static void sf_c12_edificio3stanze_feedforward(void); static real_T *c12_u(void); static real_T *c12_nord(void); static real_T *c12_sud(void); static real_T *c12_est(void); static real_T *c12_ovest(void); /* Function Definitions */ static void initialize_c12_edificio3stanze_feedforward(void) { chartInstance.c12_is_active_c12_edificio3stanze_feedforward = 0; if(!(cdrGetOutputPortReusable(chartInstance.S, 1) != 0)) { } if(!(cdrGetOutputPortReusable(chartInstance.S, 2) != 0)) { } if(!(cdrGetOutputPortReusable(chartInstance.S, 3) != 0)) { } if(!(cdrGetOutputPortReusable(chartInstance.S, 4) != 0)) { } } static void enable_c12_edificio3stanze_feedforward(void) { } static void disable_c12_edificio3stanze_feedforward(void) { } static void finalize_c12_edificio3stanze_feedforward(void) { } static void sf_c12_edificio3stanze_feedforward(void) { uint8_T c12_previousEvent; _sfTime_ = (real_T)ssGetT(chartInstance.S); _SFD_DATA_RANGE_CHECK(*c12_u(), 4U); _SFD_DATA_RANGE_CHECK(*c12_nord(), 3U); _SFD_DATA_RANGE_CHECK(*c12_sud(), 1U); _SFD_DATA_RANGE_CHECK(*c12_est(), 2U); _SFD_DATA_RANGE_CHECK(*c12_ovest(), 0U); c12_previousEvent = _sfEvent_; _sfEvent_ = CALL_EVENT; { real_T c12_b_u; real_T c12_b_ovest; real_T c12_b_est; real_T c12_b_sud; real_T c12_b_nord; _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,0); c12_b_u = *c12_u(); { real_T c12_t; real_T c12_em_d0; real_T c12_x; sf_debug_push_symbol_scope(6); sf_debug_symbol_scope_add_symbol("u", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c12_b_u); sf_debug_symbol_scope_add_symbol("nord", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c12_b_nord); sf_debug_symbol_scope_add_symbol("sud", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c12_b_sud); sf_debug_symbol_scope_add_symbol("est", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c12_b_est); sf_debug_symbol_scope_add_symbol("ovest", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c12_b_ovest); sf_debug_symbol_scope_add_symbol("t", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c12_t); CV_EML_FCN(0, 0); /* t tempo corrente */ /* durata_vento, dopo di che ladirezione del vento cambia */ /* uscite sono i valori di velocità in metri minuto del vento nelle quattro */ /* direzioni cardinali */ _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,7); c12_b_nord = 1.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,7); c12_b_sud = 1.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,7); c12_b_est = 1.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,7); c12_b_ovest = 1.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,8); c12_x = c12_b_u; c12_em_d0 = floor(c12_x); c12_t = c12_em_d0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,9); if(CV_EML_IF(0, 0, c12_t == 0.0)) { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,10); c12_b_nord = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,11); c12_b_sud = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,12); c12_b_est = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,13); c12_b_ovest = 0.0; } else { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,15); if(CV_EML_IF(0, 1, c12_t == 1.0)) { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,16); c12_b_nord = 1.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,17); c12_b_sud = -0.5; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,18); c12_b_est = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,19); c12_b_ovest = 0.0; } else { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,21); if(CV_EML_IF(0, 2, c12_t == 2.0)) { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,22); c12_b_nord = -0.5; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,23); c12_b_sud = 1.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,24); c12_b_est = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,25); c12_b_ovest = 0.0; } else { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,27); if(CV_EML_IF(0, 3, c12_t == 3.0)) { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,28); c12_b_nord = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,29); c12_b_sud = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,30); c12_b_est = 1.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,31); c12_b_ovest = -0.5; } else { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,33); if(CV_EML_IF(0, 4, c12_t == 4.0)) { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,34); c12_b_nord = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,35); c12_b_sud = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,36); c12_b_est = -0.5; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,37); c12_b_ovest = 1.0; } } } } } _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,-37); sf_debug_pop_symbol_scope(); } *c12_ovest() = c12_b_ovest; *c12_est() = c12_b_est; *c12_sud() = c12_b_sud; *c12_nord() = c12_b_nord; _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,0); } _sfEvent_ = c12_previousEvent; } static real_T *c12_u(void) { return (real_T *)ssGetInputPortSignal(chartInstance.S, 0); } static real_T *c12_nord(void) { return (real_T *)ssGetOutputPortSignal(chartInstance.S, 1); } static real_T *c12_sud(void) { return (real_T *)ssGetOutputPortSignal(chartInstance.S, 2); } static real_T *c12_est(void) { return (real_T *)ssGetOutputPortSignal(chartInstance.S, 3); } static real_T *c12_ovest(void) { return (real_T *)ssGetOutputPortSignal(chartInstance.S, 4); } /* SFunction Glue Code */ void sf_c12_edificio3stanze_feedforward_get_check_sum(mxArray *plhs[]) { ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1314792237U); ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(87456101U); ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(3290532969U); ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(1581470984U); } mxArray *sf_c12_edificio3stanze_feedforward_get_autoinheritance_info(void) { const char *autoinheritanceInfoStructFieldNames[] = {"checksum","inputTypes","outputSizes","outputTypes"}; mxArray *mxAutoinheritanceInfo = NULL; mxArray *mxChecksum = NULL; mxArray *mxInputTypes = NULL; mxArray *mxOutputSizes = NULL; mxArray *mxOutputTypes = NULL; mxAutoinheritanceInfo = mxCreateStructMatrix(1,1, sizeof(autoinheritanceInfoStructFieldNames)/sizeof(char *), autoinheritanceInfoStructFieldNames); mxChecksum = mxCreateDoubleMatrix(4,1,mxREAL); ((real_T *)mxGetPr((mxChecksum)))[0] = (real_T)(3653466835U); ((real_T *)mxGetPr((mxChecksum)))[1] = (real_T)(1252649217U); ((real_T *)mxGetPr((mxChecksum)))[2] = (real_T)(516641319U); ((real_T *)mxGetPr((mxChecksum)))[3] = (real_T)(1498284459U); mxInputTypes = mxCreateDoubleMatrix(1,1,mxREAL); ((real_T *)mxGetPr((mxInputTypes)))[0] = (real_T)(10U); mxOutputSizes = mxCreateDoubleMatrix(2,4,mxREAL); mxOutputTypes = mxCreateDoubleMatrix(1,4,mxREAL); ((real_T *)mxGetPr((mxOutputSizes)))[0] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputSizes)))[1] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputTypes)))[0] = (real_T)(10U); ((real_T *)mxGetPr((mxOutputSizes)))[2] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputSizes)))[3] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputTypes)))[1] = (real_T)(10U); ((real_T *)mxGetPr((mxOutputSizes)))[4] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputSizes)))[5] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputTypes)))[2] = (real_T)(10U); ((real_T *)mxGetPr((mxOutputSizes)))[6] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputSizes)))[7] = (real_T)(1U); ((real_T *)mxGetPr((mxOutputTypes)))[3] = (real_T)(10U); mxSetFieldByNumber(mxAutoinheritanceInfo,0,0,mxChecksum); mxSetFieldByNumber(mxAutoinheritanceInfo,0,1,mxInputTypes); mxSetFieldByNumber(mxAutoinheritanceInfo,0,2,mxOutputSizes); mxSetFieldByNumber(mxAutoinheritanceInfo,0,3,mxOutputTypes); return(mxAutoinheritanceInfo); } static void chart_debug_initialization(SimStruct *S) { if(ssIsFirstInitCond(S)) { /* do this only if simulation is starting */ if(!sim_mode_is_rtw_gen(S)) { { unsigned int chartAlreadyPresent; chartAlreadyPresent = sf_debug_initialize_chart(_edificio3stanze_feedforwardMachineNumber_, 12, 1, 1, 5, 0, 0, 0, 0, &(chartInstance.chartNumber), &(chartInstance.instanceNumber), ssGetPath(S), (void *)S); if(chartAlreadyPresent==0) { /* this is the first instance */ sf_debug_set_chart_disable_implicit_casting(_edificio3stanze_feedforwardMachineNumber_,chartInstance.chartNumber,1); sf_debug_set_chart_event_thresholds(_edificio3stanze_feedforwardMachineNumber_, chartInstance.chartNumber, 0, 0, 0); _SFD_SET_DATA_PROPS(4,1,1,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"u",0); _SFD_SET_DATA_PROPS(3,2,0,1,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"nord",0); _SFD_SET_DATA_PROPS(1,2,0,1,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"sud",0); _SFD_SET_DATA_PROPS(2,2,0,1,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"est",0); _SFD_SET_DATA_PROPS(0,2,0,1,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"ovest",0); _SFD_STATE_INFO(0,0,2); _SFD_CH_SUBSTATE_COUNT(0); _SFD_CH_SUBSTATE_DECOMP(0); } _SFD_CV_INIT_CHART(0,0,0,0); { _SFD_CV_INIT_STATE(0,0,0,0,0,0,NULL,NULL); } _SFD_CV_INIT_TRANS(0,0,NULL,NULL,0,NULL); /* Initialization of EML Model Coverage */ _SFD_CV_INIT_EML(0,1,5,0,0,0,0,0); _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",1,-1,926); _SFD_CV_INIT_EML_IF(0,0,267,276,327,925); _SFD_CV_INIT_EML_IF(0,1,336,345,423,910); _SFD_CV_INIT_EML_IF(0,2,437,446,550,902); _SFD_CV_INIT_EML_IF(0,3,568,577,688,889); _SFD_CV_INIT_EML_IF(0,4,709,718,-1,-2); _SFD_TRANS_COV_WTS(0,0,0,1,0); if(chartAlreadyPresent==0) { _SFD_TRANS_COV_MAPS(0, 0,NULL,NULL, 0,NULL,NULL, 1,NULL,NULL, 0,NULL,NULL); } _SFD_SET_DATA_VALUE_PTR(4U, c12_u()); _SFD_SET_DATA_VALUE_PTR(3U, c12_nord()); _SFD_SET_DATA_VALUE_PTR(1U, c12_sud()); _SFD_SET_DATA_VALUE_PTR(2U, c12_est()); _SFD_SET_DATA_VALUE_PTR(0U, c12_ovest()); } } } else { sf_debug_reset_current_state_configuration(_edificio3stanze_feedforwardMachineNumber_,chartInstance.chartNumber,chartInstance.instanceNumber); } } static void sf_opaque_initialize_c12_edificio3stanze_feedforward(void *chartInstanceVar) { chart_debug_initialization(chartInstance.S); initialize_c12_edificio3stanze_feedforward(); } static void sf_opaque_enable_c12_edificio3stanze_feedforward(void *chartInstanceVar) { enable_c12_edificio3stanze_feedforward(); } static void sf_opaque_disable_c12_edificio3stanze_feedforward(void *chartInstanceVar) { disable_c12_edificio3stanze_feedforward(); } static void sf_opaque_gateway_c12_edificio3stanze_feedforward(void *chartInstanceVar) { sf_c12_edificio3stanze_feedforward(); } static void sf_opaque_terminate_c12_edificio3stanze_feedforward(void *chartInstanceVar) { finalize_c12_edificio3stanze_feedforward(); } static void mdlSetWorkWidths_c12_edificio3stanze_feedforward(SimStruct *S) { if(sim_mode_is_rtw_gen(S)) { int_T chartIsInlinable = (int_T)sf_is_chart_inlinable("edificio3stanze_feedforward",12); int_T chartIsMultiInstanced = (int_T)sf_is_chart_multi_instanced("edificio3stanze_feedforward",12); ssSetStateflowIsInlinable(S,chartIsInlinable); ssSetEnableFcnIsTrivial(S,1); ssSetDisableFcnIsTrivial(S,1); if(chartIsInlinable) { ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); sf_mark_chart_expressionable_inputs(S,"edificio3stanze_feedforward",12,1); sf_mark_chart_reusable_outputs(S,"edificio3stanze_feedforward",12,4); } if (!sf_is_chart_instance_optimized_out("edificio3stanze_feedforward",12)) { int dtId; char *chartInstanceTypedefName = sf_chart_instance_typedef_name("edificio3stanze_feedforward",12); dtId = ssRegisterDataType(S, chartInstanceTypedefName); if (dtId == INVALID_DTYPE_ID ) return; /* Register the size of the udt */ if (!ssSetDataTypeSize(S, dtId, 8)) return; if(!ssSetNumDWork(S,1)) return; ssSetDWorkDataType(S, 0, dtId); ssSetDWorkWidth(S, 0, 1); ssSetDWorkName(S, 0, "ChartInstance"); /*optional name, less than 16 chars*/ sf_set_rtw_identifier(S); } ssSetHasSubFunctions(S,!(chartIsInlinable)); ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE); } ssSetChecksum0(S,(1314792237U)); ssSetChecksum1(S,(87456101U)); ssSetChecksum2(S,(3290532969U)); ssSetChecksum3(S,(1581470984U)); ssSetExplicitFCSSCtrl(S,1); } static void mdlRTW_c12_edificio3stanze_feedforward(SimStruct *S) { sf_write_symbol_mapping(S, "edificio3stanze_feedforward", 12); ssWriteRTWStrParam(S, "StateflowChartType", "Embedded MATLAB"); } static void mdlStart_c12_edificio3stanze_feedforward(SimStruct *S) { chartInstance.chartInfo.chartInstance = NULL; chartInstance.chartInfo.isEMLChart = 1; chartInstance.chartInfo.chartInitialized = 0; chartInstance.chartInfo.sFunctionGateway = sf_opaque_gateway_c12_edificio3stanze_feedforward; chartInstance.chartInfo.initializeChart = sf_opaque_initialize_c12_edificio3stanze_feedforward; chartInstance.chartInfo.terminateChart = sf_opaque_terminate_c12_edificio3stanze_feedforward; chartInstance.chartInfo.enableChart = sf_opaque_enable_c12_edificio3stanze_feedforward; chartInstance.chartInfo.disableChart = sf_opaque_disable_c12_edificio3stanze_feedforward; chartInstance.chartInfo.mdlRTW = mdlRTW_c12_edificio3stanze_feedforward; chartInstance.chartInfo.mdlStart = mdlStart_c12_edificio3stanze_feedforward; chartInstance.chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c12_edificio3stanze_feedforward; chartInstance.chartInfo.restoreLastMajorStepConfiguration = NULL; chartInstance.chartInfo.restoreBeforeLastMajorStepConfiguration = NULL; chartInstance.chartInfo.storeCurrentConfiguration = NULL; chartInstance.S = S; ssSetUserData(S,(void *)(&(chartInstance.chartInfo))); /* register the chart instance with simstruct */ } void c12_edificio3stanze_feedforward_method_dispatcher(SimStruct *S, int_T method, void *data) { switch (method) { case SS_CALL_MDL_START: mdlStart_c12_edificio3stanze_feedforward(S); break; case SS_CALL_MDL_SET_WORK_WIDTHS: mdlSetWorkWidths_c12_edificio3stanze_feedforward(S); break; default: /* Unhandled method */ sf_mex_error_message("Stateflow Internal Error:\n" "Error calling c12_edificio3stanze_feedforward_method_dispatcher.\n" "Can't handle method %d.\n", method); break; } }