96 lines
3.5 KiB
C
Raw Normal View History

/*
@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
{
public:
2025-03-12 14:17:53 +08:00
CTimetableThread(const iot_public::SRunAppInfo &stRunAppInfo,
const iot_public::CSysInfoInterfacePtr &ptrSysInfo);
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
@return truefalse
*/
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);
/*
@brief
2025-03-12 14:17:53 +08:00
@param const iot_net::CMbMessage & objMsg
@return truefalse
*/
2025-03-12 14:17:53 +08:00
bool addManualCmd(const iot_net::CMbMessage &objMsg);
private:
2025-03-12 14:17:53 +08:00
iot_public::CSysInfoInterfacePtr m_ptrSysInfo; //< 系统信息访问库智能指针
iot_public::SRunAppInfo m_stRunAppInfo; //< 本应用相关运行参数
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;
}