/**
 * @file JAWFRecordGAM.h
 * @brief Header file for class JAWFRecordGAM
 * @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 JAWFRecordGAM
 * 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_JAWFRECORDGAM_H_
#define GAMS_JAWFRECORDGAM_H_

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

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

#include "GAM.h"
#include "Message.h"

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

/**
 * @brief GAM that is used for pre-programmed operation.
 *
 * The configuration syntax is (names and signal quantity are only given as an example):
 * <pre>
 *       +WFRecordGAM = {
 *           Class = JAWFRecordGAM
 *           Directory = "../Configurations" 
 *           InputSignals = {
 *               CSV_LOAD = {
 *                   DataSource = EPICSCAInput
 *                   Type = uint32
 *               }
 *               Filename = {
 *                   Alias = CSV_NAME
 *                   DataSource = EPICSCAInput
 *               }
 *           }
 *           OutputSignals = {
 *               PREP_TIME_WF = {
 *                   DataSource = DDB1
 *               }
 * *             MHVPS_PREP_WF = {
 *                   DataSource = DDB1
 *               }
 *               BPS_PREP_WF = {
 *                   DataSource = DDB1
 *               }
 *               APS_PREP_WF = {
 *                   DataSource = DDB1
 *               }
 *               MCPS_PREP_WF = {
 *                   DataSource = DDB1
 *               }
 *               GCPS_PREP_WF = {
 *                   DataSource = DDB1
 *               }
 *               FHPS_PREP_WF = {
 *                   DataSource = DDB1
 *               }
 *           }
 *       }
 * </pre>
 * 
 */

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

    JAWFRecordGAM();

    virtual ~JAWFRecordGAM();

    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:
    void LoadFile();

    MARTe::uint32 filenameSignalIndex;

    MARTe::uint32 *loadTriggerSignal;

    MARTe::StreamString directory;

    MARTe::float32 **valueSignals;

    MARTe::int32 *timeSignal;

    MARTe::uint32 maxElements;

    // Flag determining whether file should be read (so it isn't read multiple time)
    bool readOnce;
};



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

#endif /* GAMS_JAWFRECORDGAM_H_ */
