SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
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>
28#include <satnogs-comms-lib/version.hpp>
29
30namespace satnogs::comms::lib
31{
35enum class temperature_sensor : uint8_t
36{
40};
41
52{
53public:
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
74template <typename T> class temperature
75{
76public:
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 {
109 3.0f;
110 }
111
119 float
121
127 bool
134
144 bool
146
147private:
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
GPIO device abstraction.
Definition gpio.hpp:38
I2C device abstraction.
Definition i2c.hpp:40
A class representing error messages in the SatNOGS-COMMS system.
Definition exception.hpp:83
severity
Severity levels of exceptions.
Definition exception.hpp:71
@ MAJOR
Failure causing minor mission degradation.
Definition exception.hpp:74
exception(severity sev, const char *file, int lineno, const error_msg &err_msg)
Constructor for the exception class.
invalid_sensor_exception(string_type file_name, numeric_type line)
RF-frontend for the UHF interface.
RF-frontend for the S-Band interface.
bool alert() const
Checks if any temperature sensor has triggered an alert.
bool alert(temperature_sensor s) const
Checks if a specific temperature sensor has triggered an alert.
float get(temperature_sensor s) const
Returns the temperature from a specific sensor.
temperature(bsp::i2c &i2c, bsp::gpio &alert_t_pa_uhf, bsp::gpio &alert_t_pa_sband, const rf_frontend09 &rf09, const rf_frontend24 &rf24)
float get() const
Retrieve the average board temperature.
#define EINVALSENS
Invalid sensor.
temperature_sensor
Source of temperature readings.
@ UHF_PA
UHF PA temperature sensor.
@ SBAND_PA
S-Band PA temperature sensor.