#ifndef ANCHOR_H
#define ANCHOR_H

#include <QObject>
#include "QDebug"
#include <QDateTime>
#include <QtNetwork>
#include <QTime>
#include <QDate>

class Anchor : public QObject
{
    Q_OBJECT
public:
    explicit Anchor(QObject *parent = 0);

    Q_INVOKABLE void test();
    Q_INVOKABLE QString getStrRSSI();
    Q_INVOKABLE QString getStrDate();
    Q_INVOKABLE qint64 getMsec();


signals:
    void rssiChanged();
    void dateChanged();
    void XChanged(double newXPossition);
    void YChanged(double newYPossition);

public slots:
    int getRssi();
    double getX();
    double getY();
    double getRadius();
    bool getConnectionStatus();
    void setConnectionStatus(int status);
    void setRssi(int newRssi);
    void setRssi();
    void setTrilat(int newTrilat);
    int getTrilat(int number);
    void setDateTime(QDate newDate, QTime newTime);
    void setDate();
    void setX(double xPossition);
    void setY(double yPossition);
    void setXY(double newXPossition, double newYPossition);

    void writeTcpData(QString data);
    QByteArray readTcpData();
    void connectToExist();
    void reconnect();

private:
    int itsRssi = '0';
    int itsTrilat = 123;
    QDate itsDate = QDate::currentDate();
    QTime itsTime = QTime::currentTime();
    double itsXPossition = 3.2;
    double itsYPossition = 2.7;
    double itsRadius = 2.5;
    QTcpSocket* socket;
    QTimer* timer;
    QTimer* timer2;
    //QString itsHost = "127.0.0.1";
    QString itsHost = "213.226.252.167";          // public IP
    int itsPort = 1234;
    bool itsConnectionStatus = false;

};



#endif // ANCHOR_H
