#ifndef LEARN_AT____LEARN____ENVIRONMENT_HPP_
#define LEARN_AT____LEARN____ENVIRONMENT_HPP_

// /home/siemens/bip/examples/sync_lec/learn.bip:26:1
// include package "master" header
#include <learn.hpp>

#include <Atom.hpp>

// User include given in @cpp annotation
#include <utilities.hpp>

#include <learn/AtomIPort__learn__silent.hpp>
#include <learn/AtomIPort__learn__intPort.hpp>


#include <learn/AtomEPort__learn__silent.hpp>
#include <learn/AtomEPort__learn__intPort.hpp>

#include <learn/PV__learn__intPort.hpp>
#include <learn/PV__learn__silent.hpp>



class AT__learn__Environment : public Atom {
private:
   // internal ports & associated port values
    AtomIPort__learn__intPort &_iport_decl__sendInput;
    PV__learn__intPort _iport_decl_pv__sendInput;
    AtomIPort__learn__silent &_iport_decl__getInput;
    PV__learn__silent _iport_decl_pv__getInput;
    AtomIPort__learn__silent &_iport_decl__getInputInitial;
    PV__learn__silent _iport_decl_pv__getInputInitial;
    AtomIPort__learn__silent &_iport_decl__noInput;
    PV__learn__silent _iport_decl_pv__noInput;

    // exported ports
    AtomEPort__learn__intPort &_eport_decl__sendInput;
    AtomEPort__learn__silent &_eport_decl__getInput;
    AtomEPort__learn__silent &_eport_decl__getInputInitial;
    AtomEPort__learn__silent &_eport_decl__noInput;
public:
    AT__learn__Environment(const string &name , AtomIPort__learn__intPort &_iport_decl__sendInput, AtomIPort__learn__silent &_iport_decl__getInput, AtomIPort__learn__silent &_iport_decl__getInputInitial, AtomIPort__learn__silent &_iport_decl__noInput
                             
                             , AtomEPort__learn__intPort &_eport_decl__sendInput, AtomEPort__learn__silent &_eport_decl__getInput, AtomEPort__learn__silent &_eport_decl__getInputInitial, AtomEPort__learn__silent &_eport_decl__noInput
                             
                             );
    virtual ~AT__learn__Environment();

    virtual BipError& execute(PortValue &portValue);
    virtual BipError& execute(AtomExternalPort &portValue);
    virtual BipError& initialize();
    virtual string toString() const;

protected:
    BipError& update();

    BipError& executeInternalTransitions();
    BipError& checkInvariants();

    const static size_t bvector_size = 3/(8*sizeof(int))+((3%(8*sizeof(int))) > 0 ? 1 : 0);
    int __statesbv[ bvector_size ];

    // component data declarations
    int _id__inputIndex;
    int _id__time;

    // enabledness of transitions
    bool _transguard__1;
    bool _transguard__2;
    bool _transguard__3;
    bool _transguard__4;

    // index of the latest executed transition
    int __previous;

    bool atIdle() const;
    bool toIdle();
    bool fromIdle();
    bool atRead() const;
    bool toRead();
    bool fromRead();
    bool atStop() const;
    bool toStop();
    bool fromStop();
};

#endif // LEARN_AT____LEARN____ENVIRONMENT_HPP_
