更新代码/更新库
This commit is contained in:
parent
cbdfb28e63
commit
80638aad62
Binary file not shown.
Binary file not shown.
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
# Shared objects (inc. Windows DLLs)
|
# Shared objects (inc. Windows DLLs)
|
||||||
*.dll
|
*.dll
|
||||||
*.so
|
|
||||||
*.so.*
|
|
||||||
*.dylib
|
*.dylib
|
||||||
|
|
||||||
# Executables
|
# Executables
|
||||||
|
|
|
@ -86,5 +86,5 @@ add_executable(${ProjectName}
|
||||||
# 添加编译选项
|
# 添加编译选项
|
||||||
target_compile_options(${ProjectName} PRIVATE -fno-stack-protector)
|
target_compile_options(${ProjectName} PRIVATE -fno-stack-protector)
|
||||||
|
|
||||||
target_link_libraries(${ProjectName} cmodbus cshmrtdb cdb cntp sqlite3 paho-mqtt3c pthread cjson paho-mqtt3a)
|
target_link_libraries(${ProjectName} csunmodbus csunshmrtdb csundb csunntp sqlite3 paho-mqtt3c pthread cjson paho-mqtt3a)
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
27
ems_c/main.c
27
ems_c/main.c
|
@ -28,36 +28,23 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
void *arg = NULL; // 初始化参数
|
void *arg = NULL; // 初始化参数
|
||||||
int ret = 0; // 返回值
|
int ret = 0; // 返回值
|
||||||
|
uint16_t sysheart = 0; // 系统心跳
|
||||||
|
double sysheart_value = 0.0; // 系统心跳值
|
||||||
// EMS初始化
|
// EMS初始化
|
||||||
ret = initEmsSystem(arg);
|
ret = initEmsSystem(arg);
|
||||||
|
|
||||||
// 设置SIGPIPE信号处理函数为忽略
|
|
||||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
|
|
||||||
{
|
|
||||||
printf("设置SIGPIPE信号的处理行为为SIG_IGN,失败!!!!\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("设置SIGPIPE信号的处理行为为SIG_IGN,即忽略。\n");
|
|
||||||
}
|
|
||||||
// 注册线程入口
|
// 注册线程入口
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
regeditThreadEntry(arg);
|
regeditThreadEntry(arg);
|
||||||
|
|
||||||
// 启动Ems的Api
|
|
||||||
// if (ret == 0)
|
|
||||||
// runEmsWebApi();
|
|
||||||
|
|
||||||
// 主循环,保持进程运行
|
// 主循环,保持进程运行
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/*测试模式*/
|
//设置系统心跳
|
||||||
#ifdef RELEASE_DEBUG
|
setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_RunHeartCount, (double)sysheart++);
|
||||||
// setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_TcpLog_Enable, 1.0);
|
sysheart_value = getRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_RunHeartCount);
|
||||||
// setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_UartLog_Enable, 1.0);
|
printf("System Heartbeat: %02f\n", sysheart_value);
|
||||||
// setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_ModBusLog_Enable, 1.0);
|
sleep(1); // 每1秒检查一次
|
||||||
#endif
|
|
||||||
sleep(5); // 每60秒检查一次
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main_end:
|
main_end:
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,143 @@
|
||||||
|
/*****************************************************************************
|
||||||
|
* @copyright Copyright (c) 2025-2055 Gary. All rights reserved.
|
||||||
|
* @file bsp_rtdb.h
|
||||||
|
* @brief rtdb组件
|
||||||
|
* @author Gary
|
||||||
|
* @date 2025/03/04
|
||||||
|
* @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>
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RTDB_OK,
|
||||||
|
RTDB_ERROR
|
||||||
|
} rtdb_state_e;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Rtdb_ShMem,
|
||||||
|
Rtdb_Redis,
|
||||||
|
Rtdb_End
|
||||||
|
} rtdb_type_e;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
kEE_SHM_READ, // 0
|
||||||
|
kEE_SHM_CREAT // 1
|
||||||
|
} shm_creat_type_e;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
kSign_Share_Start = 0,
|
||||||
|
kSign_ShMem = kSign_Share_Start,
|
||||||
|
kSign_Redis,
|
||||||
|
kSign_MQ, // 消息队列
|
||||||
|
kSign_Share_End
|
||||||
|
} sign_share_type_e;
|
||||||
|
|
||||||
|
// 全局变量web配置变化索引
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
kSign_Start = 0,
|
||||||
|
kSign_SysReboot = kSign_Start, // 系统reboot标记
|
||||||
|
kSign_SysSyncTime, // 系统对时
|
||||||
|
kSign_SysSetIp, // 系统IP配置
|
||||||
|
kSign_SysUpdate, // 本机系统软件升级
|
||||||
|
kSign_Rev40 = kSign_Start + 39,
|
||||||
|
kSign_End
|
||||||
|
} cfg_web_sign_e;
|
||||||
|
|
||||||
|
// 接入控制器的所有设备类型
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
kDev_Type_Start = 0, // 起始值
|
||||||
|
kDev_Type_EMS = kDev_Type_Start, // EMS本机 数量一个
|
||||||
|
kDev_Type_Pccmeter, // PCC电表 数量一个
|
||||||
|
kDev_Type_Bsmeter, // 储能电表 一般数量一个
|
||||||
|
kDev_Type_BSU, // 电池堆 数量 多个可配置
|
||||||
|
kDev_Type_BCU, // 电池簇 数量 多个可配置
|
||||||
|
kDev_Type_PCS, // PCS 数量 多个可配
|
||||||
|
kDev_Type_AirCond_LiquidCool, // 空调/液冷机组
|
||||||
|
kDev_Type_Thsensor, // 温湿度传感器 数量 多个可配置
|
||||||
|
kDev_Type_WaterThsensor, // 水浸传感器
|
||||||
|
kDev_Type_YGThsensor, // 烟感传感器 数量 多个可配置
|
||||||
|
kDev_Type_FireSystem, // 消防系统
|
||||||
|
kDev_Type_DI_DO_Device, // DI/DO设备设备
|
||||||
|
kDev_Type_UPS, // UPS设备 一般数量一个
|
||||||
|
kDev_Type_Reserve2, // 预留类型2
|
||||||
|
kDev_Type_Reserve3, // 预留类型3
|
||||||
|
kDev_Type_Reserve4, // 预留类型4
|
||||||
|
kDev_Type_Reserve5, // 预留类型5
|
||||||
|
kDev_Type_End
|
||||||
|
} dev_type_e;
|
||||||
|
|
||||||
|
extern rtdb_type_e rtdbType;
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* @brief 初始化rtdb
|
||||||
|
* @param[in] type: 实时库的类型
|
||||||
|
* @param[in] arg: 默认为空
|
||||||
|
* @param[in] shmType: 创建实时库类型
|
||||||
|
* @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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,78 @@
|
||||||
|
/*****************************************************************************
|
||||||
|
* @copyright Copyright (c) 2025-2055 Gary. All rights reserved.
|
||||||
|
* @file readme
|
||||||
|
* @brief rtdb组件
|
||||||
|
* @author Gary
|
||||||
|
* @remark 提供web端获取数据接口更改
|
||||||
|
* @date 2025/03/04
|
||||||
|
*****************************************************************************/
|
||||||
|
一、本库分为两个重要组件
|
||||||
|
1、一个是用于web配置相关的参数,通知C的组件;
|
||||||
|
2、一个是用于Web实时读取EMS系统中所有数据的组件;
|
||||||
|
|
||||||
|
二、针对两个组件使用步骤如下:
|
||||||
|
通知组件
|
||||||
|
1、首先调用初始化函数:uint8_t initWebSign(sign_share_type_e rtype, shm_creat_type_e rwtype);
|
||||||
|
2、针对不同配置的通知信号调用:void writeWebSign(sign_share_type_e rtype, cfg_web_sign_e signType, uint16_t val);
|
||||||
|
|
||||||
|
RTDB组件
|
||||||
|
1、首先调用初始化函数:uint8_t initRtdb(rtdb_type_e type, void *arg, shm_creat_type_e shmType);
|
||||||
|
2、针对不同设备不同测点调用函数:double getRtdbPointValue(rtdb_type_e type, uint16_t devType, uint16_t devId, uint16_t pointId);
|
||||||
|
|
||||||
|
|
||||||
|
三、每个函数的具体说明如下:
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* @brief 初始化rtdb
|
||||||
|
* @param[in] type: 实时库的类型
|
||||||
|
* @param[in] arg: 默认为空
|
||||||
|
* @param[in] shmType: 创建实时库类型
|
||||||
|
* @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);
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue