2025-03-12 10:03:16 +08:00
|
|
|
|
/*
|
|
|
|
|
|
@file TimetableThread.h
|
|
|
|
|
|
@brief 时间表处理线程
|
|
|
|
|
|
@author 曹顶法
|
|
|
|
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#include "pub_utility_api/TimerThreadBase.h"
|
|
|
|
|
|
#include "pub_sysinfo_api/SysInfoApi.h"
|
|
|
|
|
|
#include "net_msg_bus_api/CMbCommunicator.h"
|
|
|
|
|
|
#include "rdb_api/CRdbAccessEx.h"
|
|
|
|
|
|
#include "TimetableMsgBusMng.h"
|
|
|
|
|
|
#include "BasicOperation.h"
|
|
|
|
|
|
#include "DownloadTimetable.h"
|
|
|
|
|
|
#include "ReadTimetable.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace kbd_app
|
|
|
|
|
|
{
|
2025-03-12 14:17:53 +08:00
|
|
|
|
class CTimetableThread : public iot_public::CTimerThreadBase
|
2025-03-12 10:03:16 +08:00
|
|
|
|
{
|
|
|
|
|
|
public:
|
2025-03-12 14:17:53 +08:00
|
|
|
|
CTimetableThread(const iot_public::SRunAppInfo &stRunAppInfo,
|
|
|
|
|
|
const iot_public::CSysInfoInterfacePtr &ptrSysInfo);
|
2025-03-12 10:03:16 +08:00
|
|
|
|
virtual ~CTimetableThread();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 业务处理函数,必须继承实现自己的业务逻辑
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual void execute();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 初始化
|
|
|
|
|
|
@return 成功返回kbdSuccess,失败返回错误码
|
|
|
|
|
|
*/
|
|
|
|
|
|
int initialize();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 设置为主
|
|
|
|
|
|
@return 成功返回kbdSuccess,失败返回错误码
|
|
|
|
|
|
*/
|
|
|
|
|
|
int setMaster();
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 设置为备
|
|
|
|
|
|
@return 成功返回kbdSuccess,失败返回错误码
|
|
|
|
|
|
*/
|
|
|
|
|
|
int setSlave();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
/* @brief 处理命令 */
|
|
|
|
|
|
void handleCmd();
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 判断当前定时任务是否需要下载
|
|
|
|
|
|
@param const STableTimetableSchedule &stSchedule 当前命令
|
|
|
|
|
|
@return 成功返回true,失败返回false
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool needDownload(const STableTimetableSchedule &stSchedule);
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 添加定时任务到命令缓冲区
|
|
|
|
|
|
@param const STableTimetableSchedule &stSchedule 当前命令
|
|
|
|
|
|
@return 成功返回true,失败返回false
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool addScheduleCmd(const STableTimetableSchedule &stSchedule);
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 添加命令反馈到缓冲区
|
2025-03-12 14:17:53 +08:00
|
|
|
|
@param const iot_net::CMbMessage & objMsg 反馈消息
|
2025-03-12 10:03:16 +08:00
|
|
|
|
@return 成功返回true,失败返回false
|
|
|
|
|
|
*/
|
2025-03-12 14:17:53 +08:00
|
|
|
|
bool dispatchResponse(const iot_net::CMbMessage &objMsg);
|
|
|
|
|
|
bool addCustomResponse(const iot_net::CMbMessage &objMsg);
|
|
|
|
|
|
bool addPntResponse(const iot_net::CMbMessage &objMsg);
|
2025-03-12 10:03:16 +08:00
|
|
|
|
/*
|
|
|
|
|
|
@brief 添加人工操作命令到命令缓冲区
|
2025-03-12 14:17:53 +08:00
|
|
|
|
@param const iot_net::CMbMessage & objMsg
|
2025-03-12 10:03:16 +08:00
|
|
|
|
@return 成功返回true,失败返回false
|
|
|
|
|
|
*/
|
2025-03-12 14:17:53 +08:00
|
|
|
|
bool addManualCmd(const iot_net::CMbMessage &objMsg);
|
2025-03-12 10:03:16 +08:00
|
|
|
|
|
|
|
|
|
|
private:
|
2025-03-12 14:17:53 +08:00
|
|
|
|
iot_public::CSysInfoInterfacePtr m_ptrSysInfo; //< 系统信息访问库智能指针
|
|
|
|
|
|
iot_public::SRunAppInfo m_stRunAppInfo; //< 本应用相关运行参数
|
2025-03-12 10:03:16 +08:00
|
|
|
|
|
|
|
|
|
|
boost::gregorian::date m_readCfgDate; //< 最后一次读取配置文件的日期
|
|
|
|
|
|
boost::posix_time::ptime m_curTime; //< 当前时间,单位秒(线程每次循环获取一次)
|
|
|
|
|
|
boost::posix_time::ptime m_masterTime; //< 本进程升主的时间,单位秒
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<STableTimetableSchedule> m_vecScheduleTimetable; //< 当日需要定时下载的时间表列表,每天读取一次
|
|
|
|
|
|
|
|
|
|
|
|
CParamMngPtr m_ptrParamMng; //< 参数管理类
|
|
|
|
|
|
CTimetableMsgBusMngPtr m_ptrMsgbusMng; //< 消息总线管理类
|
|
|
|
|
|
CBasicOperationPtr m_ptrBasicOpt; //< 基础操作类
|
|
|
|
|
|
CCDownloadTimetablePtr m_ptrDownloadCmd; //< 时间表下载处理类
|
|
|
|
|
|
CReadTimetablePtr m_ptrReadCmd; //< 读取时间表处理类
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef boost::shared_ptr<CTimetableThread> CTimetableThreadPtr;
|
|
|
|
|
|
}
|