/**
 * 数据处理引擎
 **/

#ifndef DATADEALENGINE_H
#define DATADEALENGINE_H

#include "AppCommon.h"

#include "EngineBase.h"
#include "EngineFactory.h"
#include "MyYaml.h"
#include "myutils.h"
#include "json/json.h"

class DataDealEngine : public ai_matrix::EngineBase
{
public:
    DataDealEngine();
    ~DataDealEngine();

    APP_ERROR Init() override;
    APP_ERROR DeInit() override;
    APP_ERROR Process() override;

private:
    //参数初始化(列车结束时需调用)
    void InitParam();
    //图片数据解码
    bool GetJpegdOut(std::shared_ptr<DecodedData> pDecodedData, RawData &rawData);
    //构造处理数据并push
    void MakeProcessData();
    //读取图片和文本
    bool ReadFileInfo(Json::Value &jvFrameInfo, RawData &rawData, std::string &strFileName, std::string &strImgName);
    //push数据
    void PushData(const std::string &strPort, const std::shared_ptr<ProcessData> &pProcessData);

private:
    std::string strPort0_;
    std::string strPort1_;
    std::string strPort2_;
    std::string strResultPath_;
    int iIntervalTime_;
    int iPushDirection_;
    int iDirection_;
    bool bNotPushFlag_;

    ai_matrix::DataSourceConfig dataSourceConfig_;
    std::map<int, ai_matrix::DataSourceConfig> mapUseDataSouceCfg_;
    std::map<int, std::vector<std::string>> mapSourcePushPort_;

    MoveData moveData_;
    std::queue<MoveData> queuwMoveData_;
    std::string strDataDir_;

    uint32_t iOrigDataNO_;      //原过车数据个数
    uint32_t iDataNO_;          //停车后重新行驶的数据个数
    std::string strTrainDate_;  //停车后重新行驶的日期    (格式：YYYY-MM-DD)
    std::string strTrainName_;  //停车后重新行驶的时间    (格式：HH-MM-SS)
};

ENGINE_REGIST(DataDealEngine)

#endif
