File: ALARM_Functional.c1 /* 2 * Code generation for system model 'ALARM_Functional' 3 * 4 * Model : ALARM_Functional 5 * Model version : 1.1326 6 * Simulink Coder version : 8.4 (R2013a) 13-Feb-2013 7 * C source code generated on : Thu Sep 12 09:49:37 2013 8 * 9 * Note that the functions contained in this file are part of a Simulink 10 * model, and are not self-contained algorithms. 11 */ 12 13 #include "ALARM_Functional.h" 14 #include "ALARM_Functional_private.h" 15 16 /* Named constants for Chart: '<Root>/Alarm Sub-System' */ 17 #define ALARM_Functional_IN_AlarmDisplay ((uint8_T)1U) 18 #define ALARM_Functional_IN_Alarms ((uint8_T)1U) 19 #define ALARM_Functional_IN_Check ((uint8_T)1U) 20 #define ALARM_Functional_IN_Disabled ((uint8_T)1U) 21 #define ALARM_Functional_IN_Monitor ((uint8_T)2U) 22 #define ALARM_Functional_IN_NOT_ON ((uint8_T)2U) 23 #define ALARM_Functional_IN_NO_ACTIVE_CHILD ((uint8_T)0U) 24 #define ALARM_Functional_IN_No ((uint8_T)1U) 25 #define ALARM_Functional_IN_OFF ((uint8_T)2U) 26 #define ALARM_Functional_IN_OFF_i ((uint8_T)1U) 27 #define ALARM_Functional_IN_ON ((uint8_T)3U) 28 #define ALARM_Functional_IN_ON_a ((uint8_T)2U) 29 #define ALARM_Functional_IN_Silenced ((uint8_T)4U) 30 #define ALARM_Functional_IN_Yes ((uint8_T)2U) 31 #define ALARM_Functional_IN_Yes_o ((uint8_T)3U) 32 #define ALARM_Functional_IN_counting ((uint8_T)3U) 33 34 /* Forward declaration for local functions */ 35 static void ALARM_Functional_writeLog(uint8_T logEvent, B_ALARM_Functional_c_T 36 *localB); 37 static uint8_T ALARM_Functional_checkOverInfusionFlowRate(B_ALARM_Functional_c_T 38 *localB); 39 static real_T ALARM_Functional_Step_Scaling_Factor(uint8_T inputVal); 40 static uint8_T ALARM_Functional_checkUnderInfusion(B_ALARM_Functional_c_T 41 *localB); 42 static void ALARM_Functional_Level1(B_ALARM_Functional_c_T *localB, 43 DW_ALARM_Functional_f_T *localDW); 44 static real_T ALARM_Functional_setCurrentAlarm(DW_ALARM_Functional_f_T *localDW); 45 static uint8_T ALARM_Functional_setHighestAlarm(DW_ALARM_Functional_f_T *localDW); 46 static void ALARM_Functional_CheckAlarm(B_ALARM_Functional_c_T *localB, 47 DW_ALARM_Functional_f_T *localDW); 48 static void ALARM_Functional_Alarms(B_ALARM_Functional_c_T *localB, 49 DW_ALARM_Functional_f_T *localDW); 50 static void ALARM_Functional_enter_internal_CheckAlarm(B_ALARM_Functional_c_T 51 *localB, DW_ALARM_Functional_f_T *localDW); 52 static void ALARM_Functional_enter_internal_Alarms(B_ALARM_Functional_c_T 53 *localB, DW_ALARM_Functional_f_T *localDW); 54 55 /* Function for Chart: '<Root>/Alarm Sub-System' */ 56 static void ALARM_Functional_writeLog(uint8_T logEvent, B_ALARM_Functional_c_T 57 *localB) 58 { 59 /* Graphical Function 'writeLog': '<S1>:1478' */ 60 /* Transition: '<S1>:1480' */ 61 localB->ALARM_OUT_Log_Message_ID = logEvent; 62 } 63 64 /* Function for Chart: '<Root>/Alarm Sub-System' */ 65 static uint8_T ALARM_Functional_checkOverInfusionFlowRate(B_ALARM_Functional_c_T 66 *localB) 67 { 68 uint8_T ov; 69 70 /* Graphical Function 'checkOverInfusionFlowRate': '<S1>:4055' */ 71 /* Transition: '<S1>:4061' */ 72 ov = 0U; 73 if (localB->In_Therapy) { 74 /* Transition: '<S1>:4062' */ 75 if (localB->Flow_Rate > localB->Flow_Rate_High) { 76 /* Transition: '<S1>:4063' */ 77 ov = 1U; 78 } else if (localB->Flow_Rate > localB->Commanded_Flow_Rate * div_s32 79 (localB->Tolerance_Max, 100) + localB->Commanded_Flow_Rate) { 80 /* Transition: '<S1>:4064' */ 81 ov = 1U; 82 } else { 83 if (localB->Flow_Rate > localB->Commanded_Flow_Rate * div_s32 84 (localB->Tolerance_Min, 100) + localB->Commanded_Flow_Rate) { 85 /* Transition: '<S1>:4065' */ 86 ov = 2U; 87 } 88 } 89 } 90 91 return ov; 92 } 93 94 /* Function for Chart: '<Root>/Alarm Sub-System' */ 95 static real_T ALARM_Functional_Step_Scaling_Factor(uint8_T inputVal) 96 { 97 /* Graphical Function 'Step_Scaling_Factor': '<S1>:4730' */ 98 /* Transition: '<S1>:4732' */ 99 return inputVal; 100 } 101 102 /* Function for Chart: '<Root>/Alarm Sub-System' */ 103 static uint8_T ALARM_Functional_checkUnderInfusion(B_ALARM_Functional_c_T 104 *localB) 105 { 106 uint8_T c; 107 108 /* Graphical Function 'checkUnderInfusion': '<S1>:4130' */ 109 /* Transition: '<S1>:4137' */ 110 c = 0U; 111 if (localB->In_Therapy) { 112 /* Transition: '<S1>:4139' */ 113 if (localB->Flow_Rate < localB->Flow_Rate_Low) { 114 /* Transition: '<S1>:4138' */ 115 c = 1U; 116 } else if (localB->Flow_Rate < localB->Commanded_Flow_Rate - 117 localB->Commanded_Flow_Rate * div_s32(localB->Tolerance_Max, 100)) 118 { 119 /* Transition: '<S1>:4140' */ 120 c = 1U; 121 } else { 122 if (localB->Flow_Rate < localB->Commanded_Flow_Rate - 123 localB->Commanded_Flow_Rate * div_s32(localB->Tolerance_Min, 100)) { 124 /* Transition: '<S1>:4142' */ 125 c = 2U; 126 } 127 } 128 } 129 130 return c; 131 } 132 133 /* Function for Chart: '<Root>/Alarm Sub-System' */ 134 static void ALARM_Functional_Level1(B_ALARM_Functional_c_T *localB, 135 DW_ALARM_Functional_f_T *localDW) 136 { 137 uint8_T underInfusion; 138 139 /* During 'Level1': '<S1>:4113' */ 140 /* During 'InfusionNotStartedWarning': '<S1>:4577' */ 141 if (localDW->is_InfusionNotStartedWarning == ALARM_Functional_IN_No) { 142 /* During 'No': '<S1>:4583' */ 143 if (localB->Infusion_Initiate && (!localB->Reservoir_Empty)) { 144 /* Transition: '<S1>:4580' */ 145 localDW->is_InfusionNotStartedWarning = ALARM_Functional_IN_Yes; 146 } 147 } else { 148 /* During 'Yes': '<S1>:4582' */ 149 if (localB->Infusion_Initiate && (!localB->Reservoir_Empty)) { 150 /* Transition: '<S1>:4707' */ 151 localDW->is_InfusionNotStartedWarning = ALARM_Functional_IN_Yes; 152 } else { 153 /* Transition: '<S1>:4581' */ 154 localDW->is_InfusionNotStartedWarning = ALARM_Functional_IN_No; 155 } 156 } 157 158 /* During 'IsUnderInfusion': '<S1>:4114' */ 159 underInfusion = ALARM_Functional_checkUnderInfusion(localB); 160 switch (localDW->is_IsUnderInfusion) { 161 case ALARM_Functional_IN_Check: 162 /* During 'Check': '<S1>:4127' */ 163 if (underInfusion == 1) { 164 /* Transition: '<S1>:4119' */ 165 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Yes_o; 166 167 /* Entry 'Yes': '<S1>:4126' */ 168 } else { 169 if (underInfusion == 2) { 170 /* Transition: '<S1>:4121' */ 171 localDW->underInfusionTimer = 0U; 172 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Monitor; 173 174 /* Entry 'Monitor': '<S1>:4128' */ 175 } 176 } 177 break; 178 179 case ALARM_Functional_IN_Monitor: 180 /* During 'Monitor': '<S1>:4128' */ 181 if ((underInfusion == 1) || ((real_T)localDW->underInfusionTimer > 182 ALARM_Functional_Step_Scaling_Factor 183 (localB->Max_Duration_Under_Infusion))) { 184 /* Transition: '<S1>:4122' */ 185 localDW->underInfusionTimer = 0U; 186 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Yes_o; 187 188 /* Entry 'Yes': '<S1>:4126' */ 189 } else if (underInfusion == 2) { 190 /* Transition: '<S1>:4124' */ 191 localDW->underInfusionTimer++; 192 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Monitor; 193 194 /* Entry 'Monitor': '<S1>:4128' */ 195 } else { 196 if (underInfusion == 0) { 197 /* Transition: '<S1>:4118' */ 198 localDW->underInfusionTimer = 0U; 199 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Check; 200 201 /* Entry 'Check': '<S1>:4127' */ 202 } 203 } 204 break; 205 206 default: 207 /* During 'Yes': '<S1>:4126' */ 208 if (localDW->cancelAlarm == 10) { 209 /* Transition: '<S1>:4502' */ 210 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Check; 211 212 /* Entry 'Check': '<S1>:4127' */ 213 } 214 break; 215 } 216 217 /* During 'IsFlowRateNotStable': '<S1>:4143' */ 218 if (localDW->is_IsFlowRateNotStable == ALARM_Functional_IN_No) { 219 /* During 'No': '<S1>:4148' */ 220 if (localB->In_Therapy && localB->Flow_Rate_Not_Stable) { 221 /* Transition: '<S1>:4145' */ 222 localDW->is_IsFlowRateNotStable = ALARM_Functional_IN_Yes; 223 } 224 } else { 225 /* During 'Yes': '<S1>:4147' */ 226 if ((localDW->cancelAlarm == 11) && (!localB->Flow_Rate_Not_Stable)) { 227 /* Transition: '<S1>:4146' */ 228 localDW->is_IsFlowRateNotStable = ALARM_Functional_IN_No; 229 } 230 } 231 232 /* During 'IsIdleTimeExceeded': '<S1>:4149' */ 233 switch (localDW->is_IsIdleTimeExceeded) { 234 case ALARM_Functional_IN_No: 235 /* During 'No': '<S1>:4153' */ 236 if ((localB->Current_System_Mode == 1) && 237 (ALARM_Functional_Step_Scaling_Factor(localB->Max_Idle_Duration) == 1.0)) 238 { 239 /* Transition: '<S1>:4750' */ 240 /* Exit 'No': '<S1>:4153' */ 241 localDW->idletimer = 0U; 242 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_Yes; 243 } else if (localB->Current_System_Mode == 1) { 244 /* Transition: '<S1>:4746' */ 245 /* Exit 'No': '<S1>:4153' */ 246 localDW->idletimer = 0U; 247 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_counting; 248 249 /* Entry 'counting': '<S1>:4745' */ 250 localDW->idletimer++; 251 } else { 252 localDW->idletimer = 0U; 253 } 254 break; 255 256 case ALARM_Functional_IN_Yes: 257 /* During 'Yes': '<S1>:4154' */ 258 if (localDW->cancelAlarm == 12) { 259 /* Transition: '<S1>:4152' */ 260 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_No; 261 262 /* Entry 'No': '<S1>:4153' */ 263 localDW->idletimer = 0U; 264 } 265 break; 266 267 default: 268 /* During 'counting': '<S1>:4745' */ 269 if ((real_T)localDW->idletimer >= ALARM_Functional_Step_Scaling_Factor 270 (localB->Max_Idle_Duration)) { 271 /* Transition: '<S1>:4747' */ 272 /* Exit 'counting': '<S1>:4745' */ 273 localDW->idletimer++; 274 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_Yes; 275 } else { 276 localDW->idletimer++; 277 } 278 break; 279 } 280 281 /* During 'IsPausedTimeExceeded': '<S1>:4155' */ 282 switch (localDW->is_IsPausedTimeExceeded) { 283 case ALARM_Functional_IN_No: 284 /* During 'No': '<S1>:4756' */ 285 if (((localB->Current_System_Mode == 6) || (localB->Current_System_Mode == 7) 286 || (localB->Current_System_Mode == 8)) && 287 (ALARM_Functional_Step_Scaling_Factor(localB->Max_Paused_Duration) == 288 1.0)) { 289 /* Transition: '<S1>:4761' */ 290 /* Exit 'No': '<S1>:4756' */ 291 localDW->pausedtimer = 0U; 292 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_Yes; 293 } else if ((localB->Current_System_Mode == 6) || 294 (localB->Current_System_Mode == 7) || 295 (localB->Current_System_Mode == 8)) { 296 /* Transition: '<S1>:4757' */ 297 /* Exit 'No': '<S1>:4756' */ 298 localDW->pausedtimer = 0U; 299 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_counting; 300 301 /* Entry 'counting': '<S1>:4752' */ 302 localDW->pausedtimer++; 303 } else { 304 localDW->pausedtimer = 0U; 305 } 306 break; 307 308 case ALARM_Functional_IN_Yes: 309 /* During 'Yes': '<S1>:4755' */ 310 if (localDW->cancelAlarm == 13) { 311 /* Transition: '<S1>:4754' */ 312 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_No; 313 314 /* Entry 'No': '<S1>:4756' */ 315 localDW->pausedtimer = 0U; 316 } 317 break; 318 319 default: 320 /* During 'counting': '<S1>:4752' */ 321 if ((real_T)localDW->pausedtimer >= ALARM_Functional_Step_Scaling_Factor 322 (localB->Max_Paused_Duration)) { 323 /* Transition: '<S1>:4758' */ 324 /* Exit 'counting': '<S1>:4752' */ 325 localDW->pausedtimer++; 326 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_Yes; 327 } else { 328 localDW->pausedtimer++; 329 } 330 break; 331 } 332 333 /* During 'IsConfigTimeWarning': '<S1>:4161' */ 334 if (localDW->is_IsConfigTimeWarning == ALARM_Functional_IN_No) { 335 /* During 'No': '<S1>:4166' */ 336 if ((real_T)localB->Config_Timer > ALARM_Functional_Step_Scaling_Factor 337 (localB->Config_Warning_Duration)) { 338 /* Transition: '<S1>:4163' */ 339 localDW->is_IsConfigTimeWarning = ALARM_Functional_IN_Yes; 340 } 341 } else { 342 /* During 'Yes': '<S1>:4165' */ 343 if ((localDW->cancelAlarm == 14) && (!((real_T)localB->Config_Timer > 344 ALARM_Functional_Step_Scaling_Factor(localB->Config_Warning_Duration)))) 345 { 346 /* Transition: '<S1>:4164' */ 347 localDW->is_IsConfigTimeWarning = ALARM_Functional_IN_No; 348 } 349 } 350 351 /* During 'IsBatteryError': '<S1>:4167' */ 352 if (localDW->is_IsBatteryError == ALARM_Functional_IN_No) { 353 /* During 'No': '<S1>:4172' */ 354 if (localB->Battery_Low || localB->Battery_Unable_To_Charge || 355 localB->Supply_Voltage) { 356 /* Transition: '<S1>:4169' */ 357 localDW->is_IsBatteryError = ALARM_Functional_IN_Yes; 358 } 359 } else { 360 /* During 'Yes': '<S1>:4171' */ 361 if ((localDW->cancelAlarm == 15) && (!(localB->Battery_Low || 362 localB->Battery_Unable_To_Charge || localB->Supply_Voltage))) { 363 /* Transition: '<S1>:4170' */ 364 localDW->is_IsBatteryError = ALARM_Functional_IN_No; 365 } 366 } 367 368 /* During 'IsPumpHot': '<S1>:4173' */ 369 if (localDW->is_IsPumpHot == ALARM_Functional_IN_No) { 370 /* During 'No': '<S1>:4178' */ 371 if (localB->Pump_Overheated) { 372 /* Transition: '<S1>:4175' */ 373 localDW->is_IsPumpHot = ALARM_Functional_IN_Yes; 374 } 375 } else { 376 /* During 'Yes': '<S1>:4177' */ 377 if ((localDW->cancelAlarm == 16) && (!localB->Pump_Overheated)) { 378 /* Transition: '<S1>:4176' */ 379 localDW->is_IsPumpHot = ALARM_Functional_IN_No; 380 } 381 } 382 383 /* During 'IsLoggingFailed': '<S1>:4179' */ 384 if (localDW->is_IsLoggingFailed == ALARM_Functional_IN_No) { 385 /* During 'No': '<S1>:4184' */ 386 if (localB->Logging_Failed) { 387 /* Transition: '<S1>:4181' */ 388 localDW->is_IsLoggingFailed = ALARM_Functional_IN_Yes; 389 } 390 } else { 391 /* During 'Yes': '<S1>:4183' */ 392 if ((localDW->cancelAlarm == 17) && (!localB->Logging_Failed)) { 393 /* Transition: '<S1>:4182' */ 394 localDW->is_IsLoggingFailed = ALARM_Functional_IN_No; 395 } 396 } 397 398 /* During 'IsSystemMonitorFailed': '<S1>:4185' */ 399 if (localDW->is_IsSystemMonitorFailed == ALARM_Functional_IN_No) { 400 /* During 'No': '<S1>:4190' */ 401 if (localB->System_Monitor_Failed) { 402 /* Transition: '<S1>:4187' */ 403 localDW->is_IsSystemMonitorFailed = ALARM_Functional_IN_Yes; 404 } 405 } else { 406 /* During 'Yes': '<S1>:4189' */ 407 if ((localDW->cancelAlarm == 18) && (!localB->System_Monitor_Failed)) { 408 /* Transition: '<S1>:4188' */ 409 localDW->is_IsSystemMonitorFailed = ALARM_Functional_IN_No; 410 } 411 } 412 } 413 414 /* Function for Chart: '<Root>/Alarm Sub-System' */ 415 static real_T ALARM_Functional_setCurrentAlarm(DW_ALARM_Functional_f_T *localDW) 416 { 417 real_T s; 418 419 /* Graphical Function 'setCurrentAlarm': '<S1>:3955' */ 420 /* Transition: '<S1>:3975' */ 421 s = 0.0; 422 localDW->Max_Alarm_Level = 0U; 423 if (localDW->is_InfusionNotStartedWarning == ALARM_Functional_IN_Yes) { 424 /* Transition: '<S1>:4593' */ 425 s = 19.0; 426 localDW->Max_Alarm_Level = 1U; 427 } else { 428 /* Transition: '<S1>:4591' */ 429 } 430 431 if (localDW->is_IsSystemMonitorFailed == ALARM_Functional_IN_Yes) { 432 /* Transition: '<S1>:3976' */ 433 s = 18.0; 434 localDW->Max_Alarm_Level = 1U; 435 } else { 436 /* Transition: '<S1>:3977' */ 437 } 438 439 if (localDW->is_IsLoggingFailed == ALARM_Functional_IN_Yes) { 440 /* Transition: '<S1>:3979' */ 441 s = 17.0; 442 localDW->Max_Alarm_Level = 1U; 443 } else { 444 /* Transition: '<S1>:3978' */ 445 } 446 447 if (localDW->is_IsPumpHot == ALARM_Functional_IN_Yes) { 448 /* Transition: '<S1>:3981' */ 449 s = 16.0; 450 localDW->Max_Alarm_Level = 1U; 451 } else { 452 /* Transition: '<S1>:3980' */ 453 } 454 455 if (localDW->is_IsBatteryError == ALARM_Functional_IN_Yes) { 456 /* Transition: '<S1>:3982' */ 457 s = 15.0; 458 localDW->Max_Alarm_Level = 1U; 459 } else { 460 /* Transition: '<S1>:3983' */ 461 } 462 463 if (localDW->is_IsConfigTimeWarning == ALARM_Functional_IN_Yes) { 464 /* Transition: '<S1>:3985' */ 465 s = 14.0; 466 localDW->Max_Alarm_Level = 1U; 467 } else { 468 /* Transition: '<S1>:3984' */ 469 } 470 471 if (localDW->is_IsPausedTimeExceeded == ALARM_Functional_IN_Yes) { 472 /* Transition: '<S1>:3986' */ 473 s = 13.0; 474 localDW->Max_Alarm_Level = 1U; 475 } else { 476 /* Transition: '<S1>:3987' */ 477 } 478 479 if (localDW->is_IsIdleTimeExceeded == ALARM_Functional_IN_Yes) { 480 /* Transition: '<S1>:3989' */ 481 s = 12.0; 482 localDW->Max_Alarm_Level = 1U; 483 } else { 484 /* Transition: '<S1>:3988' */ 485 } 486 487 if (localDW->is_IsFlowRateNotStable == ALARM_Functional_IN_Yes) { 488 /* Transition: '<S1>:3991' */ 489 s = 11.0; 490 localDW->Max_Alarm_Level = 1U; 491 } else { 492 /* Transition: '<S1>:3990' */ 493 } 494 495 if (localDW->is_IsUnderInfusion == ALARM_Functional_IN_Yes_o) { 496 /* Transition: '<S1>:3992' */ 497 s = 10.0; 498 localDW->Max_Alarm_Level = 1U; 499 } else { 500 /* Transition: '<S1>:3993' */ 501 } 502 503 if (localDW->is_IsLowReservoir == ALARM_Functional_IN_Yes) { 504 /* Transition: '<S1>:3994' */ 505 s = 9.0; 506 localDW->Max_Alarm_Level = 2U; 507 } else { 508 /* Transition: '<S1>:3995' */ 509 } 510 511 if (localDW->is_IsDoorOpen == ALARM_Functional_IN_Yes) { 512 /* Transition: '<S1>:3997' */ 513 s = 8.0; 514 localDW->Max_Alarm_Level = 3U; 515 } else { 516 /* Transition: '<S1>:3996' */ 517 } 518 519 if (localDW->is_IsOcclusion == ALARM_Functional_IN_Yes) { 520 /* Transition: '<S1>:3999' */ 521 s = 7.0; 522 localDW->Max_Alarm_Level = 3U; 523 } else { 524 /* Transition: '<S1>:3998' */ 525 } 526 527 if (localDW->is_IsAirInLine == ALARM_Functional_IN_Yes) { 528 /* Transition: '<S1>:4000' */ 529 s = 6.0; 530 localDW->Max_Alarm_Level = 3U; 531 } else { 532 /* Transition: '<S1>:4001' */ 533 } 534 535 if (localDW->is_IsOverInfusionVTBI == ALARM_Functional_IN_Yes) { 536 /* Transition: '<S1>:4003' */ 537 s = 5.0; 538 localDW->Max_Alarm_Level = 3U; 539 } else { 540 /* Transition: '<S1>:4002' */ 541 } 542 543 if (localDW->is_IsOverInfusionFlowRate == ALARM_Functional_IN_Yes_o) { 544 /* Transition: '<S1>:4005' */ 545 s = 4.0; 546 localDW->Max_Alarm_Level = 3U; 547 } else { 548 /* Transition: '<S1>:4004' */ 549 } 550 551 if (localDW->is_IsHardwareError == ALARM_Functional_IN_Yes) { 552 /* Transition: '<S1>:4007' */ 553 s = 3.0; 554 localDW->Max_Alarm_Level = 4U; 555 } else { 556 /* Transition: '<S1>:4006' */ 557 } 558 559 if (localDW->is_IsEnviromentalError == ALARM_Functional_IN_Yes) { 560 /* Transition: '<S1>:4009' */ 561 s = 2.0; 562 localDW->Max_Alarm_Level = 4U; 563 } else { 564 /* Transition: '<S1>:4008' */ 565 } 566 567 if (localDW->is_IsEmptyReservoir == ALARM_Functional_IN_Yes) { 568 /* Transition: '<S1>:4011' */ 569 s = 1.0; 570 localDW->Max_Alarm_Level = 4U; 571 } else { 572 /* Transition: '<S1>:4010' */ 573 } 574 575 return s; 576 } 577 578 /* Function for Chart: '<Root>/Alarm Sub-System' */ 579 static uint8_T ALARM_Functional_setHighestAlarm(DW_ALARM_Functional_f_T *localDW) 580 { 581 /* Graphical Function 'setHighestAlarm': '<S1>:4098' */ 582 /* Transition: '<S1>:4104' */ 583 return localDW->Max_Alarm_Level; 584 } 585 586 /* Function for Chart: '<Root>/Alarm Sub-System' */ 587 static void ALARM_Functional_CheckAlarm(B_ALARM_Functional_c_T *localB, 588 DW_ALARM_Functional_f_T *localDW) 589 { 590 uint8_T overInfusion; 591 592 /* During 'CheckAlarm': '<S1>:3953' */ 593 /* During 'CancelAlarm': '<S1>:4012' */ 594 if (localDW->is_CancelAlarm == ALARM_Functional_IN_OFF_i) { 595 /* During 'OFF': '<S1>:4017' */ 596 if ((localDW->currentAlarm > 0) && localB->Notification_Cancel) { 597 /* Transition: '<S1>:4014' */ 598 localDW->is_CancelAlarm = ALARM_Functional_IN_ON_a; 599 600 /* Entry 'ON': '<S1>:4016' */ 601 localDW->cancelAlarm = localDW->currentAlarm; 602 ALARM_Functional_writeLog(3U, localB); 603 } 604 } else { 605 /* During 'ON': '<S1>:4016' */ 606 /* Transition: '<S1>:4015' */ 607 localDW->is_CancelAlarm = ALARM_Functional_IN_OFF_i; 608 } 609 610 /* During 'Level4': '<S1>:4019' */ 611 /* During 'IsEmptyReservoir': '<S1>:4020' */ 612 if (localDW->is_IsEmptyReservoir == ALARM_Functional_IN_No) { 613 /* During 'No': '<S1>:4024' */ 614 if (localB->In_Therapy && localB->Reservoir_Empty) { 615 /* Transition: '<S1>:4022' */ 616 localDW->is_IsEmptyReservoir = ALARM_Functional_IN_Yes; 617 } 618 } else { 619 /* During 'Yes': '<S1>:4025' */ 620 if (localB->In_Therapy && localB->Reservoir_Empty) { 621 /* Transition: '<S1>:4615' */ 622 localDW->is_IsEmptyReservoir = ALARM_Functional_IN_Yes; 623 } else { 624 if ((localDW->cancelAlarm == 1) && (!localB->Reservoir_Empty)) { 625 /* Transition: '<S1>:4023' */ 626 localDW->is_IsEmptyReservoir = ALARM_Functional_IN_No; 627 } 628 } 629 } 630 631 /* During 'IsHardwareError': '<S1>:4217' */ 632 if (localDW->is_IsHardwareError == ALARM_Functional_IN_No) { 633 /* During 'No': '<S1>:4222' */ 634 if (localB->Battery_Depleted || localB->RTC_In_Error || localB->CPU_In_Error 635 || localB->Memory_Corrupted || localB->Pump_Too_Hot || 636 localB->Watchdog_Interrupted) { 637 /* Transition: '<S1>:4223' */ 638 localDW->is_IsHardwareError = ALARM_Functional_IN_Yes; 639 } 640 } else { 641 /* During 'Yes': '<S1>:4220' */ 642 if ((localDW->cancelAlarm == 2) && (!(localB->Battery_Depleted || 643 localB->RTC_In_Error || localB->CPU_In_Error || 644 localB->Memory_Corrupted || localB->Pump_Too_Hot || 645 localB->Watchdog_Interrupted))) { 646 /* Transition: '<S1>:4221' */ 647 localDW->is_IsHardwareError = ALARM_Functional_IN_No; 648 } 649 } 650 651 /* During 'IsEnviromentalError': '<S1>:4032' */ 652 if (localDW->is_IsEnviromentalError == ALARM_Functional_IN_No) { 653 /* During 'No': '<S1>:4037' */ 654 if (localB->Temp || localB->Humidity || localB->Air_Pressure) { 655 /* Transition: '<S1>:4034' */ 656 localDW->is_IsEnviromentalError = ALARM_Functional_IN_Yes; 657 } 658 } else { 659 /* During 'Yes': '<S1>:4036' */ 660 if ((localDW->cancelAlarm == 3) && (!(localB->Temp || localB->Humidity || 661 localB->Air_Pressure))) { 662 /* Transition: '<S1>:4035' */ 663 localDW->is_IsEnviromentalError = ALARM_Functional_IN_No; 664 } 665 } 666 667 /* During 'Level3': '<S1>:4038' */ 668 /* During 'IsOverInfusionFlowRate': '<S1>:4039' */ 669 overInfusion = ALARM_Functional_checkOverInfusionFlowRate(localB); 670 switch (localDW->is_IsOverInfusionFlowRate) { 671 case ALARM_Functional_IN_Check: 672 /* During 'Check': '<S1>:4052' */ 673 if (overInfusion == 1) { 674 /* Transition: '<S1>:4044' */ 675 /* Exit 'Check': '<S1>:4052' */ 676 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Yes_o; 677 678 /* Entry 'Yes': '<S1>:4051' */ 679 } else { 680 if (overInfusion == 2) { 681 /* Transition: '<S1>:4046' */ 682 localDW->overInfusionTimer = 0U; 683 684 /* Exit 'Check': '<S1>:4052' */ 685 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Monitor; 686 687 /* Entry 'Monitor': '<S1>:4053' */ 688 } 689 } 690 break; 691 692 case ALARM_Functional_IN_Monitor: 693 /* During 'Monitor': '<S1>:4053' */ 694 if ((overInfusion == 1) || ((real_T)localDW->overInfusionTimer > 695 ALARM_Functional_Step_Scaling_Factor(localB->Max_Duration_Over_Infusion))) 696 { 697 /* Transition: '<S1>:4047' */ 698 localDW->overInfusionTimer = 0U; 699 700 /* Exit 'Monitor': '<S1>:4053' */ 701 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Yes_o; 702 703 /* Entry 'Yes': '<S1>:4051' */ 704 } else if (overInfusion == 0) { 705 /* Transition: '<S1>:4042' */ 706 localDW->overInfusionTimer = 0U; 707 708 /* Exit 'Monitor': '<S1>:4053' */ 709 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Check; 710 711 /* Entry 'Check': '<S1>:4052' */ 712 } else { 713 if (overInfusion == 2) { 714 /* Transition: '<S1>:4049' */ 715 localDW->overInfusionTimer++; 716 717 /* Exit 'Monitor': '<S1>:4053' */ 718 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Monitor; 719 720 /* Entry 'Monitor': '<S1>:4053' */ 721 } 722 } 723 break; 724 725 default: 726 /* During 'Yes': '<S1>:4051' */ 727 if (overInfusion == 1) { 728 /* Transition: '<S1>:4701' */ 729 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Yes_o; 730 731 /* Entry 'Yes': '<S1>:4051' */ 732 } else { 733 if (localDW->cancelAlarm == 4) { 734 /* Transition: '<S1>:4501' */ 735 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Check; 736 737 /* Entry 'Check': '<S1>:4052' */ 738 } 739 } 740 break; 741 } 742 743 /* During 'IsOverInfusionVTBI': '<S1>:4066' */ 744 if (localDW->is_IsOverInfusionVTBI == ALARM_Functional_IN_No) { 745 /* During 'No': '<S1>:4071' */ 746 if (localB->In_Therapy && (localB->Volume_Infused > localB->VTBI_High)) { 747 /* Transition: '<S1>:4068' */ 748 localDW->is_IsOverInfusionVTBI = ALARM_Functional_IN_Yes; 749 } 750 } else { 751 /* During 'Yes': '<S1>:4070' */ 752 if (localB->In_Therapy && (localB->Volume_Infused > localB->VTBI_High)) { 753 /* Transition: '<S1>:4702' */ 754 localDW->is_IsOverInfusionVTBI = ALARM_Functional_IN_Yes; 755 } else { 756 if (localDW->cancelAlarm == 5) { 757 /* Transition: '<S1>:4069' */ 758 localDW->is_IsOverInfusionVTBI = ALARM_Functional_IN_No; 759 } 760 } 761 } 762 763 /* During 'IsAirInLine': '<S1>:4072' */ 764 if (localDW->is_IsAirInLine == ALARM_Functional_IN_No) { 765 /* During 'No': '<S1>:4077' */ 766 if (localB->Air_In_Line) { 767 /* Transition: '<S1>:4074' */ 768 localDW->is_IsAirInLine = ALARM_Functional_IN_Yes; 769 } 770 } else { 771 /* During 'Yes': '<S1>:4076' */ 772 if ((localDW->cancelAlarm == 6) && (!localB->Air_In_Line)) { 773 /* Transition: '<S1>:4075' */ 774 localDW->is_IsAirInLine = ALARM_Functional_IN_No; 775 } 776 } 777 778 /* During 'IsOcclusion': '<S1>:4078' */ 779 if (localDW->is_IsOcclusion == ALARM_Functional_IN_No) { 780 /* During 'No': '<S1>:4083' */ 781 if (localB->Occlusion) { 782 /* Transition: '<S1>:4080' */ 783 localDW->is_IsOcclusion = ALARM_Functional_IN_Yes; 784 } 785 } else { 786 /* During 'Yes': '<S1>:4082' */ 787 if ((localDW->cancelAlarm == 7) && (!localB->Occlusion)) { 788 /* Transition: '<S1>:4081' */ 789 localDW->is_IsOcclusion = ALARM_Functional_IN_No; 790 } 791 } 792 793 /* During 'IsDoorOpen': '<S1>:4084' */ 794 if (localDW->is_IsDoorOpen == ALARM_Functional_IN_No) { 795 /* During 'No': '<S1>:4088' */ 796 if (localB->Door_Open) { 797 /* Transition: '<S1>:4086' */ 798 localDW->is_IsDoorOpen = ALARM_Functional_IN_Yes; 799 } 800 } else { 801 /* During 'Yes': '<S1>:4089' */ 802 if ((localDW->cancelAlarm == 8) && (!localB->Door_Open)) { 803 /* Transition: '<S1>:4087' */ 804 localDW->is_IsDoorOpen = ALARM_Functional_IN_No; 805 } 806 } 807 808 /* During 'Level2': '<S1>:4090' */ 809 /* During 'IsLowReservoir': '<S1>:4091' */ 810 if (localDW->is_IsLowReservoir == ALARM_Functional_IN_No) { 811 /* During 'No': '<S1>:4095' */ 812 if (localB->In_Therapy && (localB->Reservoir_Volume < localB->Low_Reservoir)) 813 { 814 /* Transition: '<S1>:4093' */ 815 localDW->is_IsLowReservoir = ALARM_Functional_IN_Yes; 816 } 817 } else { 818 /* During 'Yes': '<S1>:4096' */ 819 if ((localDW->cancelAlarm == 9) && (!(localB->Reservoir_Volume < 820 localB->Low_Reservoir))) { 821 /* Transition: '<S1>:4094' */ 822 localDW->is_IsLowReservoir = ALARM_Functional_IN_No; 823 } 824 } 825 826 ALARM_Functional_Level1(localB, localDW); 827 828 /* During 'SetAlarmStatus': '<S1>:4018' */ 829 localDW->currentAlarm = (uint8_T)ALARM_Functional_setCurrentAlarm(localDW); 830 localB->ALARM_OUT_Highest_Level_Alarm = ALARM_Functional_setHighestAlarm 831 (localDW); 832 } 833 834 /* Function for Chart: '<Root>/Alarm Sub-System' */ 835 static void ALARM_Functional_Alarms(B_ALARM_Functional_c_T *localB, 836 DW_ALARM_Functional_f_T *localDW) 837 { 838 /* During 'Alarms': '<S1>:3907' */ 839 if (!localB->System_On) { 840 /* Transition: '<S1>:3901' */ 841 /* Exit Internal 'Alarms': '<S1>:3907' */ 842 /* Exit Internal 'Notification': '<S1>:3908' */ 843 /* Exit Internal 'Audio': '<S1>:3919' */ 844 switch (localDW->is_Audio) { 845 case ALARM_Functional_IN_Disabled: 846 /* Exit 'Disabled': '<S1>:3939' */ 847 localB->ALARM_OUT_Audio_Notification_Command = 0U; 848 localDW->is_Audio = ALARM_Functional_IN_NO_ACTIVE_CHILD; 849 break; 850 851 case ALARM_Functional_IN_OFF: 852 /* Exit 'OFF': '<S1>:3937' */ 853 localB->ALARM_OUT_Audio_Notification_Command = 0U; 854 localDW->is_Audio = ALARM_Functional_IN_NO_ACTIVE_CHILD; 855 break; 856 857 case ALARM_Functional_IN_ON: 858 /* Exit 'ON': '<S1>:3938' */ 859 localB->ALARM_OUT_Audio_Notification_Command = localB->Audio_Level; 860 localDW->is_Audio = ALARM_Functional_IN_NO_ACTIVE_CHILD; 861 break; 862 863 case ALARM_Functional_IN_Silenced: 864 /* Exit 'Silenced': '<S1>:3952' */ 865 localB->ALARM_OUT_Audio_Notification_Command = 0U; 866 localDW->is_Audio = ALARM_Functional_IN_NO_ACTIVE_CHILD; 867 break; 868 869 default: 870 localDW->is_Audio = ALARM_Functional_IN_NO_ACTIVE_CHILD; 871 break; 872 } 873 874 /* Exit 'Audio': '<S1>:3919' */ 875 localB->ALARM_OUT_Display_Audio_Disabled_Indicator = localB->Disable_Audio; 876 localDW->is_active_Audio = 0U; 877 878 /* Exit Internal 'Visual': '<S1>:3909' */ 879 if (localDW->is_Visual == ALARM_Functional_IN_AlarmDisplay) { 880 /* Exit 'AlarmDisplay': '<S1>:3913' */ 881 localB->ALARM_OUT_Display_Notification_Command = localDW->currentAlarm; 882 localDW->is_Visual = ALARM_Functional_IN_NO_ACTIVE_CHILD; 883 } else { 884 localDW->is_Visual = ALARM_Functional_IN_NO_ACTIVE_CHILD; 885 } 886 887 localDW->is_active_Visual = 0U; 888 localDW->is_active_Notification = 0U; 889 890 /* Exit Internal 'CheckAlarm': '<S1>:3953' */ 891 /* Exit 'SetAlarmStatus': '<S1>:4018' */ 892 localDW->currentAlarm = (uint8_T)ALARM_Functional_setCurrentAlarm(localDW); 893 localB->ALARM_OUT_Highest_Level_Alarm = ALARM_Functional_setHighestAlarm 894 (localDW); 895 localDW->cancelAlarm = 0U; 896 localDW->is_active_SetAlarmStatus = 0U; 897 898 /* Exit Internal 'Level1': '<S1>:4113' */ 899 /* Exit Internal 'IsSystemMonitorFailed': '<S1>:4185' */ 900 localDW->is_IsSystemMonitorFailed = ALARM_Functional_IN_NO_ACTIVE_CHILD; 901 localDW->is_active_IsSystemMonitorFailed = 0U; 902 903 /* Exit Internal 'IsLoggingFailed': '<S1>:4179' */ 904 localDW->is_IsLoggingFailed = ALARM_Functional_IN_NO_ACTIVE_CHILD; 905 localDW->is_active_IsLoggingFailed = 0U; 906 907 /* Exit Internal 'IsPumpHot': '<S1>:4173' */ 908 localDW->is_IsPumpHot = ALARM_Functional_IN_NO_ACTIVE_CHILD; 909 localDW->is_active_IsPumpHot = 0U; 910 911 /* Exit Internal 'IsBatteryError': '<S1>:4167' */ 912 localDW->is_IsBatteryError = ALARM_Functional_IN_NO_ACTIVE_CHILD; 913 localDW->is_active_IsBatteryError = 0U; 914 915 /* Exit Internal 'IsConfigTimeWarning': '<S1>:4161' */ 916 localDW->is_IsConfigTimeWarning = ALARM_Functional_IN_NO_ACTIVE_CHILD; 917 localDW->is_active_IsConfigTimeWarning = 0U; 918 919 /* Exit Internal 'IsPausedTimeExceeded': '<S1>:4155' */ 920 switch (localDW->is_IsPausedTimeExceeded) { 921 case ALARM_Functional_IN_No: 922 /* Exit 'No': '<S1>:4756' */ 923 localDW->pausedtimer = 0U; 924 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 925 break; 926 927 case ALARM_Functional_IN_counting: 928 /* Exit 'counting': '<S1>:4752' */ 929 localDW->pausedtimer++; 930 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 931 break; 932 933 default: 934 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 935 break; 936 } 937 938 localDW->is_active_IsPausedTimeExceeded = 0U; 939 940 /* Exit Internal 'IsIdleTimeExceeded': '<S1>:4149' */ 941 switch (localDW->is_IsIdleTimeExceeded) { 942 case ALARM_Functional_IN_No: 943 /* Exit 'No': '<S1>:4153' */ 944 localDW->idletimer = 0U; 945 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 946 break; 947 948 case ALARM_Functional_IN_counting: 949 /* Exit 'counting': '<S1>:4745' */ 950 localDW->idletimer++; 951 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 952 break; 953 954 default: 955 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 956 break; 957 } 958 959 localDW->is_active_IsIdleTimeExceeded = 0U; 960 961 /* Exit Internal 'IsFlowRateNotStable': '<S1>:4143' */ 962 localDW->is_IsFlowRateNotStable = ALARM_Functional_IN_NO_ACTIVE_CHILD; 963 localDW->is_active_IsFlowRateNotStable = 0U; 964 965 /* Exit Internal 'IsUnderInfusion': '<S1>:4114' */ 966 localDW->is_IsUnderInfusion = ALARM_Functional_IN_NO_ACTIVE_CHILD; 967 968 /* Exit 'IsUnderInfusion': '<S1>:4114' */ 969 localDW->is_active_IsUnderInfusion = 0U; 970 971 /* Exit Internal 'InfusionNotStartedWarning': '<S1>:4577' */ 972 localDW->is_InfusionNotStartedWarning = ALARM_Functional_IN_NO_ACTIVE_CHILD; 973 localDW->is_active_InfusionNotStartedWarning = 0U; 974 localDW->is_active_Level1 = 0U; 975 976 /* Exit Internal 'Level2': '<S1>:4090' */ 977 /* Exit Internal 'IsLowReservoir': '<S1>:4091' */ 978 localDW->is_IsLowReservoir = ALARM_Functional_IN_NO_ACTIVE_CHILD; 979 localDW->is_active_IsLowReservoir = 0U; 980 localDW->is_active_Level2 = 0U; 981 982 /* Exit Internal 'Level3': '<S1>:4038' */ 983 /* Exit Internal 'IsDoorOpen': '<S1>:4084' */ 984 localDW->is_IsDoorOpen = ALARM_Functional_IN_NO_ACTIVE_CHILD; 985 localDW->is_active_IsDoorOpen = 0U; 986 987 /* Exit Internal 'IsOcclusion': '<S1>:4078' */ 988 localDW->is_IsOcclusion = ALARM_Functional_IN_NO_ACTIVE_CHILD; 989 localDW->is_active_IsOcclusion = 0U; 990 991 /* Exit Internal 'IsAirInLine': '<S1>:4072' */ 992 localDW->is_IsAirInLine = ALARM_Functional_IN_NO_ACTIVE_CHILD; 993 localDW->is_active_IsAirInLine = 0U; 994 995 /* Exit Internal 'IsOverInfusionVTBI': '<S1>:4066' */ 996 localDW->is_IsOverInfusionVTBI = ALARM_Functional_IN_NO_ACTIVE_CHILD; 997 localDW->is_active_IsOverInfusionVTBI = 0U; 998 999 /* Exit Internal 'IsOverInfusionFlowRate': '<S1>:4039' */ 1000 switch (localDW->is_IsOverInfusionFlowRate) { 1001 case ALARM_Functional_IN_Check: 1002 /* Exit 'Check': '<S1>:4052' */ 1003 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1004 break; 1005 1006 case ALARM_Functional_IN_Monitor: 1007 /* Exit 'Monitor': '<S1>:4053' */ 1008 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1009 break; 1010 1011 default: 1012 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1013 break; 1014 } 1015 1016 /* Exit 'IsOverInfusionFlowRate': '<S1>:4039' */ 1017 localDW->is_active_IsOverInfusionFlowRate = 0U; 1018 localDW->is_active_Level3 = 0U; 1019 1020 /* Exit Internal 'Level4': '<S1>:4019' */ 1021 /* Exit Internal 'IsEnviromentalError': '<S1>:4032' */ 1022 localDW->is_IsEnviromentalError = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1023 localDW->is_active_IsEnviromentalError = 0U; 1024 1025 /* Exit Internal 'IsHardwareError': '<S1>:4217' */ 1026 localDW->is_IsHardwareError = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1027 localDW->is_active_IsHardwareError = 0U; 1028 1029 /* Exit Internal 'IsEmptyReservoir': '<S1>:4020' */ 1030 localDW->is_IsEmptyReservoir = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1031 localDW->is_active_IsEmptyReservoir = 0U; 1032 localDW->is_active_Level4 = 0U; 1033 1034 /* Exit Internal 'CancelAlarm': '<S1>:4012' */ 1035 localDW->is_CancelAlarm = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1036 localDW->is_active_CancelAlarm = 0U; 1037 localDW->is_active_CheckAlarm = 0U; 1038 localDW->is_c2_ALARM_Functional = ALARM_Functional_IN_NOT_ON; 1039 } else { 1040 ALARM_Functional_CheckAlarm(localB, localDW); 1041 1042 /* During 'Notification': '<S1>:3908' */ 1043 /* During 'Visual': '<S1>:3909' */ 1044 if (localDW->is_Visual == ALARM_Functional_IN_AlarmDisplay) { 1045 /* During 'AlarmDisplay': '<S1>:3913' */ 1046 if (localDW->currentAlarm == 0) { 1047 /* Transition: '<S1>:3912' */ 1048 /* Exit 'AlarmDisplay': '<S1>:3913' */ 1049 localDW->is_Visual = ALARM_Functional_IN_OFF; 1050 1051 /* Entry 'OFF': '<S1>:3914' */ 1052 localB->ALARM_OUT_Display_Notification_Command = 0U; 1053 } else if (localDW->currentAlarm > 0) { 1054 /* Transition: '<S1>:4614' */ 1055 /* Exit 'AlarmDisplay': '<S1>:3913' */ 1056 localDW->is_Visual = ALARM_Functional_IN_AlarmDisplay; 1057 1058 /* Entry 'AlarmDisplay': '<S1>:3913' */ 1059 localB->ALARM_OUT_Display_Notification_Command = localDW->currentAlarm; 1060 } else { 1061 localB->ALARM_OUT_Display_Notification_Command = localDW->currentAlarm; 1062 } 1063 } else { 1064 /* During 'OFF': '<S1>:3914' */ 1065 if (localDW->currentAlarm > 0) { 1066 /* Transition: '<S1>:3911' */ 1067 localDW->is_Visual = ALARM_Functional_IN_AlarmDisplay; 1068 1069 /* Entry 'AlarmDisplay': '<S1>:3913' */ 1070 localB->ALARM_OUT_Display_Notification_Command = localDW->currentAlarm; 1071 } 1072 } 1073 1074 /* During 'Audio': '<S1>:3919' */ 1075 localB->ALARM_OUT_Display_Audio_Disabled_Indicator = localB->Disable_Audio; 1076 switch (localDW->is_Audio) { 1077 case ALARM_Functional_IN_Disabled: 1078 /* During 'Disabled': '<S1>:3939' */ 1079 if (localB->Disable_Audio == 2) { 1080 /* Transition: '<S1>:4610' */ 1081 /* Exit 'Disabled': '<S1>:3939' */ 1082 localDW->is_Audio = ALARM_Functional_IN_Silenced; 1083 1084 /* Entry 'Silenced': '<S1>:3952' */ 1085 localDW->audioTimer = 0U; 1086 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1087 localDW->audioTimer++; 1088 } else { 1089 /* Transition: '<S1>:4604' */ 1090 if ((localB->ALARM_OUT_Highest_Level_Alarm > 2) && 1091 (localB->Disable_Audio == 0)) { 1092 /* Transition: '<S1>:4736' */ 1093 /* Exit 'Disabled': '<S1>:3939' */ 1094 localDW->is_Audio = ALARM_Functional_IN_ON; 1095 1096 /* Entry 'ON': '<S1>:3938' */ 1097 localB->ALARM_OUT_Audio_Notification_Command = localB->Audio_Level; 1098 } else if (localB->Disable_Audio == 0) { 1099 /* Transition: '<S1>:3934' */ 1100 /* Transition: '<S1>:3928' */ 1101 /* Exit 'Disabled': '<S1>:3939' */ 1102 localDW->is_Audio = ALARM_Functional_IN_OFF; 1103 1104 /* Entry 'OFF': '<S1>:3937' */ 1105 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1106 } else { 1107 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1108 } 1109 } 1110 break; 1111 1112 case ALARM_Functional_IN_OFF: 1113 /* During 'OFF': '<S1>:3937' */ 1114 if (localB->Disable_Audio == 1) { 1115 /* Transition: '<S1>:4743' */ 1116 /* Exit 'OFF': '<S1>:3937' */ 1117 localDW->is_Audio = ALARM_Functional_IN_Disabled; 1118 1119 /* Entry 'Disabled': '<S1>:3939' */ 1120 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1121 } else { 1122 /* Transition: '<S1>:4738' */ 1123 if (localB->Disable_Audio == 2) { 1124 /* Transition: '<S1>:4739' */ 1125 /* Exit 'OFF': '<S1>:3937' */ 1126 localDW->is_Audio = ALARM_Functional_IN_Silenced; 1127 1128 /* Entry 'Silenced': '<S1>:3952' */ 1129 localDW->audioTimer = 0U; 1130 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1131 localDW->audioTimer++; 1132 } else if ((localB->ALARM_OUT_Highest_Level_Alarm > 2) && 1133 (localB->Disable_Audio == 0)) { 1134 /* Transition: '<S1>:3925' */ 1135 /* Exit 'OFF': '<S1>:3937' */ 1136 localDW->is_Audio = ALARM_Functional_IN_ON; 1137 1138 /* Entry 'ON': '<S1>:3938' */ 1139 localB->ALARM_OUT_Audio_Notification_Command = localB->Audio_Level; 1140 } else { 1141 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1142 } 1143 } 1144 break; 1145 1146 case ALARM_Functional_IN_ON: 1147 /* During 'ON': '<S1>:3938' */ 1148 if (localB->Disable_Audio == 1) { 1149 /* Transition: '<S1>:3931' */ 1150 /* Exit 'ON': '<S1>:3938' */ 1151 localDW->is_Audio = ALARM_Functional_IN_Disabled; 1152 1153 /* Entry 'Disabled': '<S1>:3939' */ 1154 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1155 } else { 1156 /* Transition: '<S1>:3927' */ 1157 if (localB->Disable_Audio == 2) { 1158 /* Transition: '<S1>:4739' */ 1159 /* Exit 'ON': '<S1>:3938' */ 1160 localDW->is_Audio = ALARM_Functional_IN_Silenced; 1161 1162 /* Entry 'Silenced': '<S1>:3952' */ 1163 localDW->audioTimer = 0U; 1164 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1165 localDW->audioTimer++; 1166 } else if ((localB->ALARM_OUT_Highest_Level_Alarm > 2) && 1167 (localB->Disable_Audio == 0)) { 1168 /* Transition: '<S1>:4609' */ 1169 /* Exit 'ON': '<S1>:3938' */ 1170 localDW->is_Audio = ALARM_Functional_IN_ON; 1171 1172 /* Entry 'ON': '<S1>:3938' */ 1173 localB->ALARM_OUT_Audio_Notification_Command = localB->Audio_Level; 1174 } else { 1175 /* Transition: '<S1>:3926' */ 1176 /* Exit 'ON': '<S1>:3938' */ 1177 localDW->is_Audio = ALARM_Functional_IN_OFF; 1178 1179 /* Entry 'OFF': '<S1>:3937' */ 1180 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1181 } 1182 } 1183 break; 1184 1185 default: 1186 /* During 'Silenced': '<S1>:3952' */ 1187 if (localB->Disable_Audio == 1) { 1188 /* Transition: '<S1>:4611' */ 1189 /* Exit 'Silenced': '<S1>:3952' */ 1190 localDW->is_Audio = ALARM_Functional_IN_Disabled; 1191 1192 /* Entry 'Disabled': '<S1>:3939' */ 1193 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1194 } else { 1195 /* Transition: '<S1>:4605' */ 1196 if ((localB->ALARM_OUT_Highest_Level_Alarm > 2) && 1197 (localB->Disable_Audio == 0)) { 1198 /* Transition: '<S1>:4736' */ 1199 /* Exit 'Silenced': '<S1>:3952' */ 1200 localDW->is_Audio = ALARM_Functional_IN_ON; 1201 1202 /* Entry 'ON': '<S1>:3938' */ 1203 localB->ALARM_OUT_Audio_Notification_Command = localB->Audio_Level; 1204 } else { 1205 if (((real_T)localDW->audioTimer > 1206 ALARM_Functional_Step_Scaling_Factor 1207 (localB->Audio_Enable_Duration)) || (localB->Disable_Audio == 0)) 1208 { 1209 /* Transition: '<S1>:3936' */ 1210 /* Transition: '<S1>:3928' */ 1211 /* Exit 'Silenced': '<S1>:3952' */ 1212 localDW->is_Audio = ALARM_Functional_IN_OFF; 1213 1214 /* Entry 'OFF': '<S1>:3937' */ 1215 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1216 } else { 1217 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1218 localDW->audioTimer++; 1219 } 1220 } 1221 } 1222 break; 1223 } 1224 } 1225 } 1226 1227 /* Function for Chart: '<Root>/Alarm Sub-System' */ 1228 static void ALARM_Functional_enter_internal_CheckAlarm(B_ALARM_Functional_c_T 1229 *localB, DW_ALARM_Functional_f_T *localDW) 1230 { 1231 uint8_T overInfusion; 1232 1233 /* Entry Internal 'CheckAlarm': '<S1>:3953' */ 1234 localDW->is_active_CancelAlarm = 1U; 1235 1236 /* Entry Internal 'CancelAlarm': '<S1>:4012' */ 1237 /* Transition: '<S1>:4013' */ 1238 localDW->is_CancelAlarm = ALARM_Functional_IN_OFF_i; 1239 localDW->is_active_Level4 = 1U; 1240 1241 /* Entry Internal 'Level4': '<S1>:4019' */ 1242 localDW->is_active_IsEmptyReservoir = 1U; 1243 1244 /* Entry Internal 'IsEmptyReservoir': '<S1>:4020' */ 1245 if (localB->In_Therapy && localB->Reservoir_Empty) { 1246 /* Transition: '<S1>:4193' */ 1247 localDW->is_IsEmptyReservoir = ALARM_Functional_IN_Yes; 1248 } else { 1249 /* Transition: '<S1>:4021' */ 1250 localDW->is_IsEmptyReservoir = ALARM_Functional_IN_No; 1251 } 1252 1253 localDW->is_active_IsHardwareError = 1U; 1254 1255 /* Entry Internal 'IsHardwareError': '<S1>:4217' */ 1256 if (localB->Battery_Depleted || localB->RTC_In_Error || localB->CPU_In_Error || 1257 localB->Memory_Corrupted || localB->Pump_Too_Hot || 1258 localB->Watchdog_Interrupted) { 1259 /* Transition: '<S1>:4224' */ 1260 localDW->is_IsHardwareError = ALARM_Functional_IN_Yes; 1261 } else { 1262 /* Transition: '<S1>:4219' */ 1263 localDW->is_IsHardwareError = ALARM_Functional_IN_No; 1264 } 1265 1266 localDW->is_active_IsEnviromentalError = 1U; 1267 1268 /* Entry Internal 'IsEnviromentalError': '<S1>:4032' */ 1269 if (localB->Temp || localB->Humidity || localB->Air_Pressure) { 1270 /* Transition: '<S1>:4198' */ 1271 localDW->is_IsEnviromentalError = ALARM_Functional_IN_Yes; 1272 } else { 1273 /* Transition: '<S1>:4033' */ 1274 localDW->is_IsEnviromentalError = ALARM_Functional_IN_No; 1275 } 1276 1277 localDW->is_active_Level3 = 1U; 1278 1279 /* Entry Internal 'Level3': '<S1>:4038' */ 1280 localDW->is_active_IsOverInfusionFlowRate = 1U; 1281 1282 /* Entry 'IsOverInfusionFlowRate': '<S1>:4039' */ 1283 overInfusion = ALARM_Functional_checkOverInfusionFlowRate(localB); 1284 1285 /* Entry Internal 'IsOverInfusionFlowRate': '<S1>:4039' */ 1286 if (overInfusion == 1) { 1287 /* Transition: '<S1>:4697' */ 1288 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Yes_o; 1289 1290 /* Entry 'Yes': '<S1>:4051' */ 1291 } else if (overInfusion == 2) { 1292 /* Transition: '<S1>:4699' */ 1293 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Monitor; 1294 1295 /* Entry 'Monitor': '<S1>:4053' */ 1296 } else { 1297 /* Transition: '<S1>:4041' */ 1298 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_Check; 1299 1300 /* Entry 'Check': '<S1>:4052' */ 1301 } 1302 1303 localDW->is_active_IsOverInfusionVTBI = 1U; 1304 1305 /* Entry Internal 'IsOverInfusionVTBI': '<S1>:4066' */ 1306 if (localB->In_Therapy && (localB->Volume_Infused > localB->VTBI_High)) { 1307 /* Transition: '<S1>:4201' */ 1308 localDW->is_IsOverInfusionVTBI = ALARM_Functional_IN_Yes; 1309 } else { 1310 /* Transition: '<S1>:4067' */ 1311 localDW->is_IsOverInfusionVTBI = ALARM_Functional_IN_No; 1312 } 1313 1314 localDW->is_active_IsAirInLine = 1U; 1315 1316 /* Entry Internal 'IsAirInLine': '<S1>:4072' */ 1317 if (localB->Air_In_Line) { 1318 /* Transition: '<S1>:4202' */ 1319 localDW->is_IsAirInLine = ALARM_Functional_IN_Yes; 1320 } else { 1321 /* Transition: '<S1>:4073' */ 1322 localDW->is_IsAirInLine = ALARM_Functional_IN_No; 1323 } 1324 1325 localDW->is_active_IsOcclusion = 1U; 1326 1327 /* Entry Internal 'IsOcclusion': '<S1>:4078' */ 1328 if (localB->Occlusion) { 1329 /* Transition: '<S1>:4203' */ 1330 localDW->is_IsOcclusion = ALARM_Functional_IN_Yes; 1331 } else { 1332 /* Transition: '<S1>:4079' */ 1333 localDW->is_IsOcclusion = ALARM_Functional_IN_No; 1334 } 1335 1336 localDW->is_active_IsDoorOpen = 1U; 1337 1338 /* Entry Internal 'IsDoorOpen': '<S1>:4084' */ 1339 if (localB->Door_Open) { 1340 /* Transition: '<S1>:4204' */ 1341 localDW->is_IsDoorOpen = ALARM_Functional_IN_Yes; 1342 } else { 1343 /* Transition: '<S1>:4085' */ 1344 localDW->is_IsDoorOpen = ALARM_Functional_IN_No; 1345 } 1346 1347 localDW->is_active_Level2 = 1U; 1348 1349 /* Entry Internal 'Level2': '<S1>:4090' */ 1350 localDW->is_active_IsLowReservoir = 1U; 1351 1352 /* Entry Internal 'IsLowReservoir': '<S1>:4091' */ 1353 if (localB->In_Therapy && (localB->Reservoir_Volume < localB->Low_Reservoir)) 1354 { 1355 /* Transition: '<S1>:4205' */ 1356 localDW->is_IsLowReservoir = ALARM_Functional_IN_Yes; 1357 } else { 1358 /* Transition: '<S1>:4092' */ 1359 localDW->is_IsLowReservoir = ALARM_Functional_IN_No; 1360 } 1361 1362 localDW->is_active_Level1 = 1U; 1363 1364 /* Entry Internal 'Level1': '<S1>:4113' */ 1365 localDW->is_active_InfusionNotStartedWarning = 1U; 1366 1367 /* Entry Internal 'InfusionNotStartedWarning': '<S1>:4577' */ 1368 if (localB->Infusion_Initiate && (!localB->Reservoir_Empty)) { 1369 /* Transition: '<S1>:4578' */ 1370 localDW->is_InfusionNotStartedWarning = ALARM_Functional_IN_Yes; 1371 } else { 1372 /* Transition: '<S1>:4579' */ 1373 localDW->is_InfusionNotStartedWarning = ALARM_Functional_IN_No; 1374 } 1375 1376 localDW->is_active_IsUnderInfusion = 1U; 1377 1378 /* Entry 'IsUnderInfusion': '<S1>:4114' */ 1379 overInfusion = ALARM_Functional_checkUnderInfusion(localB); 1380 1381 /* Entry Internal 'IsUnderInfusion': '<S1>:4114' */ 1382 if (overInfusion == 1) { 1383 /* Transition: '<S1>:4709' */ 1384 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Yes_o; 1385 1386 /* Entry 'Yes': '<S1>:4126' */ 1387 } else if (overInfusion == 2) { 1388 /* Transition: '<S1>:4710' */ 1389 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Monitor; 1390 1391 /* Entry 'Monitor': '<S1>:4128' */ 1392 } else { 1393 /* Transition: '<S1>:4116' */ 1394 localDW->is_IsUnderInfusion = ALARM_Functional_IN_Check; 1395 1396 /* Entry 'Check': '<S1>:4127' */ 1397 } 1398 1399 localDW->is_active_IsFlowRateNotStable = 1U; 1400 1401 /* Entry Internal 'IsFlowRateNotStable': '<S1>:4143' */ 1402 if (localB->In_Therapy && localB->Flow_Rate_Not_Stable) { 1403 /* Transition: '<S1>:4210' */ 1404 localDW->is_IsFlowRateNotStable = ALARM_Functional_IN_Yes; 1405 } else { 1406 /* Transition: '<S1>:4144' */ 1407 localDW->is_IsFlowRateNotStable = ALARM_Functional_IN_No; 1408 } 1409 1410 localDW->is_active_IsIdleTimeExceeded = 1U; 1411 1412 /* Entry Internal 'IsIdleTimeExceeded': '<S1>:4149' */ 1413 if ((localB->Current_System_Mode == 1) && 1414 (ALARM_Functional_Step_Scaling_Factor(localB->Max_Idle_Duration) == 1.0)) 1415 { 1416 /* Transition: '<S1>:4749' */ 1417 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_Yes; 1418 } else if (localB->Current_System_Mode == 1) { 1419 /* Transition: '<S1>:4748' */ 1420 localDW->idletimer = 0U; 1421 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_counting; 1422 1423 /* Entry 'counting': '<S1>:4745' */ 1424 localDW->idletimer++; 1425 } else { 1426 /* Transition: '<S1>:4150' */ 1427 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_No; 1428 1429 /* Entry 'No': '<S1>:4153' */ 1430 localDW->idletimer = 0U; 1431 } 1432 1433 localDW->is_active_IsPausedTimeExceeded = 1U; 1434 1435 /* Entry Internal 'IsPausedTimeExceeded': '<S1>:4155' */ 1436 if (((localB->Current_System_Mode == 6) || (localB->Current_System_Mode == 7) || 1437 (localB->Current_System_Mode == 8)) && 1438 (ALARM_Functional_Step_Scaling_Factor(localB->Max_Paused_Duration) == 1.0)) 1439 { 1440 /* Transition: '<S1>:4760' */ 1441 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_Yes; 1442 } else if ((localB->Current_System_Mode == 6) || (localB->Current_System_Mode == 1443 7) || (localB->Current_System_Mode == 8)) { 1444 /* Transition: '<S1>:4759' */ 1445 localDW->pausedtimer = 0U; 1446 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_counting; 1447 1448 /* Entry 'counting': '<S1>:4752' */ 1449 localDW->pausedtimer++; 1450 } else { 1451 /* Transition: '<S1>:4753' */ 1452 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_No; 1453 1454 /* Entry 'No': '<S1>:4756' */ 1455 localDW->pausedtimer = 0U; 1456 } 1457 1458 localDW->is_active_IsConfigTimeWarning = 1U; 1459 1460 /* Entry Internal 'IsConfigTimeWarning': '<S1>:4161' */ 1461 if ((real_T)localB->Config_Timer > ALARM_Functional_Step_Scaling_Factor 1462 (localB->Config_Warning_Duration)) { 1463 /* Transition: '<S1>:4207' */ 1464 localDW->is_IsConfigTimeWarning = ALARM_Functional_IN_Yes; 1465 } else { 1466 /* Transition: '<S1>:4162' */ 1467 localDW->is_IsConfigTimeWarning = ALARM_Functional_IN_No; 1468 } 1469 1470 localDW->is_active_IsBatteryError = 1U; 1471 1472 /* Entry Internal 'IsBatteryError': '<S1>:4167' */ 1473 if (localB->Battery_Low || localB->Battery_Unable_To_Charge || 1474 localB->Supply_Voltage) { 1475 /* Transition: '<S1>:4212' */ 1476 localDW->is_IsBatteryError = ALARM_Functional_IN_Yes; 1477 } else { 1478 /* Transition: '<S1>:4168' */ 1479 localDW->is_IsBatteryError = ALARM_Functional_IN_No; 1480 } 1481 1482 localDW->is_active_IsPumpHot = 1U; 1483 1484 /* Entry Internal 'IsPumpHot': '<S1>:4173' */ 1485 if (localB->Pump_Overheated) { 1486 /* Transition: '<S1>:4208' */ 1487 localDW->is_IsPumpHot = ALARM_Functional_IN_Yes; 1488 } else { 1489 /* Transition: '<S1>:4174' */ 1490 localDW->is_IsPumpHot = ALARM_Functional_IN_No; 1491 } 1492 1493 localDW->is_active_IsLoggingFailed = 1U; 1494 1495 /* Entry Internal 'IsLoggingFailed': '<S1>:4179' */ 1496 if (localB->Logging_Failed) { 1497 /* Transition: '<S1>:4213' */ 1498 localDW->is_IsLoggingFailed = ALARM_Functional_IN_Yes; 1499 } else { 1500 /* Transition: '<S1>:4180' */ 1501 localDW->is_IsLoggingFailed = ALARM_Functional_IN_No; 1502 } 1503 1504 localDW->is_active_IsSystemMonitorFailed = 1U; 1505 1506 /* Entry Internal 'IsSystemMonitorFailed': '<S1>:4185' */ 1507 if (localB->System_Monitor_Failed) { 1508 /* Transition: '<S1>:4209' */ 1509 localDW->is_IsSystemMonitorFailed = ALARM_Functional_IN_Yes; 1510 } else { 1511 /* Transition: '<S1>:4186' */ 1512 localDW->is_IsSystemMonitorFailed = ALARM_Functional_IN_No; 1513 } 1514 1515 localDW->is_active_SetAlarmStatus = 1U; 1516 1517 /* Entry 'SetAlarmStatus': '<S1>:4018' */ 1518 localDW->currentAlarm = (uint8_T)ALARM_Functional_setCurrentAlarm(localDW); 1519 localB->ALARM_OUT_Highest_Level_Alarm = ALARM_Functional_setHighestAlarm 1520 (localDW); 1521 } 1522 1523 /* Function for Chart: '<Root>/Alarm Sub-System' */ 1524 static void ALARM_Functional_enter_internal_Alarms(B_ALARM_Functional_c_T 1525 *localB, DW_ALARM_Functional_f_T *localDW) 1526 { 1527 /* Entry Internal 'Alarms': '<S1>:3907' */ 1528 localDW->is_active_CheckAlarm = 1U; 1529 ALARM_Functional_enter_internal_CheckAlarm(localB, localDW); 1530 localDW->is_active_Notification = 1U; 1531 1532 /* Entry Internal 'Notification': '<S1>:3908' */ 1533 localDW->is_active_Visual = 1U; 1534 1535 /* Entry Internal 'Visual': '<S1>:3909' */ 1536 if (localDW->currentAlarm > 0) { 1537 /* Transition: '<S1>:4608' */ 1538 localDW->is_Visual = ALARM_Functional_IN_AlarmDisplay; 1539 1540 /* Entry 'AlarmDisplay': '<S1>:3913' */ 1541 localB->ALARM_OUT_Display_Notification_Command = localDW->currentAlarm; 1542 } else { 1543 /* Transition: '<S1>:3910' */ 1544 localDW->is_Visual = ALARM_Functional_IN_OFF; 1545 1546 /* Entry 'OFF': '<S1>:3914' */ 1547 localB->ALARM_OUT_Display_Notification_Command = 0U; 1548 } 1549 1550 localDW->is_active_Audio = 1U; 1551 1552 /* Entry 'Audio': '<S1>:3919' */ 1553 localB->ALARM_OUT_Display_Audio_Disabled_Indicator = localB->Disable_Audio; 1554 1555 /* Entry Internal 'Audio': '<S1>:3919' */ 1556 if (localB->Disable_Audio == 1) { 1557 /* Transition: '<S1>:4599' */ 1558 localDW->is_Audio = ALARM_Functional_IN_Disabled; 1559 1560 /* Entry 'Disabled': '<S1>:3939' */ 1561 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1562 } else if (localB->Disable_Audio == 2) { 1563 /* Transition: '<S1>:4600' */ 1564 localDW->is_Audio = ALARM_Functional_IN_Silenced; 1565 1566 /* Entry 'Silenced': '<S1>:3952' */ 1567 localDW->audioTimer = 0U; 1568 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1569 localDW->audioTimer++; 1570 } else if ((localB->ALARM_OUT_Highest_Level_Alarm > 2) && 1571 (localB->Disable_Audio == 0)) { 1572 /* Transition: '<S1>:4601' */ 1573 localDW->is_Audio = ALARM_Functional_IN_ON; 1574 1575 /* Entry 'ON': '<S1>:3938' */ 1576 localB->ALARM_OUT_Audio_Notification_Command = localB->Audio_Level; 1577 } else { 1578 /* Transition: '<S1>:3924' */ 1579 localDW->is_Audio = ALARM_Functional_IN_OFF; 1580 1581 /* Entry 'OFF': '<S1>:3937' */ 1582 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1583 } 1584 } 1585 1586 /* Initial conditions for referenced model: 'ALARM_Functional' */ 1587 void ALARM_Functional_Init(B_ALARM_Functional_c_T *localB, 1588 DW_ALARM_Functional_f_T *localDW) 1589 { 1590 /* InitializeConditions for Chart: '<Root>/Alarm Sub-System' */ 1591 localDW->is_active_CheckAlarm = 0U; 1592 localDW->is_active_CancelAlarm = 0U; 1593 localDW->is_CancelAlarm = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1594 localDW->is_active_Level1 = 0U; 1595 localDW->is_active_InfusionNotStartedWarning = 0U; 1596 localDW->is_InfusionNotStartedWarning = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1597 localDW->is_active_IsBatteryError = 0U; 1598 localDW->is_IsBatteryError = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1599 localDW->is_active_IsConfigTimeWarning = 0U; 1600 localDW->is_IsConfigTimeWarning = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1601 localDW->is_active_IsFlowRateNotStable = 0U; 1602 localDW->is_IsFlowRateNotStable = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1603 localDW->is_active_IsIdleTimeExceeded = 0U; 1604 localDW->is_IsIdleTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1605 localDW->is_active_IsLoggingFailed = 0U; 1606 localDW->is_IsLoggingFailed = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1607 localDW->is_active_IsPausedTimeExceeded = 0U; 1608 localDW->is_IsPausedTimeExceeded = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1609 localDW->is_active_IsPumpHot = 0U; 1610 localDW->is_IsPumpHot = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1611 localDW->is_active_IsSystemMonitorFailed = 0U; 1612 localDW->is_IsSystemMonitorFailed = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1613 localDW->is_active_IsUnderInfusion = 0U; 1614 localDW->is_IsUnderInfusion = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1615 localDW->is_active_Level2 = 0U; 1616 localDW->is_active_IsLowReservoir = 0U; 1617 localDW->is_IsLowReservoir = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1618 localDW->is_active_Level3 = 0U; 1619 localDW->is_active_IsAirInLine = 0U; 1620 localDW->is_IsAirInLine = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1621 localDW->is_active_IsDoorOpen = 0U; 1622 localDW->is_IsDoorOpen = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1623 localDW->is_active_IsOcclusion = 0U; 1624 localDW->is_IsOcclusion = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1625 localDW->is_active_IsOverInfusionFlowRate = 0U; 1626 localDW->is_IsOverInfusionFlowRate = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1627 localDW->is_active_IsOverInfusionVTBI = 0U; 1628 localDW->is_IsOverInfusionVTBI = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1629 localDW->is_active_Level4 = 0U; 1630 localDW->is_active_IsEmptyReservoir = 0U; 1631 localDW->is_IsEmptyReservoir = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1632 localDW->is_active_IsEnviromentalError = 0U; 1633 localDW->is_IsEnviromentalError = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1634 localDW->is_active_IsHardwareError = 0U; 1635 localDW->is_IsHardwareError = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1636 localDW->is_active_SetAlarmStatus = 0U; 1637 localDW->is_active_Notification = 0U; 1638 localDW->is_active_Audio = 0U; 1639 localDW->is_Audio = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1640 localDW->is_active_Visual = 0U; 1641 localDW->is_Visual = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1642 localDW->is_active_c2_ALARM_Functional = 0U; 1643 localDW->is_c2_ALARM_Functional = ALARM_Functional_IN_NO_ACTIVE_CHILD; 1644 localDW->overInfusionTimer = 0U; 1645 localDW->underInfusionTimer = 0U; 1646 localDW->currentAlarm = 0U; 1647 localDW->audioTimer = 0U; 1648 localDW->cancelAlarm = 0U; 1649 localDW->Max_Alarm_Level = 0U; 1650 localDW->idletimer = 0U; 1651 localDW->pausedtimer = 0U; 1652 localB->ALARM_OUT_Display_Audio_Disabled_Indicator = 0U; 1653 localB->ALARM_OUT_Display_Notification_Command = 0U; 1654 localB->ALARM_OUT_Audio_Notification_Command = 0U; 1655 localB->ALARM_OUT_Highest_Level_Alarm = 0U; 1656 localB->ALARM_OUT_Log_Message_ID = 0U; 1657 } 1658 1659 /* Output and update for referenced model: 'ALARM_Functional' */ 1660 void ALARM_Functional(const Infusion_Manager_Outputs *rtu_IM_IN, const 1661 Top_Level_Mode_Outputs *rtu_TLM_MODE_IN, const 1662 System_Monitor_Output *rtu_SYS_MON_IN, const Log_Output 1663 *rtu_LOGGING_IN, const Operator_Commands *rtu_OP_CMD_IN, 1664 const Drug_Database_Inputs *rtu_DB_IN, const 1665 Device_Sensor_Inputs *rtu_SENSOR_IN, const 1666 Device_Configuration_Inputs *rtu_CONST_IN, const 1667 System_Status_Outputs *rtu_SYS_STAT_IN, const 1668 Config_Outputs *rtu_CONFIG_IN, Alarm_Outputs 1669 *rty_ALARM_OUT, B_ALARM_Functional_c_T *localB, 1670 DW_ALARM_Functional_f_T *localDW) 1671 { 1672 /* BusSelector: '<Root>/BusConversion_InsertedFor_IM_IN_at_outport_0' */ 1673 localB->Commanded_Flow_Rate = rtu_IM_IN->Commanded_Flow_Rate; 1674 localB->Current_System_Mode = rtu_IM_IN->Current_System_Mode; 1675 1676 /* BusSelector: '<Root>/BusConversion_InsertedFor_TLM_MODE_IN_at_outport_0' */ 1677 localB->System_On = rtu_TLM_MODE_IN->System_On; 1678 1679 /* BusSelector: '<Root>/BusConversion_InsertedFor_SYS_MON_IN_at_outport_0' */ 1680 localB->System_Monitor_Failed = rtu_SYS_MON_IN->System_Monitor_Failed; 1681 1682 /* BusSelector: '<Root>/BusConversion_InsertedFor_LOGGING_IN_at_outport_0' */ 1683 localB->Logging_Failed = rtu_LOGGING_IN->Logging_Failed; 1684 1685 /* BusSelector: '<Root>/BusConversion_InsertedFor_OP_CMD_IN_at_outport_0' */ 1686 localB->Infusion_Initiate = rtu_OP_CMD_IN->Infusion_Initiate; 1687 localB->Disable_Audio = rtu_OP_CMD_IN->Disable_Audio; 1688 localB->Notification_Cancel = rtu_OP_CMD_IN->Notification_Cancel; 1689 1690 /* BusSelector: '<Root>/BusConversion_InsertedFor_DB_IN_at_outport_0' */ 1691 localB->VTBI_High = rtu_DB_IN->VTBI_High; 1692 localB->Flow_Rate_High = rtu_DB_IN->Flow_Rate_High; 1693 localB->Flow_Rate_Low = rtu_DB_IN->Flow_Rate_Low; 1694 1695 /* BusSelector: '<Root>/BusConversion_InsertedFor_SENSOR_IN_at_outport_0' */ 1696 localB->Flow_Rate = rtu_SENSOR_IN->Flow_Rate; 1697 localB->Flow_Rate_Not_Stable = rtu_SENSOR_IN->Flow_Rate_Not_Stable; 1698 localB->Air_In_Line = rtu_SENSOR_IN->Air_In_Line; 1699 localB->Occlusion = rtu_SENSOR_IN->Occlusion; 1700 localB->Door_Open = rtu_SENSOR_IN->Door_Open; 1701 localB->Temp = rtu_SENSOR_IN->Temp; 1702 localB->Air_Pressure = rtu_SENSOR_IN->Air_Pressure; 1703 localB->Humidity = rtu_SENSOR_IN->Humidity; 1704 localB->Battery_Depleted = rtu_SENSOR_IN->Battery_Depleted; 1705 localB->Battery_Low = rtu_SENSOR_IN->Battery_Low; 1706 localB->Battery_Unable_To_Charge = rtu_SENSOR_IN->Battery_Unable_To_Charge; 1707 localB->Supply_Voltage = rtu_SENSOR_IN->Supply_Voltage; 1708 localB->CPU_In_Error = rtu_SENSOR_IN->CPU_In_Error; 1709 localB->RTC_In_Error = rtu_SENSOR_IN->RTC_In_Error; 1710 localB->Watchdog_Interrupted = rtu_SENSOR_IN->Watchdog_Interrupted; 1711 localB->Memory_Corrupted = rtu_SENSOR_IN->Memory_Corrupted; 1712 localB->Pump_Too_Hot = rtu_SENSOR_IN->Pump_Too_Hot; 1713 localB->Pump_Overheated = rtu_SENSOR_IN->Pump_Overheated; 1714 1715 /* BusSelector: '<Root>/BusConversion_InsertedFor_CONST_IN_at_outport_0' */ 1716 localB->Audio_Enable_Duration = rtu_CONST_IN->Audio_Enable_Duration; 1717 localB->Audio_Level = rtu_CONST_IN->Audio_Level; 1718 localB->Config_Warning_Duration = rtu_CONST_IN->Config_Warning_Duration; 1719 localB->Low_Reservoir = rtu_CONST_IN->Low_Reservoir; 1720 localB->Max_Duration_Over_Infusion = rtu_CONST_IN->Max_Duration_Over_Infusion; 1721 localB->Max_Duration_Under_Infusion = 1722 rtu_CONST_IN->Max_Duration_Under_Infusion; 1723 localB->Max_Paused_Duration = rtu_CONST_IN->Max_Paused_Duration; 1724 localB->Max_Idle_Duration = rtu_CONST_IN->Max_Idle_Duration; 1725 localB->Tolerance_Max = rtu_CONST_IN->Tolerance_Max; 1726 localB->Tolerance_Min = rtu_CONST_IN->Tolerance_Min; 1727 1728 /* BusSelector: '<Root>/BusConversion_InsertedFor_SYS_STAT_IN_at_outport_0' */ 1729 localB->Reservoir_Empty = rtu_SYS_STAT_IN->Reservoir_Empty; 1730 localB->Reservoir_Volume = rtu_SYS_STAT_IN->Reservoir_Volume; 1731 localB->Volume_Infused = rtu_SYS_STAT_IN->Volume_Infused; 1732 localB->In_Therapy = rtu_SYS_STAT_IN->In_Therapy; 1733 1734 /* BusSelector: '<Root>/BusConversion_InsertedFor_CONFIG_IN_at_outport_0' */ 1735 localB->Config_Timer = rtu_CONFIG_IN->Config_Timer; 1736 1737 /* Chart: '<Root>/Alarm Sub-System' */ 1738 /* Gateway: Alarm Sub-System */ 1739 /* During: Alarm Sub-System */ 1740 if (localDW->is_active_c2_ALARM_Functional == 0U) { 1741 /* Entry: Alarm Sub-System */ 1742 localDW->is_active_c2_ALARM_Functional = 1U; 1743 1744 /* Entry Internal: Alarm Sub-System */ 1745 if (localB->System_On) { 1746 /* Transition: '<S1>:4696' */ 1747 localDW->is_c2_ALARM_Functional = ALARM_Functional_IN_Alarms; 1748 ALARM_Functional_enter_internal_Alarms(localB, localDW); 1749 } else { 1750 /* Transition: '<S1>:3904' */ 1751 localDW->is_c2_ALARM_Functional = ALARM_Functional_IN_NOT_ON; 1752 } 1753 } else if (localDW->is_c2_ALARM_Functional == ALARM_Functional_IN_Alarms) { 1754 ALARM_Functional_Alarms(localB, localDW); 1755 } else { 1756 /* During 'NOT_ON': '<S1>:3899' */ 1757 if (localB->System_On) { 1758 /* Transition: '<S1>:3900' */ 1759 localDW->is_c2_ALARM_Functional = ALARM_Functional_IN_Alarms; 1760 ALARM_Functional_enter_internal_Alarms(localB, localDW); 1761 } 1762 } 1763 1764 /* End of Chart: '<Root>/Alarm Sub-System' */ 1765 1766 /* BusCreator: '<Root>/BusConversion_InsertedFor_ALARM_OUT_at_inport_0' */ 1767 rty_ALARM_OUT->Is_Audio_Disabled = 1768 localB->ALARM_OUT_Display_Audio_Disabled_Indicator; 1769 rty_ALARM_OUT->Notification_Message = 1770 localB->ALARM_OUT_Display_Notification_Command; 1771 rty_ALARM_OUT->Audio_Notification_Command = 1772 localB->ALARM_OUT_Audio_Notification_Command; 1773 rty_ALARM_OUT->Highest_Level_Alarm = localB->ALARM_OUT_Highest_Level_Alarm; 1774 rty_ALARM_OUT->Log_Message_ID = localB->ALARM_OUT_Log_Message_ID; 1775 } 1776 1777 /* Model initialize function */ 1778 void ALARM_Functional_initialize(const char_T **rt_errorStatus, 1779 RT_MODEL_ALARM_Functional_T *const ALARM_Functional_M, B_ALARM_Functional_c_T * 1780 localB, DW_ALARM_Functional_f_T *localDW) 1781 { 1782 /* Registration code */ 1783 1784 /* initialize error status */ 1785 rtmSetErrorStatusPointer(ALARM_Functional_M, rt_errorStatus); 1786 1787 /* block I/O */ 1788 (void) memset(((void *) localB), 0, 1789 sizeof(B_ALARM_Functional_c_T)); 1790 1791 /* states (dwork) */ 1792 (void) memset((void *)localDW, 0, 1793 sizeof(DW_ALARM_Functional_f_T)); 1794 } 1795 |