//
// Created by matrixai on 10/26/24.
//

#ifndef TRAIN_CONTROLENGINE_H
#define TRAIN_CONTROLENGINE_H

#include "AppCommon.h"
#include "EngineBase.h"
#include "EngineFactory.h"
#include "json/json.h"

using namespace ai_matrix;

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

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

private:

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

    ai_matrix::BaseConfig baseConfig_;
    ai_matrix::IdentifyConfig identifyConfig_;
    std::vector<DataSourceConfig> vecDataSourceConfig_;

    uint32_t iDetectNO_ = 1;  //动态检测数据编号
    std::map<int, uint32_t> mapDetectNO_;
    std::map<int, int> mapIdentifyType_;

    std::string strDetectDate_;
    std::string strDetectTime_;

    //参数初始化
    void initParam();
    void endIdentify(int iDataSource);
    void sendWSEngine(std::string msg);
    void detectControl(std::shared_ptr<std::string> pWSServerOrder);
    bool isDetecting();

};

ENGINE_REGIST(ControlEngine)


#endif //TRAIN_CONTROLENGINE_H
