forked from gary/ems
2
0
Fork 0
sun_ems/ems_c/bsp/bsp_rtdb.h

96 lines
3.6 KiB
C
Raw Permalink Normal View History

2025-05-13 17:49:49 +08:00
/*****************************************************************************
* @copyright 2024-202, . POWER SUPPLY CO., LTD.
* @file bsp_rtdb.h
* @brief rtdb组件
* @author Gary
* @date 2024/08/30
* @remark
*****************************************************************************/
#ifndef BSP_RTDB_H
#define BSP_RTDB_H
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <stdint.h>
#include "kit_data.h"
#include "bsp_shm.h"
#include "bsp_redis.h"
#define RTDB_CREATE_MAX 5 // RTDB创建失败超时
typedef enum
{
RTDB_OK,
RTDB_ERROR
} rtdb_state_e;
typedef enum
{
Rtdb_ShMem,
Rtdb_Redis,
Rtdb_End
} rtdb_type_e;
extern rtdb_type_e rtdbType;
/*****************************************************************************
* @brief rtdb
* @param[in] type:
* @param[in] arg:
* @return 0- 1
*****************************************************************************/
uint8_t initRtdb(rtdb_type_e type,void* arg,shm_creat_type_e shmType);
/*****************************************************************************
* @brief RTDB中的值
* @param[in] type: Rtdb_ShMem
* @param[in] devType:
* @param[in] devId: 0
* @param[in] pointId: 0
* @return
*****************************************************************************/
double getRtdbPointValue(rtdb_type_e type, uint16_t devType, uint16_t devId, uint16_t pointId);
/*****************************************************************************
* @brief RTDB中写入值
* @param[in] type: Rtdb_ShMem
* @param[in] devType:
* @param[in] devId: 0
* @param[in] pointId: 0
* @param[in] value: RTDB中写入的值
*****************************************************************************/
void setRtdbPointValue(rtdb_type_e type, uint16_t devType, uint16_t devId, uint16_t pointId, double value);
/*****************************************************************************
* @brief web与c写配置变化的通知组件
* @param[in] type: Rtdb_ShMem
* @param[in] arg:
* @return 0- 1
*****************************************************************************/
uint8_t initWebSign(sign_share_type_e rtype,shm_creat_type_e rwtype);
/*****************************************************************************
* @brief web与c写配置变化的通知组件
* @param[in] type: Rtdb_ShMem
* @param[in] signType:
* @return 0- 1
*****************************************************************************/
uint16_t readWebSign(sign_share_type_e rtype, cfg_web_sign_e signType);
/*****************************************************************************
* @brief web与c写配置变化的通知组件
* @param[in] type:
* @param[in] signType:
* @param[in] val:
* @return 0- 1
*****************************************************************************/
void writeWebSign(sign_share_type_e rtype, cfg_web_sign_e signType, uint16_t val);
#endif // BSP_RTDB_H