/**
 * @file
 * @brief Generated model file.
 * 
 * Date:  2022-05-16 17:51
 * 
 * X2C-Version: 6.2.1835
 * X2C-Edition: Educational
 */
/* This file is part of X2C. http://x2c.lcm.at/                                                                       */

/* Model: Application                                                                                                 */
/* Date:  2022-05-16 17:51                                                                                            */

/* X2C-Version: 6.2.1835                                                                                              */
/* X2C-Edition: Educational                                                                                           */

#ifndef X2C_H
#define X2C_H

#ifdef __cplusplus
extern "C" {
#endif

/**********************************************************************************************************************/
/**     Includes                                                                                                     **/
/**********************************************************************************************************************/
#include "Constant_Bool.h"
#include "PT1_Float32.h"
#include "Gain_Float32.h"
#include "RateLimiter_Float32.h"
#include "Constant_Float32.h"
#include "LoopBreaker_Bool.h"
#include "Div_Float32.h"
#include "Sin3Gen_Float32.h"
#include "Abs_Float32.h"
#include "Saturation_Float32.h"
#include "And_Bool.h"
#include "RSFlipFlop_Bool.h"
#include "Not_Bool.h"
#include "Or_Bool.h"
#include "LookupTable1D_Float32.h"
#include "EnableSwitch_Float32.h"
#include "Scope_Main.h"
#include "CommonFcts.h"

/**********************************************************************************************************************/
/**     Defines                                                                                                      **/
/**********************************************************************************************************************/
#define FUNCTIONS \
    CONSTANT_BOOL_FUNCTIONS , \
    PT1_FLOAT32_FUNCTIONS , \
    GAIN_FLOAT32_FUNCTIONS , \
    RATELIMITER_FLOAT32_FUNCTIONS , \
    CONSTANT_FLOAT32_FUNCTIONS , \
    LOOPBREAKER_BOOL_FUNCTIONS , \
    DIV_FLOAT32_FUNCTIONS , \
    SIN3GEN_FLOAT32_FUNCTIONS , \
    ABS_FLOAT32_FUNCTIONS , \
    SATURATION_FLOAT32_FUNCTIONS , \
    AND_BOOL_FUNCTIONS , \
    RSFLIPFLOP_BOOL_FUNCTIONS , \
    NOT_BOOL_FUNCTIONS , \
    OR_BOOL_FUNCTIONS , \
    LOOKUPTABLE1D_FLOAT32_FUNCTIONS , \
    ENABLESWITCH_FLOAT32_FUNCTIONS , \
    SCOPE_MAIN_FUNCTIONS

#define PARAMETER_TABLE \
    { 1, &x2cModel.blocks.bAnd } , \
    { 2, &x2cModel.blocks.bAnd1 } , \
    { 3, &x2cModel.blocks.bDuty_PFC } , \
    { 4, &x2cModel.blocks.bDuty_RB } , \
    { 5, &x2cModel.blocks.bEnableSwitch } , \
    { 6, &x2cModel.blocks.bEnable_PFC } , \
    { 7, &x2cModel.blocks.bEnable_RB } , \
    { 8, &x2cModel.blocks.bGain2 } , \
    { 9, &x2cModel.blocks.bGain4 } , \
    { 10, &x2cModel.blocks.bNot } , \
    { 11, &x2cModel.blocks.bOr } , \
    { 12, &x2cModel.blocks.bPT1 } , \
    { 13, &x2cModel.blocks.bRG_Enable1 } , \
    { 14, &x2cModel.blocks.bRG_Reload1 } , \
    { 15, &x2cModel.blocks.bRSFlipFlop } , \
    { 16, &x2cModel.blocks.bRateLimiter } , \
    { 17, &x2cModel.blocks.bSaturation } , \
    { 18, &x2cModel.blocks.bSaturation1 } , \
    { 19, &x2cModel.blocks.bSin3Gen } , \
    { 20, &x2cModel.blocks.sToggle.bAnd2 } , \
    { 21, &x2cModel.blocks.sToggle.bAnd3 } , \
    { 22, &x2cModel.blocks.sToggle.bAnd4 } , \
    { 23, &x2cModel.blocks.sToggle.bLoopBreaker } , \
    { 24, &x2cModel.blocks.sToggle.bLoopBreaker1 } , \
    { 25, &x2cModel.blocks.sToggle.bLoopBreaker2 } , \
    { 26, &x2cModel.blocks.sToggle.bNot1 } , \
    { 27, &x2cModel.blocks.sToggle.bNot2 } , \
    { 28, &x2cModel.blocks.sToggle.bRSFlipFlop1 } , \
    { 29, &x2cModel.blocks.sToggle1.bAnd2 } , \
    { 30, &x2cModel.blocks.sToggle1.bAnd3 } , \
    { 31, &x2cModel.blocks.sToggle1.bAnd4 } , \
    { 32, &x2cModel.blocks.sToggle1.bLoopBreaker } , \
    { 33, &x2cModel.blocks.sToggle1.bLoopBreaker1 } , \
    { 34, &x2cModel.blocks.sToggle1.bLoopBreaker2 } , \
    { 35, &x2cModel.blocks.sToggle1.bNot1 } , \
    { 36, &x2cModel.blocks.sToggle1.bNot2 } , \
    { 37, &x2cModel.blocks.sToggle1.bRSFlipFlop1 } , \
    { 38, &x2cModel.blocks.sU_f.bAbs } , \
    { 39, &x2cModel.blocks.sU_f.bDiv } , \
    { 40, &x2cModel.blocks.sU_f.bGain3 } , \
    { 41, &x2cModel.blocks.sU_f.bLookupTable1D1 } , \
    { 69, &x2cScope }

#define INPORT_PARAMID_TABLE \
    { 42, 1, &x2cModel.inports.bInDir } , \
    { 43, 4, &x2cModel.inports.bInIL1 } , \
    { 44, 1, &x2cModel.inports.bInIPB4 } , \
    { 45, 1, &x2cModel.inports.bInIPB5 } , \
    { 46, 1, &x2cModel.inports.bInIPB8 } , \
    { 47, 1, &x2cModel.inports.bInIPB9 } , \
    { 48, 1, &x2cModel.inports.bInIRAMYOverCurrent } , \
    { 49, 1, &x2cModel.inports.bInIRAMYOverTemp } , \
    { 50, 4, &x2cModel.inports.bInIdc } , \
    { 51, 4, &x2cModel.inports.bInIph1 } , \
    { 52, 4, &x2cModel.inports.bInIph2 } , \
    { 53, 4, &x2cModel.inports.bInIph3 } , \
    { 54, 4, &x2cModel.inports.bInPot } , \
    { 55, 4, &x2cModel.inports.bInVL1 } , \
    { 56, 4, &x2cModel.inports.bInVdc } 

#define OUTPORT_PARAMID_TABLE \
    { 57, 1, &x2cModel.outports.bOutDir } , \
    { 58, 4, &x2cModel.outports.bOutDuty1 } , \
    { 59, 4, &x2cModel.outports.bOutDuty2 } , \
    { 60, 4, &x2cModel.outports.bOutDuty3 } , \
    { 61, 4, &x2cModel.outports.bOutDutyPFC } , \
    { 62, 4, &x2cModel.outports.bOutDutyRB } , \
    { 63, 1, &x2cModel.outports.bOutIRAMYEnable } , \
    { 64, 1, &x2cModel.outports.bOutPB7_Green } , \
    { 65, 1, &x2cModel.outports.bOutPC11_Green } , \
    { 66, 1, &x2cModel.outports.bOutPC6_Red } , \
    { 67, 1, &x2cModel.outports.bOutPFCEnable } , \
    { 68, 1, &x2cModel.outports.bOutRBEnable } 


/**********************************************************************************************************************/
/**                                            Model structure definition                                            **/
/**********************************************************************************************************************/
struct x2cModel {
/*  Control Blocks                                                                                                    */
    struct {
/*      Sub-system Toggle                                                                                             */
        struct {
            AND_BOOL bAnd2;
            AND_BOOL bAnd3;
            AND_BOOL bAnd4;
            LOOPBREAKER_BOOL bLoopBreaker;
            LOOPBREAKER_BOOL bLoopBreaker1;
            LOOPBREAKER_BOOL bLoopBreaker2;
            NOT_BOOL bNot1;
            NOT_BOOL bNot2;
            RSFLIPFLOP_BOOL bRSFlipFlop1;
        } sToggle;
/*      Sub-system Toggle1                                                                                            */
        struct {
            AND_BOOL bAnd2;
            AND_BOOL bAnd3;
            AND_BOOL bAnd4;
            LOOPBREAKER_BOOL bLoopBreaker;
            LOOPBREAKER_BOOL bLoopBreaker1;
            LOOPBREAKER_BOOL bLoopBreaker2;
            NOT_BOOL bNot1;
            NOT_BOOL bNot2;
            RSFLIPFLOP_BOOL bRSFlipFlop1;
        } sToggle1;
/*      Sub-system U/f                                                                                                */
        struct {
            ABS_FLOAT32 bAbs;
            DIV_FLOAT32 bDiv;
            GAIN_FLOAT32 bGain3;
            LOOKUPTABLE1D_FLOAT32 bLookupTable1D1;
        } sU_f;
        AND_BOOL bAnd;
        AND_BOOL bAnd1;
        CONSTANT_FLOAT32 bDuty_PFC;
        CONSTANT_FLOAT32 bDuty_RB;
        ENABLESWITCH_FLOAT32 bEnableSwitch;
        CONSTANT_BOOL bEnable_PFC;
        CONSTANT_BOOL bEnable_RB;
        GAIN_FLOAT32 bGain2;
        GAIN_FLOAT32 bGain4;
        NOT_BOOL bNot;
        OR_BOOL bOr;
        PT1_FLOAT32 bPT1;
        CONSTANT_BOOL bRG_Enable1;
        CONSTANT_FLOAT32 bRG_Reload1;
        RSFLIPFLOP_BOOL bRSFlipFlop;
        RATELIMITER_FLOAT32 bRateLimiter;
        SATURATION_FLOAT32 bSaturation;
        SATURATION_FLOAT32 bSaturation1;
        SIN3GEN_FLOAT32 bSin3Gen;
    } blocks;
/*  Inports                                                                                                           */
    struct {
        bool bInDir;
        float32 bInIL1;
        bool bInIPB4;
        bool bInIPB5;
        bool bInIPB8;
        bool bInIPB9;
        bool bInIRAMYOverCurrent;
        bool bInIRAMYOverTemp;
        float32 bInIdc;
        float32 bInIph1;
        float32 bInIph2;
        float32 bInIph3;
        float32 bInPot;
        float32 bInVL1;
        float32 bInVdc;
    } inports;
/*  Outports                                                                                                          */
    struct {
        bool* bOutDir;
        float32* bOutDuty1;
        float32* bOutDuty2;
        float32* bOutDuty3;
        float32* bOutDutyPFC;
        float32* bOutDutyRB;
        bool* bOutIRAMYEnable;
        bool* bOutPB7_Green;
        bool* bOutPC11_Green;
        bool* bOutPC6_Red;
        bool* bOutPFCEnable;
        bool* bOutRBEnable;
    } outports;
};

/**********************************************************************************************************************/
/**     Externals                                                                                                    **/
/**********************************************************************************************************************/
extern struct x2cModel x2cModel;

extern const tBlockFunctions blockFunctionTable[];
extern const tParameterTable parameterIdTable[];
extern const tIoParamIdEntry inportParamIdTable[];
extern const tIoParamIdEntry outportParamIdTable[];

#define X2C_UPDATE_100_DIVIDER 100

/**********************************************************************************************************************/
/**     Prototypes                                                                                                   **/
/**********************************************************************************************************************/
void X2C_Init(void);
void X2C_Update_1(void);
void X2C_Update_100(void);

#ifdef __cplusplus
}
#endif

#endif
