You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.2 KiB
94 lines
3.2 KiB
//
|
|
// Created by zwsd
|
|
//
|
|
|
|
#pragma once
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <list>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <set>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "iflytop/components/restful_server/restful_server.hpp"
|
|
#include "iflytop/core/components/jobs/work_queue.hpp"
|
|
#include "iflytop/core/components/timer/simple_timer.hpp"
|
|
#include "iflytop/core/spdlogfactory/logger.hpp"
|
|
#include "iflytoplinuxsdk/src/iflytop/components/iflytop_front_end_service/iflytop_front_end_service.hpp"
|
|
#include "service/device_state_service.hpp"
|
|
#include "service/disinfection_ctl_service.hpp"
|
|
|
|
//
|
|
#include "configs/gconfig.hpp"
|
|
#include "iflytop/components/iflytop_front_end_service/iflytop_front_end_service.hpp"
|
|
#include "zservice_container/zservice_container.hpp"
|
|
//
|
|
|
|
//
|
|
#include "db/db_service.hpp"
|
|
#include "iflytop/components/zcanreceiver/zcanhost.hpp"
|
|
#include "service/device_io_control_service.hpp"
|
|
#include "service/disinfection_logs_manager.hpp"
|
|
#include "src/service/iflytop_can_host_device.hpp"
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* service: MainControlService
|
|
*
|
|
* 监听事件:
|
|
* 依赖状态:
|
|
* 依赖服务:
|
|
* 作用:
|
|
*
|
|
*/
|
|
|
|
namespace iflytop {
|
|
using namespace std;
|
|
using namespace core;
|
|
class MainControlService : public enable_shared_from_this<MainControlService> {
|
|
ENABLE_LOGGER(MainControlService);
|
|
|
|
shared_ptr<GConfig> m_zconfig;
|
|
shared_ptr<RestfulServer> m_restfulServer;
|
|
shared_ptr<IflytopFrontEndService> m_iflytopwsService;
|
|
shared_ptr<DBService> m_dbService;
|
|
shared_ptr<DeviceStateService> m_deviceStateService;
|
|
shared_ptr<DisinfectionCtrlService> m_disinfectionCtrlService;
|
|
shared_ptr<DeviceIoControlService> m_deviceIoControlService;
|
|
shared_ptr<DisinfectionLogsManager> m_disinfectionLogsManager;
|
|
shared_ptr<ZCanHost> m_zcanhost;
|
|
|
|
unique_ptr<Thread> m_reportThread;
|
|
|
|
unique_ptr<Thread> m_autoshutdownThread;
|
|
|
|
public:
|
|
MainControlService(){};
|
|
void initialize();
|
|
|
|
private:
|
|
void dosystem(string order, bool dump) {
|
|
if (dump) logger->info("do:{}", order);
|
|
system(order.c_str());
|
|
}
|
|
|
|
private:
|
|
HttpResponsePtr reactionConfigCardInfo_read(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
|
|
HttpResponsePtr reactionConfigCardInfo_trigger_once_report(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
|
|
HttpResponsePtr reactionConfigCardInfo_read_state(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
|
|
HttpResponsePtr hello_world(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
|
|
//
|
|
HttpResponsePtr doscript(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
|
|
HttpResponsePtr doscriptblock(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
|
|
HttpResponsePtr stopscript(HttpRequestPtr, shared_ptr<RestfulServer::Context>, std::shared_ptr<ConnectionState>);
|
|
|
|
void createReactionConfigCardInfoReportAndSend();
|
|
void processFrontEndMessage(weak_ptr<WebSocket> webSocket, json& cmd, json& receipt);
|
|
|
|
json createSensorDataJson();
|
|
};
|
|
} // namespace iflytop
|