// Generated by STruC++ - IEC 61131-3 Structured Text to C++ Compiler
// Do not edit this file manually.

#include "generated.hpp"

namespace strucpp {

// Library: iec-standard-fb
TON::TON() {
    // Initialize variables
}

void TON::operator()() {
    CURRENT_TIME = TIME();
    if (((((STATE == 0)) & (NOT(PREV_IN))) & (IN))) {
        STATE = 1;
        Q = false;
        START_TIME = CURRENT_TIME;
    } else {
        if ((NOT(IN))) {
            ET = 0LL;
            Q = false;
            STATE = 0;
        } else if ((STATE == 1)) {
            if (((START_TIME + PT) <= CURRENT_TIME)) {
                STATE = 2;
                Q = true;
                ET = PT;
            } else {
                ET = CURRENT_TIME - START_TIME;
            }
        }
    }
    PREV_IN = IN;
}


// Library: oscat-basic
INTEGRATE::INTEGRATE()
    : E(true), K(1.0)
{
    // Initialize variables
}

void INTEGRATE::operator()() {
    TX = T_PLC_MS();
    if (!INIT) {
        INIT = true;
        X_LAST = X;
    } else if (E) {
        Y = (X + X_LAST) * 0.0005 * TO_REAL(TX - LAST) * K + Y;
        X_LAST = X;
    }
    LAST = TX;
}

SPEED::SPEED() {
    // Initialize variables
}

void SPEED::operator()() {
    YMS = MS + KMH * 0.27777777777778 + KN * 0.5144444 + MH * 0.44704;
    YKMH = YMS * 3.6;
    YKN = YMS * 1.94384466037535;
    YMH = YMS * 2.2369362920544;
}

IEC_INT CEIL(IEC_REAL X) {
    IEC_INT CEIL_result;
    CEIL_result = TO_INT(X);
    if (CEIL_result < X) {
        CEIL_result = CEIL_result + 1;
    }
    return CEIL_result;
}

IEC_REAL EXPN(IEC_REAL X, IEC_INT N) {
    IEC_REAL EXPN_result;
    IEC_BOOL SIGN;
    SIGN = ((static_cast<uint64_t>(N) >> 15) & 1);
    N = ABS(N);
    if (((static_cast<uint64_t>(N) >> 0) & 1)) {
        EXPN_result = X;
    } else {
        EXPN_result = 1.0;
    }
    N = SHR(N, 1);
    while (N > 0) {
        X = X * X;
        if (((static_cast<uint64_t>(N) >> 0) & 1)) {
            EXPN_result = EXPN_result * X;
        }
        N = SHR(N, 1);
    }
    if (SIGN) {
        EXPN_result = 1.0 / EXPN_result;
    }
    return EXPN_result;
}

IEC_REAL OFFSET(IEC_REAL X, IEC_BOOL O1, IEC_BOOL O2, IEC_BOOL O3, IEC_BOOL O4, IEC_BOOL D, IEC_REAL OFFSET_1, IEC_REAL OFFSET_2, IEC_REAL OFFSET_3, IEC_REAL OFFSET_4, IEC_REAL DEFAULT) {
    IEC_REAL OFFSET_result;
    if (D) {
        OFFSET_result = DEFAULT;
    } else {
        OFFSET_result = X;
    }
    if (O1) {
        OFFSET_result = OFFSET_result + OFFSET_1;
    }
    if (O2) {
        OFFSET_result = OFFSET_result + OFFSET_2;
    }
    if (O3) {
        OFFSET_result = OFFSET_result + OFFSET_3;
    }
    if (O4) {
        OFFSET_result = OFFSET_result + OFFSET_4;
    }
    return OFFSET_result;
}

IEC_REAL RND(IEC_REAL X, IEC_INT N) {
    IEC_REAL RND_result;
    IEC_REAL M;
    if (X == 0.0) {
        RND_result = 0.0;
    } else {
        M = EXPN(10.0, N - CEIL(LOG(ABS(X))));
        RND_result = TO_REAL(TO_DINT(X * M)) / M;
    }
    return RND_result;
}

IEC_DWORD T_PLC_MS() {
    IEC_DWORD T_PLC_MS_result;
    IEC_BOOL DEBUG = 0;
    IEC_INT N = 0;
    IEC_DWORD OFFSET = 0;
    IEC_TIME TX;
    TX = TIME();
    T_PLC_MS_result = TO_DWORD(TIME_TO_MS(TX));
    if (DEBUG) {
        T_PLC_MS_result = ((SHL(T_PLC_MS_result, N)) | (SHL(static_cast<IEC_DWORD>(1), N) - 1)) + OFFSET;
    }
    return T_PLC_MS_result;
}


// =============================================================================
// Located Variables Descriptor Array
// =============================================================================

LocatedVar locatedVars[69] = {
    { LocatedArea::Input, LocatedSize::Word, 0, 0, {0, 0, 0}, nullptr },  // IW_LIT101 AT %IW0
    { LocatedArea::Input, LocatedSize::Word, 1, 0, {0, 0, 0}, nullptr },  // IW_FIT201 AT %IW1
    { LocatedArea::Input, LocatedSize::Word, 2, 0, {0, 0, 0}, nullptr },  // IW_FIT301 AT %IW2
    { LocatedArea::Input, LocatedSize::Word, 3, 0, {0, 0, 0}, nullptr },  // IW_PIT302 AT %IW3
    { LocatedArea::Input, LocatedSize::Word, 4, 0, {0, 0, 0}, nullptr },  // IW_PIT311 AT %IW4
    { LocatedArea::Input, LocatedSize::Word, 5, 0, {0, 0, 0}, nullptr },  // IW_PIT321 AT %IW5
    { LocatedArea::Input, LocatedSize::Word, 6, 0, {0, 0, 0}, nullptr },  // IW_PIT331 AT %IW6
    { LocatedArea::Input, LocatedSize::Word, 7, 0, {0, 0, 0}, nullptr },  // IW_VE314 AT %IW7
    { LocatedArea::Input, LocatedSize::Word, 8, 0, {0, 0, 0}, nullptr },  // IW_VE324 AT %IW8
    { LocatedArea::Input, LocatedSize::Word, 9, 0, {0, 0, 0}, nullptr },  // IW_VE334 AT %IW9
    { LocatedArea::Input, LocatedSize::Bit, 0, 0, {0, 0, 0}, nullptr },  // IX_LSHH102 AT %IX0.0
    { LocatedArea::Input, LocatedSize::Bit, 0, 1, {0, 0, 0}, nullptr },  // IX_LSLL103 AT %IX0.1
    { LocatedArea::Input, LocatedSize::Bit, 0, 2, {0, 0, 0}, nullptr },  // IX_LSH104 AT %IX0.2
    { LocatedArea::Input, LocatedSize::Bit, 0, 3, {0, 0, 0}, nullptr },  // IX_TE312 AT %IX0.3
    { LocatedArea::Input, LocatedSize::Bit, 0, 4, {0, 0, 0}, nullptr },  // IX_TE322 AT %IX0.4
    { LocatedArea::Input, LocatedSize::Bit, 0, 5, {0, 0, 0}, nullptr },  // IX_TE332 AT %IX0.5
    { LocatedArea::Input, LocatedSize::Bit, 0, 6, {0, 0, 0}, nullptr },  // IX_MSE313 AT %IX0.6
    { LocatedArea::Input, LocatedSize::Bit, 0, 7, {0, 0, 0}, nullptr },  // IX_MSE323 AT %IX0.7
    { LocatedArea::Input, LocatedSize::Bit, 1, 0, {0, 0, 0}, nullptr },  // IX_MSE333 AT %IX1.0
    { LocatedArea::Input, LocatedSize::Bit, 1, 1, {0, 0, 0}, nullptr },  // IX_XA502 AT %IX1.1
    { LocatedArea::Output, LocatedSize::Bit, 0, 0, {0, 0, 0}, nullptr },  // QX_RUNCMD1 AT %QX0.0
    { LocatedArea::Output, LocatedSize::Bit, 0, 1, {0, 0, 0}, nullptr },  // QX_RUNCMD2 AT %QX0.1
    { LocatedArea::Output, LocatedSize::Bit, 0, 2, {0, 0, 0}, nullptr },  // QX_RUNCMD3 AT %QX0.2
    { LocatedArea::Output, LocatedSize::Bit, 0, 3, {0, 0, 0}, nullptr },  // QX_RUNNING1 AT %QX0.3
    { LocatedArea::Output, LocatedSize::Bit, 0, 4, {0, 0, 0}, nullptr },  // QX_RUNNING2 AT %QX0.4
    { LocatedArea::Output, LocatedSize::Bit, 0, 5, {0, 0, 0}, nullptr },  // QX_RUNNING3 AT %QX0.5
    { LocatedArea::Output, LocatedSize::Bit, 0, 6, {0, 0, 0}, nullptr },  // QX_AVAIL1 AT %QX0.6
    { LocatedArea::Output, LocatedSize::Bit, 0, 7, {0, 0, 0}, nullptr },  // QX_AVAIL2 AT %QX0.7
    { LocatedArea::Output, LocatedSize::Bit, 1, 0, {0, 0, 0}, nullptr },  // QX_AVAIL3 AT %QX1.0
    { LocatedArea::Output, LocatedSize::Bit, 1, 1, {0, 0, 0}, nullptr },  // QX_INAUTO AT %QX1.1
    { LocatedArea::Output, LocatedSize::Bit, 1, 2, {0, 0, 0}, nullptr },  // QX_HIGHLEVEL AT %QX1.2
    { LocatedArea::Output, LocatedSize::Bit, 1, 3, {0, 0, 0}, nullptr },  // QX_SPILLACTIVE AT %QX1.3
    { LocatedArea::Output, LocatedSize::Bit, 1, 4, {0, 0, 0}, nullptr },  // QX_TRIPPED1 AT %QX1.4
    { LocatedArea::Output, LocatedSize::Bit, 1, 5, {0, 0, 0}, nullptr },  // QX_TRIPPED2 AT %QX1.5
    { LocatedArea::Output, LocatedSize::Bit, 1, 6, {0, 0, 0}, nullptr },  // QX_TRIPPED3 AT %QX1.6
    { LocatedArea::Output, LocatedSize::Word, 0, 0, {0, 0, 0}, nullptr },  // QW_LEVEL AT %QW0
    { LocatedArea::Output, LocatedSize::Word, 1, 0, {0, 0, 0}, nullptr },  // QW_INFLOW AT %QW1
    { LocatedArea::Output, LocatedSize::Word, 2, 0, {0, 0, 0}, nullptr },  // QW_DISCHARGE AT %QW2
    { LocatedArea::Output, LocatedSize::Word, 3, 0, {0, 0, 0}, nullptr },  // QW_PUMPSRUNNING AT %QW3
    { LocatedArea::Output, LocatedSize::Word, 4, 0, {0, 0, 0}, nullptr },  // QW_SPEED AT %QW4
    { LocatedArea::Output, LocatedSize::Word, 5, 0, {0, 0, 0}, nullptr },  // QW_TIMETOSPILL AT %QW5
    { LocatedArea::Output, LocatedSize::Word, 6, 0, {0, 0, 0}, nullptr },  // QW_TIMETOLSHH AT %QW6
    { LocatedArea::Output, LocatedSize::Word, 7, 0, {0, 0, 0}, nullptr },  // QW_NETACCUM AT %QW7
    { LocatedArea::Output, LocatedSize::Word, 8, 0, {0, 0, 0}, nullptr },  // QW_RUNHOURS1 AT %QW8
    { LocatedArea::Output, LocatedSize::Word, 9, 0, {0, 0, 0}, nullptr },  // QW_RUNHOURS2 AT %QW9
    { LocatedArea::Output, LocatedSize::Word, 10, 0, {0, 0, 0}, nullptr },  // QW_RUNHOURS3 AT %QW10
    { LocatedArea::Output, LocatedSize::Word, 11, 0, {0, 0, 0}, nullptr },  // QW_VOLTOSPILL AT %QW11
    { LocatedArea::Output, LocatedSize::Word, 12, 0, {0, 0, 0}, nullptr },  // QW_STATIONSTATE AT %QW12
    { LocatedArea::Output, LocatedSize::Word, 13, 0, {0, 0, 0}, nullptr },  // QW_PUMPSTATE1 AT %QW13
    { LocatedArea::Output, LocatedSize::Word, 14, 0, {0, 0, 0}, nullptr },  // QW_PUMPSTATE2 AT %QW14
    { LocatedArea::Output, LocatedSize::Word, 15, 0, {0, 0, 0}, nullptr },  // QW_PUMPSTATE3 AT %QW15
    { LocatedArea::Output, LocatedSize::Word, 16, 0, {0, 0, 0}, nullptr },  // QW_DUTYPUMP AT %QW16
    { LocatedArea::Output, LocatedSize::Word, 17, 0, {0, 0, 0}, nullptr },  // QW_ALARMWORD AT %QW17
    { LocatedArea::Output, LocatedSize::Word, 20, 0, {0, 0, 0}, nullptr },  // QW_CMDACK AT %QW20
    { LocatedArea::Memory, LocatedSize::Word, 0, 0, {0, 0, 0}, nullptr },  // MW_MODE AT %MW0
    { LocatedArea::Memory, LocatedSize::Word, 1, 0, {0, 0, 0}, nullptr },  // MW_CMDWORD AT %MW1
    { LocatedArea::Memory, LocatedSize::Word, 2, 0, {0, 0, 0}, nullptr },  // MW_CMDPARAM AT %MW2
    { LocatedArea::Memory, LocatedSize::Word, 3, 0, {0, 0, 0}, nullptr },  // MW_SPLEVEL AT %MW3
    { LocatedArea::Memory, LocatedSize::Word, 4, 0, {0, 0, 0}, nullptr },  // MW_STARTDUTY AT %MW4
    { LocatedArea::Memory, LocatedSize::Word, 5, 0, {0, 0, 0}, nullptr },  // MW_STARTP2 AT %MW5
    { LocatedArea::Memory, LocatedSize::Word, 6, 0, {0, 0, 0}, nullptr },  // MW_STARTP3 AT %MW6
    { LocatedArea::Memory, LocatedSize::Word, 7, 0, {0, 0, 0}, nullptr },  // MW_STOPALL AT %MW7
    { LocatedArea::Memory, LocatedSize::Word, 8, 0, {0, 0, 0}, nullptr },  // MW_HIGHALARM AT %MW8
    { LocatedArea::Memory, LocatedSize::Word, 9, 0, {0, 0, 0}, nullptr },  // MW_MINSPEED AT %MW9
    { LocatedArea::Memory, LocatedSize::Word, 10, 0, {0, 0, 0}, nullptr },  // MW_SERVICEHRS AT %MW10
    { LocatedArea::Memory, LocatedSize::Word, 20, 0, {0, 0, 0}, nullptr },  // MW_SIMINFLOW AT %MW20
    { LocatedArea::Memory, LocatedSize::Word, 21, 0, {0, 0, 0}, nullptr },  // MW_SIMMODE AT %MW21
    { LocatedArea::Memory, LocatedSize::Word, 22, 0, {0, 0, 0}, nullptr },  // MW_SIMRESET AT %MW22
    { LocatedArea::Memory, LocatedSize::Word, 23, 0, {0, 0, 0}, nullptr }  // MW_SIMTIMESCALE AT %MW23
};

#ifdef STRUCPP_THREADED
// Canonical storage pointers of the located CONFIGURATION VAR_GLOBALs.
// Populated in the configuration constructor (like locatedVars[] above).
void *locatedGlobals[69] = {
    nullptr,  // IW_LIT101 AT %IW0
    nullptr,  // IW_FIT201 AT %IW1
    nullptr,  // IW_FIT301 AT %IW2
    nullptr,  // IW_PIT302 AT %IW3
    nullptr,  // IW_PIT311 AT %IW4
    nullptr,  // IW_PIT321 AT %IW5
    nullptr,  // IW_PIT331 AT %IW6
    nullptr,  // IW_VE314 AT %IW7
    nullptr,  // IW_VE324 AT %IW8
    nullptr,  // IW_VE334 AT %IW9
    nullptr,  // IX_LSHH102 AT %IX0.0
    nullptr,  // IX_LSLL103 AT %IX0.1
    nullptr,  // IX_LSH104 AT %IX0.2
    nullptr,  // IX_TE312 AT %IX0.3
    nullptr,  // IX_TE322 AT %IX0.4
    nullptr,  // IX_TE332 AT %IX0.5
    nullptr,  // IX_MSE313 AT %IX0.6
    nullptr,  // IX_MSE323 AT %IX0.7
    nullptr,  // IX_MSE333 AT %IX1.0
    nullptr,  // IX_XA502 AT %IX1.1
    nullptr,  // QX_RUNCMD1 AT %QX0.0
    nullptr,  // QX_RUNCMD2 AT %QX0.1
    nullptr,  // QX_RUNCMD3 AT %QX0.2
    nullptr,  // QX_RUNNING1 AT %QX0.3
    nullptr,  // QX_RUNNING2 AT %QX0.4
    nullptr,  // QX_RUNNING3 AT %QX0.5
    nullptr,  // QX_AVAIL1 AT %QX0.6
    nullptr,  // QX_AVAIL2 AT %QX0.7
    nullptr,  // QX_AVAIL3 AT %QX1.0
    nullptr,  // QX_INAUTO AT %QX1.1
    nullptr,  // QX_HIGHLEVEL AT %QX1.2
    nullptr,  // QX_SPILLACTIVE AT %QX1.3
    nullptr,  // QX_TRIPPED1 AT %QX1.4
    nullptr,  // QX_TRIPPED2 AT %QX1.5
    nullptr,  // QX_TRIPPED3 AT %QX1.6
    nullptr,  // QW_LEVEL AT %QW0
    nullptr,  // QW_INFLOW AT %QW1
    nullptr,  // QW_DISCHARGE AT %QW2
    nullptr,  // QW_PUMPSRUNNING AT %QW3
    nullptr,  // QW_SPEED AT %QW4
    nullptr,  // QW_TIMETOSPILL AT %QW5
    nullptr,  // QW_TIMETOLSHH AT %QW6
    nullptr,  // QW_NETACCUM AT %QW7
    nullptr,  // QW_RUNHOURS1 AT %QW8
    nullptr,  // QW_RUNHOURS2 AT %QW9
    nullptr,  // QW_RUNHOURS3 AT %QW10
    nullptr,  // QW_VOLTOSPILL AT %QW11
    nullptr,  // QW_STATIONSTATE AT %QW12
    nullptr,  // QW_PUMPSTATE1 AT %QW13
    nullptr,  // QW_PUMPSTATE2 AT %QW14
    nullptr,  // QW_PUMPSTATE3 AT %QW15
    nullptr,  // QW_DUTYPUMP AT %QW16
    nullptr,  // QW_ALARMWORD AT %QW17
    nullptr,  // QW_CMDACK AT %QW20
    nullptr,  // MW_MODE AT %MW0
    nullptr,  // MW_CMDWORD AT %MW1
    nullptr,  // MW_CMDPARAM AT %MW2
    nullptr,  // MW_SPLEVEL AT %MW3
    nullptr,  // MW_STARTDUTY AT %MW4
    nullptr,  // MW_STARTP2 AT %MW5
    nullptr,  // MW_STARTP3 AT %MW6
    nullptr,  // MW_STOPALL AT %MW7
    nullptr,  // MW_HIGHALARM AT %MW8
    nullptr,  // MW_MINSPEED AT %MW9
    nullptr,  // MW_SERVICEHRS AT %MW10
    nullptr,  // MW_SIMINFLOW AT %MW20
    nullptr,  // MW_SIMMODE AT %MW21
    nullptr,  // MW_SIMRESET AT %MW22
    nullptr  // MW_SIMTIMESCALE AT %MW23
};

// C linkage: a host runtime is built once and loads many .so files, so it
// cannot reach namespaced C++ symbols by mangled name portably.
extern "C" void *const *strucpp_get_located_globals(void) { return locatedGlobals; }
extern "C" uint32_t strucpp_get_located_global_count(void) { return locatedGlobalsCount; }
#endif  // STRUCPP_THREADED

Configuration_CONFIG0::Configuration_CONFIG0()
    : INST_SIM(&G_SIMCMD_INFLOW, &G_SIMCMD_MODE, &G_SIMCMD_RESET, &G_SIMCMD_TIMESCALE, &G_O_RUNCMD, &G_O_SPEED_X10, &G_SIMACTIVE, &G_SIM_CLEARRESET, &G_SIM_LEVEL_MM, &G_SIM_INFLOW_X10, &G_SIM_DISCH_X10, &G_SIM_MANIFOLDP, &G_SIM_PUMPP, &G_SIM_VIB_X10, &G_SIM_LSHH, &G_SIM_LSLL_WET, &G_SIM_SPILL, &G_SIM_THERMALOK, &G_SIM_SEALLEAK, &G_SIM_MAINSOK),INST_MUX(&IW_LIT101, &IW_FIT201, &IW_FIT301, &IW_PIT302, &IW_PIT311, &IW_PIT321, &IW_PIT331, &IW_VE314, &IW_VE324, &IW_VE334, &IX_LSHH102, &IX_LSLL103, &IX_LSH104, &IX_TE312, &IX_TE322, &IX_TE332, &IX_MSE313, &IX_MSE323, &IX_MSE333, &IX_XA502, &QX_RUNCMD1, &QX_RUNCMD2, &QX_RUNCMD3, &QX_RUNNING1, &QX_RUNNING2, &QX_RUNNING3, &QX_AVAIL1, &QX_AVAIL2, &QX_AVAIL3, &QX_INAUTO, &QX_HIGHLEVEL, &QX_SPILLACTIVE, &QX_TRIPPED1, &QX_TRIPPED2, &QX_TRIPPED3, &QW_LEVEL, &QW_INFLOW, &QW_DISCHARGE, &QW_PUMPSRUNNING, &QW_SPEED, &QW_TIMETOSPILL, &QW_TIMETOLSHH, &QW_NETACCUM, &QW_RUNHOURS1, &QW_RUNHOURS2, &QW_RUNHOURS3, &QW_VOLTOSPILL, &QW_STATIONSTATE, &QW_PUMPSTATE1, &QW_PUMPSTATE2, &QW_PUMPSTATE3, &QW_DUTYPUMP, &QW_ALARMWORD, &QW_CMDACK, &MW_MODE, &MW_CMDWORD, &MW_CMDPARAM, &MW_SPLEVEL, &MW_STARTDUTY, &MW_STARTP2, &MW_STARTP3, &MW_STOPALL, &MW_HIGHALARM, &MW_MINSPEED, &MW_SERVICEHRS, &MW_SIMINFLOW, &MW_SIMMODE, &MW_SIMRESET, &MW_SIMTIMESCALE, &G_LEVELRAW_MM, &G_LEVEL_MM, &G_LEVEL_M, &G_INFLOW_LPS, &G_DISCH_LPS, &G_MANIFOLDP_KPA, &G_PUMPP_KPA, &G_VIB_MMS, &G_LSHH, &G_LSLL_WET, &G_SPILLDETECTED, &G_THERMALOK, &G_SEALLEAK, &G_MAINSOK, &G_CMD_MODE, &G_CMD_WORD, &G_CMD_PARAM, &G_SP_LEVEL, &G_SP_STARTDUTY, &G_SP_STARTP2, &G_SP_STARTP3, &G_SP_STOPALL, &G_SP_HIGHALARM, &G_SP_MINSPEED, &G_SP_SERVICEHRS, &G_O_RUNCMD, &G_O_RUNNING, &G_O_AVAILABLE, &G_O_TRIPPED, &G_O_INAUTO, &G_O_HIGHLEVEL, &G_O_SPILLACTIVE, &G_O_LEVEL_MM, &G_O_INFLOW_X10, &G_O_DISCH_X10, &G_O_PUMPSRUN, &G_O_SPEED_X10, &G_O_TIMETOSPILL, &G_O_TIMETOLSHH, &G_O_NETACCUM, &G_O_RUNHOURS, &G_O_VOLTOSPILL, &G_O_STATIONSTATE, &G_O_PUMPSTATE, &G_O_DUTYPUMP, &G_O_ALARMWORD, &G_O_CMDACK, &DEF_MODE, &DEF_SP_LEVEL, &DEF_START_DUTY, &DEF_START_P2, &DEF_START_P3, &DEF_STOP_ALL, &DEF_HIGH_ALARM, &DEF_MIN_SPEED, &DEF_SERVICE_HRS, &G_SIMACTIVE, &G_SIM_CLEARRESET, &G_SIMCMD_INFLOW, &G_SIMCMD_MODE, &G_SIMCMD_RESET, &G_SIMCMD_TIMESCALE, &G_SIM_LEVEL_MM, &G_SIM_INFLOW_X10, &G_SIM_DISCH_X10, &G_SIM_MANIFOLDP, &G_SIM_PUMPP, &G_SIM_VIB_X10, &G_SIM_LSHH, &G_SIM_LSLL_WET, &G_SIM_SPILL, &G_SIM_THERMALOK, &G_SIM_SEALLEAK, &G_SIM_MAINSOK),INST_CTL(&G_LEVELRAW_MM, &G_LEVEL_MM, &G_LEVEL_M, &G_INFLOW_LPS, &G_DISCH_LPS, &G_PUMPP_KPA, &G_VIB_MMS, &G_LSHH, &G_LSLL_WET, &G_SPILLDETECTED, &G_THERMALOK, &G_SEALLEAK, &G_MAINSOK, &G_CMD_MODE, &G_CMD_WORD, &G_CMD_PARAM, &G_SP_LEVEL, &G_SP_STARTDUTY, &G_SP_STARTP2, &G_SP_STARTP3, &G_SP_STOPALL, &G_SP_HIGHALARM, &G_SP_MINSPEED, &G_SP_SERVICEHRS, &G_O_RUNCMD, &G_O_RUNNING, &G_O_AVAILABLE, &G_O_TRIPPED, &G_O_INAUTO, &G_O_HIGHLEVEL, &G_O_SPILLACTIVE, &G_O_LEVEL_MM, &G_O_INFLOW_X10, &G_O_DISCH_X10, &G_O_PUMPSRUN, &G_O_SPEED_X10, &G_O_TIMETOSPILL, &G_O_TIMETOLSHH, &G_O_NETACCUM, &G_O_RUNHOURS, &G_O_VOLTOSPILL, &G_O_STATIONSTATE, &G_O_PUMPSTATE, &G_O_DUTYPUMP, &G_O_ALARMWORD, &G_O_CMDACK)
{
    // Wire up tasks and resources
    task_programs_storage[0] = &INST_SIM;
    task_programs_storage[1] = &INST_MUX;
    task_programs_storage[2] = &INST_CTL;
    tasks_storage[0] = TaskInstance("PLC_TASK", 100000000LL, 0, &task_programs_storage[0], 3);
    resources_storage[0] = ResourceInstance("RES0", "PLC", &tasks_storage[0], 1);
    // Initialize located variable pointers
    locatedVars[0].pointer = IW_LIT101.value.raw_ptr();
    locatedVars[1].pointer = IW_FIT201.value.raw_ptr();
    locatedVars[2].pointer = IW_FIT301.value.raw_ptr();
    locatedVars[3].pointer = IW_PIT302.value.raw_ptr();
    locatedVars[4].pointer = IW_PIT311.value.raw_ptr();
    locatedVars[5].pointer = IW_PIT321.value.raw_ptr();
    locatedVars[6].pointer = IW_PIT331.value.raw_ptr();
    locatedVars[7].pointer = IW_VE314.value.raw_ptr();
    locatedVars[8].pointer = IW_VE324.value.raw_ptr();
    locatedVars[9].pointer = IW_VE334.value.raw_ptr();
    locatedVars[10].pointer = IX_LSHH102.value.raw_ptr();
    locatedVars[11].pointer = IX_LSLL103.value.raw_ptr();
    locatedVars[12].pointer = IX_LSH104.value.raw_ptr();
    locatedVars[13].pointer = IX_TE312.value.raw_ptr();
    locatedVars[14].pointer = IX_TE322.value.raw_ptr();
    locatedVars[15].pointer = IX_TE332.value.raw_ptr();
    locatedVars[16].pointer = IX_MSE313.value.raw_ptr();
    locatedVars[17].pointer = IX_MSE323.value.raw_ptr();
    locatedVars[18].pointer = IX_MSE333.value.raw_ptr();
    locatedVars[19].pointer = IX_XA502.value.raw_ptr();
    locatedVars[20].pointer = QX_RUNCMD1.value.raw_ptr();
    locatedVars[21].pointer = QX_RUNCMD2.value.raw_ptr();
    locatedVars[22].pointer = QX_RUNCMD3.value.raw_ptr();
    locatedVars[23].pointer = QX_RUNNING1.value.raw_ptr();
    locatedVars[24].pointer = QX_RUNNING2.value.raw_ptr();
    locatedVars[25].pointer = QX_RUNNING3.value.raw_ptr();
    locatedVars[26].pointer = QX_AVAIL1.value.raw_ptr();
    locatedVars[27].pointer = QX_AVAIL2.value.raw_ptr();
    locatedVars[28].pointer = QX_AVAIL3.value.raw_ptr();
    locatedVars[29].pointer = QX_INAUTO.value.raw_ptr();
    locatedVars[30].pointer = QX_HIGHLEVEL.value.raw_ptr();
    locatedVars[31].pointer = QX_SPILLACTIVE.value.raw_ptr();
    locatedVars[32].pointer = QX_TRIPPED1.value.raw_ptr();
    locatedVars[33].pointer = QX_TRIPPED2.value.raw_ptr();
    locatedVars[34].pointer = QX_TRIPPED3.value.raw_ptr();
    locatedVars[35].pointer = QW_LEVEL.value.raw_ptr();
    locatedVars[36].pointer = QW_INFLOW.value.raw_ptr();
    locatedVars[37].pointer = QW_DISCHARGE.value.raw_ptr();
    locatedVars[38].pointer = QW_PUMPSRUNNING.value.raw_ptr();
    locatedVars[39].pointer = QW_SPEED.value.raw_ptr();
    locatedVars[40].pointer = QW_TIMETOSPILL.value.raw_ptr();
    locatedVars[41].pointer = QW_TIMETOLSHH.value.raw_ptr();
    locatedVars[42].pointer = QW_NETACCUM.value.raw_ptr();
    locatedVars[43].pointer = QW_RUNHOURS1.value.raw_ptr();
    locatedVars[44].pointer = QW_RUNHOURS2.value.raw_ptr();
    locatedVars[45].pointer = QW_RUNHOURS3.value.raw_ptr();
    locatedVars[46].pointer = QW_VOLTOSPILL.value.raw_ptr();
    locatedVars[47].pointer = QW_STATIONSTATE.value.raw_ptr();
    locatedVars[48].pointer = QW_PUMPSTATE1.value.raw_ptr();
    locatedVars[49].pointer = QW_PUMPSTATE2.value.raw_ptr();
    locatedVars[50].pointer = QW_PUMPSTATE3.value.raw_ptr();
    locatedVars[51].pointer = QW_DUTYPUMP.value.raw_ptr();
    locatedVars[52].pointer = QW_ALARMWORD.value.raw_ptr();
    locatedVars[53].pointer = QW_CMDACK.value.raw_ptr();
    locatedVars[54].pointer = MW_MODE.value.raw_ptr();
    locatedVars[55].pointer = MW_CMDWORD.value.raw_ptr();
    locatedVars[56].pointer = MW_CMDPARAM.value.raw_ptr();
    locatedVars[57].pointer = MW_SPLEVEL.value.raw_ptr();
    locatedVars[58].pointer = MW_STARTDUTY.value.raw_ptr();
    locatedVars[59].pointer = MW_STARTP2.value.raw_ptr();
    locatedVars[60].pointer = MW_STARTP3.value.raw_ptr();
    locatedVars[61].pointer = MW_STOPALL.value.raw_ptr();
    locatedVars[62].pointer = MW_HIGHALARM.value.raw_ptr();
    locatedVars[63].pointer = MW_MINSPEED.value.raw_ptr();
    locatedVars[64].pointer = MW_SERVICEHRS.value.raw_ptr();
    locatedVars[65].pointer = MW_SIMINFLOW.value.raw_ptr();
    locatedVars[66].pointer = MW_SIMMODE.value.raw_ptr();
    locatedVars[67].pointer = MW_SIMRESET.value.raw_ptr();
    locatedVars[68].pointer = MW_SIMTIMESCALE.value.raw_ptr();
#ifdef STRUCPP_THREADED
    // Initialize located-global pointers
    locatedGlobals[0] = IW_LIT101.value.raw_ptr();
    locatedGlobals[1] = IW_FIT201.value.raw_ptr();
    locatedGlobals[2] = IW_FIT301.value.raw_ptr();
    locatedGlobals[3] = IW_PIT302.value.raw_ptr();
    locatedGlobals[4] = IW_PIT311.value.raw_ptr();
    locatedGlobals[5] = IW_PIT321.value.raw_ptr();
    locatedGlobals[6] = IW_PIT331.value.raw_ptr();
    locatedGlobals[7] = IW_VE314.value.raw_ptr();
    locatedGlobals[8] = IW_VE324.value.raw_ptr();
    locatedGlobals[9] = IW_VE334.value.raw_ptr();
    locatedGlobals[10] = IX_LSHH102.value.raw_ptr();
    locatedGlobals[11] = IX_LSLL103.value.raw_ptr();
    locatedGlobals[12] = IX_LSH104.value.raw_ptr();
    locatedGlobals[13] = IX_TE312.value.raw_ptr();
    locatedGlobals[14] = IX_TE322.value.raw_ptr();
    locatedGlobals[15] = IX_TE332.value.raw_ptr();
    locatedGlobals[16] = IX_MSE313.value.raw_ptr();
    locatedGlobals[17] = IX_MSE323.value.raw_ptr();
    locatedGlobals[18] = IX_MSE333.value.raw_ptr();
    locatedGlobals[19] = IX_XA502.value.raw_ptr();
    locatedGlobals[20] = QX_RUNCMD1.value.raw_ptr();
    locatedGlobals[21] = QX_RUNCMD2.value.raw_ptr();
    locatedGlobals[22] = QX_RUNCMD3.value.raw_ptr();
    locatedGlobals[23] = QX_RUNNING1.value.raw_ptr();
    locatedGlobals[24] = QX_RUNNING2.value.raw_ptr();
    locatedGlobals[25] = QX_RUNNING3.value.raw_ptr();
    locatedGlobals[26] = QX_AVAIL1.value.raw_ptr();
    locatedGlobals[27] = QX_AVAIL2.value.raw_ptr();
    locatedGlobals[28] = QX_AVAIL3.value.raw_ptr();
    locatedGlobals[29] = QX_INAUTO.value.raw_ptr();
    locatedGlobals[30] = QX_HIGHLEVEL.value.raw_ptr();
    locatedGlobals[31] = QX_SPILLACTIVE.value.raw_ptr();
    locatedGlobals[32] = QX_TRIPPED1.value.raw_ptr();
    locatedGlobals[33] = QX_TRIPPED2.value.raw_ptr();
    locatedGlobals[34] = QX_TRIPPED3.value.raw_ptr();
    locatedGlobals[35] = QW_LEVEL.value.raw_ptr();
    locatedGlobals[36] = QW_INFLOW.value.raw_ptr();
    locatedGlobals[37] = QW_DISCHARGE.value.raw_ptr();
    locatedGlobals[38] = QW_PUMPSRUNNING.value.raw_ptr();
    locatedGlobals[39] = QW_SPEED.value.raw_ptr();
    locatedGlobals[40] = QW_TIMETOSPILL.value.raw_ptr();
    locatedGlobals[41] = QW_TIMETOLSHH.value.raw_ptr();
    locatedGlobals[42] = QW_NETACCUM.value.raw_ptr();
    locatedGlobals[43] = QW_RUNHOURS1.value.raw_ptr();
    locatedGlobals[44] = QW_RUNHOURS2.value.raw_ptr();
    locatedGlobals[45] = QW_RUNHOURS3.value.raw_ptr();
    locatedGlobals[46] = QW_VOLTOSPILL.value.raw_ptr();
    locatedGlobals[47] = QW_STATIONSTATE.value.raw_ptr();
    locatedGlobals[48] = QW_PUMPSTATE1.value.raw_ptr();
    locatedGlobals[49] = QW_PUMPSTATE2.value.raw_ptr();
    locatedGlobals[50] = QW_PUMPSTATE3.value.raw_ptr();
    locatedGlobals[51] = QW_DUTYPUMP.value.raw_ptr();
    locatedGlobals[52] = QW_ALARMWORD.value.raw_ptr();
    locatedGlobals[53] = QW_CMDACK.value.raw_ptr();
    locatedGlobals[54] = MW_MODE.value.raw_ptr();
    locatedGlobals[55] = MW_CMDWORD.value.raw_ptr();
    locatedGlobals[56] = MW_CMDPARAM.value.raw_ptr();
    locatedGlobals[57] = MW_SPLEVEL.value.raw_ptr();
    locatedGlobals[58] = MW_STARTDUTY.value.raw_ptr();
    locatedGlobals[59] = MW_STARTP2.value.raw_ptr();
    locatedGlobals[60] = MW_STARTP3.value.raw_ptr();
    locatedGlobals[61] = MW_STOPALL.value.raw_ptr();
    locatedGlobals[62] = MW_HIGHALARM.value.raw_ptr();
    locatedGlobals[63] = MW_MINSPEED.value.raw_ptr();
    locatedGlobals[64] = MW_SERVICEHRS.value.raw_ptr();
    locatedGlobals[65] = MW_SIMINFLOW.value.raw_ptr();
    locatedGlobals[66] = MW_SIMMODE.value.raw_ptr();
    locatedGlobals[67] = MW_SIMRESET.value.raw_ptr();
    locatedGlobals[68] = MW_SIMTIMESCALE.value.raw_ptr();
#endif
}

const char* Configuration_CONFIG0::get_name() const {
    return "CONFIG0";
}

ResourceInstance* Configuration_CONFIG0::get_resources() {
    return resources_storage;
}

size_t Configuration_CONFIG0::get_resource_count() const {
    return 1;
}

}  // namespace strucpp