summaryrefslogtreecommitdiffstats
path: root/vehicle-signals/vehiclesignals.h
blob: 734cb27ddde0098a9d8778a88ef243a09d2f5d68 (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
/*
 * Copyright (C) 2022,2023 Konsulko Group
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef VEHICLESIGNALS_H
#define VEHICLESIGNALS_H

#include <QObject>

#include "VehicleSignalsConfig.h"

class QtKuksaClient;

// VSS signal interface class

class VehicleSignals : public QObject
{
	Q_OBJECT

public:
        explicit VehicleSignals(const VehicleSignalsConfig &config, QObject * parent = Q_NULLPTR);
        virtual ~VehicleSignals();

	Q_INVOKABLE void connect();	
	Q_INVOKABLE void authorize();

	Q_INVOKABLE void get(const QString &path, const bool actuator = false);

	Q_INVOKABLE void set(const QString &path, const QString &value, const bool actuator = false);
	Q_INVOKABLE void set(const QString &path, const qint32 value, const bool actuator = false);
	Q_INVOKABLE void set(const QString &path, const qint64 value, const bool actuator = false);
	Q_INVOKABLE void set(const QString &path, const quint32 value, const bool actuator = false);
	Q_INVOKABLE void set(const QString &path, const quint64 value, const bool actuator = false);
	Q_INVOKABLE void set(const QString &path, const float value, const bool actuator = false);
	Q_INVOKABLE void set(const QString &path, const double value, const bool actuator = false);

	Q_INVOKABLE void subscribe(const QString &path, const bool actuator = false);
	Q_INVOKABLE void subscribe(const QMap<QString, bool> &signals_);

signals:
	void connected();
	void authorized();
	void disconnected();
	void getSuccessResponse(QString path, QString value, QString timestamp);
	void setErrorResponse(QString path, QString error);
	void signalNotification(QString path, QString value, QString timestamp);

private slots:
	void onConnected();
	void onGetResponse(QString path, QString value, QString timestamp);
	void onSetResponse(QString path, QString error);
	void onSubscribeResponse(QString path, QString value, QString timestamp);
	void onSubscribeDone(const QMap<QString, bool> &signals_, bool canceled);

private:
	VehicleSignalsConfig m_config;
	QtKuksaClient *m_broker;

	void resubscribe(const QMap<QString, bool> &signals_);
};

#endif // VEHICLESIGNALS_H