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

CivHydrTest::~CivHydrTest()
{

}

void CivNetTopoTest::test(char* uri)
{
    char error[256];
   bool res = netTopo(uri, error);
    std::cout << "测试结果" << res << std::endl;
}

void CivResdualChrolmeTest::test(char* uri)
{
    // {"startTime":'',"endTime":'',"水池":[{"code":'',"余氯量":},{"code":'',"余氯量":}]}
    std::string conditionMap = "{\"TK0000001\":50,\"TK0000002\":100}";
    std::string startTimeStr = "2021-01-19 00:00:00";
    std::string endTimeStr = "2021-01-19 24:00:00";

    char* condition = const_cast<char*>(conditionMap.c_str());
    char* startTime = const_cast<char*>(startTimeStr.c_str());
    char* endTime = const_cast<char*>(endTimeStr.c_str());
    char error[250];
    bool res = residualChlorineAnalysis(uri, startTime, endTime,condition, error);

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

// 优化调度测试
void CivOptSchedulingTest::test(char* uri)
{
    std::string condtionMap = "{\"bcdd358e-1925-47be-8e20-d93999e33c1c\":{\"min\":30, \"max\" : 40}, \
    \"fd605205-c10e-4f7e-81a4-89c88166e763\" : {\"min\":50, \"max\" : 60}, \"c446cc2c-4110-406a-bda1-4f9544e38cb4\" : {\"min\":70, \"max\" : 80}}";
    int time = 17;
  
    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, "2021-1-27 11:00:00");

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

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