-
Notifications
You must be signed in to change notification settings - Fork 0
/
device.h
64 lines (58 loc) · 1.75 KB
/
device.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
#ifndef DEVICE_H
#define DEVICE_H
#include <QObject>
#include <vector>
#include "protocol.h"
#include "protocol10007.h"
#include "deviceCallback.h"
template<
template <class, class> class Prtcl,
class Connection,
class DataType
>
class Device : public ProtocolCallback<DataType>
{
public:
typedef typename Protocol<DataType>::ValuesRetType RetType;
typedef Protocol<DataType> ProtocolType;
typedef typename Protocol<DataType>::Command Command;
Device(DeviceCallback<DataType> *);
int actualValuesReceived(RetType) const;
int actualValues();
private:
std::auto_ptr<ProtocolType> protocol_;
mutable DeviceCallback<DataType> *clb_;
};
template<
template <class, class> class Prtcl,
class Connection,
class DataType
>
Device<Prtcl, Connection, DataType>::Device(DeviceCallback<DataType>* clb)
:clb_(clb)
{
protocol_.reset(new Prtcl<Connection, DataType>(this));
}
template<
template <class, class> class Prtcl,
class Connection,
class DataType
>
int Device<Prtcl, Connection, DataType>::actualValues()
{
return protocol_->executeCommand(Protocol<DataType>::GetValues);
//return protocol_->askForActualValues();
}
template<
template <class, class> class Prtcl,
class Connection,
class DataType
>
int Device<Prtcl, Connection, DataType>::actualValuesReceived(RetType ret) const
{
qDebug() << "Device::actualValuesReceived" ;
if(ret.get() != nullptr)
clb_->renewScreen(ret);
return 1;
}
#endif // DEVICE_H