96 lines
3.6 KiB
C
96 lines
3.6 KiB
C
|
/*****************************************************************************
|
|||
|
* @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
|