summaryrefslogtreecommitdiffstats
path: root/CanController/tcpclusterdatacontrol.h
blob: c3e2422f2c24780a09ef4b4158ab502635a4a1a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt multiscreen demo application.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef TCPCLUSTERDATACONTROL_H
#define TCPCLUSTERDATACONTROL_H

#include "clusterdatacontrolinterface.h"

#include <QTcpSocket>

class TCPClusterDataControl : public ClusterDataControlInterface
{
    Q_OBJECT

public:
    TCPClusterDataControl(QObject *parent = 0);
    ~TCPClusterDataControl();

    int carId() const;
    bool headLight() const;
    bool parkLight() const;
    bool rightTurnLight() const;
    bool leftTurnLight() const;
    int gear() const;
    bool lightFailure() const;
    bool frontLeftDoorOpen() const;
    bool frontRightDoorOpen() const;
    bool rearLeftDoorOpen() const;
    bool rearRightDoorOpen() const;
    bool hoodOpen() const;
    bool trunkOpen() const;
    bool flatTire() const;
    double direction() const;
    double longitude() const;
    double latitude() const;
    double vehicleSpeed() const;
    bool hazardSignal() const;
    bool brake() const;
    double oilTemp() const;
    int oilPressure() const;
    double batteryPotential() const;
    double gasLevel() const;
    int rpm() const;
    int engineTemp() const;

public slots:
    void connectToServer();
    void onConnectionStateChanged(QAbstractSocket::SocketState socketState);
    void handleTcpError(QAbstractSocket::SocketError socketError);

    void setVehicleSpeed(double vehicleSpeed);
    void setLatitude(double latitude);
    void setLongitude(double longitude);
    void setDirection(double direction);
    void setFlatTire(bool flatTire);
    void setFrontLeftDoorOpen(bool doorOpen);
    void setFrontRightDoorOpen(bool doorOpen);
    void setRearLeftDoorOpen(bool doorOpen);
    void setRearRightDoorOpen(bool doorOpen);
    void setHoodOpen(bool doorOpen);
    void setTrunkOpen(bool doorOpen);
    void setLightFailure(bool lightFailure);
    void setGear(int gear);
    void setLeftTurnLight(bool leftTurnLight);
    void setRightTurnLight(bool rightTurnLight);
    void setHeadLight(bool headLight);
    void setParkLight(bool parkLight);
    void setCarId(int carId);
    void setHazardSignal(bool hazardSignal);
    void setBrake(bool brake);
    void setOilTemp(double oilTemp);
    void setOilPressure(int oilPressure);
    void setBatteryPotential(double batteryPotential);
    void setGasLevel(double gasLevel);
    void setRpm(int rpm);
    void setEngineTemp(int engineTemp);

private:
    void write(const char *, qint64 );
    void write(const char *);

private:
    QTcpSocket m_tcpSocket;
    bool m_frontLeftDoorOpen;
    bool m_frontRightDoorOpen;
    bool m_rearLeftDoorOpen;
    bool m_rearRightDoorOpen;
    bool m_hoodOpen;
    bool m_trunkOpen;
    bool m_headLight;
    bool m_parkLight;
    bool m_rightTurnLight;
    bool m_leftTurnLight;
    bool m_hazardSignal;
    bool m_brake;
};

#endif // TCPCLUSTERDATACONTROL_H