-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruntime.h
60 lines (51 loc) · 1.95 KB
/
runtime.h
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
//
// runtime.h
// rwchcd
//
// (C) 2016 Thibaut VARENE
// License: GPLv2 - http://www.gnu.org/licenses/gpl-2.0.html
//
/**
* @file
* Runtime API.
*/
#ifndef rwchcd_runtime_h
#define rwchcd_runtime_h
#include "rwchcd.h"
#include "timekeep.h"
#include <stdatomic.h>
/** Runtime environment structure */
struct s_runtime {
struct {
bool configured;
enum e_runmode startup_runmode; ///< if #startup_sysmode is #SYS_MANUAL, this runtime runmode will be applied and is *REQUIRED*.
enum e_runmode startup_dhwmode; ///< if #startup_sysmode is #SYS_MANUAL, this runtime dhwmode will be applied and is *REQUIRED*
enum e_systemmode startup_sysmode; ///< sysmode applied at startup. *REQUIRED*
const char * notifier; ///< notifier execvp()'d when alarms are logged. Arguments are individual alarm messages
} set;
struct {
_Atomic enum e_systemmode systemmode; ///< current operation mode
_Atomic enum e_runmode runmode; ///< CANNOT BE #RM_AUTO
_Atomic enum e_runmode dhwmode; ///< CANNOT BE #RM_AUTO or #RM_DHWONLY
atomic_bool stopdhw; ///< DHW kill switch: if true, all DHWTs running RM_AUTO will switch to RM_FROSTFREE
_Atomic timekeep_t timestep; ///< Stores the elapsed time between the last two consecutive runs of runtime_run()
timekeep_t lastrun; ///< Last time runtime_run() was executed
} run;
struct s_plant * restrict plant; ///< running plant
};
struct s_runtime * runtime_get(void);
int runtime_init(void);
int runtime_set_systemmode(const enum e_systemmode sysmode);
int runtime_set_runmode(const enum e_runmode runmode);
int runtime_set_dhwmode(const enum e_runmode dhwmode);
int runtime_online(void);
int runtime_run(void);
int runtime_offline(void);
void runtime_exit(void);
enum e_systemmode runtime_systemmode(void);
enum e_runmode runtime_runmode(void);
enum e_runmode runtime_dhwmode(void);
bool runtime_get_stopdhw(void);
int runtime_set_stopdhw(bool state);
timekeep_t runtime_get_timestep(void);
#endif /* rwchcd_runtime_h */