/**
 * @file JARampupGAM.h
 * @brief Header file for class JARampupGAM
 * @date Jan, 2019
 * @author rhari
 *
 * @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 JARampupGAM
 * 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_JARampupGAM_H_
#define GAMS_JARampupGAM_H_

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

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

#include "GAM.h"

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

/**
 * @brief GAM that rampup output value with specified target value and duration.
 *
 * The configuration syntax is (names and signal quantity are only given as an example):
 * <pre>
 *      +FHPSRampupGAM = {
 *         Class = JARampupGAM
 *         InputSignals = {
 *             Currspv = {
 *                 Alias = FHPS_REF
 *                 DataSource = DDB1
 *                 Type = float32
 *             }
 *             Targetv = {
 *                 Alias = FHPS_AUTO_TAGV
 *                 DataSource = EPICSCAInput
 *                 Type = float32
 *             }
 *             Time = {
 *                 Alias = FHPS_AUTO_TIME
 *                 DataSource = EPICSCAInput
 *                 Type = float32
 *             }
 *             Start = {
 *                 Alias = FHPS_AUTO_START
 *                 DataSource = EPICSCAInput
 *                 Type = uint32
 *             }
 *         }
 *         OutputSignals = {
 *             FHPS_REF = {
 *                 DataSource = DDB1
 *                 Type = float32
 *             }
 *         }
 *       }
 *  
 * </pre>
 * 
 */

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

    JARampupGAM();

    virtual ~JARampupGAM();

    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:
    // Input signal containing current current_setpoint
    MARTe::float32 *current_setpoint;

    // Input signal containing the frequency of the waveform.
    MARTe::float32 *target_value;

    // Input signal containing the amplitude of the waveform.
    MARTe::float32 *rampup_time;

    // Input signal containing CCPS_ON_REQUEST
    MARTe::uint32 *start;

    // Input signal PLC_STANDBY
    MARTe::uint32 *standby;

    // MANUAL AUTO button
    MARTe::uint32 *isAuto;

    // Input signal
    MARTe::float32 *FHPS_PrePro;

    // Output
    MARTe::float32 *output;
    // State output
    MARTe::uint32 *state; //0:NotOperation, 1:InOperation, 2:Finish, 3:Error

    // Internal variables
    MARTe::float32 rampup_rate;
    bool inRampup;
    bool resetFlag;
    bool inWaitHVON;
    bool inWaitStandby;

};



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

#endif /* GAMS_JARampupGAM_H_ */
