/* Include files */ #include "edificio3stanze_feedforward_sfun.h" #include "c8_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 c8_IN_NO_ACTIVE_CHILD (0) /* Variable Declarations */ /* Variable Definitions */ static SFc8_edificio3stanze_feedforwardInstanceStruct chartInstance; /* Function Declarations */ static void initialize_c8_edificio3stanze_feedforward(void); static void enable_c8_edificio3stanze_feedforward(void); static void disable_c8_edificio3stanze_feedforward(void); static void finalize_c8_edificio3stanze_feedforward(void); static void sf_c8_edificio3stanze_feedforward(void); static real_T *c8_u(void); static real_T *c8_e(void); /* Function Definitions */ static void initialize_c8_edificio3stanze_feedforward(void) { chartInstance.c8_is_active_c8_edificio3stanze_feedforward = 0; if(!(cdrGetOutputPortReusable(chartInstance.S, 1) != 0)) { } } static void enable_c8_edificio3stanze_feedforward(void) { } static void disable_c8_edificio3stanze_feedforward(void) { } static void finalize_c8_edificio3stanze_feedforward(void) { } static void sf_c8_edificio3stanze_feedforward(void) { uint8_T c8_previousEvent; _sfTime_ = (real_T)ssGetT(chartInstance.S); _SFD_DATA_RANGE_CHECK(*c8_u(), 1U); _SFD_DATA_RANGE_CHECK(*c8_e(), 0U); c8_previousEvent = _sfEvent_; _sfEvent_ = CALL_EVENT; { real_T c8_em_d0; real_T c8_b_e; _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,7); c8_b_e = *c8_e(); { real_T c8_em_d1; real_T c8_em_d2; real_T c8_em_d3; real_T c8_x; sf_debug_push_symbol_scope(2); sf_debug_symbol_scope_add_symbol("e", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c8_b_e); sf_debug_symbol_scope_add_symbol("u", 0, 0U, 0U, 0U, 0U, 1.0, 0, 0.0, 0U, 0, &c8_em_d0); 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); c8_x = c8_b_e; c8_em_d3 = floor(c8_x); c8_b_e = c8_em_d3; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,8); c8_em_d0 = 0.0; _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,9); if(CV_EML_IF(0, 0, c8_b_e == 0.0)) { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,10); sf_mex_import(sf_mex_call("binornd", 1U, 2U, 6, 1.0, 6, 0.4), "binornd", &c8_em_d2, 0, 0U, 0, 0); c8_em_d0 = c8_em_d2; } else { _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,12); sf_mex_import(sf_mex_call("binornd", 1U, 2U, 6, 1.0, 6, 0.7), "binornd", &c8_em_d1, 0, 0U, 0, 0); c8_em_d0 = c8_em_d1; } _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,-12); sf_debug_pop_symbol_scope(); } *c8_u() = c8_em_d0; _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,7); } _sfEvent_ = c8_previousEvent; } static real_T *c8_u(void) { return (real_T *)ssGetOutputPortSignal(chartInstance.S, 1); } static real_T *c8_e(void) { return (real_T *)ssGetInputPortSignal(chartInstance.S, 0); } /* SFunction Glue Code */ void sf_c8_edificio3stanze_feedforward_get_check_sum(mxArray *plhs[]) { ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(3084774258U); ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(3148680291U); ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(604308233U); ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(2452872959U); } mxArray *sf_c8_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)(1972479952U); ((real_T *)mxGetPr((mxChecksum)))[1] = (real_T)(3173383405U); ((real_T *)mxGetPr((mxChecksum)))[2] = (real_T)(2779834443U); ((real_T *)mxGetPr((mxChecksum)))[3] = (real_T)(4257059582U); mxInputTypes = mxCreateDoubleMatrix(1,1,mxREAL); ((real_T *)mxGetPr((mxInputTypes)))[0] = (real_T)(10U); mxOutputSizes = mxCreateDoubleMatrix(2,1,mxREAL); mxOutputTypes = mxCreateDoubleMatrix(1,1,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); 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_, 8, 1, 1, 2, 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(1,2,0,1,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"u",0); _SFD_SET_DATA_PROPS(0,1,1,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"e",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,1,0,0,0,0,0); _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",1,-1,297); _SFD_CV_INIT_EML_IF(0,0,224,233,263,296); _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(1U, c8_u()); _SFD_SET_DATA_VALUE_PTR(0U, c8_e()); } } } else { sf_debug_reset_current_state_configuration(_edificio3stanze_feedforwardMachineNumber_,chartInstance.chartNumber,chartInstance.instanceNumber); } } static void sf_opaque_initialize_c8_edificio3stanze_feedforward(void *chartInstanceVar) { chart_debug_initialization(chartInstance.S); initialize_c8_edificio3stanze_feedforward(); } static void sf_opaque_enable_c8_edificio3stanze_feedforward(void *chartInstanceVar) { enable_c8_edificio3stanze_feedforward(); } static void sf_opaque_disable_c8_edificio3stanze_feedforward(void *chartInstanceVar) { disable_c8_edificio3stanze_feedforward(); } static void sf_opaque_gateway_c8_edificio3stanze_feedforward(void *chartInstanceVar) { sf_c8_edificio3stanze_feedforward(); } static void sf_opaque_terminate_c8_edificio3stanze_feedforward(void *chartInstanceVar) { finalize_c8_edificio3stanze_feedforward(); } static void mdlSetWorkWidths_c8_edificio3stanze_feedforward(SimStruct *S) { if(sim_mode_is_rtw_gen(S)) { int_T chartIsInlinable = (int_T)sf_is_chart_inlinable("edificio3stanze_feedforward",8); int_T chartIsMultiInstanced = (int_T)sf_is_chart_multi_instanced("edificio3stanze_feedforward",8); 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",8,1); sf_mark_chart_reusable_outputs(S,"edificio3stanze_feedforward",8,1); } if (!sf_is_chart_instance_optimized_out("edificio3stanze_feedforward",8)) { int dtId; char *chartInstanceTypedefName = sf_chart_instance_typedef_name("edificio3stanze_feedforward",8); 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,(3084774258U)); ssSetChecksum1(S,(3148680291U)); ssSetChecksum2(S,(604308233U)); ssSetChecksum3(S,(2452872959U)); ssSetExplicitFCSSCtrl(S,1); } static void mdlRTW_c8_edificio3stanze_feedforward(SimStruct *S) { sf_write_symbol_mapping(S, "edificio3stanze_feedforward", 8); ssWriteRTWStrParam(S, "StateflowChartType", "Embedded MATLAB"); } static void mdlStart_c8_edificio3stanze_feedforward(SimStruct *S) { chartInstance.chartInfo.chartInstance = NULL; chartInstance.chartInfo.isEMLChart = 1; chartInstance.chartInfo.chartInitialized = 0; chartInstance.chartInfo.sFunctionGateway = sf_opaque_gateway_c8_edificio3stanze_feedforward; chartInstance.chartInfo.initializeChart = sf_opaque_initialize_c8_edificio3stanze_feedforward; chartInstance.chartInfo.terminateChart = sf_opaque_terminate_c8_edificio3stanze_feedforward; chartInstance.chartInfo.enableChart = sf_opaque_enable_c8_edificio3stanze_feedforward; chartInstance.chartInfo.disableChart = sf_opaque_disable_c8_edificio3stanze_feedforward; chartInstance.chartInfo.mdlRTW = mdlRTW_c8_edificio3stanze_feedforward; chartInstance.chartInfo.mdlStart = mdlStart_c8_edificio3stanze_feedforward; chartInstance.chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c8_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 c8_edificio3stanze_feedforward_method_dispatcher(SimStruct *S, int_T method, void *data) { switch (method) { case SS_CALL_MDL_START: mdlStart_c8_edificio3stanze_feedforward(S); break; case SS_CALL_MDL_SET_WORK_WIDTHS: mdlSetWorkWidths_c8_edificio3stanze_feedforward(S); break; default: /* Unhandled method */ sf_mex_error_message("Stateflow Internal Error:\n" "Error calling c8_edificio3stanze_feedforward_method_dispatcher.\n" "Can't handle method %d.\n", method); break; } }