/* Include files */
#include <stddef.h>
#include "blas.h"
#include "ctc_sfun.h"
#include "c2_ctc.h"
#include "mwmathutil.h"
#define CHARTINSTANCE_CHARTNUMBER (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER (chartInstance->instanceNumber)
#include "ctc_sfun_debug_macros.h"
#define _SF_MEX_LISTEN_FOR_CTRL_C(S) sf_mex_listen_for_ctrl_c(sfGlobalDebugInstanceStruct,S);
/* Type Definitions */
/* Named Constants */
#define CALL_EVENT (-1)
/* Variable Declarations */
/* Variable Definitions */
static real_T _sfTime_;
static const char * c2_debug_family_names[17] = { "m1", "m2", "l1", "l2", "q1",
"q2", "qd1", "qd2", "M", "C", "G", "nargin", "nargout", "q", "qd", "qdd", "Q"
};
/* Function Declarations */
static void initialize_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void initialize_params_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void enable_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void disable_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void c2_update_debugger_state_c2_ctc(SFc2_ctcInstanceStruct
*chartInstance);
static const mxArray *get_sim_state_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void set_sim_state_c2_ctc(SFc2_ctcInstanceStruct *chartInstance, const
mxArray *c2_st);
static void finalize_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void sf_gateway_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void c2_chartstep_c2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void initSimStructsc2_ctc(SFc2_ctcInstanceStruct *chartInstance);
static void init_script_number_translation(uint32_T c2_machineNumber, uint32_T
c2_chartNumber, uint32_T c2_instanceNumber);
static const mxArray *c2_sf_marshallOut(void *chartInstanceVoid, void *c2_inData);
static void c2_emlrt_marshallIn(SFc2_ctcInstanceStruct *chartInstance, const
mxArray *c2_Q, const char_T *c2_identifier, real_T c2_y[2]);
static void c2_b_emlrt_marshallIn(SFc2_ctcInstanceStruct *chartInstance, const
mxArray *c2_u, const emlrtMsgIdentifier *c2_parentId, real_T c2_y[2]);
static void c2_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c2_mxArrayInData, const char_T *c2_varName, void *c2_outData);
static const mxArray *c2_b_sf_marshallOut(void *chartInstanceVoid, void
*c2_inData);
static real_T c2_c_emlrt_marshallIn(SFc2_ctcInstanceStruct *chartInstance, const
mxArray *c2_u, const emlrtMsgIdentifier *c2_parentId);
static void c2_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c2_mxArrayInData, const char_T *c2_varName, void *c2_outData);
static const mxArray *c2_c_sf_marshallOut(void *chartInstanceVoid, void
*c2_inData);
static void c2_d_emlrt_marshallIn(SFc2_ctcInstanceStruct *chartInstance, const
mxArray *c2_u, const emlrtMsgIdentifier *c2_parentId, real_T c2_y[4]);
static void c2_c_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c2_mxArrayInData, const char_T *c2_varName, void *c2_outData);
static void c2_info_helper(const mxArray **c2_info);
static const mxArray *c2_emlrt_marshallOut(const char * c2_u);
static const mxArray *c2_b_emlrt_marshallOut(const uint32_T c2_u);
static void c2_eml_scalar_eg(SFc2_ctcInstanceStruct *chartInstance);
static void c2_eml_xgemm(SFc2_ctcInstanceStruct *chartInstance, real_T c2_A[4],
real_T c2_B[2], real_T c2_C[2], real_T c2_b_C[2]);
static const mxArray *c2_d_sf_marshallOut(void *chartInstanceVoid, void
*c2_inData);
static int32_T c2_e_emlrt_marshallIn(SFc2_ctcInstanceStruct *chartInstance,
const mxArray *c2_u, const emlrtMsgIdentifier *c2_parentId);
static void c2_d_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c2_mxArrayInData, const char_T *c2_varName, void *c2_outData);
static uint8_T c2_f_emlrt_marshallIn(SFc2_ctcInstanceStruct *chartInstance,
const mxArray *c2_b_is_active_c2_ctc, const char_T *c2_identifier);
static uint8_T c2_g_emlrt_marshallIn(SFc2_ctcInstanceStruct *chartInstance,
const mxArray *c2_u, const emlrtMsgIdentifier *c2_parentId);
static void c2_b_eml_xgemm(SFc2_ctcInstanceStruct *chartInstance, real_T c2_A[4],
real_T c2_B[2], real_T c2_C[2]);
static void init_dsm_address_info(SFc2_ctcInstanceStruct *chartInstance);
/* Function Definitions */
static void initialize_c2_ctc(SFc2_ctcInstanceStruct *chartInstance)
{
chartInstance->c2_sfEvent = CALL_EVENT;
_sfTime_ = sf_get_time(chartInstance->S);
chartInstance->c2_is_active_c2_ctc = 0U;
}
static void initialize_params_c2_ctc(SFc2_ctcInstanceStruct *chartInstance)
{
(void)chartInstance;
}
static void enable_c2_ctc(SFc2_ctcInstanceStruct *chartInstance)
{
_sfTime_ = sf_get_time(chartInstance->S);
}
static void disable_c2_ctc(SFc2_ctcInstanceStruct *chartInstance)
{
_sfTime_ = sf_get_time(chartInstance->S);
}
static void c2_update_debugger_state_c2_ctc(SFc2_ctcInstanceStruct
*chartInstance)
{
(void)chartInstance;
}
static const mxArray *get_sim_state_c2_ctc(SFc2_ctcInstanceStruct *chartInstance)
{
const mxArray *c2_st;
const mxArray *c2_y = NULL;
int32_T c2_i0;
real_T c2_u[2];
const mxArray *c2_b_y = NULL;
uint8_T c2_hoistedGlobal;
uint8_T c2_b_u;
const mxArray *c2_c_y = NULL;
real_T (*c2_Q)[2];
c2_Q = (real_T (*)[2])ssGetOutputPortSignal(chartInstance->S, 1);
c2_st = NULL;
c2_st = NULL;
c2_y = NULL;
sf_mex_assign(&c2_y, sf_mex_createcellmatrix(2, 1), false);
for (c2_i0 = 0; c2_i0 < 2; c2_i0++) {
c2_u[c2_i0] = (*c2_Q)[c2_i0];
}
c2_b_y = NULL;
sf_mex_assign(&c2_b_y, sf_mex_create("y", c2_u, 0, 0U, 1U, 0U, 1, 2), false);
sf_mex_setcell(c2_y, 0, c2_b_y);
c2_hoistedGlobal = chartInstance->c2_is_active_c2_ctc;
c2_b_u = c2_hoistedGlobal;
c2_c_y = NULL;
sf_mex_assign(&c2_c_y, sf_mex_create("y", &c2_b_u, 3, 0U, 0U, 0U, 0), false);
sf_mex_setcell(c2_y, 1, c2_c_y);
sf_mex_assign(&c2_st, c2_y, false);
return c2_st;
}
static void set_sim_state_c2_ctc(SFc2_ctcInstanceStruct *chartInstance, const
mxArray *c2_st)
{
const mxArray *c2_u;
real_T c2_dv0[2];
int32_T c2_i1;
real_T (*c2_Q)[2];
c2_Q = (real_T (*)[2])ssGetOutputPortSignal(chartInstance->S, 1);
chartInstance->c2_doneDoubleBufferReInit = true;
c2_u = sf_mex_dup(c2_st);
c2_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c2_u, 0)), "Q",
c2_dv0);
for (c2_i1 = 0; c2_i1 < 2; c2_i1++) {
(*c2_Q)[c2_i1] = c2_dv0[c2_i1];
}
chartInstance->c2_is_active_c2_ctc = c2_f_emlrt_marshallIn(chartInstance,
sf_mex_dup(sf_mex_getcell(c2_u, 1)), "is_active_c2_ctc");
sf_mex_destroy(&c2_u);
c2_update_debugger_state_c2_ctc(chartInstance);
sf_mex_destroy(&c2_st);
}
static void finalize_c2_ctc(SFc2_ctcInstanceStruct *chartInstance)
{
(void)chartInstance;
}
static void sf_gateway_c2_ctc(SFc2_ctcInstanceStruct *chartInstance)
{
int32_T c2_i2;
int32_T c2_i3;
int32_T c2_i4;
int32_T c2_i5;
real_T (*c2_qdd)[2];
real_T (*c2_qd)[2];
real_T (*c2_Q)[2];
real_T (*c2_q)[2];
c2_qdd = (real_T (*)[2])ssGetInputPortSignal(chartInstance->S, 2);
c2_qd = (real_T (*)[2])ssGetInputPortSignal(chartInstance->S, 1);
c2_Q = (real_T (*)[2])ssGetOutputPortSignal(chartInstance->S, 1);
c2_q = (real_T (*)[2])ssGetInputPortSignal(chartInstance->S, 0);
_SFD_SYMBOL_SCOPE_PUSH(0U, 0U);
_sfTime_ = sf_get_time(chartInstance->S);
_SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 1U, chartInstance->c2_sfEvent);
for (c2_i2 = 0; c2_i2 < 2; c2_i2++) {
_SFD_DATA_RANGE_CHECK((*c2_q)[c2_i2], 0U);
}
chartInstance->c2_sfEvent = CALL_EVENT;
c2_chartstep_c2_ctc(chartInstance);
_SFD_SYMBOL_SCOPE_POP();
_SFD_CHECK_FOR_STATE_INCONSISTENCY(_ctcMachineNumber_,
chartInstance->chartNumber, chartInstance->instanceNumber);
for (c2_i3 = 0; c2_i3 < 2; c2_i3++) {
_SFD_DATA_RANGE_CHECK((*c2_Q)[c2_i3], 1U);
}
for (c2_i4 = 0; c2_i4 < 2; c2_i4++) {
_SFD_DATA_RANGE