Subversion Repositories Projects

Rev

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 <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:
    // Object für Serielport
    ManageSerialPort *serialPort;

    // Settings-Object
    cSettings *Settings;

    // 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;

    QIcon Icons[30];

    QByteArray allDataReceived;
    QTimer *timer;
    QTimer *Poll;
    QFile  *CSVFile;
    QString RXS;
    QString LastSend;

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

    int ParameterSet[11][MaxParameter];

    void init_GUI();
    void init_Objects();
    void init_Connections();

    void init_Arrays();
    void init_Icons();

    void update_Plot();
    void config_Plot();

    QComboBox *setCombo(QComboBox *Combo, int Set, int Wert);
    int get_Value(QComboBox *Combo);

    bool check_CRC(QString RXString);
    QString add_CRC(QString TXString);

    void send_Data(char CMD, char Data[150],unsigned int Length, bool Resend = true);
    void new_RXData(QString RX_Data);

    void show_DebugData();
    void show_ParameterSet(int Set);
    void store_ParameterSet(int Set);

    void write_Settings();
    void write_CSV();

    QString Encode64(char Data[150],unsigned int Length);
    bool Decode64(char *RxdBuffer, int len, bool Long = false);

    void set_LED(QToolButton *ToolButton, bool On=false);

    void init_Plot();

private slots:
    void slot_ac_Config();
    void slot_ac_StartPlotter();

    void slot_SliderMotorTest(int Wert);

    void slot_newDataReceived(const QByteArray &dataReceived);
    void slot_OpenPort();
    void slot_Quit();

    void slot_Timer();
    void slot_Poll();

    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();

    void slot_About();
};

#endif