Subversion Repositories Projects

Rev

Rev 442 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/***************************************************************************
 *   Copyright (C) 2008 by Manuel Schrape                                  *
 *   manuel.schrape@gmx.de                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License.        *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/



#ifndef MKTOOL_H
#define MKTOOL_H

#include <QMainWindow>
#include <QSettings>
#include <QString>
#include <QTimer>
#include <QComboBox>
#include <QIcon>
#include <QProcess>

#include <qwt_plot_curve.h>
#include <qwt_plot_grid.h>
#include <qwt_legend.h>
#include <qwt_plot.h>
#include <qwt_compass.h>
#include <qwt_compass_rose.h>
#include <qwt_dial_needle.h>

#include "ui_mktool.h"
#include "wdg_Settings.h"
#include "dlg_LCD.h"
#include "dlg_Map.h"
#include "dlg_MotorMixer.h"

#include "../Classes/cSettings.h"
#include "../Classes/cKML_Server.h"
#include "../Classes/cQMK_Server.h"
#include "../Classes/cAttitude.h"
#include "../Classes/cSpeedMeter.h"
#include "../Logger/Logger.h"
#include "../typedefs.h"

//quadcopter lib stuff
#include "../libMK/Handler.h"
#include "../libMK/Communication.h"
#include "../libMK/QTSerialCommunication.h"

class QextSerialPort;

class MKTool : public QMainWindow, public Ui::dlg_mktool_UI
{
      Q_OBJECT

public:
      MKTool();
      ~MKTool();

private:
    // data-exchange from the MK
    KopterData * data;

    // data-handler to send commands to MK
    Handler *handler;

    // connect to MK/disconnect from MK
    Communication *com;

    // settings object (program configuration)
    cSettings *Settings;

    // settings widget (FC settings)
    wdg_Settings *f_Settings;

    // HTTP server object for KML files
    cKML_Server *KML_Server;

    // QMK-serverobjekt
    cQMK_Server *QMK_Server;

    // LCD dialog
    dlg_LCD *f_LCD;

    // MotorMixer dialog
    dlg_MotorMixer *f_MotorMixer;

    // Map dialog
    dlg_Map *f_Map;

    //TCP socket - needed by QMK server
    QTcpSocket *TcpSocket;

    //FIXME: replace ticker with something else
    // Default-Ticker
    //QTimer *Ticker;

    // copy of the tabs from the main widget
    QWidget *TabWidgets[7];

    // analog names (label)
    QLabel *lb_Analog[MaxAnalog];

    // analog values (line edit)
    QLineEdit *le_Analog[MaxAnalog];

    // Plots für die Analogwerte
    QwtPlotCurve *Plot[MaxAnalog];

    // Datenspeicher für die Plots
    double aData[MaxAnalog][MaxPlot];
    double aID[MaxPlot];
    int NextPlot;

    AttitudeIndicator *Attitude;
    cSpeedMeter * SpeedMeter;

    // Ticker-Event-Array
    //FIXME: move ticker to QTCommunication
    //bool TickerEvent[MaxTickerEvents];
    //bool TickerDiv;

    // logger for CVS, MySQL and others
    Logger * logger;

    // software update
    QProcess *Update;

    // FC-Settings
    int FCSettings[MaxParameter];

    // initialize program
    void init_GUI();
    void init_Objects();
    void init_Connections();
    void init_Arrays();
    void init_Plot();
    void init_Cockpit();

    // plot data
    void update_Plot();
    void config_Plot();

//    void new_NaviData(sRxData RX);
    void parse_TargetKML();

    // show and save debug/log
    void show_DebugData();
    void update_Log();

    // save program settings
    void set_Preferences();

private slots:
    void slot_QMKS_Connect();
    void slot_QMKS_Connected();
    void slot_QMKS_Disconnected(int Error);

    void slot_set_Settings(cSettings *t_Settings);

    void slot_MAP_SetTarget(sWayPoint Target);
    void slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints);


    void slot_showTerminal(int Typ, QString Text);

    void slot_ac_Hardware();
    void slot_rb_Hardware();

    void slot_ac_StartServer();

    void slot_Test();

    void slot_ac_Config();
    void slot_ac_Preferences();
    void slot_ac_StartPlotter();
    void slot_ac_View();
    void slot_ac_FastDebug();
    void slot_ac_NoDebug();
    void slot_ac_FastNavi();
    void slot_ac_NoNavi();
    void slot_ac_About();
    void slot_ac_GetLabels();
    void slot_ac_Motortest();
    void slot_ac_LCD();
    void slot_ac_Map();
    void slot_ac_MotorMixer();

    void slot_pb_HexFile();
    void slot_pb_SendTarget();

    // Default-Ticker
    //FIXME: put this in libMK/QTCommunication.cpp
    //void slot_Ticker();

    // LCD page up / down
    void slot_LCD_UP();
    void slot_LCD_DOWN();

    void slot_Motortest(sMotorData p_Motor);

    // Firmeware-Update
    void slot_pb_Update();
    void slot_UpdateShell();

    // Seriell-Port Slots
//    void slot_newData(sRxData RX);
    void slot_OpenPort();

    void slot_TabChanged(int Tab);

    void slot_RecordLog();

    void slot_ScrollPlot(int Pos);

    // FC-Settings lesen / Schreiben
    void slot_GetFCSettings();
    void slot_SetFCSettings();
};

#endif