Subversion Repositories Projects

Rev

Rev 159 | Go to most recent revision | Blame | 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 "ui_mktool.h"

#include "../SerialPort/ManageSerialPort.h"
#include "../cSettings.h"

class QextSerialPort;

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

public:
      MKTool();
      ~MKTool();

private:
    bool AllowSend;
    // Object für Serielport
    ManageSerialPort *serialPort;

    // Settings-Object
    cSettings *Settings;

    // Default-Ticker
    QTimer *Ticker;

    // Die Tabs des Hauptfensters
    QWidget *TabWidgets[6];

    // Analogwert-Beschreibungen
    QLabel *lb_Analog[MaxAnalog];

    // Analogwerte
    int AnalogData[MaxAnalog];

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

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

    // Ticker-Event-Array
    bool TickerEvent[MaxTickerEvents];
    bool TickerDiv;

    int LCD_Page;
    int LCD_MAX_Page;

    // Alle Icons
    QIcon Icons[30];

//    QByteArray allDataReceived;

    // Object für das Datenfile;
    QFile  *CSVFile;

    sMode Mode;
    sRxData RxData;

    QString RXS;
    QString LastSend;

    // TestOnly
    QProcess *Update;


//    int DecodeData[150];
    char TX_Data[150];

    int ParameterSet[11][MaxParameter];

    // Programm Initialisieren
    void init_GUI();
    void init_Objects();
    void init_Connections();
    void init_Arrays();
    void init_Icons();
    void init_Plot();

    // Daten-Plotter
    void update_Plot();
    void config_Plot();

    // Settings-Bereich
    QComboBox *setCombo(QComboBox *Combo, int Set, int Wert);
    int get_Value(QComboBox *Combo);
    void show_ParameterSet(int Set);
    void store_ParameterSet(int Set);
    void set_LED(QToolButton *ToolButton, bool On=false);

    // Daten Senden, Empfangen und verarbeiten
    void send_Data(char CMD, int Address, char Data[150],unsigned int Length, bool Resend = true);
    void new_RXData(sRxData RX);

    // Debugdaten anzeigen und speichern.
    void show_DebugData();
    void write_CSV();

    // Programmeinstellungen speichern
    void write_Settings();

private slots:
    void slot_ac_Config();
    void slot_ac_Preferences();
    void slot_ac_StartPlotter();
    void slot_ac_View();
    void slot_ac_MehrDaten();
    void slot_ac_About();
    void slot_ac_GetLabels();
    void slot_ac_Motortest();

    // Default-Ticker
    void slot_Ticker();

    void slot_LCD_UP();
    void slot_LCD_DOWN();

    void slot_Motortest(int Motor1, int Motor2, int Motor3, int Motor4);

    void slot_pb_Update();

    void slot_UpdateShell();

    // Seriell-Port Slots
    void slot_newDataReceived(const QByteArray &dataReceived);
    void slot_OpenPort();

    void slot_tbUp();
    void slot_tbDown();
    void slot_tbLeft();
    void slot_tbRight();
    void slot_LEDtoValue();
    void slot_ValuetoLED16(int Wert);
    void slot_ValuetoLED17(int Wert);

    void slot_TabChanged(int Tab);

    void slot_RecordCSV();

    void slot_ScrollPlot(int Pos);

    void slot_GetParameter();
    void slot_SetParameter();
    void slot_LoadParameter();
    void slot_SaveParameter();

    void slot_SetLogDir();
    void slot_SetParDir();
};

#endif