#include <iostream>
#include <libpq-fe.h>
#include "CivHydrFuncInter.h"
#include "iostream"
#include "time.h"
#include <time.h>
#include "string.h"
#include "CivTestContext.h"
#include "CivHydrTest.h"
#include <vector>
#include <string>

#include <windows.h>
#include <consoleapi2.h>


using namespace std;

int main(int argc, char* argv[])
{
	while (true)
	{
		const char* uri = "host=192.168.19.100 port=5432 dbname=JinXian user=postgres password=admin";
		char* findUri = const_cast<char*>(uri);

		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
		cout << "水力模型接口测试，请输入对应的测试号：(输入0退出)\n";
		cout << "\t1.水力接口测试\n";
		cout << "\t2.水质计算接口测试\n";
		cout << "\t3.追踪测试\n";
		cout << "\t4.上游追踪\n";
		cout << "\t5.下游追踪\n";
		cout << "\t6.水源供水范围分析\n";
		cout << "\t7.方案模拟\n";

		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
		int test_no;
		cout << "请输入：";
		cin >> test_no;
		cout << "你选择的测试号是：" << test_no << endl;
		CivTestContext context;

		clock_t start, end;
		start = clock();
		
		switch (test_no)
		{
		case 0://退出
			exit(0);
			break;
		case 1://1.测试水力
			context.setHydrTest(new CivConHydrTest());
			context.contextTest(findUri);
			break;
		case 2://测试水质
			context.setHydrTest(new CivConQuaTest());
			context.contextTest(findUri);
			break;
		case 3://3.测试追踪
			context.setHydrTest(new CivConTrackTest());
			context.contextTest(findUri);
			break;
		case 4://4.测试上游追踪
			context.setHydrTest(new CivUpstreamTrackingTest());
			context.contextTest(findUri);
			break;
		case 5://5.测试下游追踪
			context.setHydrTest(new CivDownStreamTrackingTest());
			context.contextTest(findUri);
			break;
		case 6://6.测试水源供水范围
			context.setHydrTest(new CivWaterSupplyScopeTest());
			context.contextTest(findUri);
			break;
		case 7://6.测试水源供水范围
			context.setHydrTest(new CivProjSimulationTest());
			context.contextTest(findUri);
			break;
		default:
			cout << "输入测试号错误！" << endl;
			break;
		}
		end = clock();
		cout << (end - start)/1000 << endl;
	}
  
    return 0;
}