forked from gary/ems
2
0
Fork 0
sun_ems/ems_c/main.c

65 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*****************************************************************************
* @copyright 2024-2024, . POWER SUPPLY CO., LTD.
* @file main.c
* @brief 主进程入口文件
* @author Gary
* @date 2024/08/30
* @remark 初修订
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <sys/wait.h>
#include "argparse.h"
#include "daemon.h"
#include "app_task_regedit.h"
#include "mw_schedule_handle.h"
/*****************************************************************************
* @brief 主函数入口
* @param[in] argc命令行参数个数
* @param[in] argv命令行参数字符数组
* @return 返回状态码
*****************************************************************************/
int main(int argc, char *argv[])
{
void *arg = NULL; // 初始化参数
int ret = 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秒检查一次
}
main_end:
return ret; // 返回状态
}