File: thermal.h

package info (click to toggle)
snapraid 13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,656 kB
  • sloc: ansic: 46,018; makefile: 1,004; sh: 154
file content (76 lines) | stat: -rw-r--r-- 2,318 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (C) 2025 Andrea Mazzoleni
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __THERMAL_H
#define __THERMAL_H

#include "elem.h"

/****************************************************************************/
/* thermal */

/**
 * Period of temperature measures
 */
#define THERMAL_PERIOD_SECONDS 30

/**
 * Max number of temperature measures
 */
#define THERMAL_MAX 100

/**
 * Minimum value of the R^2 to consider valid a measure
 */
#define THERMAL_R_SQUARED_LIMIT 0.9

struct snapraid_thermal_point {
	double temperature; /**< Temperatures in celsius */
	double time; /**< Time in seconds */
};

struct snapraid_thermal_params {
	double k_heat; /**< Heating coefficient */
	double t_steady; /**< Steady state temperature during heating */
	double t_ambient; /**< Ambient temperature */
	double rmse; /**< Root mean square error of the fit */
	double r_squared; /**< Coefficient of determination */
	double max_error; /**< Maximum absolute error in fit */
};

struct snapraid_thermal {
	uint64_t device; /**< Device ID. */
	char name[PATH_MAX]; /**< Name of the disk. Note that it's not unique as more physical disks may map to the same logical disk */
	int latest_temperature; /**< Latest temperature */
	struct snapraid_thermal_point data[THERMAL_MAX]; /**< Measures. Stopped after the first sleep. */
	unsigned count; /**< Number of measures */
	struct snapraid_thermal_params params; /**< Estimated thermal parameters */
	tommy_node node; /**< Next node in the list. */
};

/**
 * Allocate a thermal state.
 */
struct snapraid_thermal* thermal_alloc(uint64_t dev, const char* name);

/**
 * Deallocate a thermal state.
 */
void thermal_free(struct snapraid_thermal* thermal);

#endif