2013-04-05 22:46:56 +02:00
|
|
|
#ifndef ISIMULATOR_H
|
|
|
|
#define ISIMULATOR_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QUdpSocket>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <math.h>
|
|
|
|
#include "uavtalk/telemetrymanager.h"
|
|
|
|
#include "uavobjectmanager.h"
|
|
|
|
#include "actuatordesired.h"
|
|
|
|
#include "altitudeactual.h"
|
|
|
|
#include "attitudeactual.h"
|
|
|
|
#include "velocityactual.h"
|
|
|
|
#include "positionactual.h"
|
|
|
|
#include "gcstelemetrystats.h"
|
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
class Simulator : public QObject {
|
|
|
|
Q_OBJECT
|
2013-04-05 22:46:56 +02:00
|
|
|
public:
|
2013-05-18 14:17:26 +02:00
|
|
|
// static ISimulator* Instance();
|
|
|
|
// protected:
|
|
|
|
Simulator();
|
|
|
|
~ISimulator();
|
2013-04-05 22:46:56 +02:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
bool isAutopilotConnected();
|
|
|
|
bool isFGConnected();
|
2013-04-05 22:46:56 +02:00
|
|
|
|
|
|
|
signals:
|
2013-05-18 14:17:26 +02:00
|
|
|
void myStart();
|
|
|
|
void autopilotConnected();
|
|
|
|
void autopilotDisconnected();
|
|
|
|
void fgConnected();
|
|
|
|
void fgDisconnected();
|
2013-04-05 22:46:56 +02:00
|
|
|
|
|
|
|
private slots:
|
2013-05-18 14:17:26 +02:00
|
|
|
void onStart();
|
|
|
|
void transmitUpdate();
|
|
|
|
void receiveUpdate();
|
|
|
|
void onAutopilotConnect();
|
|
|
|
void onAutopilotDisconnect();
|
|
|
|
void onFGConnectionTimeout();
|
|
|
|
void telStatsUpdated(UAVObject *obj);
|
2013-04-05 22:46:56 +02:00
|
|
|
|
|
|
|
private:
|
2013-05-18 14:17:26 +02:00
|
|
|
// static ISimulator* _instance;
|
2013-04-05 22:46:56 +02:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
QUdpSocket *inSocket;
|
|
|
|
QUdpSocket *outSocket;
|
|
|
|
ActuatorDesired *actDesired;
|
|
|
|
AltitudeActual *altActual;
|
|
|
|
VelocityActual *velActual;
|
|
|
|
AttitudeActual *attActual;
|
|
|
|
PositionActual *posActual;
|
|
|
|
GCSTelemetryStats *telStats;
|
|
|
|
QHostAddress fgHost;
|
|
|
|
int inPort;
|
|
|
|
int outPort;
|
|
|
|
int updatePeriod;
|
|
|
|
QTimer *txTimer;
|
|
|
|
QTimer *fgTimer;
|
|
|
|
bool autopilotConnectionStatus;
|
|
|
|
bool fgConnectionStatus;
|
|
|
|
int fgTimeout;
|
2013-04-05 22:46:56 +02:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
void processUpdate(QString & data);
|
|
|
|
void setupOutputObject(UAVObject *obj, int updatePeriod);
|
|
|
|
void setupInputObject(UAVObject *obj, int updatePeriod);
|
|
|
|
void setupObjects();
|
2013-04-05 22:46:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ISIMULATOR_H
|