#include "CivHydrSimulation.h"
#include "CivInpConvertor.h"

CivHydrSimulation::CivHydrSimulation(const std::string& uri):mUri(uri)
{

}

CivHydrSimulation::~CivHydrSimulation()
{

}

bool CivHydrSimulation::hdyrSimulation()
{
    CivInpConvertor convertor(mUri);
    std::string inpFileS = convertor.convertBaseInp();
    if (inpFileS.empty())
        return false;

    if (!mHydrCompute.hdyrCompute())
    {
        return false;
    }
    mHydrCompute.saveResult(mUri);

    return true;
}

bool CivHydrSimulation::qualitySimulation()
{
    CivInpConvertor convertor(mUri);
    std::string inpFileS = convertor.convertBaseInp();
    if (inpFileS.empty())
        return false;

    if (!mHydrCompute.qualityCompute())
    {
        return false;
    }

    mHydrCompute.saveResult(mUri);

    return true;
}

bool  CivHydrSimulation::trackingSimulation(char* snNode, int hours,std::string& jsonResult)
{ 
    CivInpConvertor convertor(mUri);
    std::string inpFileS = convertor.convertTrackInp(snNode, std::to_string(hours));
    if (inpFileS.empty())
        return false;

    if (!mHydrCompute.qualityCompute())
    {
        return false;
    }

    mHydrCompute.getTrackingResult(mUri,jsonResult);

    return true;
}