#include "CivHydrTest.h"
#include "CivHydrFuncInter.h"
#include <iostream>
#include <string>

CivHydrTest::~CivHydrTest()
{

}

// 优化调度测试
void CivOptSchedulingTest::test(char* uri)
{
    std::string condtionMap = "{\"JD0000159\":{\"min\":20,\"max\":48},\"JD0000324\":{\"min\":20,\"max\":48},\"JD0000416\":{\"min\":20,\"max\":48},\"JD0000422\":{\"min\":20,\"max\":48},\"JD0000457\":{\"min\":20,\"max\":48},\"JD0000532\":{\"min\":20,\"max\":48},\"JD0000538\":{\"min\":20,\"max\":48},\"JD0000582\":{\"min\":20,\"max\":48},\"JD0000648\":{\"min\":20,\"max\":48},\"JD0000652\":{\"min\":20,\"max\":48},\"JD0000665\":{\"min\":20,\"max\":48},\"JD0000703\":{\"min\":20,\"max\":48},\"JD0000724\":{\"min\":20,\"max\":48}}";
    int time = 9;

    char* condition = const_cast<char*>(condtionMap.c_str());

    char result[1024 * 512];
    bool res = optimalSchedulingSimulation(uri, condition, 9, result);

    std::cout << "测试结果" << res << std::endl;
    std::cout << result << std::endl;
}

// 水力测试
void CivConHydrTest::test(char* uri)
{
    int succ = hdyrSimulation(uri);
    std::cout << "测试结果：" << succ << std::endl;
}


// 水质测试
void CivConQuaTest::test(char* uri)
{
    int succ = qualitySimulation(uri);
    std::cout << "测试结果：" << succ << std::endl;
}

// 追踪分析
void CivConTrackTest::test(char* uri)
{

    char result[1024 * 512];

    char sn[64];
    strcpy_s(sn, "5c8afd3e-b361-4458-b5ca-6891ec80ae8c");

    memset(result, 0, sizeof(result) / sizeof(char));
    int succ = trackingSimulation(uri, sn, 1, result);

    std::cout << result << std::endl;
    std::cout << "测试结果：" << succ << std::endl;

}

void CivUpstreamTrackingTest::test(char* uri)
{
    // 追踪节点编号
    char sn[64];
    strcpy(sn, "913fdd03-6b29-4a61-9c3b-e2f0bb33cb3c");

    char result[1024 * 128];

    bool isSucc = upstreamTracking(uri, sn, result);

    std::cout << result << std::endl;
    std::cout << "测试结果：" << isSucc << std::endl;
}

/**
   下游追踪
*/
void CivDownStreamTrackingTest::test(char* uri)
{
    // 追踪节点编号
    char sn[64];
    strcpy(sn, "48ff56e6-b50f-4003-ad5c-95240c114e42");

    char result[1024 * 512];

    bool isSucc = downstreamTracking(uri, sn, result);

    std::cout << result << std::endl;
    std::cout << "测试结果：" << isSucc << std::endl;
}


/**
   水源供水范围分析
*/
void CivWaterSupplyScopeTest::test(char* uri)
{
    // 追踪节点编号
    char sn[512];
    strcpy(sn, "913fdd03-6b29-4a61-9c3b-e2f0bb33cb3c");

    char result[1024 * 32];

    bool isSucc = waterSupplyScopeAnalysis(uri, sn, result);

    std::cout << result << std::endl;
    std::cout << "测试结果：" << isSucc << std::endl;
}

void CivProjSimulationTest::test(char* uri)
{
    // 追踪节点编号
    char projCode[512];
    strcpy(projCode, "e9443d7f-d05b-4768-94b7-084a5d0fe3ba");

    char time[512];
    strcpy(time, "2020-09-24 09:00:00");

    bool isSucc = projSimulation(uri, projCode, time);

    std::cout << "测试结果：" << isSucc << std::endl;
}
