Commit d19dee3a authored by 刘乐's avatar 刘乐

1, 测试框架修改

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