File: rules.h

package info (click to toggle)
ion 3.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,700 kB
  • ctags: 10,983
  • sloc: ansic: 141,798; sh: 22,848; makefile: 7,818; python: 1,638; sql: 311; perl: 197; awk: 178; xml: 50; java: 19
file content (217 lines) | stat: -rw-r--r-- 6,741 bytes parent folder | download | duplicates (2)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/******************************************************************************
 **                           COPYRIGHT NOTICE
 **      (c) 2012 The Johns Hopkins University Applied Physics Laboratory
 **                         All rights reserved.
 **
 **     This material may only be used, modified, or reproduced by or for the
 **       U.S. Government pursuant to the license rights granted under
 **          FAR clause 52.227-14 or DFARS clauses 252.227-7013/7014
 **
 **     For any other permissions, please contact the Legal Office at JHU/APL.
 ******************************************************************************/

/*****************************************************************************
 **
 ** \file rules.h
 **
 **
 ** Description:
 **
 **\todo Right now this is a dumping ground for common utilities across
 **\todo agent and manager. Need to make this a little more eloquent.
 ** Notes:
 **
 ** Assumptions:
 **
 ** Modification History:
 **  MM/DD/YY  AUTHOR         DESCRIPTION
 **  --------  ------------   ---------------------------------------------
 **  11/08/12  E. Birrane     Redesign of messaging architecture.
 **  06/24/13  E. Birrane     Migrated from uint32_t to time_t.
 *****************************************************************************/

#ifndef _RULES_H_
#define _RULES_H_

#include "lyst.h"

#include "shared/utils/nm_types.h"

#include "shared/primitives/mid.h"

/*#include "shared/msg/pdu.h"
#include "shared/msg/msg_def.h"
#include "shared/msg/msg_reports.h"
*/

/*
 * +--------------------------------------------------------------------------+
 * |							  CONSTANTS  								  +
 * +--------------------------------------------------------------------------+
 */

#define DTNMP_RULE_EXEC_ALWAYS (-1)
#define CONTROL_ACTIVE (1)
#define CONTROL_INACTIVE (0)

/*
 * +--------------------------------------------------------------------------+
 * |							  	MACROS  								  +
 * +--------------------------------------------------------------------------+
 */


/*
 * +--------------------------------------------------------------------------+
 * |							  DATA TYPES  								  +
 * +--------------------------------------------------------------------------+
 */



typedef struct
{
	Object itemObj;           /**> Serialized rule in an SDR. */
	uint32_t size;       /**> Size of rule in ruleObj.   */

	/* Descriptor Information. */
    int64_t  num_evals;       /**> # times left to eval rule. */
    uint32_t interval_ticks;  /**> # 1Hz ticks between evals. */
    eid_t    sender;          /**> Who sent this rule def.    */

    /* Below is not kept in the SDR. */
	Object descObj;   /** > This descriptor in SDR. */
} rule_time_prod_desc_t;


/**
 * Associated Message Type(s): MSG_TYPE_CTRL_PERIOD_PROD
 *
 * Purpose:
 *
 * +--------+------------+--------+---------+
 * | Start  | Period (s) | Count  | Results |
 * | (TS)   | (SDNV)     | (SDNV) |   (MC)  |
 * +--------+------------+--------+---------+
 */
typedef struct {
    time_t time;     /**> The time to start the production.   */
    uvast period;   /**> The delay between productions.      */
    uvast count;    /**> The # times to produce the message. */
    Lyst     mids; /**> The MIDs to include in the report.  */

    /* Below is not serialized. */
    uint32_t countdown_ticks; /**> # ticks before next eval.  */
    rule_time_prod_desc_t desc; /**> SDR descriptor. */
} rule_time_prod_t;



typedef struct
{
	Object itemObj;           /**> Serialized rule in an SDR. */
	uint32_t size;            /**> Size of rule in ruleObj.   */

	/* Descriptor Information. */
    int64_t  num_evals;       /**> # times left to eval rule. */
    uint32_t interval_ticks;  /**> # 1Hz ticks between evals. */
    eid_t    sender;          /**> Who sent this rule def.    */

    /* Below is not kept in the SDR. */
	Object descObj;           /** > This descriptor in SDR. */
} rule_pred_prod_descr_t;


/**
 * Associated Message Type(s): MSG_TYPE_CTRL_PRED_PROD
 *
 * Purpose:
 *
 * +--------+-----------+--------+---------+
 * | Start  | Predicate | Count  | Results |
 * | (TS)   |    (MC)   | (SDNV) |   (MC)  |
 * +--------+-----------+--------+---------+
 */
typedef struct {
    time_t time;       /**> The time to start the production. */
    Lyst predicate;    /**> The predicate driving report production.*/
    uvast count;       /**> The # times to produce the message. */
    Lyst contents;     /**> The MIDs to include in the report. */

    /* Below is not serialized. */
    uint32_t countdown_ticks;       /**> # ticks before next eval.  */
    rule_pred_prod_descr_t descObj; /**> SDR descriptor */
} rule_pred_prod_t;



typedef struct
{
	Object itemObj;           /**> Serialized ctrl in an SDR. */
	uint32_t size;            /**> Size of ctrl in ctrlObj.   */

	/* Descriptor Information. */
    eid_t    sender;          /**> Who sent this ctrl def.    */
    uint8_t  state;           /**> 0: INACTIVE, 1, ACTIVE     */

    /* Below is not kept in the SDR. */
	Object descObj;           /** > This descriptor in SDR. */
} ctrl_exec_desc_t;

/**
 * Associated Message Type(s): MSG_TYPE_CTRL_PERF_CTRL
 *
 * Purpose: Runs a control on the agent.
 *
 * +-------+-----------+
 * | Start |  Controls |
 * |  (TS) |    (MC)   |
 * +-------+-----------+
 */
typedef struct {
    time_t time;              /**> The time to run the control. */
    Lyst contents;            /**> The controls (macro) to run. */

    /* Below is not serialized. */
    uint32_t countdown_ticks; /**> # ticks before next eval.  */
    ctrl_exec_desc_t desc; /**> SDR descriptor. */

} ctrl_exec_t;



/*
 * +--------------------------------------------------------------------------+
 * |						  FUNCTION PROTOTYPES  							  +
 * +--------------------------------------------------------------------------+
 */


/* Create functions. */
rule_time_prod_t *rule_create_time_prod_entry(time_t time,
							   				  uvast count,
											  uvast period,
											  Lyst contents);

rule_pred_prod_t *rule_create_pred_prod_entry(time_t time,
		   	   	   	   	   	   	   	   	      Lyst predicate,
		   	   	   	   	   	   	   	   	      uvast count,
		   	   	   	   	   	   	   	   	      Lyst contents);

ctrl_exec_t *ctrl_create_exec(time_t time, Lyst contents);


/* Release functions.*/
void rule_release_time_prod_entry(rule_time_prod_t *msg);
void rule_release_pred_prod_entry(rule_pred_prod_t *msg);
void ctrl_release_exec(ctrl_exec_t *msg);


/* Lyst functions. */
void rule_time_clear_lyst(Lyst *list, ResourceLock *mutex, int destroy);
void rule_pred_clear_lyst(Lyst *list, ResourceLock *mutex, int destroy);
void ctrl_clear_lyst(Lyst *list, ResourceLock *mutex, int destroy);



#endif // _RULES_H_