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
77
78
79
// ConfigManager.h

#ifndef _CONFIGMANAGER_h
#define _CONFIGMANAGER_h

#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif
#include "Configuration.h"
#include "SystemStatus.h"
#include "Alarms.h"

/**
 * \brief	Configuration class. Store config parameters and manage communicate interface
 * 
 * The class store all configuration and allows the interoperability with the GUI
 * or control scripts
 * It does not directly manage the communication. It just export the SetParameter and 
 * GetParameter function
 * 
 * The system configuration is stored in the core_config t_config struct.
 * 
 * The class initialize configuration with default parameters
 */
class ConfigManagerClass 
{
 protected:

	 

 public:
	 bool SetParameter(String p, String v);
	 String GetParameter(String p);
	 void Init(void *_core, t_SystemStatus* _sys_s, AlarmClass *_Alarms);
	 t_config core_config;

	 std::function<void()> callback_BeforeConfigurationGet = NULL;
	 std::function<void()> callback_BeforeConfigurationSet = NULL;
	 std::function<void()> callback_AfterConfigurationSet = NULL;

	 void addHandler_BeforeConfigurationGet(std::function<void()> callback)
	 {
		 callback_BeforeConfigurationGet = callback;
	 }

	 void addHandler_BeforeConfigurationSet(std::function<void()> callback)
	 {
		 callback_BeforeConfigurationSet = callback;
	 }

	 void addHandler_AfterConfigurationSet(std::function<void()> callback)
	 {
		 callback_AfterConfigurationSet = callback;
	 }

private:
	AlarmClass *Alarms;
	void* core;
	t_SystemStatus *sys_s;

	uint32_t GenerateFlag(int alarm_code);

};

#endif

//                  #     # ### 
//                  ##    #  #  
//                  # #   #  #  
//                  #  #  #  #  
//                  #   # #  #  
//                  #    ##  #  
//                  #     # ### 
//
// Nuclear Instruments 2020 - All rights reserved
// Any commercial use of this code is forbidden
// Contact info@nuclearinstruments.eu