diff --git a/clib/web/aarch64/libcrtdb.so b/clib/web/aarch64/libcrtdb.so deleted file mode 100644 index 3cb0135..0000000 Binary files a/clib/web/aarch64/libcrtdb.so and /dev/null differ diff --git a/clib/web/x86/libcrtdb.so b/clib/web/x86/libcrtdb.so deleted file mode 100644 index 0c025ea..0000000 Binary files a/clib/web/x86/libcrtdb.so and /dev/null differ diff --git a/ems_c/.gitignore b/ems_c/.gitignore index 611a4ae..22b17bb 100644 --- a/ems_c/.gitignore +++ b/ems_c/.gitignore @@ -24,8 +24,6 @@ # Shared objects (inc. Windows DLLs) *.dll -*.so -*.so.* *.dylib # Executables diff --git a/ems_c/CMakeLists.txt b/ems_c/CMakeLists.txt index e40df6d..8107dfa 100644 --- a/ems_c/CMakeLists.txt +++ b/ems_c/CMakeLists.txt @@ -86,5 +86,5 @@ add_executable(${ProjectName} # 添加编译选项 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) diff --git a/clib/web/include/bsp_rtdb.h b/ems_c/clib/aarch64/include/bsp_rtdb.h similarity index 100% rename from clib/web/include/bsp_rtdb.h rename to ems_c/clib/aarch64/include/bsp_rtdb.h diff --git a/ems_c/clib/aarch64/libcrtdb.so b/ems_c/clib/aarch64/libcrtdb.so new file mode 100644 index 0000000..3d1f073 Binary files /dev/null and b/ems_c/clib/aarch64/libcrtdb.so differ diff --git a/ems_c/clib/aarch64/libcsundb.so b/ems_c/clib/aarch64/libcsundb.so new file mode 100644 index 0000000..f952617 Binary files /dev/null and b/ems_c/clib/aarch64/libcsundb.so differ diff --git a/ems_c/clib/aarch64/libcsunmodbus.so b/ems_c/clib/aarch64/libcsunmodbus.so new file mode 100644 index 0000000..2d1120c Binary files /dev/null and b/ems_c/clib/aarch64/libcsunmodbus.so differ diff --git a/ems_c/clib/aarch64/libcsunntp.so b/ems_c/clib/aarch64/libcsunntp.so new file mode 100644 index 0000000..cf700a8 Binary files /dev/null and b/ems_c/clib/aarch64/libcsunntp.so differ diff --git a/ems_c/clib/aarch64/libcsunshmrtdb.so b/ems_c/clib/aarch64/libcsunshmrtdb.so new file mode 100644 index 0000000..fb978e4 Binary files /dev/null and b/ems_c/clib/aarch64/libcsunshmrtdb.so differ diff --git a/clib/web/readme b/ems_c/clib/aarch64/readme similarity index 100% rename from clib/web/readme rename to ems_c/clib/aarch64/readme diff --git a/ems_c/clib/clib.tar.gz b/ems_c/clib/clib.tar.gz deleted file mode 100644 index c44c292..0000000 Binary files a/ems_c/clib/clib.tar.gz and /dev/null differ diff --git a/ems_c/main.c b/ems_c/main.c index 79553e6..24037fe 100644 --- a/ems_c/main.c +++ b/ems_c/main.c @@ -28,36 +28,23 @@ int main(int argc, char *argv[]) { void *arg = NULL; // 初始化参数 int ret = 0; // 返回值 + uint16_t sysheart = 0; // 系统心跳 + double sysheart_value = 0.0; // 系统心跳值 // EMS初始化 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) regeditThreadEntry(arg); - // 启动Ems的Api - // if (ret == 0) - // runEmsWebApi(); - // 主循环,保持进程运行 while (1) { - /*测试模式*/ -#ifdef RELEASE_DEBUG - // setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_TcpLog_Enable, 1.0); - // setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_UartLog_Enable, 1.0); - // setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_ModBusLog_Enable, 1.0); -#endif - sleep(5); // 每60秒检查一次 + //设置系统心跳 + setRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_RunHeartCount, (double)sysheart++); + sysheart_value = getRtdbPointValue(rtdbType, kDev_Type_EMS, 0, kEms_RunHeartCount); + printf("System Heartbeat: %02f\n", sysheart_value); + sleep(1); // 每1秒检查一次 } main_end: diff --git a/release/ems/bin/EMS_C_V1.0.0 b/release/ems/bin/EMS_C_V1.0.0 deleted file mode 100644 index 22b8899..0000000 Binary files a/release/ems/bin/EMS_C_V1.0.0 and /dev/null differ diff --git a/release/ems/bin/EMS_C_V1.0.0_lib b/release/ems/bin/EMS_C_V1.0.0_lib new file mode 100644 index 0000000..72ef0d2 Binary files /dev/null and b/release/ems/bin/EMS_C_V1.0.0_lib differ diff --git a/release/ems/clib/aarch64/include/bsp_rtdb.h b/release/ems/clib/aarch64/include/bsp_rtdb.h new file mode 100644 index 0000000..b45aaec --- /dev/null +++ b/release/ems/clib/aarch64/include/bsp_rtdb.h @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 \ No newline at end of file diff --git a/release/ems/clib/aarch64/libcrtdb.so b/release/ems/clib/aarch64/libcrtdb.so new file mode 100644 index 0000000..3d1f073 Binary files /dev/null and b/release/ems/clib/aarch64/libcrtdb.so differ diff --git a/release/ems/clib/aarch64/libcsundb.so b/release/ems/clib/aarch64/libcsundb.so new file mode 100644 index 0000000..f952617 Binary files /dev/null and b/release/ems/clib/aarch64/libcsundb.so differ diff --git a/release/ems/clib/aarch64/libcsunmodbus.so b/release/ems/clib/aarch64/libcsunmodbus.so new file mode 100644 index 0000000..2d1120c Binary files /dev/null and b/release/ems/clib/aarch64/libcsunmodbus.so differ diff --git a/release/ems/clib/aarch64/libcsunntp.so b/release/ems/clib/aarch64/libcsunntp.so new file mode 100644 index 0000000..cf700a8 Binary files /dev/null and b/release/ems/clib/aarch64/libcsunntp.so differ diff --git a/release/ems/clib/aarch64/libcsunshmrtdb.so b/release/ems/clib/aarch64/libcsunshmrtdb.so new file mode 100644 index 0000000..fb978e4 Binary files /dev/null and b/release/ems/clib/aarch64/libcsunshmrtdb.so differ diff --git a/release/ems/clib/aarch64/readme b/release/ems/clib/aarch64/readme new file mode 100644 index 0000000..dbd69e6 --- /dev/null +++ b/release/ems/clib/aarch64/readme @@ -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); + diff --git a/release/ems/clib/clib.tar.gz b/release/ems/clib/clib.tar.gz deleted file mode 100644 index c44c292..0000000 Binary files a/release/ems/clib/clib.tar.gz and /dev/null differ