/**
 * 所有识别信息合并Engine
 * */

#ifndef MERGERALLENGINE_H
#define MERGERALLENGINE_H

#include "AppCommon.h"
#include "MyYaml.h"
#include "EngineBase.h"
#include "EngineFactory.h"
#include "myutils.h"

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

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

private:
    //初始化参数信息
    void InitParam();
    //push结果
    void PushData(std::shared_ptr<Train> pTrain);

    int QueueHaveDataCount();

    std::string strPort0_;
    std::string strPort1_;
    std::string strPort2_;
    std::string strPort3_;

    std::map<std::string, bool> mapPopPort_;    //[key-获取数据端口; value-端口是否使用]]
    int iPopPortCnt_ = 0;
    std::queue<std::shared_ptr<void>> queuePort0_;
    std::queue<std::shared_ptr<void>> queuePort1_;
    std::queue<std::shared_ptr<void>> queuePort2_;
    std::queue<std::shared_ptr<void>> queuePort3_;

    int iTrainIndex_;
    
    bool bUploadFlag_;
    int iPushDirection_;
    std::queue<std::shared_ptr<Train>> queTrain_;

    bool bHeadFrontFlag_;
};

ENGINE_REGIST(MergerAllEngine)

#endif
