-
Notifications
You must be signed in to change notification settings - Fork 13
/
CcTx.h
73 lines (62 loc) · 1.69 KB
/
CcTx.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
/*
* Author: Jack Kelly
*
* THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
* LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
* PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
* QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
* DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
*/
#ifndef SENSOR_H
#define SENSOR_H
#ifdef TESTING
#include "tests/FakeArduino.h"
#endif
#include "RxPacketFromSensor.h"
#include "DynamicArray.h"
#include "RollingAv.h"
/**
* Class for Current Cost / EDF Transceiver (TRX) units
*/
class CcTrx {
public:
CcTrx();
CcTrx(const id_t& _id);
virtual ~CcTrx();
virtual void print() const;
bool is_active() const;
id_t id; /* Deliberately public */
bool active;
};
/**
* Class for Current Cost Transmit-Only units
*/
class CcTx : public CcTrx {
public:
CcTx();
CcTx(const id_t& _id);
~CcTx();
void update(const RxPacketFromSensor& packet);
void missing();
const millis_t& get_eta();
void print();
protected:
void init(); // called from constructors
millis_t eta; // estimated time of arrival in milliseconds since power-on
RollingAv sample_period;
uint8_t num_periods_missed;
millis_t last_seen;
};
class CcTxArray : public DynamicArray<CcTx> {
public:
void next();
void print_name() const;
};
class CcTrxArray : public DynamicArray<CcTrx> {
public:
void next();
void print_name() const;
};
#endif /* SENSOR_H */