fperez 625e253b7c Add new FM API methods
New API methods have been added to allow getting,
setting, and clearing faults by providing both
alarm_id and entity_instance_id.

Changes in this commit:
- For clear_fault operation, the query has been updated
to allow the removal of multiple rows with a single
query. The entity_instance_id parameter can now be a
prefix, enabling the matching of multiple alarms with
the same alarm_id.
This change does not affect existing use cases.

- New method get_faults_by_id_n_eid, This method allows
API clients to retrieve a list of alarms that match an
alarm_id and a prefix of entity_instance_id, thereby
matching multiple alarms.

- New method set_faults. This method accepts a list of
alarms as a parameter and calls the same core set_fault
function for each alarm.

[PASS] Build and install packages
[PASS] Remove several alarms that matches 'alarm_id',
       'entity_instance_id=%'
[PASS] Get list of alarms that match 'alarm_id' and
       'entity_instance_id=%'
[PASS] Verify that the new behavior for removing alarms
       does not affect previous use cases.
[PASS] Test set_faults API function providing a list
       of alarms. Verify the alarms in the list are
       being created.
[PASS] Enable debug mode to verify that queries are as
       expected.

Story: 2011106
task: 50756

Change-Id: Ib9dcfa97960a5d50865133a61810681e5a09edbe
Signed-off-by: fperez <fabrizio.perez@windriver.com>
2024-08-12 16:43:59 -03:00

71 lines
1.3 KiB
C++

//
// Copyright (c) 2024 Wind River Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
#ifndef _FM_MSG_H
#define _FM_MSG_H
#include <vector>
#include "fmAPI.h"
#include <stdint.h>
#define FM_MSG_VAL_KEY (0x1a0ff11d)
#define FM_MSG_WAIT_FAIL (5)
#define FM_MSG_MAX_RET (2)
#define FM_MSG_INF_WAIT (0)
typedef enum {
EFmMsgV1= 1,
EFmMaxVersion
}EFmMsgVersionT;
typedef enum {
EFmMsgRx=0,
EFmMsgTx=1,
EFmMsgMax
}EFmMsgTypesT;
typedef enum {
EFmCreateFault = 0,
EFmUpdateFault,
EFmDeleteFault,
EFmDeleteFaults,
EFmGetFault,
EFmGetFaults,
EFmReturnUUID,
EFmGetFaultsById,
EFmGetFaultsByIdnEid,
EFmActMax
}EFmMsgActionsT;
typedef struct {
EFmMsgVersionT version;
EFmMsgActionsT action;
uint32_t msg_size;
uint32_t msg_rc; //filled in by server
} SFmMsgHdrT;
typedef std::vector<char> fm_buff_t;
EFmErrorT fm_msg_utils_prep_requet_msg(fm_buff_t &buff,
EFmMsgActionsT act, const void * data, uint32_t len) ;
static inline void * ptr_to_data(fm_buff_t &buff) {
return &(buff[sizeof(SFmMsgHdrT)]);
}
static inline SFmMsgHdrT * ptr_to_hdr(fm_buff_t &buff) {
return (SFmMsgHdrT *)&(buff[0]);
}
static inline bool fm_valid_srv_msg(SFmMsgHdrT *msg, uint32_t exp_size) {
return (msg->msg_size==exp_size);
}
#endif /* _FM_MSG_H */