• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / SpiNNMan / 6574804013

19 Oct 2023 12:47PM UTC coverage: 51.937% (+1.2%) from 50.777%
6574804013

Pull #327

github

Christian-B
typing changes
Pull Request #327: Type Annotations and Checking

105 of 1288 branches covered (0.0%)

Branch coverage included in aggregate %.

2375 of 2375 new or added lines in 180 files covered. (100.0%)

4775 of 8108 relevant lines covered (58.89%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.06
/spinnman/model/adc_info.py
1
# Copyright (c) 2015 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
import struct
1✔
16
from typing import Optional
1✔
17
from spinnman import constants
1✔
18

19
_PATTERN = struct.Struct(
1✔
20
    "<"   # Little-endian
21
    "8H"  # uint16_t adc[8]
22
    "4h"  # int16_t t_int[4]
23
    "4h"  # int16_t t_ext[4]
24
    "4h"  # int16_t fan[4]
25
    "I"   # uint32_t warning
26
    "I")  # uint32_t shutdown
27

28

29
class ADCInfo(object):
1✔
30
    """
31
    Container for the ADC data that's been retrieved from an FPGA.
32
    """
33
    __slots__ = [
1✔
34
        "_fan_0",
35
        "_fan_1",
36
        "_temp_btm",
37
        "_temp_ext_0",
38
        "_temp_ext_1",
39
        "_temp_top",
40
        "_voltage_1_2a",
41
        "_voltage_1_2b",
42
        "_voltage_1_2c",
43
        "_voltage_1_8",
44
        "_voltage_3_3",
45
        "_voltage_supply"]
46

47
    def __init__(self, adc_data: bytes, offset: int):
1✔
48
        """
49
        :param bytes adc_data:
50
            bytes from an SCP packet containing ADC information
51
        :raise SpinnmanInvalidParameterException:
52
            If the message does not contain valid ADC information
53
        """
54
        data = _PATTERN.unpack_from(adc_data, offset)
×
55

56
        self._voltage_1_2c = data[1] * constants.BMP_V_SCALE_2_5
×
57
        self._voltage_1_2b = data[2] * constants.BMP_V_SCALE_2_5
×
58
        self._voltage_1_2a = data[3] * constants.BMP_V_SCALE_2_5
×
59
        self._voltage_1_8 = data[4] * constants.BMP_V_SCALE_2_5
×
60
        self._voltage_3_3 = data[6] * constants.BMP_V_SCALE_3_3
×
61
        self._voltage_supply = data[7] * constants.BMP_V_SCALE_12
×
62
        self._temp_top = float(data[8]) * constants.BMP_TEMP_SCALE
×
63
        self._temp_btm = float(data[9]) * constants.BMP_TEMP_SCALE
×
64
        if data[12] != constants.BMP_MISSING_TEMP:
×
65
            self._temp_ext_0: Optional[float] = (
×
66
                float(data[12]) * constants.BMP_TEMP_SCALE)
67
        else:
68
            self._temp_ext_0 = None
×
69
        if data[13] != constants.BMP_MISSING_TEMP:
×
70
            self._temp_ext_1: Optional[float] = (
×
71
                float(data[13]) * constants.BMP_TEMP_SCALE)
72
        else:
73
            self._temp_ext_1 = None
×
74
        if data[16] != constants.BMP_MISSING_FAN:
×
75
            self._fan_0: Optional[float] = float(data[16])
×
76
        else:
77
            self._fan_0 = None
×
78
        if data[17] != constants.BMP_MISSING_FAN:
×
79
            self._fan_1: Optional[float] = float(data[17])
×
80
        else:
81
            self._fan_1 = None
×
82

83
    @property
1✔
84
    def voltage_1_2c(self) -> float:
1✔
85
        """
86
        Actual voltage of the 1.2V c supply rail.
87

88
        :rtype: float
89
        """
90
        return self._voltage_1_2c
×
91

92
    @property
1✔
93
    def voltage_1_2b(self) -> float:
1✔
94
        """
95
        Actual voltage of the 1.2V b supply rail.
96

97
        :rtype: float
98
        """
99
        return self._voltage_1_2b
×
100

101
    @property
1✔
102
    def voltage_1_2a(self) -> float:
1✔
103
        """
104
        Actual voltage of the 1.2V a supply rail.
105

106
        :rtype: float
107
        """
108
        return self._voltage_1_2a
×
109

110
    @property
1✔
111
    def voltage_1_8(self) -> float:
1✔
112
        """
113
        Actual voltage of the 1.8V supply rail.
114

115
        :rtype: float
116
        """
117
        return self._voltage_1_8
×
118

119
    @property
1✔
120
    def voltage_3_3(self) -> float:
1✔
121
        """
122
        Actual voltage of the 3.3V supply rail.
123

124
        :rtype: float
125
        """
126
        return self._voltage_3_3
×
127

128
    @property
1✔
129
    def voltage_supply(self) -> float:
1✔
130
        """
131
        Actual voltage of the main power supply (nominally 12V).
132

133
        :rtype: float
134
        """
135
        return self._voltage_supply
×
136

137
    @property
1✔
138
    def temp_top(self) -> float:
1✔
139
        """
140
        Temperature top.
141

142
        :rtype: float
143
        """
144
        return self._temp_top
×
145

146
    @property
1✔
147
    def temp_btm(self) -> float:
1✔
148
        """
149
        Temperature bottom.
150

151
        :rtype: float
152
        """
153
        return self._temp_btm
×
154

155
    @property
1✔
156
    def temp_ext_0(self) -> Optional[float]:
1✔
157
        """
158
        Temperature external 0.
159

160
        :rtype: float or None
161
        """
162
        return self._temp_ext_0
×
163

164
    @property
1✔
165
    def temp_ext_1(self) -> Optional[float]:
1✔
166
        """
167
        Temperature external 1.
168

169
        :rtype: float or None
170
        """
171
        return self._temp_ext_1
×
172

173
    @property
1✔
174
    def fan_0(self) -> Optional[float]:
1✔
175
        """
176
        Fan 0.
177

178
        :rtype: float or None
179
        """
180
        return self._fan_0
×
181

182
    @property
1✔
183
    def fan_1(self) -> Optional[float]:
1✔
184
        """
185
        Fan 1.
186

187
        :rtype: float or None
188
        """
189
        return self._fan_1
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc