-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdltrelais.h
91 lines (72 loc) · 1.98 KB
/
dltrelais.h
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
#ifndef DLT_RELAIS_H
#define DLT_RELAIS_H
#include <QObject>
/**
* @licence app begin@
* Copyright (C) 2021 Alexander Wenzel
*
* This file is part of the DLT Relais project.
*
* \copyright This code is licensed under GPLv3.
*
* \author Alexander Wenzel <[email protected]>
*
* \file dltrelais.h
* @licence end@
*/
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QSerialPort>
#include <QTimer>
class DLTRelais : public QObject
{
Q_OBJECT
public:
explicit DLTRelais(QObject *parent = nullptr);
~DLTRelais();
// Start and stop connection
void checkPortName();
void start();
void stop();
// Trigger Relais
void trigger(int num,unsigned int duration);
void on(int num);
void off(int num);
// Interface name
QString getInterface() { return interface; }
void setInterface(QString interface) { this->interface = interface; }
// Active
bool getActive() { return active; }
void setActive(bool active) { this->active = active; }
// Relais names
QString getRelaisName(int num) { if(num>0 && num<5) return relaisName[num-1]; else return QString(); }
void setRelaisName(int num,const QString &name) { if(num>0 && num<5) this->relaisName[num-1] = name; }
// Settings
void clearSettings();
void writeSettings(QXmlStreamWriter &xml,int num);
void readSettings(const QString &filename,int num);
int getType() const;
void setType(int newType);
signals:
// Called when status changed
void status(QString text);
private slots:
// Serial data available
void readyRead();
// Watchdog Timeout
void timeout();
private:
// Temporary variables
QSerialPort serialPort;
QTimer timer;
unsigned int watchDogCounter,watchDogCounterLast;
// Settings
int type;
QString interface;
QString interfaceSerialNumber;
ushort interfaceProductIdentifier;
ushort interfaceVendorIdentifier;
QString relaisName[4];
bool active;
};
#endif // DLT_RELAIS_H