Commit d19dee3a authored by 刘乐's avatar 刘乐

1, 测试框架修改

parent aafa2bec
......@@ -13,6 +13,11 @@ CivTestContext::~CivTestContext()
delete mTest;
}
void CivTestContext::setHydrTest(CivHydrTest* test)
{
mTest = test;
}
void CivTestContext::contextTest(char* uri)
{
if (mTest == nullptr)
......
......@@ -6,8 +6,11 @@ class CivTestContext
{
public:
explicit CivTestContext(CivHydrTest* test);
CivTestContext() = default;
~CivTestContext();
void setHydrTest(CivHydrTest* test);
void contextTest(char* uri);
private:
......
......@@ -8,42 +8,68 @@
#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);
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 << "C++对象模型测试程序,请输入对应的测试号:(输入0退出)\n";
cout << "\t1.水力接口测试\n";
cout << "\t2.水质计算接口测试\n";
cout << "\t3.追踪测试\n";
cout << "\t4.上游追踪\n";
cout << "\t5.下游追踪\n";
cout << "\t6.水源供水范围分析\n";
// 测试水力
/* CivTestContext context(new CivConHydrTest());
context.contextTest(findUri);*/
// 测试水质
/*CivTestContext context(new CivConQuaTest());
context.contextTest(findUri);*/
// 测试追踪分析
/*CivTestContext context(new CivConTrackTest());
context.contextTest(findUri);*/
// 上游追踪
/*CivTestContext context(new CivUpstreamTrackingTest());
context.contextTest(findUri);*/
// 下游追踪
CivTestContext context(new CivDownStreamTrackingTest());
context.contextTest(findUri);
// 水源供水范围分析
/* CivTestContext context(new CivWaterSupplyScopeTest());
context.contextTest(findUri);*/
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
int test_no;
cout << "请输入:";
cin >> test_no;
cout << "你选择的测试号是:" << test_no << endl;
CivTestContext context;
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;
default:
cout << "输入测试号错误!" << endl;
break;
}
}
getchar();
return 0;
}
\ No newline at end of file
#include "CivBreakPipeAnalysis.h"
CivBreakPipeAnalysis::CivBreakPipeAnalysis()
{
}
CivBreakPipeAnalysis::~CivBreakPipeAnalysis()
{
}
\ No newline at end of file
#pragma once
#include <string>
/**
ܷ
*/
class CivBreakPipeAnalysis
{
public:
explicit CivBreakPipeAnalysis();
~CivBreakPipeAnalysis();
};
#include "CivCloseValveProj.h"
CivCloseValveProj::CivCloseValveProj()
{
}
CivCloseValveProj::~CivCloseValveProj()
{
}
\ No newline at end of file
#pragma once
/**
طģ
*/
class CivCloseValveProj
{
public:
CivCloseValveProj();
~CivCloseValveProj();
};
#include "CivInpProject.h"
CivInpProject::CivInpProject()
{
}
CivInpProject::~CivInpProject()
{
}
bool CivInpProject::writeToFile(const string& filename)
{
return true;
}
\ No newline at end of file
#pragma once
#include <string>
using namespace std;
/*
ݿinpļ
*/
class CivInpProject
{
public:
explicit CivInpProject();
~CivInpProject();
bool writeToFile(const string& filename);
private:
};
#include "CivStopWaterAnalysis.h"
CivStopWaterAnalysis::CivStopWaterAnalysis()
{
}
CivStopWaterAnalysis::~CivStopWaterAnalysis()
{
}
\ No newline at end of file
#pragma once
/**
ͣˮ
*/
class CivStopWaterAnalysis
{
public:
CivStopWaterAnalysis();
~CivStopWaterAnalysis();
};
......@@ -153,6 +153,8 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CivBaseInpBuilder.cpp" />
<ClCompile Include="CivBreakPipeAnalysis.cpp" />
<ClCompile Include="CivCloseValveProj.cpp" />
<ClCompile Include="CivHydDataType.cpp" />
<ClCompile Include="CivHydrCompute.cpp" />
<ClCompile Include="CivHydrFuncInter.cpp" />
......@@ -160,16 +162,20 @@
<ClCompile Include="CivInpBuilder.cpp" />
<ClCompile Include="CivInpConvertor.cpp" />
<ClCompile Include="CivInpDirector.cpp" />
<ClCompile Include="CivInpProject.cpp" />
<ClCompile Include="CivNewInp.cpp" />
<ClCompile Include="CivOptSchedSimulation.cpp" />
<ClCompile Include="CivProjInpBuilder.cpp" />
<ClCompile Include="CivProjManager.cpp" />
<ClCompile Include="CivProjSimulation.cpp" />
<ClCompile Include="CivSimulResultCache.cpp" />
<ClCompile Include="CivStopWaterAnalysis.cpp" />
<ClCompile Include="CivTrackingAnalysis.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivBaseInpBuilder.h" />
<ClInclude Include="CivBreakPipeAnalysis.h" />
<ClInclude Include="CivCloseValveProj.h" />
<ClInclude Include="CivGraphList.h" />
<ClInclude Include="CivHydDataType.h" />
<ClInclude Include="CivHydrCompute.h" />
......@@ -178,12 +184,14 @@
<ClInclude Include="CivInpBuilder.h" />
<ClInclude Include="CivInpConvertor.h" />
<ClInclude Include="CivInpDirector.h" />
<ClInclude Include="CivInpProject.h" />
<ClInclude Include="CivNewInp.h" />
<ClInclude Include="CivOptSchedSimulation.h" />
<ClInclude Include="CivProjInpBuilder.h" />
<ClInclude Include="CivProjManager.h" />
<ClInclude Include="CivProjSimulation.h" />
<ClInclude Include="CivSimulResultCache.h" />
<ClInclude Include="CivStopWaterAnalysis.h" />
<ClInclude Include="CivTrackingAnalysis.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
......@@ -60,6 +60,18 @@
<ClCompile Include="CivInpBuilder.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivBreakPipeAnalysis.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivCloseValveProj.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivInpProject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivStopWaterAnalysis.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivHydrFuncInter.h">
......@@ -110,5 +122,17 @@
<ClInclude Include="CivBaseInpBuilder.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivStopWaterAnalysis.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivInpProject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivCloseValveProj.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivBreakPipeAnalysis.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -23,13 +23,12 @@ bool CivProjInpDbHelper::getNode(CivNode& node)
{
JunctionTable nodeTableFields;
std::vector<std::string> fields =
{
nodeTableFields.sn,
nodeTableFields.elev,
nodeTableFields.baseDemand,
nodeTableFields.demandPattern
};
std::vector<std::string> fields;
fields.push_back(nodeTableFields.sn);
fields.push_back(nodeTableFields.elev);
fields.push_back(nodeTableFields.baseDemand);
fields.push_back(nodeTableFields.demandPattern);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector,mCondition);
......@@ -54,16 +53,17 @@ bool CivProjInpDbHelper::getPipe(CivPipe& pipes)
{
PipeTable pipeTable;
std::vector<std::string> fields = {
pipeTable.snNo,
pipeTable.startPoint,
pipeTable.endPoint,
pipeTable.length,
pipeTable.diameter,
pipeTable.friction,
pipeTable.localLoss,
pipeTable.status
};
std::vector<std::string> fields;
fields.push_back(pipeTable.snNo);
fields.push_back(pipeTable.startPoint);
fields.push_back(pipeTable.endPoint);
fields.push_back(pipeTable.length);
fields.push_back(pipeTable.diameter);
fields.push_back(pipeTable.friction);
fields.push_back(pipeTable.localLoss);
fields.push_back(pipeTable.status);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPELINE, fields, resultVector);
......@@ -93,16 +93,17 @@ bool CivProjInpDbHelper::getTank(CivTank& tanks)
{
TankTable tankTable;
std::vector<std::string> fields = {
tankTable.sn,
tankTable.elev,
tankTable.initLevel,
tankTable.minLevel,
tankTable.maxLevel,
tankTable.diametor,
tankTable.minVolume,
tankTable.volumeCurve
};
std::vector<std::string> fields;
fields.push_back(tankTable.sn);
fields.push_back(tankTable.elev);
fields.push_back(tankTable.initLevel);
fields.push_back(tankTable.minLevel);
fields.push_back(tankTable.maxLevel);
fields.push_back(tankTable.diametor);
fields.push_back(tankTable.minVolume);
fields.push_back(tankTable.volumeCurve);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(TANK, fields, resultVector);
......@@ -130,15 +131,15 @@ bool CivProjInpDbHelper::getTank(CivTank& tanks)
bool CivProjInpDbHelper::getValve(CivValve& valves)
{
ValveTable vaveTable;
std::vector<std::string> fields = {
vaveTable.sn,
vaveTable.startPoint,
vaveTable.endPoint,
vaveTable.length,
vaveTable.type,
vaveTable.setting,
vaveTable.lossCoeff
};
std::vector<std::string> fields;
fields.push_back(vaveTable.sn);
fields.push_back(vaveTable.startPoint);
fields.push_back(vaveTable.endPoint);
fields.push_back(vaveTable.length);
fields.push_back(vaveTable.type);
fields.push_back(vaveTable.setting);
fields.push_back(vaveTable.lossCoeff);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(VALVE, fields, resultVector);
......@@ -165,13 +166,14 @@ bool CivProjInpDbHelper::getValve(CivValve& valves)
bool CivProjInpDbHelper::getPumps(CivPumps& pumps)
{
PumpTable pmTable;
std::vector<std::string> fields = {
pmTable.sn,
pmTable.startPoint,
pmTable.endPoint,
pmTable.headCurve,
pmTable.power
};
std::vector<std::string> fields;
fields.push_back(pmTable.sn);
fields.push_back(pmTable.startPoint);
fields.push_back(pmTable.endPoint);
fields.push_back(pmTable.headCurve);
fields.push_back(pmTable.power);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PUMP, fields, resultVector);
......@@ -205,11 +207,9 @@ bool CivProjInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
{
ResourcesTable restemTable;
std::vector<std::string> fields = {
restemTable.sn,
restemTable.totalHead,
restemTable.headPattern
};
std::vector<std::string> fields;
fields.push_back(restemTable.sn);
fields.push_back(restemTable.headPattern);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(RESIVOIR, fields, resultVector);
......@@ -233,11 +233,11 @@ bool CivProjInpDbHelper::getCoordinates(CivCoordinates& coord)
{
JunctionTable nodeTable;
std::vector<std::string> fields = {
nodeTable.sn,
nodeTable.xCoord,
nodeTable.yCoord
};
std::vector<std::string> fields;
fields.push_back(nodeTable.sn);
fields.push_back(nodeTable.xCoord);
fields.push_back(nodeTable.yCoord);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector);
......@@ -264,11 +264,11 @@ bool CivProjInpDbHelper::getQuality(CivQuality& quality)
{
JunctionTable nodeTable;
std::vector<std::string> fields =
{
nodeTable.sn,
nodeTable.initQuality
};
std::vector<std::string> fields;
fields.push_back(nodeTable.sn);
fields.push_back(nodeTable.initQuality);
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PIPENODE, fields, resultVector);
......
......@@ -15,6 +15,14 @@
#define TANK Str("水池")
#define PUMP Str("水泵")
#define VALVE Str("阀门")
#define PROJ_PIPELINE Str("方案管段")
#define PROJ_PIPENODE Str("方案节点")
#define PROJ_RESIVOIR Str("方案水库")
#define PROJ_TANK Str("方案水池")
#define PROJ_PUMP Str("方案水泵")
#define PROJ_VALVE Str("方案阀门")
#define NODERESULTTABLE Str("节点模拟值")
#define PIPERESULTTABLE Str("管段模拟值")
#define PATTERNTABLE Str("水力模式")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment