#include "CivHydrFuncInter.h"
#include "CivSysLog.h"

#include "CivHydrSimulation.h"
#include "CivTrackingAnalysis.h"
#include "CivProjSimulation.h"

bool PANDANALYSIS_API hdyrSimulation(char* uri)
{
    CivHydrSimulation simulation(uri);
    return simulation.hdyrSimulation();
}

bool PANDANALYSIS_API qualitySimulation(char* uri)
{
    CivHydrSimulation simulation(uri);
    return simulation.qualitySimulation();
}

bool PANDANALYSIS_API trackingSimulation(char* uri, char* sN, int hours, char* result)
{
    CivHydrSimulation simulation(uri);

    std::string res;
    if (!simulation.trackingSimulation(sN, hours, res))
        return false;

    strcpy(result, res.c_str());

    return  true;
}

bool PANDANALYSIS_API upstreamTracking(char* uri, char* sn, char* result)
{
    CivTrackingAnalysis track(uri);
    track.createGraphFrom();

    std::string jsonResult;
    if (!track.upstreamTracking(sn, jsonResult))
        return false;

    strcpy(result, jsonResult.c_str());

    return true;
}

bool PANDANALYSIS_API downstreamTracking(char* uri, char* sn, char* result)
{
    CivTrackingAnalysis track(uri);
    track.createGraphFrom();

    std::string jsonResult;
    if (!track.downstreamTracking(sn, jsonResult))
        return false;

    strcpy(result, jsonResult.c_str());
    return true;
}

bool PANDANALYSIS_API waterSupplyScopeAnalysis(char* uri, char* sn, char* result)
{
    
    return true;
}

bool PANDANALYSIS_API projSimulation(char* uri, char* projCode, char* time)
{
    CivProjSimulation projSimulation(uri);

    if (!projSimulation.simulationProj(projCode, time))
        return false;

    return true;
}