Subversion Repositories Projects

Rev

Rev 440 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 440 Rev 449
1
/***************************************************************************
1
/***************************************************************************
2
 *   Copyright (C) 2009 by Manuel Schrape                                  *
2
 *   Copyright (C) 2009 by Manuel Schrape                                  *
3
 *   manuel.schrape@gmx.de                                                 *
3
 *   manuel.schrape@gmx.de                                                 *
4
 *                                                                         *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License.        *
7
 *   the Free Software Foundation; either version 2 of the License.        *
8
 *                                                                         *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
18
 ***************************************************************************/
19
#ifndef CCONNECTION_H
19
#ifndef CCONNECTION_H
20
#define CCONNECTION_H
20
#define CCONNECTION_H
21
 
21
 
22
#include <QObject>
22
#include <QObject>
23
#include <QTcpSocket>
23
#include <QTcpSocket>
24
#include <QTimer>
24
#include <QTimer>
25
 
25
 
26
#include "ToolBox.h"
26
#include "ToolBox.h"
27
#include "../global.h"
27
#include "../global.h"
28
#include "../SerialPort/ManageSerialPort.h"
28
#include "../SerialPort/ManageSerialPort.h"
29
#include "../libMK/Parser.h"
29
#include "../libMK/Parser.h"
30
 
30
 
31
#define C_TTY 1
31
#define C_TTY 1
32
#define C_IP 2
32
#define C_IP 2
33
 
33
 
34
class cConnection : public QObject
34
class cConnection : public QObject
35
{
35
{
36
    Q_OBJECT
36
    Q_OBJECT
37
 
37
 
38
    public:
38
    public:
39
        cConnection();
39
        cConnection();
40
        bool isOpen();
40
        bool isOpen();
41
        bool Open(int Typ, QString Address);
41
        bool Open(int Typ, QString Address);
42
        bool Close();
42
        bool Close();
43
        bool send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend = true);
43
        bool send_Cmd(char CMD, int Address, char Data[MAX_DATA_SIZE],unsigned int Length, bool Resend = true);
44
        void stop_ReSend();
44
        void stop_ReSend();
45
 
45
 
46
    private:
46
    private:
47
        ManageSerialPort *TTY;
47
        ManageSerialPort *TTY;
48
        QTcpSocket *TcpSocket;
48
        QTcpSocket *TcpSocket;
49
        QTimer *o_Timer;
49
        QTimer *o_Timer;
50
 
50
 
51
        QByteArray s_ReSend;
51
        QByteArray s_ReSend;
52
 
52
 
53
        bool b_isOpen;
53
        bool b_isOpen;
54
        int  i_Type;
54
        int  i_Type;
55
        sRxData RxData;
55
//        sRxData RxData;
56
 
56
 
57
        void new_Data(QString Data);
57
        void new_Data(QString Data);
58
 
58
 
59
    private slots:
59
    private slots:
60
        void slot_newDataReceived(const QByteArray &dataReceived);
60
        void slot_newDataReceived(const QByteArray &dataReceived);
61
        void slot_IP_Connected();
61
        void slot_IP_Connected();
62
        void slot_IP_Disconnect();
62
        void slot_IP_Disconnect();
63
        void slot_IP_ReadLine();
63
        void slot_IP_ReadLine();
64
 
64
 
65
        void slot_Timer();
65
        void slot_Timer();
66
//        void slot_Error(QAbstractSocket::SocketError Error);
66
//        void slot_Error(QAbstractSocket::SocketError Error);
67
 
67
 
68
    signals:
68
    signals:
69
        void newData(sRxData RxData);
69
//        void newData(sRxData RxData);
70
        void showTerminal(int Typ, QString Text);
70
        void showTerminal(int Typ, QString Text);
71
};
71
};
72
 
72
 
73
#endif // CCONNECTION_H
73
#endif // CCONNECTION_H
74
 
74