/*
 * Siemens AG (R) Fuzzy-C Compiler Version 3.0.0
 *
 * Source file: "C:\SIEFUZZY\EXAMPLES\PEND\PENDEX.FPL"
 *
 * Compiled Thu Feb 10 15:00:33 1994
 *
 * Option settings
 * ---------------
 *   Belief type:                           fixed unsigned byte
 *   C format:                              ANSI
 *   Expression complexity:                 32767
 *   Default inference/defuz method (IDM):  Maxdot_Centroid
 *   Default lookup table size:             256
 *   Default public code:                   OFF
 *   Default dynamic init of USER/IDM:      OFF
 *   Emit lookup tables for members:        OFF
 *   Generate debug code:                   ON
 *   Maximum name length:                   40
 *   Emit unused members:                   OFF
 *   Verbose compiler messages:             ON
 *   Implement operators as functions:      OFF
 *   Error file:                            OFF
 *   Disable if on rule right hand side:    OFF
 *   Disable inline conclusions:            OFF
 *   Parameter structures:                  OFF
 *   Return rule alphas:                    OFF
 *   Output files base name:                pendexd
 */

/*
 * Portability definitions and internal structures.
 */

#define FCC_STDC_STYLE 1

#include <stdlib.h>
#include <math.h>
#include <fcdslib.h>
#include <online.h>
#include "pendexd.h"

FLOAT FCC_Integrator_Sum;

/*
 * Externally defined USER implementation functions
 */

static void Integrator_Init (void);

/*
 * Initializes all statically initialized user-defined objects and IDMs
 */

void FCC_user_init(void)
{
    Integrator_Init ();
}

const FCC_OPPTRTB FCC_debug_ops[] = {
    FCCtandb,
    FCCtorb,
    FCCtdpb,
    FCCtdsb,
    FCCtbdb,
    FCCtbsb,
    FCCtepb,
    FCCtesb,
    FCCtapb,
    FCCtasb,
    FCCthpb,
    FCCthsb
};

/*
 * VAR Error
 */

/*
 * MEMBER N
 */

static struct FCCptfb FCC_Error_N_pts[] = {
    { -1.00000000000, 255u },
    { -0.400000000000, 255u },
    { 0.000000000000, 0u },
    { 0.000000000000, 0u },
    { 0.000000000000, 0u }
};

/*
 * MEMBER Z
 */

static struct FCCptfb FCC_Error_Z_pts[] = {
    { -0.400000000000, 0u },
    { 0.000000000000, 255u },
    { 0.400000000000, 0u },
    { 0.400000000000, 0u },
    { 0.400000000000, 0u }
};

/*
 * MEMBER P
 */

static struct FCCptfb FCC_Error_P_pts[] = {
    { 0.000000000000, 0u },
    { 0.400000000000, 255u },
    { 1.00000000000, 255u },
    { 1.00000000000, 255u },
    { 1.00000000000, 255u }
};

/*
 * VAR dError
 */

/*
 * MEMBER N
 */

static struct FCCptfb FCC_dError_N_pts[] = {
    { -1.00000000000, 255u },
    { -0.400000000000, 255u },
    { 0.000000000000, 0u },
    { 0.000000000000, 0u },
    { 0.000000000000, 0u }
};

/*
 * MEMBER Z
 */

static struct FCCptfb FCC_dError_Z_pts[] = {
    { -0.400000000000, 0u },
    { 0.000000000000, 255u },
    { 0.400000000000, 0u },
    { 0.400000000000, 0u },
    { 0.400000000000, 0u }
};

/*
 * MEMBER P
 */

static struct FCCptfb FCC_dError_P_pts[] = {
    { 0.000000000000, 0u },
    { 0.400000000000, 255u },
    { 1.00000000000, 255u },
    { 1.00000000000, 255u },
    { 1.00000000000, 255u }
};

/*
 * VAR Current
 */

/*
 * MEMBER Z
 */

/*
 *    moment: 0
 *      area: 0.525
 *  centroid: 0
 *    height: 1
 * hcentroid: 0
 */

static struct FCCif FCC_Current_Z_info = { 0.000000000000, 133.875000000 };

/*
 * MEMBER NB
 */

/*
 *    moment: -0.4996875
 *      area: 0.4875
 *  centroid: -1.025
 *    height: 1
 * hcentroid: -1.025
 */

static struct FCCif FCC_Current_NB_info = { -127.420312500, 124.312500000 };

/*
 * MEMBER PB
 */

/*
 *    moment: 0.4996875
 *      area: 0.4875
 *  centroid: 1.025
 *    height: 1
 * hcentroid: 1.025
 */

static struct FCCif FCC_Current_PB_info = { 127.420312500, 124.312500000 };

/*
 * MEMBER PS
 */

/*
 *    moment: 0.401625
 *      area: 0.525
 *  centroid: 0.765
 *    height: 1
 * hcentroid: 0.765
 */

static struct FCCif FCC_Current_PS_info = { 102.414375000, 133.875000000 };

/*
 * MEMBER NS
 */

/*
 *    moment: -0.401625
 *      area: 0.525
 *  centroid: -0.765
 *    height: 1
 * hcentroid: -0.765
 */

static struct FCCif FCC_Current_NS_info = { -102.414375000, 133.875000000 };

/*
 * VAR IntegralError
 */

/*
 * DEBUG information
 */

extern ULONG FCC_online_iteration;
extern UWORD FCC_samples_per_autosend;
extern UBYTE FCC_fp_precision;
extern ULONG FCC_error_info[];
extern UBYTE FCC_online_flags;
extern UWORD FCC_capture_bufsize;
extern UWORD FCC_post_trigger;

struct
{
    UWORD FCC_no_items;
    UBYTE FCC_version[96];
    ULONG FCC_change_id;
    UWORD FCC_capture_trigger[12];
    FLOAT Error;
    FUBYTE FCC_Error_is_N;
    FUBYTE FCC_Error_is_Z;
    FUBYTE FCC_Error_is_P;
    FLOAT dError;
    FUBYTE FCC_dError_is_N;
    FUBYTE FCC_dError_is_Z;
    FUBYTE FCC_dError_is_P;
    FLOAT Current;
    FLOAT IntegralError;
    UBYTE Pendulum;
    FUBYTE FCC_Pendulum_er1;
    FUBYTE FCC_Pendulum_er1w;
    UWORD FCC_Pendulum_er1p1;
    UWORD FCC_Pendulum_er1i1;
    UWORD FCC_Pendulum_er1i2;
    UWORD FCC_Pendulum_er1o1;
    FUBYTE FCC_Pendulum_er2;
    FUBYTE FCC_Pendulum_er2w;
    UWORD FCC_Pendulum_er2p1;
    UWORD FCC_Pendulum_er2i1;
    UWORD FCC_Pendulum_er2i2;
    UWORD FCC_Pendulum_er2o1;
    FUBYTE Rule1;
    FUBYTE FCC_Rule1_w;
    FUBYTE Rule2;
    FUBYTE FCC_Rule2_w;
    FUBYTE Rule3;
    FUBYTE FCC_Rule3_w;
    FUBYTE Rule4;
    FUBYTE FCC_Rule4_w;
    FUBYTE Rule5;
    FUBYTE FCC_Rule5_w;
    FUBYTE Rule6;
    FUBYTE FCC_Rule6_w;
    FUBYTE Rule7;
    FUBYTE FCC_Rule7_w;
    FLOAT FCC_const0;
    FLOAT FCC_const1;
    FLOAT FCC_const2;
    FLOAT FCC_const3;
} FCC_debug_values =
{
    65,
    "Target Online Debugging Environment V1.0.0\nCopyright (c) 1993 Siemens AG.  All rights reserved.",
    2757852496,
    { 0 },
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    255,
    0,
    255,
    0,
    255,
    0,
    51,
    0,
    255,
    0,
    255,
    0,
    255,
    0,
    0,
    0,
    0,
};

DTITEM FCC_debug_table[] = {
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1, &FCC_debug_values.FCC_no_items
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_ARRAY, 0, IO_UBYTE, IO_FLOAT, 96, FCC_debug_values.FCC_version
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_ULONG, IO_FLOAT, 1, &FCC_debug_values.FCC_change_id
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_ULONG, IO_FLOAT, 1, &FCC_online_iteration
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1, &FCC_samples_per_autosend
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_UBYTE, IO_FLOAT, 1, &FCC_fp_precision
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_ARRAY, 0, IO_ULONG, IO_FLOAT, 6, FCC_error_info
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_UBYTE, IO_FLOAT, 1, &FCC_online_flags
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1, &FCC_capture_bufsize
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_ARRAY, 0, IO_UWORD, IO_FLOAT, 12, FCC_debug_values.FCC_capture_trigger
        },
    { ONLINE_TYPE_SPECIAL, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1, &FCC_post_trigger
        },
    { ONLINE_TYPE_VAR, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.Error
        },
    { ONLINE_TYPE_IMBF_TRUTH, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Error_is_N },
    { ONLINE_TYPE_PLIST, ONLINE_CLASS_PLIST, 0, IO_FLOAT, IO_FUBYTE, 5, FCC_Error_N_pts
        },
    { ONLINE_TYPE_IMBF_TRUTH, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Error_is_Z },
    { ONLINE_TYPE_PLIST, ONLINE_CLASS_PLIST, 0, IO_FLOAT, IO_FUBYTE, 5, FCC_Error_Z_pts
        },
    { ONLINE_TYPE_IMBF_TRUTH, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Error_is_P },
    { ONLINE_TYPE_PLIST, ONLINE_CLASS_PLIST, 0, IO_FLOAT, IO_FUBYTE, 5, FCC_Error_P_pts
        },
    { ONLINE_TYPE_VAR, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.dError
        },
    { ONLINE_TYPE_IMBF_TRUTH, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1,
        &FCC_debug_values.FCC_dError_is_N },
    { ONLINE_TYPE_PLIST, ONLINE_CLASS_PLIST, 0, IO_FLOAT, IO_FUBYTE, 5, FCC_dError_N_pts
        },
    { ONLINE_TYPE_IMBF_TRUTH, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1,
        &FCC_debug_values.FCC_dError_is_Z },
    { ONLINE_TYPE_PLIST, ONLINE_CLASS_PLIST, 0, IO_FLOAT, IO_FUBYTE, 5, FCC_dError_Z_pts
        },
    { ONLINE_TYPE_IMBF_TRUTH, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1,
        &FCC_debug_values.FCC_dError_is_P },
    { ONLINE_TYPE_PLIST, ONLINE_CLASS_PLIST, 0, IO_FLOAT, IO_FUBYTE, 5, FCC_dError_P_pts
        },
    { ONLINE_TYPE_VAR, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.Current
        },
    { ONLINE_TYPE_MATHINFOF, ONLINE_CLASS_ARRAY, 0, IO_FLOAT, IO_FLOAT, 2, &FCC_Current_Z_info
        },
    { ONLINE_TYPE_MATHINFOF, ONLINE_CLASS_ARRAY, 0, IO_FLOAT, IO_FLOAT, 2, &FCC_Current_NB_info
        },
    { ONLINE_TYPE_MATHINFOF, ONLINE_CLASS_ARRAY, 0, IO_FLOAT, IO_FLOAT, 2, &FCC_Current_PB_info
        },
    { ONLINE_TYPE_MATHINFOF, ONLINE_CLASS_ARRAY, 0, IO_FLOAT, IO_FLOAT, 2, &FCC_Current_PS_info
        },
    { ONLINE_TYPE_MATHINFOF, ONLINE_CLASS_ARRAY, 0, IO_FLOAT, IO_FLOAT, 2, &FCC_Current_NS_info
        },
    { ONLINE_TYPE_VAR, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.IntegralError
        },
    { ONLINE_TYPE_RULEBASE, ONLINE_CLASS_SCALAR, 0, IO_UBYTE, IO_FLOAT, 1, &FCC_debug_values.Pendulum
        },
    { ONLINE_TYPE_UNUSED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.FCC_Pendulum_er1 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Pendulum_er1w
        },
    { ONLINE_TYPE_OP_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1, &FCC_debug_values.FCC_Pendulum_er1p1
        },
    { ONLINE_TYPE_IMBF_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Pendulum_er1i1 },
    { ONLINE_TYPE_IMBF_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Pendulum_er1i2 },
    { ONLINE_TYPE_OMBF_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Pendulum_er1o1 },
    { ONLINE_TYPE_UNUSED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.FCC_Pendulum_er2 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Pendulum_er2w
        },
    { ONLINE_TYPE_OP_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1, &FCC_debug_values.FCC_Pendulum_er2p1
        },
    { ONLINE_TYPE_IMBF_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Pendulum_er2i1 },
    { ONLINE_TYPE_IMBF_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Pendulum_er2i2 },
    { ONLINE_TYPE_OMBF_INDEX, ONLINE_CLASS_SCALAR, 0, IO_UWORD, IO_FLOAT, 1,
        &FCC_debug_values.FCC_Pendulum_er2o1 },
    { ONLINE_TYPE_FIXED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.Rule1 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Rule1_w
        },
    { ONLINE_TYPE_FIXED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.Rule2 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Rule2_w
        },
    { ONLINE_TYPE_FIXED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.Rule3 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Rule3_w
        },
    { ONLINE_TYPE_FIXED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.Rule4 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Rule4_w
        },
    { ONLINE_TYPE_FIXED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.Rule5 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Rule5_w
        },
    { ONLINE_TYPE_FIXED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.Rule6 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Rule6_w
        },
    { ONLINE_TYPE_FIXED_PREMISE, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT,
        1, &FCC_debug_values.Rule7 },
    { ONLINE_TYPE_WEIGHT, ONLINE_CLASS_SCALAR, 0, IO_FUBYTE, IO_FLOAT, 1, &FCC_debug_values.FCC_Rule7_w
        },
    { ONLINE_TYPE_UNUSED_OTHER, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 0,
        (void *) 0 },
    { ONLINE_TYPE_UNUSED_OTHER, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 0,
        (void *) 0 },
    { ONLINE_TYPE_CONSTANT, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.FCC_const0
        },
    { ONLINE_TYPE_CONSTANT, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.FCC_const1
        },
    { ONLINE_TYPE_CONSTANT, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.FCC_const2
        },
    { ONLINE_TYPE_CONSTANT, ONLINE_CLASS_SCALAR, 0, IO_FLOAT, IO_FLOAT, 1, &FCC_debug_values.FCC_const3
        },
};

/*
 * FPL objects.
 */

/*
 * RULEBASE Pendulum
 */

static void Pendulum (FLOAT Error, FLOAT dError, FLOAT *Current);

static void Pendulum (FLOAT Error, FLOAT dError, FLOAT *Current)
{

    FUBYTE FCC_alpha;
    FUBYTE FCC_Error_is_N;
    FUBYTE FCC_Error_is_Z;
    FUBYTE FCC_Error_is_P;
    FUBYTE FCC_dError_is_N;
    FUBYTE FCC_dError_is_Z;
    FUBYTE FCC_dError_is_P;
    struct FCCif FCC_Current_temp;

    FCC_Current_temp.n = 0.0;
    FCC_Current_temp.d = 0.0;

    FCC_debug_values.Pendulum = 0;

    FCC_Error_is_N = FCCpfb (Error, 5, FCC_Error_N_pts);
    FCC_debug_values.FCC_Error_is_N = FCC_Error_is_N;
    FCC_Error_is_Z = FCCpfb (Error, 5, FCC_Error_Z_pts);
    FCC_debug_values.FCC_Error_is_Z = FCC_Error_is_Z;
    FCC_Error_is_P = FCCpfb (Error, 5, FCC_Error_P_pts);
    FCC_debug_values.FCC_Error_is_P = FCC_Error_is_P;
    FCC_dError_is_N = FCCpfb (dError, 5, FCC_dError_N_pts);
    FCC_debug_values.FCC_dError_is_N = FCC_dError_is_N;
    FCC_dError_is_Z = FCCpfb (dError, 5, FCC_dError_Z_pts);
    FCC_debug_values.FCC_dError_is_Z = FCC_dError_is_Z;
    FCC_dError_is_P = FCCpfb (dError, 5, FCC_dError_P_pts);
    FCC_debug_values.FCC_dError_is_P = FCC_dError_is_P;

/*
 * RULE Rule1
 */

    if (FCC_debug_values.FCC_Rule1_w != 0)
    {
        FCC_alpha = FCCmandb(FCC_Error_is_N,FCC_dError_is_Z);
        FCC_debug_values.Rule1 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            /* Current = PB */

            FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule1_w)
                * FCC_Current_PB_info.n;
            FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule1_w)
                * FCC_Current_PB_info.d;
        }
    }
    else
        FCC_debug_values.Rule1 = 0u;

/*
 * RULE Rule2
 */

    if (FCC_debug_values.FCC_Rule2_w != 0)
    {
        FCC_alpha = FCCmandb(FCC_Error_is_N,FCC_dError_is_P);
        FCC_debug_values.Rule2 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            /* Current = PS */

            FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule2_w)
                * FCC_Current_PS_info.n;
            FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule2_w)
                * FCC_Current_PS_info.d;
        }
    }
    else
        FCC_debug_values.Rule2 = 0u;

/*
 * RULE Rule3
 */

    if (FCC_debug_values.FCC_Rule3_w != 0)
    {
        FCC_alpha = FCCmandb(FCC_Error_is_Z,FCC_dError_is_P);
        FCC_debug_values.Rule3 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            /* Current = NS */

            FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule3_w)
                * FCC_Current_NS_info.n;
            FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule3_w)
                * FCC_Current_NS_info.d;
        }
    }
    else
        FCC_debug_values.Rule3 = 0u;

/*
 * RULE Rule4
 */

    if (FCC_debug_values.FCC_Rule4_w != 0)
    {
        FCC_alpha = FCCmandb(FCC_Error_is_Z,FCC_dError_is_Z);
        FCC_debug_values.Rule4 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            /* Current = Z */

            FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule4_w)
                * FCC_Current_Z_info.n;
            FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule4_w)
                * FCC_Current_Z_info.d;
        }
    }
    else
        FCC_debug_values.Rule4 = 0u;

/*
 * RULE Rule5
 */

    if (FCC_debug_values.FCC_Rule5_w != 0)
    {
        FCC_alpha = FCCmandb(FCC_Error_is_Z,FCC_dError_is_N);
        FCC_debug_values.Rule5 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            /* Current = PS */

            FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule5_w)
                * FCC_Current_PS_info.n;
            FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule5_w)
                * FCC_Current_PS_info.d;
        }
    }
    else
        FCC_debug_values.Rule5 = 0u;

/*
 * RULE Rule6
 */

    if (FCC_debug_values.FCC_Rule6_w != 0)
    {
        FCC_alpha = FCCmandb(FCC_Error_is_P,FCC_dError_is_N);
        FCC_debug_values.Rule6 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            /* Current = NS */

            FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule6_w)
                * FCC_Current_NS_info.n;
            FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule6_w)
                * FCC_Current_NS_info.d;
        }
    }
    else
        FCC_debug_values.Rule6 = 0u;

/*
 * RULE Rule7
 */

    if (FCC_debug_values.FCC_Rule7_w != 0)
    {
        FCC_alpha = FCCmandb(FCC_Error_is_P,FCC_dError_is_Z);
        FCC_debug_values.Rule7 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            /* Current = NB */

            FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule7_w)
                * FCC_Current_NB_info.n;
            FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Rule7_w)
                * FCC_Current_NB_info.d;
        }
    }
    else
        FCC_debug_values.Rule7 = 0u;

/*
 * Extra RULE FCC_debug_values.FCC_Pendulum_er1
 */

    if (FCC_debug_values.FCC_Pendulum_er1w != 0)
    {
        FCC_alpha = *((FUBYTE *) FCC_debug_table[FCC_debug_values.FCC_Pendulum_er1i1].addr);

        if (FCC_debug_values.FCC_Pendulum_er1i2 != 0)
            FCC_alpha = (*FCC_debug_ops[FCC_debug_values.FCC_Pendulum_er1p1])(FCC_alpha,
                     *((FUBYTE *) FCC_debug_table[FCC_debug_values.FCC_Pendulum_er1i2].addr));

        FCC_debug_values.FCC_Pendulum_er1 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            if (FCC_debug_values.FCC_Pendulum_er1o1 != 0)
            {
                /* Current = ??? */

                FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Pendulum_er1w)
                    * ((struct FCCif *) (FCC_debug_table[FCC_debug_values.FCC_Pendulum_er1o1].addr))->n;
                FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Pendulum_er1w)
                    * ((struct FCCif *) (FCC_debug_table[FCC_debug_values.FCC_Pendulum_er1o1].addr))->d;
            }
        }
    }
    else
        FCC_debug_values.FCC_Pendulum_er1 = 0u;

/*
 * Extra RULE FCC_debug_values.FCC_Pendulum_er2
 */

    if (FCC_debug_values.FCC_Pendulum_er2w != 0)
    {
        FCC_alpha = *((FUBYTE *) FCC_debug_table[FCC_debug_values.FCC_Pendulum_er2i1].addr);

        if (FCC_debug_values.FCC_Pendulum_er2i2 != 0)
            FCC_alpha = (*FCC_debug_ops[FCC_debug_values.FCC_Pendulum_er2p1])(FCC_alpha,
                     *((FUBYTE *) FCC_debug_table[FCC_debug_values.FCC_Pendulum_er2i2].addr));

        FCC_debug_values.FCC_Pendulum_er2 = FCC_alpha;

        if (FCC_alpha != 0u)
        {
            FCC_debug_values.Pendulum++;

            if (FCC_debug_values.FCC_Pendulum_er2o1 != 0)
            {
                /* Current = ??? */

                FCC_Current_temp.n += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Pendulum_er2w)
                    * ((struct FCCif *) (FCC_debug_table[FCC_debug_values.FCC_Pendulum_er2o1].addr))->n;
                FCC_Current_temp.d += FCC_alpha * ((FLOAT) FCC_debug_values.FCC_Pendulum_er2w)
                    * ((struct FCCif *) (FCC_debug_table[FCC_debug_values.FCC_Pendulum_er2o1].addr))->d;
            }
        }
    }
    else
        FCC_debug_values.FCC_Pendulum_er2 = 0u;

    if (FCC_Current_temp.d != 0.000000000000)
        *Current = (FCC_Current_temp.n / FCC_Current_temp.d);
    else
        *Current = 0.000000000000;
}

/*
 * PROCUNIT Integrator
 */

static void Integrator_Init(void)
{
    FCC_Integrator_Sum = 0.000000000000;
}

static void Integrator (FLOAT Error, FLOAT *IntegralError);

static void Integrator (FLOAT Error, FLOAT *IntegralError)
{

    FCC_Integrator_Sum = (FCC_Integrator_Sum)+(Error);
    *IntegralError = FCC_Integrator_Sum;
}

/*
 * PROJECT Pend
 */

void Pend (FLOAT Error, FLOAT dError, FLOAT *Current, FLOAT *IntegralError)
{

    FCC_debug_values.Error = Error;
    FCC_debug_values.dError = dError;

/*
 * RULEBASE Pendulum
 */

    Pendulum (Error, dError, Current);

/*
 * PROCUNIT Integrator
 */

    Integrator (Error, IntegralError);

    FCC_debug_values.Current = *Current;
    FCC_debug_values.IntegralError = *IntegralError;
}

