📄 serialsim_no_observer_acc.c
字号:
serialsim_no_observer_DWork->Stationary_a_MODE[0] = (int_T)
SUBSYS_DISABLED;
}
}
}
}
}
/* run blocks if enabled */
if (serialsim_no_observer_DWork->Stationary_a_MODE[0] == SUBSYS_ENABLED) {
if (ssIsContinuousTask(S, tid)) {
/* Fcn: '<S37>/ira'
*
* Regarding '<S37>/ira':
* Expression: u[6]*u[1] - u[5]*u[2]
*/
serialsim_no_observer_B->ira_b = rtb_Switch_a[1] * rtb_iqr -
rtb_Switch_a[0] * rtb_idr;
/* Fcn: '<S37>/irb'
*
* Regarding '<S37>/irb':
* Expression: ((-u[6]-sqrt3*u[5])*u[1] + (u[5]-sqrt3*u[6])*u[2]) / 2
*/
serialsim_no_observer_B->irb_b = ( ( ( -rtb_Switch_a[1] ) -
1.7320508075688772E+000 * rtb_Switch_a[0] ) * rtb_iqr + (
rtb_Switch_a[0] -
1.7320508075688772E+000 * rtb_Switch_a[1] ) * rtb_idr ) / 2.0;
/* Fcn: '<S37>/isa'
*
* Regarding '<S37>/isa':
* Expression: u[3]
*/
serialsim_no_observer_B->isa_b = rtb_iqs;
/* Fcn: '<S37>/isb'
*
* Regarding '<S37>/isb':
* Expression: -(u[3] + sqrt3*u[4]) / 2
*/
serialsim_no_observer_B->isb_b = ( -( rtb_iqs +
1.7320508075688772E+000 * rtb_ids ) ) / 2.0;
} }
}
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [0.0, 1.0] */
/* Constant: '<S30>/Constant2' */
serialsim_no_observer_B->Constant2_a =
serialsim_no_observer_P->Constant2_a_Value;
}
/* SubSystem: '<S30>/Synchronous reference frame' */
/* Output and update for enable system: '<S30>/Synchronous reference frame' */
{
/* simstruct variables */
serialsim_no_observer_BlockIO *serialsim_no_observer_B =
(serialsim_no_observer_BlockIO *) _ssGetBlockIO(S);
serialsim_no_observer_D_Work *serialsim_no_observer_DWork =
(serialsim_no_observer_D_Work *) ssGetRootDWork(S);
/* detect enable/disable transitions */
if (ssIsSampleHit(S, 1, tid)) {
EnableStates prevEnableState = (EnableStates)
serialsim_no_observer_DWork->Synchronou_a_MODE[0];
EnableStates enableState;
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [0.0, 1.0] */
serialsim_no_observer_DWork->Synchronou_a_MODE[1] =
(serialsim_no_observer_B->Constant2_a) ? SUBSYS_ENABLED :
SUBSYS_DISABLED;
}
enableState = (EnableStates)
serialsim_no_observer_DWork->Synchronou_a_MODE[1];
if (enableState == SUBSYS_ENABLED) {
if (prevEnableState == SUBSYS_DISABLED) {
/* SUBSYS_BECOMING_ENABLED */
if ( ssGetT(S) != ssGetTStart(S) ) {
ssSetSolverNeedsReset(S);
}
/* (system initialize function is empty) */
/* (system enable function is empty) */
serialsim_no_observer_DWork->Synchronou_a_MODE[0] = (int_T)
SUBSYS_ENABLED;
}
} else {
if (prevEnableState == SUBSYS_ENABLED) {
/* SUBSYS_BECOMING_DISABLED */
ssSetSolverNeedsReset(S);
/* Disable for enable system: '<S30>/Synchronous reference frame' */
{
/* simstruct variables */
serialsim_no_observer_BlockIO *serialsim_no_observer_B =
(serialsim_no_observer_BlockIO *) _ssGetBlockIO(S);
serialsim_no_observer_D_Work *serialsim_no_observer_DWork =
(serialsim_no_observer_D_Work *) ssGetRootDWork(S);
serialsim_no_observer_Parameters *serialsim_no_observer_P =
(serialsim_no_observer_Parameters *) ssGetDefaultParam(S);
/* DisableFcn of enable SubSystem Block: <S30>/Synchronous reference frame */
if (serialsim_no_observer_DWork->Synchronou_a_MODE[0] == (int_T)
SUBSYS_ENABLED) {
/* (Virtual) Outport Block: <S38>/ira,irb */
serialsim_no_observer_B->ira_c =
serialsim_no_observer_P->ira_irb_c_Y0;
serialsim_no_observer_B->irb_c =
serialsim_no_observer_P->ira_irb_c_Y0;
/* (Virtual) Outport Block: <S38>/isa,isb */
serialsim_no_observer_B->isa_c =
serialsim_no_observer_P->isa_isb_c_Y0;
serialsim_no_observer_B->isb_c =
serialsim_no_observer_P->isa_isb_c_Y0;
serialsim_no_observer_DWork->Synchronou_a_MODE[0] = (int_T)
SUBSYS_DISABLED;
}
}
}
}
}
/* run blocks if enabled */
if (serialsim_no_observer_DWork->Synchronou_a_MODE[0] == SUBSYS_ENABLED) {
if (ssIsContinuousTask(S, tid)) {
/* Fcn: '<S38>/ira'
*
* Regarding '<S38>/ira':
* Expression: u[6]*u[1] + u[5]*u[2]
*/
serialsim_no_observer_B->ira_c = rtb_Switch_a[1] * rtb_iqr +
rtb_Switch_a[0] * rtb_idr;
/* Fcn: '<S38>/irb'
*
* Regarding '<S38>/irb':
* Expression: ((-u[6]+sqrt3*u[5])*u[1] + (-sqrt3*u[6]-u[5])*u[2]) / 2
*/
serialsim_no_observer_B->irb_c = ( ( ( -rtb_Switch_a[1] ) +
1.7320508075688772E+000 * rtb_Switch_a[0] ) * rtb_iqr + ( (
-1.7320508075688772E+000) *
rtb_Switch_a[1] - rtb_Switch_a[0] ) * rtb_idr ) / 2.0;
/* Fcn: '<S38>/isa'
*
* Regarding '<S38>/isa':
* Expression: u[8]*u[3] + u[7]*u[4]
*/
serialsim_no_observer_B->isa_c = rtb_Switch_a[3] * rtb_iqs +
rtb_Switch_a[2] * rtb_ids;
/* Fcn: '<S38>/isb'
*
* Regarding '<S38>/isb':
* Expression: ((-u[8]+sqrt3*u[7])*u[3] + (-sqrt3*u[8]-u[7])*u[4]) / 2
*/
serialsim_no_observer_B->isb_c = ( ( ( -rtb_Switch_a[3] ) +
1.7320508075688772E+000 * rtb_Switch_a[2] ) * rtb_iqs + ( (
-1.7320508075688772E+000) *
rtb_Switch_a[3] - rtb_Switch_a[2] ) * rtb_ids ) / 2.0;
} }
}
if (ssIsContinuousTask(S, tid)) { /* Sample time: [0.0, 0.0] */
/* MultiPortSwitch: '<S30>/Multiport Switch' */
switch ((int_T)serialsim_no_observer_B->Constant3_a) {
case 1:
rtb_Multiport_Switch_a[0] = serialsim_no_observer_B->ira_a;
rtb_Multiport_Switch_a[1] = serialsim_no_observer_B->irb_a;
break;
case 2:
rtb_Multiport_Switch_a[0] = serialsim_no_observer_B->ira_b;
rtb_Multiport_Switch_a[1] = serialsim_no_observer_B->irb_b;
break;
case 3:
rtb_Multiport_Switch_a[0] = serialsim_no_observer_B->ira_c;
rtb_Multiport_Switch_a[1] = serialsim_no_observer_B->irb_c;
break;
default:
/* Result undefined */
#if defined(MATLAB_MEX_FILE)
(void)mexPrintf("Error: Invalid control input for block:"
"<S30>/Multiport Switch\n"
"Result is undefined.");
#endif
break;
}
/* Sum: '<S30>/Sum2' */
rtb_Sum2_a = -rtb_Multiport_Switch_a[0];
rtb_Sum2_a -= rtb_Multiport_Switch_a[1];
}
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [0.0, 1.0] */
/* Constant: '<S29>/Constant3' */
serialsim_no_observer_B->Constant3_c =
serialsim_no_observer_P->Constant3_c_Value;
/* Constant: '<S35>/Constant6' */
serialsim_no_observer_B->Constant6_a[0] =
serialsim_no_observer_P->Constant6_a_Value[0];
serialsim_no_observer_B->Constant6_a[1] =
serialsim_no_observer_P->Constant6_a_Value[1];
/* Memory: '<S17>/Memory1' */
{
int_T i1;
real_T *y0 = &serialsim_no_observer_B->Memory1[0];
real_T *dw_PreviousInput =
&serialsim_no_observer_DWork->Memory1_PreviousInput[0];
for (i1=0; i1 < 6; i1++) {
y0[i1] = dw_PreviousInput[i1];
}
}
}
if (ssIsContinuousTask(S, tid)) { /* Sample time: [0.0, 0.0] */
/* Step: '<S7>/Step' */
if (ssIsMajorTimeStep(S)) {
if (ssGetTaskTime(S,tid) >= serialsim_no_observer_P->Step_Time) {
serialsim_no_observer_DWork->Step_MODE = 1;
} else {
serialsim_no_observer_DWork->Step_MODE = 0;
}
}
/* Output value */
rtb_Step = (serialsim_no_observer_DWork->Step_MODE == 1) ?
serialsim_no_observer_P->Step_YFinal : serialsim_no_observer_P->Step_Y0;
/* Step: '<S7>/Step1' */
if (ssIsMajorTimeStep(S)) {
if (ssGetTaskTime(S,tid) >= serialsim_no_observer_P->Step1_Time) {
serialsim_no_observer_DWork->Step1_MODE = 1;
} else {
serialsim_no_observer_DWork->Step1_MODE = 0;
}
}
/* Output value */
rtb_Step1 = (serialsim_no_observer_DWork->Step1_MODE == 1) ?
serialsim_no_observer_P->Step1_YFinal : serialsim_no_observer_P->Step1_Y0;
/* Step: '<S7>/Step2' */
if (ssIsMajorTimeStep(S)) {
if (ssGetTaskTime(S,tid) >= serialsim_no_observer_P->Step2_Time) {
serialsim_no_observer_DWork->Step2_MODE = 1;
} else {
serialsim_no_observer_DWork->Step2_MODE = 0;
}
}
/* Output value */
rtb_Step2 = (serialsim_no_observer_DWork->Step2_MODE == 1) ?
serialsim_no_observer_P->Step2_YFinal : serialsim_no_observer_P->Step2_Y0;
/* Step: '<S7>/Step3' */
if (ssIsMajorTimeStep(S)) {
if (ssGetTaskTime(S,tid) >= serialsim_no_observer_P->Step3_Time) {
serialsim_no_observer_DWork->Step3_MODE = 1;
} else {
serialsim_no_observer_DWork->Step3_MODE = 0;
}
}
/* Output value */
rtb_Step3 = (serialsim_no_observer_DWork->Step3_MODE == 1) ?
serialsim_no_observer_P->Step3_YFinal : serialsim_no_observer_P->Step3_Y0;
}
if (ssIsSampleHit(S, 2, tid)) { /* Sample time: [-2.0, 0.0] */
/* DiscretePulseGenerator: '<S5>/Pulse Generator' */
real_T time = ssGetTaskTime(S,tid);
real_T delay = 0.0;
if ( (int_T)serialsim_no_observer_DWork->Pulse_Generator_IWORK.justEnabled )
{
serialsim_no_observer_DWork->Pulse_Generator_IWORK.justEnabled = 0;
if (time >= delay) {
real_T ratio = (time - delay)/
serialsim_no_observer_P->Pulse_Generator_Period;
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles =
(int)floor(ratio);
if (
fabs((serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles+1)-
ratio ) < DBL_EPSILON * ratio )
{
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles =
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles+1;
}
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles =
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles;
if (time < delay +
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles *
serialsim_no_observer_P->Pulse_Generator_Period
+ serialsim_no_observer_P->Pulse_Generator_Duty *
serialsim_no_observer_P->Pulse_Generator_Period/100) {
serialsim_no_observer_DWork->Pulse_Generator_IWORK.currValue = 1;
serialsim_no_observer_DWork->Pulse_Generator_RWORK.nextTime = delay +
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles
* serialsim_no_observer_P->Pulse_Generator_Period
+ serialsim_no_observer_P->Pulse_Generator_Duty *
serialsim_no_observer_P->Pulse_Generator_Period/100;
} else {
serialsim_no_observer_DWork->Pulse_Generator_IWORK.currValue = 0;
serialsim_no_observer_DWork->Pulse_Generator_RWORK.nextTime = delay +
(serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles
+ 1) * serialsim_no_observer_P->Pulse_Generator_Period;
}
} else {
serialsim_no_observer_DWork->Pulse_Generator_IWORK.numCompleteCycles = 0;
serialsim_no_observer_DWork->Pulse_Generator_IWORK.currValue = 0;
serialsim_no_observer_DWork->Pulse_Generator_RWORK.nextTime = delay;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -