1#!/usr/bin/env python3
2#
3#   Copyright 2019 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17
18class Origin:
19    """The origin types of a given measurement or calibration.
20
21    The Monsoon returns calibration packets for three types of origin:
22
23        ZERO: The calibrated zeroing point.
24        REFERENCE: The reference point used for the returned samples.
25        SCALE: The factor at which to scale the returned samples to get power
26               consumption data.
27    """
28    ZERO = 0
29    REFERENCE = 1
30    SCALE = 2
31
32    values = [ZERO, REFERENCE, SCALE]
33
34
35class Granularity:
36    """The granularity types.
37
38    Monsoon leverages two different granularities when returning power
39    measurements. If the power usage exceeds the threshold of the fine
40    measurement region, a coarse measurement will be used instead.
41
42    This also means that there need to be two calibration values: one for coarse
43    and one for fine.
44    """
45    COARSE = 0
46    FINE = 1
47
48    values = [COARSE, FINE]
49
50
51class Reading:
52    """The extraneous possible reading types.
53
54    Aside from coarse and fine readings (see Granularity), some Monsoons can
55    gather readings on the voltage and gain control.
56    """
57    VOLTAGE = 0x4
58    GAIN = 0x6
59
60    values = [VOLTAGE, GAIN]
61
62
63class Channel:
64    """The possible channel types.
65
66    Monsoons can read power measurements from the following three inputs.
67    Calibration and reading values may also be available on these channels.
68    """
69    MAIN = 0
70    USB = 1
71    AUX = 2
72
73    values = [MAIN, USB, AUX]
74