/**
 * @file JATerminalInterfaceGAM.h
 * @brief Header file for class JATerminalInterfaceGAM
 * @date Feb 19, 2020
 * @author kuchida
 *
 * @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
 * the Development of Fusion Energy ('Fusion for Energy').
 * Licensed under the EUPL, Version 1.1 or - as soon they will be approved
 * by the European Commission - subsequent versions of the EUPL (the "Licence")
 * You may not use this work except in compliance with the Licence.
 * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
 *
 * @warning Unless required by applicable law or agreed to in writing,
 * software distributed under the Licence is distributed on an "AS IS"
 * basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the Licence permissions and limitations under the Licence.

 * @details This header file contains the declaration of the class JATerminalInterfaceGAM
 * with all of its public, protected and private members. It may also include
 * definitions for inline methods which need to be visible to the compiler.
 */

#ifndef GAMS_JATerminalInterfaceGAM_H_
#define GAMS_JATerminalInterfaceGAM_H_

/*---------------------------------------------------------------------------*/
/*                        Standard header includes                           */
/*---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------*/
/*                        Project header includes                            */
/*---------------------------------------------------------------------------*/

#include "GAM.h"

/*---------------------------------------------------------------------------*/
/*                           Class declaration                               */
/*---------------------------------------------------------------------------*/

/**
 * @brief GAM calculates one output value by comparing input value and fixed parameters.
 *
 * The configuration syntax is (names and signal quantity are only given as an example):
 * <pre>
 * 
 *         +terminalInterfaceGAM = {
 *           Class = JATerminalInterfaceGAM
 *           mhvps_hvon_term = 4
 *           aps_hvon_term = 1
 *           aps_swon_term = 16
 *           bps_hvon_term = 2
 *           bps_swon_term = 8
 *           InputSignals = {
 *               MHVPS_HVON = {
 *                   DataSource = DDB1
 *                   Type = uint32
 *               }
 *               APS_HVON = {
 *                   DataSource = DDB1
 *                   Type = uint32
 *               }
 *               APS_SWON = {
 *                   DataSource = DDB1
 *                   Type = uint32
 *               }
 *               BPS_HVON = {
 *                   DataSource = DDB1
 *                   Type = uint32
 *               }
 *               BPS_SWON = {
 *                   DataSource = DDB1
 *                   Type = uint32
 *               }
 *               Value = {
 *                   DataSource = DDB1
 *                   Type = uint32
 *               }
 *           }
 *           OutputSignals = {
 *               Value = {
 *                   DataSource = NI6259
 *                   Type = uint32
 *                   Trigger = 1
 *               }
 *           }
 *       }
 * 
 * </pre>
 * 
 */

class JATerminalInterfaceGAM : public MARTe::GAM, public MARTe::StatefulI {
public:
    CLASS_REGISTER_DECLARATION()

    JATerminalInterfaceGAM();

    virtual ~JATerminalInterfaceGAM();

    virtual bool Initialise(MARTe::StructuredDataI & data);

    virtual bool Setup();

    virtual bool Execute();

    virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
                                  const MARTe::char8 * const nextStateName);

private:
    // Fixed GAM input
    MARTe::uint32 mhvps_hvon_term;
    MARTe::uint32 aps_hvon_term;
    MARTe::uint32 aps_swon_term;
    MARTe::uint32 bps_hvon_term;
    MARTe::uint32 bps_swon_term;

    // Input signals
    //MARTe::uint32 *mhvps_manm;
    MARTe::uint32 *mhvps_hvon;

    //MARTe::uint32 *aps_manm;
    MARTe::uint32 *aps_hvon;
    MARTe::uint32 *aps_swon;

    //MARTe::uint32 *bps_manm;
    MARTe::uint32 *bps_hvon;
    MARTe::uint32 *bps_swon;

    MARTe::uint32 *short_pulse_mode;

    MARTe::uint32 *stateMachineOutput;
    MARTe::uint8 *ni6528p3Value;
    MARTe::uint8 *ni6528p4Value;

    // Output signals
    MARTe::uint32 *outputSignalNI6259; 
    MARTe::uint8 *outputSignalNI6528P3;
    MARTe::uint8 *outputSignalNI6528P4;

    MARTe::uint8 aps_hvon_state;
    MARTe::uint8 aps_swon_state;
    MARTe::uint8 mhvps_hvon_state;
    MARTe::uint8 bps_hvon_state;
    MARTe::uint8 bps_swon_state;
    MARTe::uint8 p3Value;
    MARTe::uint8 p4Value;

};



/*---------------------------------------------------------------------------*/
/*                        Inline method definitions                          */
/*---------------------------------------------------------------------------*/

#endif /* GAMS_JATerminalInterfaceGAM_H_ */
