|
1 | 1 | from aprslib.packets.base import APRSPacket |
2 | 2 |
|
3 | 3 | class TelemetryAddon(object): |
4 | | - analog_values = None |
| 4 | + _analog_values = None |
5 | 5 | _sequence_number = 0 |
6 | 6 | _digital_value = 0 |
7 | 7 |
|
| 8 | + |
8 | 9 | def __init__(self, *args, **kwargs): |
| 10 | + self._analog_values = AnalogList() |
9 | 11 | super(TelemetryAddon, self).__init__( *args, **kwargs) |
10 | 12 |
|
11 | | - self. analog_values = AnalogList() |
| 13 | + @property |
| 14 | + def analog_values(self): |
| 15 | + return self._analog_values |
| 16 | + |
| 17 | + @analog_values.setter |
| 18 | + def analog_values(self, v): |
| 19 | + if not isinstance(v, list): |
| 20 | + raise TypeError("Expected analog_values to be list, got %s" % type(v)) |
| 21 | + if len(v) != 5: |
| 22 | + raise ValueError("Expected a list of 5 elements, got a list of %d" % len(v)) |
| 23 | + |
| 24 | + self._analog_values[:] = v |
12 | 25 |
|
13 | 26 | @property |
14 | 27 | def sequence_number(self): |
@@ -48,32 +61,30 @@ def __setitem__(self, i, v): |
48 | 61 | def __setslice__(self, i, j, v): |
49 | 62 | if i > j: |
50 | 63 | i, j = j, i |
51 | | - if (not 0 <= i <= 5) or (not 0 <= j <= 5): |
52 | | - raise IndexError("Slice outside of range [0:5], got %s" % [i, j]) |
53 | 64 |
|
54 | | - for x in range(i, j): |
| 65 | + for x in range(max(0, i), min(5, j)): |
55 | 66 | list.__setitem__(self, x, v[x]) |
56 | 67 |
|
57 | | - def append(self, other): |
| 68 | + def append(self, a): |
58 | 69 | raise NotImplementedError("not supported") |
59 | 70 |
|
60 | | - def remove(self, other): |
| 71 | + def remove(self, a): |
61 | 72 | raise NotImplementedError("not supported") |
62 | 73 |
|
63 | | - def pop(self): |
| 74 | + def pop(self, a): |
64 | 75 | raise NotImplementedError("not supported") |
65 | 76 |
|
66 | | - def extend(self): |
| 77 | + def extend(self, a): |
67 | 78 | raise NotImplementedError("not supported") |
68 | 79 |
|
69 | | - def insert(self): |
| 80 | + def insert(self, a, b): |
70 | 81 | raise NotImplementedError("not supported") |
71 | 82 |
|
72 | 83 |
|
73 | 84 | class TelemetryReport(TelemetryAddon, APRSPacket): |
74 | 85 | @property |
75 | 86 | def format(self): |
76 | | - return 'raw' |
| 87 | + return 'telemetry' |
77 | 88 |
|
78 | 89 | _comment = '' |
79 | 90 |
|
|
0 commit comments