SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
Toggle main menu visibility
Loading...
Searching...
No Matches
temperature.hpp
Go to the documentation of this file.
1
/*
2
* SatNOGS-COMMS control library
3
*
4
* Copyright (C) 2024, Libre Space Foundation <http://libre.space>
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* SPDX-License-Identifier: GNU General Public License v3.0 or later
20
*/
21
22
#pragma once
23
24
#include <cstdint>
25
#include <
satnogs-comms-lib/bsp/i2c.hpp
>
26
#include <
satnogs-comms-lib/emc1702.hpp
>
27
#include <
satnogs-comms-lib/exception.hpp
>
28
#include <satnogs-comms-lib/version.hpp>
29
30
namespace
satnogs::comms::lib
31
{
35
enum class
temperature_sensor
: uint8_t
36
{
37
PCB
,
38
UHF_PA
,
39
SBAND_PA
40
};
41
51
class
invalid_sensor_exception
:
public
exception
52
{
53
public
:
54
invalid_sensor_exception
(string_type file_name, numeric_type line)
55
:
exception
(
exception
::
severity
::
MAJOR
, file_name, line,
56
error_msg
{
"Invalid sensor error"
,
"invalsenserr"
,
EINVALSENS
})
57
58
{
59
}
60
};
61
74
template
<
typename
T>
class
temperature
75
{
76
public
:
77
temperature
(
bsp::i2c
&i2c,
bsp::gpio
&alert_t_pa_uhf,
78
bsp::gpio
&alert_t_pa_sband,
const
rf_frontend09
&rf09,
79
const
rf_frontend24
&rf24)
80
: m_pcb(
"pcb"
, i2c, pcb_addr),
81
m_uhf(
"pa-uhf"
, i2c, uhf_addr, alert_t_pa_uhf),
82
m_sband(
"pa-sband"
, i2c, sband_addr, alert_t_pa_sband),
83
m_rf09(rf09),
84
m_rf24(rf24)
85
86
{
87
static_assert
(std::is_same_v<emc1702, T>,
"Unsupported temperature sensor"
);
88
}
89
90
// Contructor specialiazation if needed can be applied by using:
91
//
92
// template <typename X = T, typename std::enable_if_t<std::is_same_v<
93
// temperature<X>, temperature<emc1702>>>>
94
// temperature(bsp::i2c &i2c)
95
// {
96
// }
97
104
float
105
get
()
const
106
{
107
return
(
get
(
temperature_sensor::PCB
) +
get
(
temperature_sensor::UHF_PA
) +
108
get
(
temperature_sensor::SBAND_PA
)) /
109
3.0f;
110
}
111
119
float
120
get
(
temperature_sensor
s)
const
;
121
127
bool
128
alert
()
const
129
{
130
return
alert
(
temperature_sensor::PCB
) ||
131
alert
(
temperature_sensor::UHF_PA
) ||
132
alert
(
temperature_sensor::SBAND_PA
);
133
}
134
144
bool
145
alert
(
temperature_sensor
s)
const
;
146
147
private
:
148
static
constexpr
uint8_t pcb_addr = 0b101101;
149
static
constexpr
uint8_t uhf_addr = 0b1001101;
150
static
constexpr
uint8_t sband_addr =
151
version::num(0, 3, 1) < version::hw() ? 0b101001 : 0b11000;
152
153
T m_pcb;
154
T m_uhf;
155
T m_sband;
156
const
rf_frontend09
&m_rf09;
157
const
rf_frontend24
&m_rf24;
158
};
159
160
}
// namespace satnogs::comms::lib
satnogs::comms::lib::bsp::gpio
GPIO device abstraction.
Definition
gpio.hpp:38
satnogs::comms::lib::bsp::i2c
I2C device abstraction.
Definition
i2c.hpp:40
satnogs::comms::lib::exception::error_msg
A class representing error messages in the SatNOGS-COMMS system.
Definition
exception.hpp:83
satnogs::comms::lib::exception::severity
severity
Severity levels of exceptions.
Definition
exception.hpp:71
satnogs::comms::lib::exception::severity::MAJOR
@ MAJOR
Failure causing minor mission degradation.
Definition
exception.hpp:74
satnogs::comms::lib::exception::exception
exception(severity sev, const char *file, int lineno, const error_msg &err_msg)
Constructor for the exception class.
Definition
exception.hpp:102
satnogs::comms::lib::invalid_sensor_exception::invalid_sensor_exception
invalid_sensor_exception(string_type file_name, numeric_type line)
Definition
temperature.hpp:54
satnogs::comms::lib::rf_frontend09
RF-frontend for the UHF interface.
Definition
rf_frontend09.hpp:51
satnogs::comms::lib::rf_frontend24
RF-frontend for the S-Band interface.
Definition
rf_frontend24.hpp:88
satnogs::comms::lib::temperature::alert
bool alert() const
Checks if any temperature sensor has triggered an alert.
Definition
temperature.hpp:128
satnogs::comms::lib::temperature::alert
bool alert(temperature_sensor s) const
Checks if a specific temperature sensor has triggered an alert.
satnogs::comms::lib::temperature::get
float get(temperature_sensor s) const
Returns the temperature from a specific sensor.
satnogs::comms::lib::temperature::temperature
temperature(bsp::i2c &i2c, bsp::gpio &alert_t_pa_uhf, bsp::gpio &alert_t_pa_sband, const rf_frontend09 &rf09, const rf_frontend24 &rf24)
Definition
temperature.hpp:77
satnogs::comms::lib::temperature::get
float get() const
Retrieve the average board temperature.
Definition
temperature.hpp:105
emc1702.hpp
EINVALSENS
#define EINVALSENS
Invalid sensor.
Definition
errno_extended.hpp:37
exception.hpp
i2c.hpp
satnogs::comms::lib
Definition
ad8318.hpp:30
satnogs::comms::lib::temperature_sensor
temperature_sensor
Source of temperature readings.
Definition
temperature.hpp:36
satnogs::comms::lib::temperature_sensor::PCB
@ PCB
PCB temperature sensor.
Definition
temperature.hpp:37
satnogs::comms::lib::temperature_sensor::UHF_PA
@ UHF_PA
UHF PA temperature sensor.
Definition
temperature.hpp:38
satnogs::comms::lib::temperature_sensor::SBAND_PA
@ SBAND_PA
S-Band PA temperature sensor.
Definition
temperature.hpp:39
libsatnogs-comms
include
satnogs-comms-lib
temperature.hpp
Generated by
1.17.0