KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
monitor.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2012-2014 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : monitor.h
11  * Created : 7 jul. 2014
12  * Author : Vincent van Beveren
13  */
14 
15 #ifndef MONITOR_H_
16 #define MONITOR_H_
17 
18 /**
19  * @file monitor.h
20  *
21  * @ingroup pv
22  *
23  * The monitor module is responsible for sending variables to the remote party based on
24  * subscription. It does not do any of the actual sending of data it self. It just keeps track
25  * of which variables to write.
26  *
27  * @author Vincent van Beveren
28  */
29 
30 #include <stdint.h>
31 #include <stdbool.h>
32 #include "vars.h"
33 
34 #include "util/databuffer.h"
35 
36 /// Maximum number of variables which can be monitored
37 #define MON_MAX_VARS ( TOTAL_VAR_COUNT )
38 
39 /// Maximim blob size
40 #define MON_MAX_BLOB (559 + TOTAL_VAR_COUNT * 4)
41 
42 /**
43  * Subscribe to array of variables
44  *
45  * @param varIds The array of variable IDs
46  * @param count The number of variables
47  * @param rate The rate value
48  *
49  * @retval true Success
50  * @retval false Failure, see err module
51  */
52 bool monSubscribeVars(int32_t * varIds, int count, int rate);
53 
54 /**
55  * Unsubscribe to array of variables. If the ID does not exist, it is ignored.
56  *
57  * @param varIds The array of variable IDs
58  * @param count The number of variables
59  */
60 void monUnsubscribeVars(int32_t * varIds, int count);
61 
62 /**
63  * Subscribe to a variable.
64  *
65  * @param varId The variable ID
66  * @param rate The rate value
67  *
68  * @retval true Success
69  * @retval false Failure, see err module
70  */
71 bool monSubscribeVar(int32_t varId, int rate);
72 
73 /**
74  * Unsubscribe to a variable. If the ID does not exist, it is ignored.
75  *
76  * @param varId The variable ID
77  */
78 void monUnsubscribeVar(int32_t varId);
79 
80 /**
81  * Write update variable information into the specified buffer.
82  *
83  * @param buffer Buffer to write into
84  * @param offset Offset (variable index) to start from. Begin at 0.
85  * @param rate The rate value acts as a filter such that
86  * all variables var_rate >= rate will be added to the update
87  * packet. For example, is there are variables with rate
88  * 1, 2 and 3, providing rate value 3, only variables with 3
89  * will be added. When providing rate 2, variables with rate
90  * 2 and 3 will be added.
91  *
92  * @retval -1 Error, check error module
93  * @retval 0 All ok, all variables written
94  * @retval other Written up to specified offset
95  */
96 int monUpdate(DataBuffer * buffer, int offset, int rate);
97 
98 #endif /* MONITOR_H_ */
bool monSubscribeVars(int32_t *varIds, int count, int rate)
Subscribe to array of variables.
Definition: monitor.c:83
Provides access to all variables of the various subsystems.
void monUnsubscribeVars(int32_t *varIds, int count)
Unsubscribe to array of variables.
Defines a DataBuffer structure.
Definition: databuffer.h:45
bool monSubscribeVar(int32_t varId, int rate)
Subscribe to a variable.
Definition: monitor.c:53
void monUnsubscribeVar(int32_t varId)
Unsubscribe to a variable.
Definition: monitor.c:95
DataBuffer reads and writes data into a buffer in the same format as defined in the data Java DataOut...
int monUpdate(DataBuffer *buffer, int offset, int rate)
Write update variable information into the specified buffer.
Definition: monitor.c:119