po_hi_driver_pus_parameter_monitoring.h 18.1 KB
Newer Older
1 2 3 4 5
/*
 * This is a part of PolyORB-HI-C distribution, a minimal
 * middleware written for generated code from AADL models.
 * You should use it with the Ocarina toolsuite.
 *
yoogx's avatar
yoogx committed
6
 * For more informations, please visit http://www.openaadl.org
7
 *
yoogx's avatar
yoogx committed
8
 * Copyright (C) 2010-2019 ESA & ISAE, 2019-2020 OpenAADL
9 10 11 12 13 14 15 16 17 18 19 20 21
 */

#ifndef __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_H__ 
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_H__ 

/*
 * This file is part of the implementation of the Parameter
 * Monitoring service of PUS (service type 12).
 */

/*
 * To work, this code must be interfaces with code generated
 * from Ocarina/TASTE. It requires the following definitions:
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
 *  - __po_hi_driver_pus_rid_t : event identifiers
 *  - __po_hi_driver_pus_pid_t : parameter identifiers
 *  - __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_LIST_SIZE : size of the monitoring
 *    list.
 */


#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_MAX_CHECK_PER_ITEM 4


#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_ENABLE                   1                   /* 01 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_DISABLE                  1<<1                /* 02 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_CHECK_TRANSITION_REPORT  ((1<<3)|(1<<2))     /* 12 */
/*
 * The following are the minimum capabilities
 */


#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_CHANGE_REPORTING_DELAY   ((1<<1)|1)          /* 03 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_CLEAR               ((1<<2))            /* 04 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_ADD                 ((1<<2)|1)          /* 05 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_DELETE              ((1<<2)|(1<<1))     /* 06 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_MODIFY              ((1<<2)|(1<<1)|1)   /* 07 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_REPORT_ASK          (1<<3)              /* 08 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_REPORT_ANSWER       ((1<<3)|1)          /* 09 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_OOL_ASK                  ((1<<3)|(1<<1))     /* 10 */
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_OOL_ANSWER               ((1<<3)|(1<<1)|1)   /* 11 */
/*
 * The following are additional capabilities.
51 52
 */

53 54 55 56 57
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_LIST_FULL      14
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_EXIST          15
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_NO_ACCESS      16
#define __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_NOT_BOOLEAN    17

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
typedef struct
{
   char*                      low_limit;
   __po_hi_driver_pus_rid_t   low_limit_rid,
   char*                      high_limit;
   __po_hi_driver_pus_rid_t   high_limit_rid,
}__po_hi_driver_pus_parameter_monitoring_limit_check_t;


typedef struct
{
   char*                      low_delta;
   __po_hi_driver_pus_rid_t   low_delta_rid,
   char*                      high_delta;
   __po_hi_driver_pus_rid_t   high_delta_rid,
}__po_hi_driver_pus_parameter_monitoring_delta_check_t;


typedef struct
{
   char*                      expected_value;
   __po_hi_driver_pus_rid_t   rid,
}__po_hi_driver_pus_parameter_monitoring_expected_check_t;

typedef struct
{
84 85 86 87 88 89 90
   __po_hi_int_t  check_position;
   int            check_selection_parameter;
}__po_hi_driver_pus_parameter_monitoring_modification_t;

typedef struct
{
   __po_hi_pus_parameter_monitoring_pid_t                      pid;
91 92 93 94 95 96 97 98 99 100 101 102 103 104
   __po_hi_uint32_t                                            interval;
   __po_hi_uint32_t                                            n_values;
   /* Number of values that are monitored before issuing a value check */
   __po_hi_uint32_t                                            n_delta;
   /* Number of values that are monitored before issuing a delta check */
   __po_hi_uint32_t                                            n_limit_checks;
   __po_hi_uint32_t                                            n_delta_checks;
   __po_hi_uint32_t                                            n_expected_checks;
   __po_hi_driver_pus_parameter_monitoring_limit_check_t       limit_checks[__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_MAX_CHECK_PER_ITEM];
   __po_hi_driver_pus_parameter_monitoring_delta_check_t       delta_checks[__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_MAX_CHECK_PER_ITEM];
   __po_hi_driver_pus_parameter_monitoring_expected_check_t    expected_checks[__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_MAX_CHECK_PER_ITEM];
}__po_hi_driver_pus_parameter_monitoring_item_t;


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

typedef struct
{
   __po_hi_bool_t                                              enable;
   __po_hi_uint32_t                                            max_reporting_delay;
   __po_hi_uint32_t                                            n_items;
   __po_hi_driver_pus_parameter_monitoring_item_t              items;
}__po_hi_driver_pus_parameter_monitoring_status_t;


#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_EXPECTED_VALUE       0
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_WITHIN_LIMITS        0
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_WITHIN_THRESOLDS     0
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_UNCHECKED            1
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_INVALID              2
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_UNSELECTED           3
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_UNEXPECTED_VALUE     4
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_BELOW_LIMIT          4
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_BELOW_THRESOLD       4
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_ABOVE_LIMIT          5
#define   __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_ABOVE_THRESOLD       5

typedef struct
{

   __po_hi_pus_parameter_monitoring_pid_t                      pid;
   char*                                                       param_value;
   char*                                                       limit_crossed;
   __po_hi_uint8_t                                             previous_status;
   /* 
    * Correspond to a value of the macro 
    * __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_* 
    */
   __po_hi_uint8_t                                             current_status;
   /* 
    * Correspond to a value of the macro 
    * __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_CHECKING_STATUS_* 
    */
   __po_hi_time_t                                              crossed_time;
}__po_hi_driver_pus_parameter_monitoring_report_status_item_t;


typedef struct
{
   __po_hi_uint32_t                                               n_items;
   __po_hi_driver_pus_parameter_monitoring_report_status_item_t*  items;
}__po_hi_driver_pus_parameter_monitoring_ool_status_t;


typedef struct
{
   __po_hi_uint32_t                                               n_items;
   __po_hi_driver_pus_parameter_monitoring_report_status_item_t*  items;
}__po_hi_driver_pus_parameter_monitoring_check_transition_report_t;


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
int __po_hi_driver_pus_parameter_monitoring_enable (char* data, int data_length);
/*
 * Enable the monitoring of one, several or all parameters.
 * The data argument is RAW data while the data_length arg specifies the size
 * of the data argument.
 * It corresponds to subtype 1 
 * (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_ENABLE).
 *
 * The data argument is structured like this :
 *      ___________________________________________
 *     |  N  | PARAM 1 | PARAM 2 | ..... | PARAM N |
 *      -------------------------------------------
 *            <------->
 *         Repeated N times
 *
 * The value of N indicates the number of parameter to enable.
 * If N = 0, then, the whole monitoring of all parameters
 * is enable.
 *
 * Returns __PO_HI_SUCCESS if no error is raised.
 */

int __po_hi_driver_pus_parameter_monitoring_disable (char* data, int data_length);
/*
 * Disable the monitoring of one, several or all parameters.
 * The data argument is RAW data while the data_length arg specifies the size
 * of the data argument.
 * It corresponds to subtype 2
 * (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_DISABLE).
 *
 * The data argument is structured like this :
 *      ___________________________________________
 *     |  N  | PARAM 1 | PARAM 2 | ..... | PARAM N |
 *      -------------------------------------------
 *            <------->
 *         Repeated N times
 *
 * The value of N indicates the number of parameter to disable.
 * If N = 0, then, the whole monitoring of all parameters
 * is disable.
 *
 * Returns __PO_HI_SUCCESS if no error is raised.
 */


int __po_hi_driver_pus_parameter_monitoring_change_reporting_delay (__po_hi_uint32_t delay);
/*
 * Change the reporting delay. Correspond to section 15.3.2 of the ECSS
 * standard, subtype 3 (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_CHANGE_REPORTING_DELAY).
 *
 * Returns __PO_HI_SUCCESS if no error is detected.
 */


215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
int __po_hi_driver_pus_parameter_monitoring_clear ();
/*
 * Clear the monitoring list. Correspond to service subtype 4
 * (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_CLEAR)
 *
 * Returns __PO_HI_SUCCESS if no error is encountered.
 */


int __po_hi_driver_pus_parameter_monitoring_add_items (__po_hi_uint32_t                                          interval,
                                                      __po_hi_uint32_t                                           n_samples_values,
                                                      __po_hi_uint32_t                                           n_samples_delta,
                                                      __po_hi_uint32_t                                           n_parameters,
                                                      char*                                                      data,
                                                      __po_hi_uint32_t                                           data_length);
/*
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
 * The interval parameter corresponds to the interval at which parameters are
 * monitored.
 * The n_samples_values param corresponds to the number of values should be
 * sampled before a value monitoring report.
 * The n_samples_delta param corresponds to the number of values that should be
 * sampled before issuing a delta monitoring report.
 * The n_parameters param indicates how many parameters are we adding to the
 * monitoring list.
 * The data param contains relevant data for adding one or several monitoring
 * report definition to the list.
 * The data_length param defines the size of the data parameter.
 *
 * The data parameter is structured as in the 15.3.4 section of the ECSS PUS
 * standard. It repeats n_parameters times the same sequence that defines the
 * addition of a parameter to the monitoring list.
 *
 * Returns : 
 *    __PO_HI_SUCCESS             if no error is encountered.
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_LIST_FULL 
 *                               if the monitoring list is full
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_EXIST
 *                               if the parameter is already monitored.
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_NO_ACCESS
 *                               if the parameter is not accessible.
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_NOT_BOOLEAN
 *                               if the parameter is not boolean.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
 */


int __po_hi_driver_pus_parameter_monitoring_add_item (__po_hi_uint32_t                                           interval,
                                                      __po_hi_uint32_t                                           n_samples_values,
                                                      __po_hi_uint32_t                                           n_samples_delta,
                                                      __po_hi_driver_pus_pid_t                                   pid,
                                                      __po_hi_bool_t                                             is_valid,
                                                      __po_hi_uint32_t                                           n_limit_checks,
                                                      __po_hi_driver_pus_parameter_monitoring_limit_check_t*     limit_checks,
                                                      __po_hi_uint32_t                                           n_delta_checks,
                                                      __po_hi_driver_pus_parameter_monitoring_delta_check_t*     delta_checks,
                                                      __po_hi_uint32_t                                           n_expected_checks,
                                                      __po_hi_driver_pus_parameter_monitoring_expected_check_t*  expected_checks);

/*
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
 * Returns 
 *    __PO_HI_SUCCESS if no error is encountered.
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_LIST_FULL 
 *                               if the monitoring list is full
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_EXIST
 *                               if the parameter is already monitored.
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_NO_ACCESS
 *                               if the parameter is not accessible.
 *    __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_ERROR_NOT_BOOLEAN
 *                               if the parameter is not boolean.
 */

int __po_hi_driver_pus_parameter_monitoring_delete_item (__po_hi_driver_pus_pid_t pid);
/*
 * Delete a parameter from the monitoring list.
 * The pid param corresponds to the parameter to remove from the list.
 *
 * Returns 
 *    __PO_HI_SUCCESS if no error is encountered.
 */

int __po_hi_driver_pus_parameter_monitoring_delete_items (__po_hi_uint32_t n_parameters,
                                                          char*            data,
                                                          __po_hi_uint32_t data_length);
/*
 * Delete several parameters from the parameter list. The n_parameters param
 * indicates how many parameters are removed from the list. The data param is
 * a raw structure that contain all parameter id to be removed. The data_length
 * size specifies the size of the data param.
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
 *
 * Correspond to subtype 6
 * (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_DELETE)
 * 
 * Returns 
 *    __PO_HI_SUCCESS if no error is encountered.
 */

int __po_hi_driver_pus_parameter_monitoring_modify_item (__po_hi_driver_pus_pid_t pid,
                                                         __po_hi_bool_t                                             is_valid,
                                                         __po_hi_uint32_t                                           n_limit_checks,
                                                         __po_hi_driver_pus_parameter_monitoring_modification_t*    checks_modifications;
                                                         __po_hi_driver_pus_parameter_monitoring_limit_check_t*     limit_checks,
                                                         __po_hi_uint32_t                                           n_delta_checks,
                                                         __po_hi_driver_pus_parameter_monitoring_modification_t*    delta_modifications;
                                                         __po_hi_driver_pus_parameter_monitoring_delta_check_t*     delta_checks,
                                                         __po_hi_uint32_t                                           n_expected_checks,
                                                         __po_hi_driver_pus_parameter_monitoring_modification_t*    expected_modifications;
                                                         __po_hi_driver_pus_parameter_monitoring_expected_check_t*  expected_checks);

/*
 * Modify the monitoring of one parameter. The checks_modifications,
 * delta_modifications and expected_modifications parameters correspond to the
 * "Check Position" and "Check Selection Parameter#" item in section 1.3.6 of
 * the standard. For each modified parameter, we must have a value in
 * *_modifications data that indicate how the change are applied.
 *
 * Returns __PO_HI_SUCCESS if no error is encountered.
 */



int __po_hi_driver_pus_parameter_monitoring_modify_items (__po_hi_uint32_t n_parameters,
                                                          char*            data,
                                                          __po_hi_uint32_t data_length);
/*
 * Modify several parameters from the parameter list. The n_parameters param
 * indicates how many parameters are removed from the list. The data param is
 * a structure, detailed in section 15.3.6 of the standard.
 *
 * Correspond to service subtype 7 of the service 12.
 * (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_MODIFY)
344 345 346
 * 
 * Returns 
 *    __PO_HI_SUCCESS if no error is encountered.
347 348
 */

349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
int __po_hi_driver_pus_parameter_monitoring_report_list ();
/*
 * Report the list of ALL monitored parameters. Correspond to service subtype 8
 * (ask for report, TC packet - __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_REPORT_ASK)
 * and 9 (send the report, TM packet - __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_LIST_REPORT_ANSWER).
 *
 * Returns __PO_HI_SUCCESS if no error are encountered.
 */


int __po_hi_driver_pus_parameter_monitoring_report_ool ();
/*
 * Issue a report with ALL out of limit parameters. This corresponds to the
 * service subtype 10 (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_OOL_ASK)
 * for the TC packet and service 11 (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_OOL_ANSWER)
 * for the TM packet.
 *
 * Correspond to the section 15.3.8 of the ECSS standard.
 *
 * Returns __PO_HI_SUCCESS if no error are encountered.
 */


int __po_hi_driver_pus_parameter_monitoring_report_check_transitions ();
/*
 * Report the transition list that have been performed since the last report.
 * Correspond to service subtype 12
 * (__PO_HI_DRIVER_PUS_PARAMETER_MONITORING_SUBTYPE_CHECK_TRANSITION_REPORT)
 * and it sends a TM packet to the ground that contains the check transitions
 * informations. The packet structure is detailed in section 15.3.9 of the ECSS
 * standard.
 *
 * Returns __PO_HI_SUCCESS if no error are encountered.
 */


385

386
#endif /* __PO_HI_DRIVER_PUS_PARAMETER_MONITORING_H__ */