#ifndef ANTENNASIMULATOR_H
#define ANTENNASIMULATOR_H

#include <QObject>
//#include "datatypes.h"

class AntennaSimulator: public QObject
{
    Q_OBJECT

public:
    enum number_of_bars_t
    {
        _1bars=1,
        _2bars=2,
        _4bars=4,

        NUMBER_OF_BARS_T_MAX=6
    };

    typedef float radians_t;
    typedef float radians_per_sec_t;
    typedef unsigned long timetag_t;
    typedef unsigned int bar_number_t;

    typedef struct {
        float            scanWidth;
        float            elCoverage;
        float            scanRate;
        number_of_bars_t nbars;
    } antennaCfg_t;

    typedef struct {
        number_of_bars_t  numBars;
        radians_per_sec_t scanRate;
        radians_t         scanWidth;
        radians_t         barElevation[NUMBER_OF_BARS_T_MAX]; // max 4 bars
    } antennaParam_t;

    typedef enum _scanStatus_t_ {
        idle,
        scanBar1,
        scanBar2,
        scanBar3,
        scanBar4,
        positioningToBar1,
        positioningToBar2,
        positioningToBar3,
        positioningToBar4
    } scanStatus_t;

    typedef struct {
        timetag_t    updateTime;
        scanStatus_t scanStatus;
        radians_t    azimuth;
        radians_t    elevation;
        bar_number_t barNumber;
        bool         frameInProg;
        bool         barInProg;
    } antennaStatus_t;

    typedef enum {
        simIdle,
        simRunning,
        simStopping,
        simStopped
    } simStatus_t;

    explicit AntennaSimulator(QObject *parent = 0);
    ~AntennaSimulator();

    void            initialize(const antennaCfg_t& antCfg);
    void            execute(timetag_t ttag);
    void            getStatus(antennaStatus_t& antStatus);
    void            setSimStatus(simStatus_t status);
    void            setElevation(radians_t elevation);
    simStatus_t&    getSimStatus();
    antennaParam_t& getAntCfg();

protected:
    antennaStatus_t m_antStatus;
    antennaParam_t  m_antCfg;
    simStatus_t     m_simStatus;

    radians_t calcDeltaAz(timetag_t ttag);
    radians_t calcDeltaEl(timetag_t ttag);
};

#endif // ANTENNASIMULATOR_H
