Commit 125f003e authored by 刘乐's avatar 刘乐

接口重写

parent e70c7e93
...@@ -3,35 +3,25 @@ ...@@ -3,35 +3,25 @@
#include "CivInpBuilder.h" #include "CivInpBuilder.h"
#include "CivTypes.h" #include "CivTypes.h"
#include "CivAssembly.h" #include "CivAssembly.h"
#include "CivInpDbHelper.h"
#define ASSERT(A,B) if ((A) == nullptr || (B) == nullptr) return; #define ASSERT(A,B) if ((A) == nullptr || (B) == nullptr) return
CivBaseInpBuilder::CivBaseInpBuilder() CivBaseInpBuilder::CivBaseInpBuilder(const std::string & uri)
:CivInpBuilder() mNewInp(new CivNewInp()) :CivInpBuilder(uri)
{ {
mHelper = new CivInpDbHelper(uri);
} }
CivBaseInpBuilder::~CivBaseInpBuilder() CivBaseInpBuilder::~CivBaseInpBuilder()
{ {
delete mNewInp;
}
CivNewInp* CivBaseInpBuilder::getNewInp()
{
return mNewInp;
}
CivBaseInpBuilder::CivBaseInpBuilder()
{
} }
void CivBaseInpBuilder::buildNode() void CivBaseInpBuilder::buildNode()
{ {
CivNode node; CivNode node;
if (!mDbConn->getNode(node)) if (!mHelper->getNode(node))
return; return;
mNewInp->setNode(node); mNewInp->setNode(node);
...@@ -39,10 +29,10 @@ void CivBaseInpBuilder::buildNode() ...@@ -39,10 +29,10 @@ void CivBaseInpBuilder::buildNode()
void CivBaseInpBuilder::buildPipe() void CivBaseInpBuilder::buildPipe()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivPipe pipe; CivPipe pipe;
if (!mDbConn->getPipe(pipe)) if (!mHelper->getPipe(pipe))
return; return;
mNewInp->setPipes(pipe); mNewInp->setPipes(pipe);
...@@ -50,10 +40,10 @@ void CivBaseInpBuilder::buildPipe() ...@@ -50,10 +40,10 @@ void CivBaseInpBuilder::buildPipe()
void CivBaseInpBuilder::buildTank() void CivBaseInpBuilder::buildTank()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivTank tank; CivTank tank;
if (!mDbConn->getTank(tank)) if (!mHelper->getTank(tank))
return; return;
mNewInp->setTank(tank); mNewInp->setTank(tank);
...@@ -61,10 +51,10 @@ void CivBaseInpBuilder::buildTank() ...@@ -61,10 +51,10 @@ void CivBaseInpBuilder::buildTank()
void CivBaseInpBuilder::buildVavle() void CivBaseInpBuilder::buildVavle()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivValve valve; CivValve valve;
if (!mDbConn->getValve(valve)) if (!mHelper->getValve(valve))
return; return;
mNewInp->setValves(valve); mNewInp->setValves(valve);
...@@ -72,10 +62,10 @@ void CivBaseInpBuilder::buildVavle() ...@@ -72,10 +62,10 @@ void CivBaseInpBuilder::buildVavle()
void CivBaseInpBuilder::buildPump() void CivBaseInpBuilder::buildPump()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivPumps valve; CivPumps valve;
if (!mDbConn->getPumps(valve)) if (!mHelper->getPumps(valve))
return; return;
mNewInp->setPumps(valve); mNewInp->setPumps(valve);
...@@ -83,10 +73,10 @@ void CivBaseInpBuilder::buildPump() ...@@ -83,10 +73,10 @@ void CivBaseInpBuilder::buildPump()
void CivBaseInpBuilder::buildReservoir() void CivBaseInpBuilder::buildReservoir()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivReservoirs res; CivReservoirs res;
if (!mDbConn->getReservoirs(res)) if (!mHelper->getReservoirs(res))
return; return;
mNewInp->setReservoirs(res); mNewInp->setReservoirs(res);
...@@ -94,10 +84,10 @@ void CivBaseInpBuilder::buildReservoir() ...@@ -94,10 +84,10 @@ void CivBaseInpBuilder::buildReservoir()
void CivBaseInpBuilder::buildEmitter() void CivBaseInpBuilder::buildEmitter()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivEmitters emmiters; CivEmitters emmiters;
if (!mDbConn->getEmitters(emmiters)) if (!mHelper->getEmitters(emmiters))
return; return;
mNewInp->setEmitters(emmiters); mNewInp->setEmitters(emmiters);
...@@ -105,37 +95,21 @@ void CivBaseInpBuilder::buildEmitter() ...@@ -105,37 +95,21 @@ void CivBaseInpBuilder::buildEmitter()
void CivBaseInpBuilder::buildPatterns() void CivBaseInpBuilder::buildPatterns()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivPatterns pattern; CivPatterns pattern;
if (!mDbConn->getPatterns(pattern)) if (!mHelper->getPatterns(pattern))
return; return;
mNewInp->setPatterns(pattern); mNewInp->setPatterns(pattern);
} }
void CivBaseInpBuilder::buildParamter()
{
ASSERT(mDbConn, mNewInp)
std::vector<CivParameter> parameters;
if (!mDbConn->getParameter(parameters))
return;
size_t total = parameters.size();
for (int i = 0; i < total; i++)
{
CivParameter param = parameters[i];
mNewInp->setParamter(param, param.mType);
}
}
void CivBaseInpBuilder::buildCoordnates() void CivBaseInpBuilder::buildCoordnates()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivCoordinates coords; CivCoordinates coords;
if (!mDbConn->getCoordinates(coords)) if (!mHelper->getCoordinates(coords))
return; return;
mNewInp->setCoordnates(coords); mNewInp->setCoordnates(coords);
...@@ -148,10 +122,10 @@ void CivBaseInpBuilder::buildVertices() ...@@ -148,10 +122,10 @@ void CivBaseInpBuilder::buildVertices()
void CivBaseInpBuilder::buildLabels() void CivBaseInpBuilder::buildLabels()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivLabels labels; CivLabels labels;
if (!mDbConn->getLabels(labels)) if (!mHelper->getLabels(labels))
return; return;
mNewInp->setLabels(labels); mNewInp->setLabels(labels);
...@@ -159,10 +133,10 @@ void CivBaseInpBuilder::buildLabels() ...@@ -159,10 +133,10 @@ void CivBaseInpBuilder::buildLabels()
void CivBaseInpBuilder::buildTags() void CivBaseInpBuilder::buildTags()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivTags tag; CivTags tag;
if (!mDbConn->getTags(tag)) if (!mHelper->getTags(tag))
return; return;
mNewInp->setTags(tag); mNewInp->setTags(tag);
...@@ -175,22 +149,27 @@ void CivBaseInpBuilder::buildBackDrop() ...@@ -175,22 +149,27 @@ void CivBaseInpBuilder::buildBackDrop()
void CivBaseInpBuilder::buildQuality() void CivBaseInpBuilder::buildQuality()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
if (mResetToZero)
CivQuality quality; {
if (!mDbConn->getQuality(quality)) mNewInp->setQuality(mInitQuality);
return; return;
}
CivQuality quality;
if (!mHelper->getQuality(quality));
return;
mNewInp->setQuality(quality); mNewInp->setQuality(quality);
} }
void CivBaseInpBuilder::buildSources() void CivBaseInpBuilder::buildSources()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivSources sources; CivSources sources;
if (!mDbConn->getSources(sources)) if (!mHelper->getSources(sources))
return; return;
mNewInp->setSources(sources); mNewInp->setSources(sources);
...@@ -198,10 +177,10 @@ void CivBaseInpBuilder::buildSources() ...@@ -198,10 +177,10 @@ void CivBaseInpBuilder::buildSources()
void CivBaseInpBuilder::buildMixing() void CivBaseInpBuilder::buildMixing()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivMixing mixing; CivMixing mixing;
if (!mDbConn->getMixing(mixing)) if (!mHelper->getMixing(mixing))
return; return;
mNewInp->setMixing(mixing); mNewInp->setMixing(mixing);
...@@ -209,21 +188,21 @@ void CivBaseInpBuilder::buildMixing() ...@@ -209,21 +188,21 @@ void CivBaseInpBuilder::buildMixing()
void CivBaseInpBuilder::buildCurves() void CivBaseInpBuilder::buildCurves()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
/*CivCurves curves; CivCurves curves;
if (!mDbConn->getCurves(curves)) if (!mHelper->getCurves(curves))
return; return;
mNewInp->setCurves(curves);*/ mNewInp->setCurves(curves);
} }
void CivBaseInpBuilder::buildStatus() void CivBaseInpBuilder::buildStatus()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivStatus status; CivStatus status;
if (!mDbConn->getStatus(status)) if (!mHelper->getStatus(status))
return; return;
mNewInp->setStatus(status); mNewInp->setStatus(status);
...@@ -241,10 +220,10 @@ void CivBaseInpBuilder::buildRules() ...@@ -241,10 +220,10 @@ void CivBaseInpBuilder::buildRules()
void CivBaseInpBuilder::buildDemands() void CivBaseInpBuilder::buildDemands()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
CivDemands mand; CivDemands mand;
if (!mDbConn->getDemands(mand)) if (!mHelper->getDemands(mand))
return; return;
mNewInp->setDemands(mand); mNewInp->setDemands(mand);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
class CivBaseInpBuilder :public CivInpBuilder class CivBaseInpBuilder :public CivInpBuilder
{ {
public: public:
explicit CivBaseInpBuilder(); explicit CivBaseInpBuilder(const std::string& uri);
~CivBaseInpBuilder(); ~CivBaseInpBuilder();
virtual void buildNode(); virtual void buildNode();
...@@ -18,7 +18,6 @@ public: ...@@ -18,7 +18,6 @@ public:
virtual void buildReservoir(); virtual void buildReservoir();
virtual void buildEmitter(); virtual void buildEmitter();
virtual void buildPatterns(); virtual void buildPatterns();
virtual void buildParamter();
virtual void buildCoordnates(); virtual void buildCoordnates();
virtual void buildVertices(); virtual void buildVertices();
virtual void buildLabels(); virtual void buildLabels();
......
#include "CivGraphFactory.h" #include "CivGraphFactory.h"
#include "CivGraphList.h" #include "CivGraphList.h"
#include "CivDbConn.h" #include "CivInpDbHelper.h"
#include "CivPgConn.h"
#include "CivTrackingResultCache.h" #include "CivTrackingResultCache.h"
CivGraphFactory::CivGraphFactory() CivGraphFactory::CivGraphFactory()
...@@ -9,7 +8,7 @@ CivGraphFactory::CivGraphFactory() ...@@ -9,7 +8,7 @@ CivGraphFactory::CivGraphFactory()
} }
bool CivGraphFactory::initGraph(CivDbConn* dbConn, ALGraph<CivGraphJunction, CivGraphEdage>* graph) bool CivGraphFactory::initGraph(CivInpDbHelper* dbConn, ALGraph<CivGraphJunction, CivGraphEdage>* graph)
{ {
if (graph == nullptr) if (graph == nullptr)
return false; return false;
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "CivGraphList.h" #include "CivGraphList.h"
// 声明模板图类型 // 声明模板图类型
class CivDbConn;
class CivGraphJunction; class CivGraphJunction;
class CivGraphEdage; class CivGraphEdage;
class CivInpDbHelper;
class CivGraphFactory class CivGraphFactory
{ {
...@@ -18,5 +18,5 @@ public: ...@@ -18,5 +18,5 @@ public:
*@param dbConn 数据库连接 *@param dbConn 数据库连接
*@param graph 有向图 *@param graph 有向图
*/ */
bool initGraph(CivDbConn* dbConn, ALGraph<CivGraphJunction, CivGraphEdage>* graph); bool initGraph(CivInpDbHelper* dbConn, ALGraph<CivGraphJunction, CivGraphEdage>* graph);
}; };
#include "CivHydrCompute.h" #include "CivHydrCompute.h"
#include "CivTypes.h" #include "CivSimuResStruct.h"
CivHydrCompute::CivHydrCompute(char* inp, char* rptFile, char* binFile) CivHydrCompute::CivHydrCompute(char* inp, char* rptFile, char* binFile)
:mInpFile(inp),mRptFile(rptFile),mBinFile(binFile) :mInpFile(inp),mRptFile(rptFile),mBinFile(binFile)
...@@ -160,7 +160,6 @@ bool CivHydrCompute::hdyrCompute() ...@@ -160,7 +160,6 @@ bool CivHydrCompute::hdyrCompute()
void CivHydrCompute::getNodeResult(short time) void CivHydrCompute::getNodeResult(short time)
{ {
// 计算节点 // 计算节点
int nNodeCount; int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount); ENgetcount(EN_NODECOUNT, &nNodeCount);
...@@ -171,31 +170,33 @@ void CivHydrCompute::getNodeResult(short time) ...@@ -171,31 +170,33 @@ void CivHydrCompute::getNodeResult(short time)
ENgetlinktype(i, typeCode); ENgetlinktype(i, typeCode);
if (*typeCode == EN_TANK || *typeCode== EN_RESERVOIR) if (*typeCode == EN_TANK || *typeCode== EN_RESERVOIR)
{ {
TankResultItem tankItem;
// 编号
ENgetnodeid(i, tankItem.szNo);
// 水池容量
ENgetnodevalue(i, EN_TANKVOLUME, &tankItem.dTankVolume);
// 水池最大容量
ENgetnodevalue(i, EN_MAXVOLUME, &tankItem.dTankMaxVolume);
// 液位高度
ENgetnodevalue(i, EN_TANKLEVEL, &tankItem.dTankLevel);
continue; continue;
} }
else
{
NodeResultItem nodeItem;
// 编号
ENgetnodeid(i, nodeItem.szNo);
// 水头
ENgetnodevalue(i, EN_HEAD, &nodeItem.dHead);
// 压力
ENgetnodevalue(i, EN_PRESSURE, &nodeItem.dPressure);
// 标高
ENgetnodevalue(i, EN_ELEVATION, &nodeItem.dElevation);
// 实际需水量
ENgetnodevalue(i, EN_DEMAND, &nodeItem.dDemand);
}
NodeResultItem nodeItem; // nodeItem.dInterval = time;
// 编号
ENgetnodeid(i, nodeItem.szNo);
// 水头
ENgetnodevalue(i, EN_HEAD, &nodeItem.dHead);
// 压力
ENgetnodevalue(i, EN_PRESSURE, &nodeItem.dPressure);
// 标高
ENgetnodevalue(i, EN_ELEVATION, &nodeItem.dElevation);
// 实际需水量
ENgetnodevalue(i, EN_DEMAND, &nodeItem.dDemand);
// 水池容量
ENgetnodevalue(i, EN_TANKVOLUME, &nodeItem.dTankVolume);
// 水池最大容量
ENgetnodevalue(i, EN_MAXVOLUME, &nodeItem.dTankMaxVolume);
// 液位高度
ENgetnodevalue(i, EN_TANKLEVEL, &nodeItem.dTankLevel);
nodeItem.dInterval = time;
// 放到缓存类中 // 放到缓存类中
//mResultCache.addNodeItems(nodeItem); //mResultCache.addNodeItems(nodeItem);
...@@ -229,8 +230,7 @@ void CivHydrCompute::getLinkResult(short time) ...@@ -229,8 +230,7 @@ void CivHydrCompute::getLinkResult(short time)
ENgetlinkid(i, linkItem.szNo); ENgetlinkid(i, linkItem.szNo);
// 流量 // 流量
ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow); ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow);
// 流向
linkItem.nFlowDirect = (linkItem.dFlow >= 0) ? 0 : 1;
// 流速 // 流速
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity); ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);
// 水头损失 // 水头损失
...@@ -244,12 +244,10 @@ void CivHydrCompute::getLinkResult(short time) ...@@ -244,12 +244,10 @@ void CivHydrCompute::getLinkResult(short time)
else else
strcpy_s(linkItem.szStatus, "开启"); strcpy_s(linkItem.szStatus, "开启");
linkItem.dInterval = time; //linkItem.dInterval = time;
// 放到缓存类中 // 放到缓存类中
// mResultCache.addLinkItems(linkItem); // mResultCache.addLinkItems(linkItem);
} }
} }
void CivHydrCompute::getNodeQuality(short time) void CivHydrCompute::getNodeQuality(short time)
......
#include "CivHydrFuncInter.h" #include "CivHydrFuncInter.h"
#include "CivSysLog.h" #include "CivSysLog.h"
#include "CivTableTemp.h"
#include "CivPgConn.h"
#include "CivHydrSimulation.h" #include "CivHydrSimulation.h"
#include "CivTrackingAnalysis.h" #include "CivTrackingAnalysis.h"
bool FUNEXPORT modelMatation(char* uri) bool FUNEXPORT modelMatation(char* uri)
{ {
// 创建数据库连接
CivDbConn* pgConn = new CivPgConn(uri);
pgConn->checkHyDrNetTable();
delete pgConn;
return true; return true;
} }
bool FUNEXPORT hdyrSimulation(char* uri) bool FUNEXPORT hdyrSimulation(char* uri)
{ {
// 创建数据库连接 return true;
CivDbConn* pgConn = new CivPgConn(uri);
// 模拟计算对象
CivHydrSimulation* mHyDr = new CivHydrSimulation(pgConn);
//开始模拟
int flag = mHyDr->hdyrSimulation();
delete mHyDr;
delete pgConn;
return flag;
} }
bool FUNEXPORT qualitySimulation(char* uri) bool FUNEXPORT qualitySimulation(char* uri)
{ {
// 创建数据库连接
CivDbConn* pgConn = new CivPgConn(uri); return true;
// 模拟计算对象
CivHydrSimulation* mHyDr = new CivHydrSimulation();
mHyDr->registDb(pgConn);
//开始模拟
int flag = mHyDr->qualitySimulation();
delete pgConn;
delete mHyDr;
return flag;
} }
bool FUNEXPORT trackingSimulation(char* uri, char* sN, int hours, char* result) bool FUNEXPORT trackingSimulation(char* uri, char* sN, int hours, char* result)
{ {
// 创建数据库连接
CivDbConn* pgConn = new CivPgConn(uri);
// 模拟计算对象 return true;
CivHydrSimulation* mHyDr = new CivHydrSimulation();
mHyDr->registDb(pgConn);
//开始模拟
bool flag = mHyDr->trackingSimulation(sN, hours);
std::string strResult;
if (flag)
{
mHyDr->getTrackingResult(hours, strResult);
strcpy(result, strResult.c_str());
}
delete pgConn;
delete mHyDr;
return flag;
} }
bool FUNEXPORT getRptByCondition(char* uri, char* type, char* condition, char* result) bool FUNEXPORT getRptByCondition(char* uri, char* type, char* condition, char* result)
{ {
CivDbConn* dbConn = new CivPgConn(uri);
if (!dbConn->open())
{
delete dbConn;
return false;
}
std::string table;
std::vector<std::string> fileds;
if (type == PIPENODE)
{
table = NODERESULTTABLE;
CivNodeResultTableTemp::NodeResultTable tableTemp;
fileds.push_back(tableTemp.Number);
fileds.push_back(tableTemp.dDemand);
fileds.push_back(tableTemp.dHead);
fileds.push_back(tableTemp.dPressure);
fileds.push_back(tableTemp.dElevation);
fileds.push_back(tableTemp.dQuality);
}
else if (type == PIPELINE)
{
table = PIPERESULTTABLE;
CivPipeResultTableTemp::PipeResultTable pipeTable;
fileds.push_back(pipeTable.szNo);
fileds.push_back(pipeTable.dFlow);
fileds.push_back(pipeTable.dVelocity);
fileds.push_back(pipeTable.dHeadloss);
fileds.push_back(pipeTable.dUnitHeadloss);
fileds.push_back(pipeTable.dLocalHeadloss);
fileds.push_back(pipeTable.dFrictionHeadloss);
fileds.push_back(pipeTable.dQuality);
}
else
{
delete dbConn;
return false;
}
std::vector<std::map<std::string,std::string>> res;
if (!dbConn->getValuesFromTableByCondition(table, condition, fileds, res))
{
delete dbConn;
return false;
}
delete dbConn;
// 拼接字符串
size_t total = res.size();
std::string strRes;
strRes.append("[");
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> tempMap = res[i];
strRes.append("{");
for (auto iter = tempMap.begin(); iter != tempMap.end(); iter++)
{
strRes.append(iter->first);
strRes.append(":");
strRes.append(iter->second);
strRes.append(",");
}
strRes = strRes.substr(0, strRes.length() - 1);
strRes.append("},");
}
strRes = strRes.substr(0, strRes.length() - 1);
strRes.append("]");
std::cout << strRes << std::endl;
int leng = strRes.length();
for (int i = 0; i < leng; i++)
{
result[i] = strRes[i];
}
return true; return true;
} }
bool FUNEXPORT upstreamTracking(char* uri, char* sn, char* result) bool FUNEXPORT upstreamTracking(char* uri, char* sn, char* result)
{ {
// 创建数据库连接
CivDbConn* pgConn = new CivPgConn(uri);
CivTrackingAnalysis analySis;
if (!analySis.createGraphFrom(pgConn))
return false;
std::string res;
std::string strSn = sn;
if (!analySis.upstreamTracking(strSn, res))
{
delete pgConn;
return false;
}
strcpy(result, res.c_str());
delete pgConn;
return true; return true;
} }
bool FUNEXPORT downstreamTracking(char* uri, char* sn, char* result) bool FUNEXPORT downstreamTracking(char* uri, char* sn, char* result)
{ {
// 创建数据库连接
CivDbConn* pgConn = new CivPgConn(uri);
CivTrackingAnalysis analySis;
if (!analySis.createGraphFrom(pgConn))
return false;
std::string res;
std::string strSn = sn;
if (!analySis.downstreamTracking(strSn, res))
{
delete pgConn;
return false;
}
strcpy(result, res.c_str());
delete pgConn;
return true; return true;
} }
bool FUNEXPORT waterSupplyScopeAnalysis(char* uri, char* sn, char* result) bool FUNEXPORT waterSupplyScopeAnalysis(char* uri, char* sn, char* result)
{ {
// 创建数据库连接
CivDbConn* pgConn = new CivPgConn(uri);
CivTrackingAnalysis analySis;
if (!analySis.createGraphFrom(pgConn))
return false;
std::string res;
std::string strSn = sn;
if (!analySis.waterSupplyScopeAnalysis(strSn, res))
{
delete pgConn;
return false;
}
strcpy(result, res.c_str());
delete pgConn;
return true; return true;
} }
\ No newline at end of file
#include "CivHydrSimulation.h" #include "CivHydrSimulation.h"
#include "CivPgConn.h"
#include "CivNewInp.h" #include "CivNewInp.h"
#include "CivBuilder.h"
#include "CivInpDirector.h" #include "CivInpDirector.h"
#include "CivSysLog.h" #include "CivSysLog.h"
#include "epanet2.h" #include "epanet2.h"
...@@ -26,28 +24,6 @@ bool CivHydrSimulation::hdyrSimulation() ...@@ -26,28 +24,6 @@ bool CivHydrSimulation::hdyrSimulation()
bool CivHydrSimulation::qualitySimulation() bool CivHydrSimulation::qualitySimulation()
{ {
CivSysLog::getInstance()->info("开始水质分析计算", "qualitySimulation", __FUNCTION__);
if (!convertInp(ANALYSIS_AGE, ""))
{
CivSysLog::getInstance()->error("写入inp文件失败", "qualitySimulation", __FUNCTION__);
return false;
}
CivSysLog::getInstance()->info("写入inp成功", "qualitySimulation", __FUNCTION__);
// 水质计算
if (!qualityCompute())
{
CivSysLog::getInstance()->error("水质分析计算失败", "CivHydrCalc", __FUNCTION__);
return false;
}
//模拟数据刷新
if (!brushingResult())
{
CivSysLog::getInstance()->error("水质分析结果存储失败", "CivHydrCalc", __FUNCTION__);
return false;
}
return true; return true;
} }
......
...@@ -4,118 +4,64 @@ ...@@ -4,118 +4,64 @@
#define ASSERT(A,B) if ((A) == nullptr || (B) == nullptr) return; #define ASSERT(A,B) if ((A) == nullptr || (B) == nullptr) return;
CivInpBuilder::CivInpBuilder():mNewInp(new CivNewInp()) CivInpBuilder::CivInpBuilder(const std::string & uri)
:mNewInp(new CivNewInp()), mUri(uri)
{ {
mOptions.mType = "OPTIONS";
mTimes.mType = "TIMES";
mReactions.mType = "REACTIONS";
mReport.mType = "REPORT";
} }
CivInpBuilder::~CivInpBuilder() CivInpBuilder::~CivInpBuilder()
{ {
delete mNewInp; delete mNewInp;
delete mHelper;
} }
CivNewInp* CivInpBuilder::getNewInp() void CivInpBuilder::setOption(const std::string& name,
const std::string& val)
{ {
return mNewInp; CivParameter::ParamTable table = { name,val };
mOptions.addItem(table);
} }
void CivInpBuilder::setTimes(const std::string& name,
CivInpBuilder::CivInpBuilder() const std::string& val)
{
}
void CivInpBuilder::buildNode()
{
CivNode node;
if (!mDbConn->getNode(node))
return;
mNewInp->setNode(node);
}
void CivInpBuilder::buildPipe()
{
ASSERT(mDbConn, mNewInp)
CivPipe pipe;
if (!mDbConn->getPipe(pipe))
return;
mNewInp->setPipes(pipe);
}
void CivInpBuilder::buildTank()
{
ASSERT(mDbConn, mNewInp)
CivTank tank;
if (!mDbConn->getTank(tank))
return;
mNewInp->setTank(tank);
}
void CivInpBuilder::buildVavle()
{
ASSERT(mDbConn, mNewInp)
CivValve valve;
if (!mDbConn->getValve(valve))
return;
mNewInp->setValves(valve);
}
void CivInpBuilder::buildPump()
{ {
ASSERT(mDbConn, mNewInp) CivParameter::ParamTable table = { name,val };
mTimes.addItem(table);
CivPumps valve;
if (!mDbConn->getPumps(valve))
return;
mNewInp->setPumps(valve);
} }
void CivInpBuilder::buildReservoir() void CivInpBuilder::setReport(const std::string& name,
const std::string& val)
{ {
ASSERT(mDbConn, mNewInp) CivParameter::ParamTable table = { name,val };
mReport.addItem(table);
CivReservoirs res;
if (!mDbConn->getReservoirs(res))
return;
mNewInp->setReservoirs(res);
} }
void CivInpBuilder::buildEmitter() void CivInpBuilder::setReaction(const std::string& name,
const std::string& val)
{ {
ASSERT(mDbConn, mNewInp) CivParameter::ParamTable table = { name,val };
mReactions.addItem(table);
CivEmitters emmiters;
if (!mDbConn->getEmitters(emmiters))
return;
mNewInp->setEmitters(emmiters);
} }
void CivInpBuilder::buildPatterns() std::string CivInpBuilder::getNewInp()
{ {
ASSERT(mDbConn, mNewInp) std::string inpFile = "test.inp";
if (mNewInp->writeToFile(inpFile))
CivPatterns pattern; return NULL;
if (!mDbConn->getPatterns(pattern))
return;
mNewInp->setPatterns(pattern); return inpFile;
} }
void CivInpBuilder::buildParamter() void CivInpBuilder::buildParamter()
{ {
ASSERT(mDbConn, mNewInp) ASSERT(mHelper, mNewInp);
std::vector<CivParameter> parameters; std::vector<CivParameter> parameters;
if (!mDbConn->getParameter(parameters)) if (!mHelper->getParameter(parameters))
return; return;
size_t total = parameters.size(); size_t total = parameters.size();
...@@ -123,125 +69,15 @@ void CivInpBuilder::buildParamter() ...@@ -123,125 +69,15 @@ void CivInpBuilder::buildParamter()
{ {
CivParameter param = parameters[i]; CivParameter param = parameters[i];
mNewInp->setParamter(param, param.mType); mNewInp->setParamter(param, param.mType);
} }
}
void CivInpBuilder::buildCoordnates()
{
ASSERT(mDbConn, mNewInp)
CivCoordinates coords;
if (!mDbConn->getCoordinates(coords))
return;
mNewInp->setCoordnates(coords);
}
void CivInpBuilder::buildVertices()
{
return;
}
void CivInpBuilder::buildLabels()
{
ASSERT(mDbConn, mNewInp)
CivLabels labels;
if (!mDbConn->getLabels(labels))
return;
mNewInp->setLabels(labels);
}
void CivInpBuilder::buildTags()
{
ASSERT(mDbConn, mNewInp)
CivTags tag;
if (!mDbConn->getTags(tag))
return;
mNewInp->setTags(tag);
}
void CivInpBuilder::buildBackDrop()
{
return;
}
void CivInpBuilder::buildQuality()
{
ASSERT(mDbConn, mNewInp)
CivQuality quality;
if (!mDbConn->getQuality(quality))
return;
mNewInp->setQuality(quality);
}
void CivInpBuilder::buildSources()
{
ASSERT(mDbConn, mNewInp)
CivSources sources;
if (!mDbConn->getSources(sources))
return;
mNewInp->setSources(sources);
} }
void CivInpBuilder::buildMixing() void CivInpBuilder::resetAllToZero()
{ {
ASSERT(mDbConn, mNewInp) mResetToZero = true;
CivMixing mixing;
if (!mDbConn->getMixing(mixing))
return;
mNewInp->setMixing(mixing);
} }
void CivInpBuilder::buildCurves() void CivInpBuilder::setQuality(const std::string& name, const std::string& val)
{ {
ASSERT(mDbConn, mNewInp) mInitQuality.addItem({ name ,val });
/*CivCurves curves;
if (!mDbConn->getCurves(curves))
return;
mNewInp->setCurves(curves);*/
}
void CivInpBuilder::buildStatus()
{
ASSERT(mDbConn, mNewInp)
CivStatus status;
if (!mDbConn->getStatus(status))
return;
mNewInp->setStatus(status);
}
void CivInpBuilder::buildControls()
{
}
void CivInpBuilder::buildRules()
{
}
void CivInpBuilder::buildDemands()
{
ASSERT(mDbConn, mNewInp)
CivDemands mand;
if (!mDbConn->getDemands(mand))
return;
mNewInp->setDemands(mand);
} }
\ No newline at end of file
#ifndef _CIVINPEXPOTER_H #ifndef _CIVINPEXPOTER_H
#define _CIVINPEXPOTER_H #define _CIVINPEXPOTER_H
#include "CivNewInp.h" #include "CivNewInp.h"
#include "CivInpHelperAbs.h"
/** /**
* 抽象建造者 * 抽象建造者
...@@ -8,37 +9,71 @@ ...@@ -8,37 +9,71 @@
class CivInpBuilder class CivInpBuilder
{ {
public: public:
explicit CivInpBuilder(const std::string& uri);
explicit CivInpBuilder();
virtual ~CivInpBuilder(); virtual ~CivInpBuilder();
virtual void buildNode(); /**
virtual void buildPipe(); *@brief 设置选择项值
virtual void buildTank(); */
virtual void buildVavle(); void setOption(const std::string& name, const std::string& val);
virtual void buildPump();
virtual void buildReservoir(); /**
virtual void buildEmitter(); *@brief 设置模拟时间选项
virtual void buildPatterns(); */
virtual void buildParamter(); void setTimes(const std::string& name, const std::string& val);
virtual void buildCoordnates();
virtual void buildVertices(); /**
virtual void buildLabels(); *@brief 设置输出报告选项
virtual void buildTags(); */
virtual void buildBackDrop(); void setReport(const std::string& name, const std::string& val);
virtual void buildQuality();
virtual void buildSources(); /**
virtual void buildMixing(); *@brief 设置反应系数选项
virtual void buildCurves(); */
virtual void buildStatus(); void setReaction(const std::string& name, const std::string& val);
virtual void buildControls();
virtual void buildRules(); void setQuality(const std::string& name, const std::string& val);
virtual void buildDemands(); void resetAllToZero();
/**
CivNewInp* getNewInp(); *@brief 返回装成的inp文件名
*/
std::string getNewInp();
void buildParamter();
virtual void buildNode()=0;
virtual void buildPipe()=0;
virtual void buildTank()=0;
virtual void buildVavle()=0;
virtual void buildPump()=0;
virtual void buildReservoir()=0;
virtual void buildEmitter()=0;
virtual void buildPatterns()=0;
virtual void buildCoordnates()=0;
virtual void buildVertices()=0;
virtual void buildLabels()=0;
virtual void buildTags()=0;
virtual void buildBackDrop()=0;
virtual void buildQuality()=0;
virtual void buildSources()=0;
virtual void buildMixing()=0;
virtual void buildCurves()=0;
virtual void buildStatus()=0;
virtual void buildControls()=0;
virtual void buildRules()=0;
virtual void buildDemands()=0;
protected: protected:
CivParameter mOptions;
CivParameter mTimes;
CivParameter mReactions;
CivParameter mReport;
CivQuality mInitQuality; // 节点的初始水质
CivNewInp* mNewInp; CivNewInp* mNewInp;
CivInpHelperAbs* mHelper;
bool mResetToZero = false;;
std::string mUri;
}; };
#endif // !_CIVINPEXPOTER_H #endif // !_CIVINPEXPOTER_H
......
#include "CivInpConvertor.h" #include "CivInpConvertor.h"
#include "CivProjInpBuilder.h"
#include "CivInpDirector.h"
#include "CivBaseInpBuilder.h"
CivInpConvertor::CivInpConvertor(const std::string& uri) CivInpConvertor::CivInpConvertor(const std::string& uri)
:mUri(uri)
{ {
} }
...@@ -10,7 +14,53 @@ CivInpConvertor::~CivInpConvertor() ...@@ -10,7 +14,53 @@ CivInpConvertor::~CivInpConvertor()
} }
char* CivInpConvertor::getInp() std::string CivInpConvertor::convertPorjInp(
const std::string& projCode,
const std::string& start)
{ {
CivProjInpBuilder* builder = new CivProjInpBuilder(mUri);
builder->setProjCode(projCode);
builder->setTimes("Duration", "0");
builder->setTimes("Start Clocktime", start);
CivInpDirector director;
director.setBuilder(builder);
director.create();
std::string inpFile = builder->getNewInp();
delete builder;
return inpFile;
}
std::string CivInpConvertor::convertBaseInp()
{
CivInpBuilder* builder = new CivBaseInpBuilder(mUri);
CivInpDirector director;
director.setBuilder(builder);
director.create();
std::string inpFile = builder->getNewInp();
delete builder;
return inpFile;
}
std::string CivInpConvertor::convertTrackInp(const std::string& sn,
const std::string& hours)
{
CivInpBuilder* builder = new CivBaseInpBuilder(mUri);
builder->setOption("Quality Tracking", sn);
builder->setTimes("Duration", hours);
builder->resetAllToZero();
builder->setQuality(sn, "1");
CivInpDirector director;
director.setBuilder(builder);
director.create();
std::string inpFile = builder->getNewInp();
delete builder;
return inpFile;
} }
\ No newline at end of file
#pragma once #pragma once
#include <string> #include <string>
#include "CivInpBuilder.h"
/** /**
管网数据库数据转inp文件中转器 管网数据库数据转inp文件中转器
*/ */
class CivInpConvertor class CivInpConvertor
{ {
public: public:
explicit CivInpConvertor(const std::string& uri); explicit CivInpConvertor(const std::string& uri);
~CivInpConvertor(); ~CivInpConvertor();
char* getInp(); /**
private: *@brief 转成方案模拟的inp文件
*@param projCode 方案编码
*@param startTime 模拟时间
*/
std::string convertPorjInp(const std::string& projCode,
const std::string& startTime);
/**
*@brief 转成方案普通inp
*/
std::string convertBaseInp();
/**
*@brief 追踪模拟inp文件
*@param sn 追踪的节点
*@param hours 追踪小时数
*/
std::string convertTrackInp(const std::string& sn,const std::string& hours);
private:
std::string mUri;
}; };
\ No newline at end of file
#include "CivInpDirector.h" #include "CivInpDirector.h"
#include "CivBuilder.h" #include "CivInpBuilder.h"
void CivInpDirector::setBuilder(CivBuilder* builder) void CivInpDirector::setBuilder(CivInpBuilder* builder)
{ {
mBuilder = builder; mBuilder = builder;
} }
......
#ifndef CIVINPDIRECTOR_H #ifndef CIVINPDIRECTOR_H
#define CIVINPDIRECTOR_H #define CIVINPDIRECTOR_H
class CivBuilder; class CivInpBuilder;
// ָ // ָ
class CivInpDirector class CivInpDirector
{ {
public: public:
void setBuilder(CivBuilder* builder); void setBuilder(CivInpBuilder* builder);
void create(); void create();
private: private:
CivBuilder* mBuilder; CivInpBuilder* mBuilder;
}; };
......
...@@ -18,18 +18,7 @@ CivNewInp::~CivNewInp() ...@@ -18,18 +18,7 @@ CivNewInp::~CivNewInp()
} }
void CivNewInp::setQualityType(QualityAnalyType type, const std::string& qualityName) bool CivNewInp::writeToFile(const std::string& fileName)
{
mQualityType = type;
mQualityName = qualityName;
}
void CivNewInp::setDuration(int duration)
{
mDuration = duration;
}
bool CivNewInp::writeToFile(char* fileName)
{ {
// 检查是否存在值 // 检查是否存在值
std::string res = mTextStream.str(); std::string res = mTextStream.str();
...@@ -320,23 +309,8 @@ void CivNewInp::setQuality(const CivQuality& quality) ...@@ -320,23 +309,8 @@ void CivNewInp::setQuality(const CivQuality& quality)
for (auto iter = tables.rbegin(); iter != tables.rend(); iter++) for (auto iter = tables.rbegin(); iter != tables.rend(); iter++)
{ {
CivQuality::Table table = *iter; CivQuality::Table table = *iter;
writeStringFormat(table.ID); writeStringFormat(table.ID);
if (mQualityType == ANALYSIS_TRACE) writeString(table.InitQuality);
{
if (table.ID == mQualityName)
{
writeString("1");
continue;
}
else {
writeString("0");
}
}
else
{
writeString(table.InitQuality);
}
} }
writeString(""); writeString("");
} }
...@@ -423,28 +397,6 @@ void CivNewInp::setOptions(const CivParameter& params) ...@@ -423,28 +397,6 @@ void CivNewInp::setOptions(const CivParameter& params)
CivParameter::ParamTable table = *iter; CivParameter::ParamTable table = *iter;
std::string strName = table.name; std::string strName = table.name;
std::string strValue = table.val; std::string strValue = table.val;
// 改变quality
if (strName =="Quality")
{
switch (mQualityType)
{
case ANALYSIS_TRACE:
strValue = "Trace " + mQualityName;
break;
case ANALYSIS_AGE:
strValue = "AGE mg / L";
break;
case ANALYSIS_CONCENTRATION:
strValue = mQualityName + " mg / L";
break;
case ANALYSIS_RESERVE:
strValue = "NONE";
break;
default:
break;
}
}
writeStringFormat(strName); writeStringFormat(strName);
writeString(strValue); writeString(strValue);
} }
...@@ -465,16 +417,7 @@ void CivNewInp::setTimes(const CivParameter& params) ...@@ -465,16 +417,7 @@ void CivNewInp::setTimes(const CivParameter& params)
{ {
CivParameter::ParamTable table = *iter; CivParameter::ParamTable table = *iter;
writeStringFormat(table.name); writeStringFormat(table.name);
writeString(table.val);
if (mDuration >-1 && table.name == "Duration")
{
writeString(std::to_string(mDuration));
}
else
{
writeString(table.val);
}
} }
writeString(""); writeString("");
} }
......
...@@ -32,12 +32,7 @@ public: ...@@ -32,12 +32,7 @@ public:
explicit CivNewInp(); explicit CivNewInp();
~CivNewInp(); ~CivNewInp();
bool writeToFile(char* fileName); bool writeToFile(const std::string& fileName);
/**
管网组件
*/
void setQualityType(QualityAnalyType type,const std::string& qualityName);
void setDuration(int duration);
void setTtitle(const std::string& title); void setTtitle(const std::string& title);
void setNode(const CivNode& node); void setNode(const CivNode& node);
void setPipes(const CivPipe& pipes); void setPipes(const CivPipe& pipes);
...@@ -84,12 +79,7 @@ private: ...@@ -84,12 +79,7 @@ private:
std::string currentTime(); std::string currentTime();
private: private:
std::ostringstream mTextStream;
std::ostringstream mTextStream;
QualityAnalyType mQualityType = ANALYSIS_AGE; //水质分析类型, 默认水龄
std::string mQualityName; // 追踪的节点名 或者化合物名
int mDuration = -1;
std::map<std::string, void (CivNewInp::*)(const CivParameter&)> mParamMap; // 参数类型映射 std::map<std::string, void (CivNewInp::*)(const CivParameter&)> mParamMap; // 参数类型映射
}; };
#endif // !CIVNEWINP_H #endif // !CIVNEWINP_H
......
#include "CivProjInpBuilder.h" #include "CivProjInpBuilder.h"
#include "CivProjInpDbHelper.h"
CivProjInpBuilder::CivProjInpBuilder(const std::string& uri)
:CivInpBuilder(uri)
{
mHelper = new CivProjInpDbHelper(uri);
}
CivProjInpBuilder::~CivProjInpBuilder()
{
}
void CivProjInpBuilder::buildNode() void CivProjInpBuilder::buildNode()
{ {
...@@ -40,10 +51,6 @@ void CivProjInpBuilder::buildPatterns() ...@@ -40,10 +51,6 @@ void CivProjInpBuilder::buildPatterns()
} }
void CivProjInpBuilder::buildParamter()
{
}
void CivProjInpBuilder::buildCoordnates() void CivProjInpBuilder::buildCoordnates()
{ {
...@@ -109,7 +116,7 @@ void CivProjInpBuilder::buildDemands() ...@@ -109,7 +116,7 @@ void CivProjInpBuilder::buildDemands()
} }
CivNewInp* getNewInp() void CivProjInpBuilder::setProjCode(const std::string& projCode)
{ {
mProjCode = projCode;
} }
\ No newline at end of file
...@@ -4,29 +4,36 @@ ...@@ -4,29 +4,36 @@
/** /**
ģתinpļ ģתinpļ
*/ */
class CivProjInpBuilder :public CivInpBuilder class CivProjInpBuilder:public CivInpBuilder
{ {
public: public:
virtual void buildNode(); explicit CivProjInpBuilder(const std::string& uri);
virtual void buildPipe(); ~CivProjInpBuilder();
virtual void buildTank();
virtual void buildVavle(); /**/
virtual void buildPump(); void setProjCode(const std::string& projCode);
virtual void buildReservoir();
virtual void buildEmitter(); void buildNode() override;
virtual void buildPatterns() ; void buildPipe()override;
virtual void buildParamter() ; void buildTank()override;
virtual void buildCoordnates() ; void buildVavle()override;
virtual void buildVertices() ; void buildPump()override;
virtual void buildLabels() ; void buildReservoir()override;
virtual void buildTags() ; void buildEmitter()override;
virtual void buildBackDrop() ; void buildPatterns() override;
virtual void buildQuality() ; void buildCoordnates() override;
virtual void buildSources() ; void buildVertices() override;
virtual void buildMixing() ; void buildLabels() override;
virtual void buildCurves() ; void buildTags() override;
virtual void buildStatus() ; void buildBackDrop() override;
virtual void buildControls() ; void buildQuality() override;
virtual void buildRules() ; void buildSources() override;
virtual void buildDemands() ; void buildMixing() override;
void buildCurves() override;
void buildStatus() override;
void buildControls() override;
void buildRules() override;
void buildDemands() override;
private:
std::string mProjCode;
}; };
#pragma once
#include<string>
typedef struct ResultItem
{
char szNo[64];
std::string dDate;
std::string dTime;
float dQuality;
};
// ڵģֵ
struct NodeResultItem:public ResultItem
{
float dHead;
float dPressure;
float dElevation;
float dDemand;
};
// ܶνģֵ
struct LinkResultItem:public ResultItem
{
char szStatus[32];
float dFlow;
float dVelocity;
float dHeadloss;// λˮ
};
// ˮ
struct TankResultItem :public ResultItem
{
float dTankVolume;
float dTankMaxVolume;
float dTankLevel;
};
#define NodeResultItems std::map<std::string,NodeResultItem>
#define LinkResultItems std::map<std::string,LinkResultItem>
#include "CivSimulResultCache.h" #include "CivSimulResultCache.h"
#include"CivSysLog.h" #include"CivSysLog.h"
#include "CivDbConn.h"
void CivSimulResultCache::addNodeQuality(float quality, int interval, Str sNo) void CivSimulResultCache::addNodeQuality(float quality, int interval, const std::string& sNo)
{ {
if (mNodeItemsMap.find(interval) == mNodeItemsMap.end()) if (mNodeItemsMap.find(interval) == mNodeItemsMap.end())
return; return;
...@@ -14,26 +13,7 @@ void CivSimulResultCache::addNodeQuality(float quality, int interval, Str sNo) ...@@ -14,26 +13,7 @@ void CivSimulResultCache::addNodeQuality(float quality, int interval, Str sNo)
mNodeItemsMap[interval][sNo].dQuality = quality; mNodeItemsMap[interval][sNo].dQuality = quality;
} }
bool CivSimulResultCache::updateToDb(CivDbConn* dbConn) void CivSimulResultCache::addLinkQuality(float quality, int interval,const std::string& sNo)
{
if (dbConn == nullptr)
return false;
// 更行节点
for (auto iter = mNodeItemsMap.begin();iter!=mNodeItemsMap.end();iter++)
{
dbConn->updateNode(iter->second);
}
for (auto iter = mLinkItemsMap.begin(); iter != mLinkItemsMap.end(); iter++)
{
dbConn->updateLink(iter->second);
}
return true;
}
void CivSimulResultCache::addLinkQuality(float quality, int interval, Str sNo)
{ {
if (mLinkItemsMap.find(interval) == mLinkItemsMap.end()) if (mLinkItemsMap.find(interval) == mLinkItemsMap.end())
return; return;
...@@ -47,12 +27,12 @@ void CivSimulResultCache::addLinkQuality(float quality, int interval, Str sNo) ...@@ -47,12 +27,12 @@ void CivSimulResultCache::addLinkQuality(float quality, int interval, Str sNo)
void CivSimulResultCache::addNodeItems(const NodeResultItem& nodeItem) void CivSimulResultCache::addNodeItems(const NodeResultItem& nodeItem)
{ {
mNodeItemsMap[nodeItem.dInterval][nodeItem.szNo] = nodeItem; // mNodeItemsMap[nodeItem.dInterval][nodeItem.szNo] = nodeItem;
} }
void CivSimulResultCache::addLinkItems(const LinkResultItem& linkItem) void CivSimulResultCache::addLinkItems(const LinkResultItem& linkItem)
{ {
mLinkItemsMap[linkItem.dInterval][linkItem.szNo] = linkItem; //mLinkItemsMap[linkItem.dInterval][linkItem.szNo] = linkItem;
} }
void CivSimulResultCache::getResultByTime(int time, NodeResultItems& nodeItems, LinkResultItems& linkItems) void CivSimulResultCache::getResultByTime(int time, NodeResultItems& nodeItems, LinkResultItems& linkItems)
...@@ -64,7 +44,6 @@ void CivSimulResultCache::getResultByTime(int time, NodeResultItems& nodeItems, ...@@ -64,7 +44,6 @@ void CivSimulResultCache::getResultByTime(int time, NodeResultItems& nodeItems,
auto linkIter = mLinkItemsMap.find(time); auto linkIter = mLinkItemsMap.find(time);
if (nodeIter == mNodeItemsMap.end() || linkIter == mLinkItemsMap.end()) if (nodeIter == mNodeItemsMap.end() || linkIter == mLinkItemsMap.end())
{ {
CivSysLog::getInstance()->error("存储数据出错了,找不到该对应时段的值", "CivSimulResultCache", __FUNCTION__);
return; return;
} }
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
#define CIVSIMULRESULTCACHE_H #define CIVSIMULRESULTCACHE_H
#include <map> #include <map>
#include "CivTypes.h" #include "CivSimuResStruct.h"
class CivDbConn;
/** /**
模拟结果缓存类 模拟结果缓存类
...@@ -18,7 +16,7 @@ public: ...@@ -18,7 +16,7 @@ public:
*@param interval:模拟第几次 *@param interval:模拟第几次
*@param sNo:本点号 *@param sNo:本点号
*/ */
void addNodeQuality(float quality, int interval, Str sNo); void addNodeQuality(float quality, int interval, const std::string& sNo);
/** /**
*@brief 缓存管线水质 *@brief 缓存管线水质
...@@ -26,7 +24,7 @@ public: ...@@ -26,7 +24,7 @@ public:
*@param interval:模拟第几次 *@param interval:模拟第几次
*@param sNo:管线编号 *@param sNo:管线编号
*/ */
void addLinkQuality(float quality, int interval, Str sNo); void addLinkQuality(float quality, int interval, const std::string& sNo);
/** /**
*@brief 缓存节点水力模拟情况 *@brief 缓存节点水力模拟情况
...@@ -45,12 +43,6 @@ public: ...@@ -45,12 +43,6 @@ public:
*/ */
void clear(); void clear();
/**
*@brief 缓存数据更新到数据库
*@param dbConn:数据库连接对象
*/
bool updateToDb(CivDbConn* dbConn);
/** /**
*@brief 根据时段获取 *@brief 根据时段获取
*@param time 时段 *@param time 时段
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
#include "CivSimulResultCache.h" #include "CivSimulResultCache.h"
#include "CivHydrSimulation.h" #include "CivHydrSimulation.h"
#include "CivGraphFactory.h" #include "CivGraphFactory.h"
#include "CivDbConn.h"
CivTrackingAnalysis::CivTrackingAnalysis() CivTrackingAnalysis::CivTrackingAnalysis(const std::string& uri)
:mGraph(new ALGraph<CivGraphJunction, CivGraphEdage>()) :mGraph(new ALGraph<CivGraphJunction, CivGraphEdage>()),mUri(uri)
{ {
} }
...@@ -15,86 +14,86 @@ CivTrackingAnalysis::~CivTrackingAnalysis() ...@@ -15,86 +14,86 @@ CivTrackingAnalysis::~CivTrackingAnalysis()
delete mGraph; delete mGraph;
} }
bool CivTrackingAnalysis::createGraphFrom(CivDbConn* dbConn) bool CivTrackingAnalysis::createGraphFrom()
{ {
if (dbConn == nullptr)
return false;
CivHydrSimulation simulation; //CivHydrSimulation simulation;
simulation.registDb(dbConn); //simulation.registDb(dbConn);
if (!simulation.hdyrInstantSimulation()) //if (!simulation.hdyrInstantSimulation())
return false; // return false;
NodeResultItems nodeItems; //NodeResultItems nodeItems;
LinkResultItems linkItems; //LinkResultItems linkItems;
simulation.getDataByTime(0, nodeItems, linkItems); //simulation.getDataByTime(0, nodeItems, linkItems);
if (nodeItems.size() <= 0)
return false;
// 顶点坐标
CivCoordinates coords;
dbConn->getCoordinates(coords);
std::list<CivCoordinates::CoordTable> coordTableLis = coords.mTables; //if (nodeItems.size() <= 0)
std::list<CivCoordinates::CoordTable>::iterator iter; // return false;
for (iter = coordTableLis.begin(); iter != coordTableLis.end(); iter++)
{
CivCoordinates::CoordTable coordTable = *iter;
// 插入顶点数据
CivGraphJunction graphJunction(coordTable.ID, coordTable.XCoord, coordTable.YCoord);
auto iter = nodeItems.find(coordTable.ID);
if (iter != nodeItems.end())
{
graphJunction.setHead(iter->second.dHead);
}
mGraph->insertAVertex(graphJunction);
}
// 管段 //// 顶点坐标
CivPipe civPipe; //CivCoordinates coords;
dbConn->getPipe(civPipe); //dbConn->getCoordinates(coords);
//std::list<CivCoordinates::CoordTable> coordTableLis = coords.mTables;
//std::list<CivCoordinates::CoordTable>::iterator iter;
//for (iter = coordTableLis.begin(); iter != coordTableLis.end(); iter++)
//{
// CivCoordinates::CoordTable coordTable = *iter;
// // 插入顶点数据
// CivGraphJunction graphJunction(coordTable.ID, coordTable.XCoord, coordTable.YCoord);
// auto iter = nodeItems.find(coordTable.ID);
// if (iter != nodeItems.end())
// {
// graphJunction.setHead(iter->second.dHead);
// }
// mGraph->insertAVertex(graphJunction);
//}
std::list<CivPipe::PipesTable> pipesTableLis = civPipe.mTables; //// 管段
std::list<CivPipe::PipesTable>::iterator pIter; //CivPipe civPipe;
//dbConn->getPipe(civPipe);
for (pIter = pipesTableLis.begin(); pIter != pipesTableLis.end(); pIter++) //std::list<CivPipe::PipesTable> pipesTableLis = civPipe.mTables;
{ //std::list<CivPipe::PipesTable>::iterator pIter;
CivPipe::PipesTable pipeTable = *pIter;
// 获取管段起点坐标
CivGraphJunction graphJunction1(pipeTable.Node1);
int index1 = mGraph->getVertexIndex(graphJunction1);
CivGraphJunction sStartjuction = mGraph->getData(index1);
// 获取管段终点坐标值
CivGraphJunction graphJunction2(pipeTable.Node2);
int index2 = mGraph->getVertexIndex(graphJunction2);
CivGraphJunction endJunction = mGraph->getData(index2);
if (sStartjuction.getHead() > endJunction.getHead())
{
CivGraphEdage edAge(pipeTable.ID, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
mGraph->insertAEdge(sStartjuction, endJunction, edAge);
}
else if (sStartjuction.getHead() == endJunction.getHead())
{
CivGraphEdage edAge1(pipeTable.ID, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
mGraph->insertAEdge(sStartjuction, endJunction, edAge1);
CivGraphEdage edAge2(pipeTable.ID, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() });
mGraph->insertAEdge(endJunction, sStartjuction, edAge2);
}
else
{
CivGraphEdage edAge(pipeTable.ID, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() });
mGraph->insertAEdge(endJunction, sStartjuction, edAge);
}
} //for (pIter = pipesTableLis.begin(); pIter != pipesTableLis.end(); pIter++)
//{
// CivPipe::PipesTable pipeTable = *pIter;
// // 获取管段起点坐标
// CivGraphJunction graphJunction1(pipeTable.Node1);
// int index1 = mGraph->getVertexIndex(graphJunction1);
// CivGraphJunction sStartjuction = mGraph->getData(index1);
// // 获取管段终点坐标值
// CivGraphJunction graphJunction2(pipeTable.Node2);
// int index2 = mGraph->getVertexIndex(graphJunction2);
// CivGraphJunction endJunction = mGraph->getData(index2);
// if (sStartjuction.getHead() > endJunction.getHead())
// {
// CivGraphEdage edAge(pipeTable.ID, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
// mGraph->insertAEdge(sStartjuction, endJunction, edAge);
// }
// else if (sStartjuction.getHead() == endJunction.getHead())
// {
// CivGraphEdage edAge1(pipeTable.ID, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
// mGraph->insertAEdge(sStartjuction, endJunction, edAge1);
// CivGraphEdage edAge2(pipeTable.ID, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() });
// mGraph->insertAEdge(endJunction, sStartjuction, edAge2);
// }
// else
// {
// CivGraphEdage edAge(pipeTable.ID, pipeTable.Length, { endJunction.getXCoord(),endJunction.getYCoord(), sStartjuction.getXCoord(),sStartjuction.getYCoord() });
// mGraph->insertAEdge(endJunction, sStartjuction, edAge);
// }
//}
return true; return true;
} }
......
#pragma once #pragma once
#include "CivHydDataType.h" #include "CivHydDataType.h"
#include "CivGraphList.h" #include "CivGraphList.h"
#include "CivTrackingResultCache.h" #include "CivTrackingResultCache.h"
...@@ -7,20 +6,12 @@ ...@@ -7,20 +6,12 @@
#define ALGORITHMEXPORT __declspec(dllexport) #define ALGORITHMEXPORT __declspec(dllexport)
class CivDbConn;
class ALGORITHMEXPORT CivTrackingAnalysis class ALGORITHMEXPORT CivTrackingAnalysis
{ {
public: public:
explicit CivTrackingAnalysis(); explicit CivTrackingAnalysis(const std::string& uri);
~CivTrackingAnalysis(); ~CivTrackingAnalysis();
/**
*@brief 根据数据库管网构建管网有向图
*@param dbConn 数据库连接
*/
bool createGraphFrom(CivDbConn* dbConn);
/** /**
*@brief 追踪节点上游路径 *@brief 追踪节点上游路径
*@param sN 节点本点号 *@param sN 节点本点号
...@@ -43,6 +34,12 @@ public: ...@@ -43,6 +34,12 @@ public:
bool waterSupplyScopeAnalysis(const std::string& sN, std::string& jsonResult); bool waterSupplyScopeAnalysis(const std::string& sN, std::string& jsonResult);
private: private:
/**
*@brief 根据数据库管网构建管网有向图
*@param uri 数据库连接地址
*/
bool createGraphFrom();
/** /**
*@brief 节点和管段集合信息转换成json字符串 *@brief 节点和管段集合信息转换成json字符串
*@param junctions 节点信息集合 *@param junctions 节点信息集合
...@@ -83,5 +80,6 @@ private: ...@@ -83,5 +80,6 @@ private:
std::vector<CivGraphEdage>& pipes); std::vector<CivGraphEdage>& pipes);
private: private:
std::string mUri;
ALGraph<CivGraphJunction, CivGraphEdage>* mGraph; // 管网有向图 ALGraph<CivGraphJunction, CivGraphEdage>* mGraph; // 管网有向图
}; };
...@@ -189,6 +189,7 @@ ...@@ -189,6 +189,7 @@
<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="CivSimuResStruct.h" />
<ClInclude Include="CivTrackingAnalysis.h" /> <ClInclude Include="CivTrackingAnalysis.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
...@@ -125,5 +125,8 @@ ...@@ -125,5 +125,8 @@
<ClInclude Include="CivBaseInpBuilder.h"> <ClInclude Include="CivBaseInpBuilder.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivSimuResStruct.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define DBEXPORT __declspec(dllexport) #define DBEXPORT __declspec(dllexport)
#define Str std::string
class CivAssembly; class CivAssembly;
class CivNode; class CivNode;
class CivPipe; class CivPipe;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
/** /**
数据库连接类 数据库连接类
*/ */
class CivConnection class CivConnection
{ {
public: public:
CivConnection(); CivConnection();
...@@ -16,7 +16,7 @@ public: ...@@ -16,7 +16,7 @@ public:
/** /**
*@brief 建立数据,与具体的数据有关子类实现 *@brief 建立数据,与具体的数据有关子类实现
*/ */
virtual bool connect(const std::string url) = 0; virtual bool connect(const std::string& url) = 0;
/** /**
*@brief 关闭数据,与具体的数据有关子类实现 *@brief 关闭数据,与具体的数据有关子类实现
......
#include "CivDbConn.h"
#include "CivCommonUtils.h"
#include <sstream>
CivDbConn::CivDbConn()
{
mIsOpen = false;
}
CivDbConn::~CivDbConn()
{
}
bool CivDbConn::isValid() const
{
return mIsOpen;
}
Str CivDbConn::getLastError() const
{
return mLastError;
}
#ifndef CIVDBCONN_H
#define CIVDBCONN_H
#include "CivTypes.h"
#include "CivAssembly.h"
#include "CivTableTemp.h"
#define DBEXPORT __declspec(dllexport)
/**
数据库连接接口
*/
class DBEXPORT CivDbConn
{
public:
CivDbConn();
virtual ~CivDbConn();
// 获取组件对象
virtual bool getNode(CivNode& node)=0;
virtual bool getPipe(CivPipe& pipe)=0;
virtual bool getTank(CivTank& tank)=0;
virtual bool getValve(CivValve& valve)=0;
virtual bool getPumps(CivPumps& pump)=0;
virtual bool getReservoirs(CivReservoirs& reservoirs)=0;
virtual bool getEmitters(CivEmitters& emitter)=0;
virtual bool getCoordinates(CivCoordinates& coord)=0;
virtual bool getMixing(CivMixing& mixing)=0;
virtual bool getParameter(std::vector <CivParameter>& params)=0;
virtual bool getPatterns(CivPatterns& patterns)=0;
virtual bool getCurves(CivCurves& curves)=0;
virtual bool getDemands(CivDemands& demands)=0;
virtual bool getSources(CivSources& sources)=0;
virtual bool getStatus(CivStatus& status)=0;
virtual bool getQuality(CivQuality& quality)=0;
virtual bool getLabels(CivLabels& labels)=0;
virtual bool getTags(CivTags& tags)=0;
/**
*@brief 连接数据库,与具体的数据有关子类实现
*/
virtual bool open() = 0;
/**
*@brief 关闭数据库连接,与具体的数据有关子类实现
*/
virtual void close() = 0;
/**
*@brief 判断某张表是否存在,判断方法跟具体的数据库有关,延迟到子类实现
*@param tableName: 表名称
*/
virtual bool tableExist(StrQuote tableName) = 0;
/**
*@brief 根据字段值条件删除数据
*@param table:表
*@param filedName:字段名
*@param fieldValue:字段值
*/
virtual bool deleteByField(StrQuote table, StrQuote filedName, StrQuote fieldValue) =0 ;
/**
*@brief 更新点表数据
*@param nodeItems:需要更新的值
*/
virtual bool updateNode(const NodeResultItems& nodeItems) = 0;
/**
*@brief 更新线表的数据
*@param: lineItems: 线数据
*/
virtual bool updateLink(const LinkResultItems& lineItems) = 0;
/**
*@brief 执行sql语句
*@param: sql 需要执行的sql语句
*/
virtual bool execSql(StrQuote sql) = 0;
/**
*@brief 获取指定表的字段信息
*@param fileds 需要查询那些字段
*@param result 查询的结果集
*/
virtual bool getFieldValueFromTable(const std::string& table,
const std::vector<std::string>& fileds,
std::vector< std::vector<std::string>>& result) = 0;
/**
*@brief 根据条件获取某表的指定字段的值
*@param table 查询的表
*@param condition 查询条件
*@param fileds 需要查询那些字段
*@param result 查询的结果集
*/
virtual bool getValuesFromTableByCondition(const std::string& table,
const std::string& condition,
const std::vector<std::string>& fileds,
std::vector< std::map<std::string, std::string>>& result) = 0;
// 获取当前执行错误信息
Str getLastError() const;
bool isValid() const;
protected:
bool mIsOpen = false; // 数据库连接信息
char* mLastError; // 执行sql的错误信息
};
#endif // !CIVDBCONN_H
#include "CivInpDbHelper.h" #include "CivInpDbHelper.h"
#include "CivTableTemp.h" #include "CivTableFields.h"
#include "CivConnection.h" #include "CivConnection.h"
#include "CivPgDbConnection.h" #include "CivPgDbConnection.h"
CivInpDbHelper::CivInpDbHelper(CivConnection* dbConn) CivInpDbHelper::CivInpDbHelper(const std::string& uri)
:CivInpHelperAbs(dbConn) :CivInpHelperAbs(uri)
{ {
} }
...@@ -214,11 +214,6 @@ bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs) ...@@ -214,11 +214,6 @@ bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
return true; return true;
} }
bool CivInpDbHelper::getEmitters(CivEmitters& emitter)
{
return true;
}
bool CivInpDbHelper::getCoordinates(CivCoordinates& coord) bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
{ {
JunctionTable nodeTable; JunctionTable nodeTable;
...@@ -250,132 +245,16 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord) ...@@ -250,132 +245,16 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
return true; return true;
} }
bool CivInpDbHelper::getMixing(CivMixing& mixing)
{
return true;
}
bool CivInpDbHelper::getParameter(std::vector<CivParameter>& params)
{
ParametorTable restemTable;
std::vector<std::string> fields = {
restemTable.name,
restemTable.val,
restemTable.type
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(OPTIONTTABLE, fields, resultVector);
std::map<std::string, std::vector<CivParameter::ParamTable>> tempMap;
for (int i = 0; i < resultVector.size(); i++)
{
CivParameter::ParamTable pTable;
std::map<std::string, std::string> map = resultVector[i];
pTable.name = map.find(fields[0])->second;
pTable.val = map.find(fields[1])->second;
std::string type = map.find(fields[2])->second;
tempMap[type].push_back(pTable);
}
// 遍历临时存储的数据拼接参数对象
for (auto iter = tempMap.begin(); iter != tempMap.end(); iter++)
{
CivParameter param;
std::string type = iter->first;
std::vector<CivParameter::ParamTable> paramTables = iter->second;
param.setType(type);
int total = paramTables.size();
for (int i = 0; i < total; i++)
param.addItem(paramTables[i]);
params.push_back(param);
}
return true;
}
bool CivInpDbHelper::getPatterns(CivPatterns& patterns)
{
PatternTable patternTable;
std::vector<std::string> fields = {
patternTable.modelName,
patternTable.modelData,
patternTable.modelType
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PATTERNTABLE, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
std::map<std::string, std::string> map = resultVector[i];
CivPatterns::PatternTable pTable;
pTable.name = map.find(fields[0])->second;
pTable.val = map.find(fields[1])->second;
patterns.addItem(pTable);
}
return true;
}
bool CivInpDbHelper::getCurves(CivCurves& curves)
{
CurveTable curveTable;
std::vector<std::string> fields = {
curveTable.CurveName,
curveTable.CurveType,
curveTable.CurveData
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PATTERNTABLE, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivCurves::CurvesTable cTable;
std::map<std::string, std::string> map = resultVector[i];
cTable.ID = map.find(fields[0])->second;
cTable.XCoord = map.find(fields[1])->second;
cTable.YCoord = map.find(fields[2])->second;
curves.addItem(cTable);
}
return true;
}
bool CivInpDbHelper::getDemands(CivDemands& demands)
{
return true;
}
bool CivInpDbHelper::getSources(CivSources& sources)
{
return true;
}
bool CivInpDbHelper::getStatus(CivStatus& status)
{
return true;
}
bool CivInpDbHelper::getQuality(CivQuality& quality) bool CivInpDbHelper::getQuality(CivQuality& quality)
{ {
JunctionTable nodeTable; JunctionTable nodeTable;
std::vector<std::string> fields = { nodeTable.sn,nodeTable.initQuality }; std::vector<std::string> fields =
{
nodeTable.sn,
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);
...@@ -395,12 +274,3 @@ bool CivInpDbHelper::getQuality(CivQuality& quality) ...@@ -395,12 +274,3 @@ bool CivInpDbHelper::getQuality(CivQuality& quality)
return true; return true;
} }
bool CivInpDbHelper::getLabels(CivLabels& labels)
{
return true;
}
bool CivInpDbHelper::getTags(CivTags& tags)
{
return true;
}
\ No newline at end of file
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#include <memory> #include <memory>
/** /**
从数据库获取inp文件相关的类 从数据库获取inp文件相关的类
*/ */
class CivInpDbHelper:public CivInpHelperAbs class INPDLLEXPORT CivInpDbHelper:public CivInpHelperAbs
{ {
public: public:
explicit CivInpDbHelper(CivConnection* dbConn); explicit CivInpDbHelper(const std::string& uri);
~CivInpDbHelper(); ~CivInpDbHelper();
bool getNode(CivNode& node)override; bool getNode(CivNode& node)override;
...@@ -18,16 +18,6 @@ public: ...@@ -18,16 +18,6 @@ public:
bool getValve(CivValve& valve) override; bool getValve(CivValve& valve) override;
bool getPumps(CivPumps& pump) override; bool getPumps(CivPumps& pump) override;
bool getReservoirs(CivReservoirs& reservoirs) override; bool getReservoirs(CivReservoirs& reservoirs) override;
bool getEmitters(CivEmitters& emitter) override;
bool getCoordinates(CivCoordinates& coord) override; bool getCoordinates(CivCoordinates& coord) override;
bool getMixing(CivMixing& mixing) override; bool getQuality(CivQuality& quality) override;
bool getParameter(std::vector<CivParameter>& param) override;
bool getPatterns(CivPatterns& patterns) override;
bool getCurves(CivCurves& curves) override;
bool getDemands(CivDemands& demands) override;
bool getSources(CivSources& sources) override;
bool getStatus(CivStatus& status) override;
bool getQuality(CivQuality& quality) override;
bool getLabels(CivLabels& labels) override;
bool getTags(CivTags& tags) override;
}; };
#include "CivInpHelperAbs.h" #include "CivInpHelperAbs.h"
#include "CivConnection.h" #include "CivConnection.h"
#include "CivTableTemp.h" #include "CivPgDbConnection.h"
#include "CivTableFields.h"
CivInpHelperAbs::CivInpHelperAbs(CivConnection* dbConn) CivInpHelperAbs::CivInpHelperAbs(const std::string& uri)
:mDbConn(dbConn)
{ {
mDbConn = new CivPgDbConnection();
mDbConn->connect(uri);
} }
CivInpHelperAbs::~CivInpHelperAbs() CivInpHelperAbs::~CivInpHelperAbs()
{ {
mDbConn->disconnect();
delete mDbConn;
} }
bool CivInpHelperAbs::getNode(CivNode& node) bool CivInpHelperAbs::getEmitters(CivEmitters& emitter)
{ {
return true; return true;
} }
bool CivInpHelperAbs::getPipe(CivPipe& pipes) bool CivInpHelperAbs::getMixing(CivMixing& mixing)
{ {
return true; return true;
} }
bool CivInpHelperAbs::getTank(CivTank& tanks) bool CivInpHelperAbs::getParameter(std::vector<CivParameter>& params)
{ {
return true; ParametorTable restemTable;
}
bool CivInpHelperAbs::getValve(CivValve& valves) std::vector<std::string> fields = {
{ restemTable.name,
return true; restemTable.val,
} restemTable.type
};
bool CivInpHelperAbs::getPumps(CivPumps& pumps) std::vector<std::map<std::string, std::string>> resultVector;
{ mDbConn->query(OPTIONTTABLE, fields, resultVector);
return true;
}
bool CivInpHelperAbs::getReservoirs(CivReservoirs& reservoirs) std::map<std::string, std::vector<CivParameter::ParamTable>> tempMap;
{ for (int i = 0; i < resultVector.size(); i++)
return true; {
} CivParameter::ParamTable pTable;
std::map<std::string, std::string> map = resultVector[i];
pTable.name = map.find(fields[0])->second;
pTable.val = map.find(fields[1])->second;
bool CivInpHelperAbs::getEmitters(CivEmitters& emitter) std::string type = map.find(fields[2])->second;
{ tempMap[type].push_back(pTable);
return true; }
}
bool CivInpHelperAbs::getCoordinates(CivCoordinates& coord) // 遍历临时存储的数据拼接参数对象
{ for (auto iter = tempMap.begin(); iter != tempMap.end(); iter++)
return true; {
} CivParameter param;
std::string type = iter->first;
std::vector<CivParameter::ParamTable> paramTables = iter->second;
bool CivInpHelperAbs::getMixing(CivMixing& mixing) param.setType(type);
{
return true;
}
bool CivInpHelperAbs::getParameter(std::vector<CivParameter>& params) size_t total = paramTables.size();
{ for (int i = 0; i < total; i++)
param.addItem(paramTables[i]);
params.push_back(param);
}
return true; return true;
} }
bool CivInpHelperAbs::getPatterns(CivPatterns& patterns) bool CivInpHelperAbs::getPatterns(CivPatterns& patterns)
{ {
PatternTable patternTable;
std::vector<std::string> fields = {
patternTable.modelName,
patternTable.modelData,
patternTable.modelType
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PATTERNTABLE, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
std::map<std::string, std::string> map = resultVector[i];
CivPatterns::PatternTable pTable;
pTable.name = map.find(fields[0])->second;
pTable.val = map.find(fields[1])->second;
patterns.addItem(pTable);
}
return true; return true;
} }
bool CivInpHelperAbs::getCurves(CivCurves& curves) bool CivInpHelperAbs::getCurves(CivCurves& curves)
{ {
CurveTable curveTable;
std::vector<std::string> fields = {
curveTable.CurveName,
curveTable.CurveType,
curveTable.CurveData
};
std::vector<std::map<std::string, std::string>> resultVector;
mDbConn->query(PATTERNTABLE, fields, resultVector);
size_t totals = resultVector.size();
for (int i = 0; i < totals; i++)
{
CivCurves::CurvesTable cTable;
std::map<std::string, std::string> map = resultVector[i];
cTable.ID = map.find(fields[0])->second;
cTable.XCoord = map.find(fields[1])->second;
cTable.YCoord = map.find(fields[2])->second;
curves.addItem(cTable);
}
return true; return true;
} }
...@@ -92,11 +141,6 @@ bool CivInpHelperAbs::getStatus(CivStatus& status) ...@@ -92,11 +141,6 @@ bool CivInpHelperAbs::getStatus(CivStatus& status)
return true; return true;
} }
bool CivInpHelperAbs::getQuality(CivQuality& quality)
{
return true;
}
bool CivInpHelperAbs::getLabels(CivLabels& labels) bool CivInpHelperAbs::getLabels(CivLabels& labels)
{ {
return true; return true;
......
...@@ -3,35 +3,39 @@ ...@@ -3,35 +3,39 @@
class CivConnection; class CivConnection;
#define INPDLLEXPORT __declspec(dllexport)
/** /**
תinpݿ 转inp操作数据库类
*/ */
class CivInpHelperAbs class INPDLLEXPORT CivInpHelperAbs
{ {
public: public:
explicit CivInpHelperAbs(CivConnection* dbConn); explicit CivInpHelperAbs(const std::string& uri);
virtual ~CivInpHelperAbs(); virtual ~CivInpHelperAbs();
virtual bool getNode(CivNode& node) ; // 组件需要重载
virtual bool getPipe(CivPipe& pipe) ; virtual bool getNode(CivNode& node)=0 ;
virtual bool getTank(CivTank& tank) ; virtual bool getPipe(CivPipe& pipe)=0 ;
virtual bool getValve(CivValve& valve) ; virtual bool getTank(CivTank& tank) = 0;
virtual bool getPumps(CivPumps& pump) ; virtual bool getValve(CivValve& valve) =0;
virtual bool getReservoirs(CivReservoirs& reservoirs) ; virtual bool getPumps(CivPumps& pump) =0;
virtual bool getEmitters(CivEmitters& emitter) ; virtual bool getReservoirs(CivReservoirs& reservoirs) =0;
virtual bool getCoordinates(CivCoordinates& coord) ;
virtual bool getMixing(CivMixing& mixing) ; virtual bool getCoordinates(CivCoordinates& coord) =0;
virtual bool getParameter(std::vector<CivParameter>& param) ; virtual bool getQuality(CivQuality& quality)=0;
virtual bool getPatterns(CivPatterns& patterns) ;
virtual bool getCurves(CivCurves& curves) ; // 不要重载函数
virtual bool getDemands(CivDemands& demands) ; bool getPatterns(CivPatterns& patterns) ;
virtual bool getSources(CivSources& sources) ; bool getCurves(CivCurves& curves) ;
virtual bool getStatus(CivStatus& status) ; bool getDemands(CivDemands& demands) ;
virtual bool getQuality(CivQuality& quality) ; bool getSources(CivSources& sources) ;
virtual bool getLabels(CivLabels& labels) ; bool getStatus(CivStatus& status) ;
virtual bool getTags(CivTags& tags) ; bool getLabels(CivLabels& labels) ;
bool getTags(CivTags& tags) ;
bool getMixing(CivMixing& mixing);
bool getParameter(std::vector<CivParameter>& param);
bool getEmitters(CivEmitters& emitter);
protected: protected:
CivConnection* mDbConn; CivConnection* mDbConn;
std::map<std::string, std::map<std::string, std::string>> mCacheMap;
}; };
This diff is collapsed.
#ifndef CIVPGCONN_H
#define CIVPGCONN_H
#include <libpq-fe.h>
#include "CivDbConn.h"
/**
postgress 数据库
*/
class DBEXPORT CivPgConn: public CivDbConn
{
public:
CivPgConn(char* uri);
virtual ~CivPgConn();
/**
*@brief 连接数据库,与具体的数据有关子类实现
*/
bool open() override;
/**
*@brief 关闭数据库连接,与具体的数据有关子类实现
*/
void close() override;
/**
*@brief 判断某张表是否存在,判断方法跟具体的数据库有关,延迟到子类实现
*@tableName: 表名称
*/
bool tableExist(StrQuote tableName)override;
/**
*@brief 执行sql语句
*@sql: 需要执行的sql语句
*/
bool execSql(StrQuote sql) override;
bool getNode(CivNode& node) override;
bool getPipe(CivPipe& pipe) override;
bool getTank(CivTank& tank) override;
bool getValve(CivValve& valve) override;
bool getPumps(CivPumps& pump) override;
bool getReservoirs(CivReservoirs& reservoirs) override;
bool getEmitters(CivEmitters& emitter) override;
bool getCoordinates(CivCoordinates& coord) override;
bool getMixing(CivMixing& mixing) override;
bool getParameter(std::vector<CivParameter>& param) override;
bool getPatterns(CivPatterns& patterns) override;
bool getCurves(CivCurves& curves) override;
bool getDemands(CivDemands& demands) override;
bool getSources(CivSources& sources) override;
bool getStatus(CivStatus& status) override;
bool getQuality(CivQuality& quality) override;
bool getLabels(CivLabels& labels) override;
bool getTags(CivTags& tags) override;
/**
*@brief 根据字段值条件删除数据
*@param table:表
*@param filedName:字段名
*@paramfieldValue:字段值
*/
bool deleteByField(StrQuote table, StrQuote filedName, StrQuote fieldValue) override;
/**
*@brief 更新点表数据
*@param nodeItems:需要更新的值
*/
bool updateNode(const NodeResultItems& nodeItems) override;
/**
*@brief 更新线表的数据
*@param lineItems: 线数据
*/
bool updateLink(const LinkResultItems& lineItems) override;
bool getFieldValueFromTable(const std::string& table,
const std::vector<std::string>& fileds,
std::vector< std::vector<std::string>>& result) override;
bool getValuesFromTableByCondition(
const std::string& table,
const std::string& condition,
const std::vector<std::string>& fileds,
std::vector< std::map<std::string, std::string>>& result) override;
private:
PGconn* mConn; // 连接对象
PGresult* mResult; // 查询结果集
char* mUri;
};
#endif // !CIVPGCONN_H
...@@ -11,7 +11,7 @@ CivPgDbConnection::~CivPgDbConnection() ...@@ -11,7 +11,7 @@ CivPgDbConnection::~CivPgDbConnection()
disconnect(); disconnect();
} }
bool CivPgDbConnection::connect(const std::string url) bool CivPgDbConnection::connect(const std::string& url)
{ {
disconnect(); disconnect();
......
...@@ -17,7 +17,7 @@ public: ...@@ -17,7 +17,7 @@ public:
/** /**
*@brief 建立数据,与具体的数据有关子类实现 *@brief 建立数据,与具体的数据有关子类实现
*/ */
virtual bool connect(const std::string url); virtual bool connect(const std::string& url);
/** /**
*@brief 关闭数据,与具体的数据有关子类实现 *@brief 关闭数据,与具体的数据有关子类实现
......
#include "CivProjInpDbHelper.h" #include "CivProjInpDbHelper.h"
#include "CivConnection.h" #include "CivConnection.h"
CivProjInpDbHelper::CivProjInpDbHelper(CivConnection* dbConn) CivProjInpDbHelper::CivProjInpDbHelper(const std::string& uri)
:CivInpHelperAbs(dbConn) :CivInpHelperAbs(uri)
{ {
} }
CivProjInpDbHelper::~CivProjInpDbHelper() CivProjInpDbHelper::~CivProjInpDbHelper()
...@@ -42,63 +41,14 @@ bool CivProjInpDbHelper::getReservoirs(CivReservoirs& reservoirs) ...@@ -42,63 +41,14 @@ bool CivProjInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
return true; return true;
} }
bool CivProjInpDbHelper::getEmitters(CivEmitters& emitter)
{
return true;
}
bool CivProjInpDbHelper::getCoordinates(CivCoordinates& coord) bool CivProjInpDbHelper::getCoordinates(CivCoordinates& coord)
{ {
return true; return true;
} }
bool CivProjInpDbHelper::getMixing(CivMixing& mixing)
{
return true;
}
bool CivProjInpDbHelper::getParameter(std::vector<CivParameter>& param)
{
return true;
}
bool CivProjInpDbHelper::getPatterns(CivPatterns& patterns)
{
return true;
}
bool CivProjInpDbHelper::getCurves(CivCurves& curves)
{
return true;
}
bool CivProjInpDbHelper::getDemands(CivDemands& demands)
{
return true;
}
bool CivProjInpDbHelper::getSources(CivSources& sources)
{
return true;
}
bool CivProjInpDbHelper::getStatus(CivStatus& status)
{
return true;
}
bool CivProjInpDbHelper::getQuality(CivQuality& quality) bool CivProjInpDbHelper::getQuality(CivQuality& quality)
{ {
return true; return true;
} }
bool CivProjInpDbHelper::getLabels(CivLabels& labels)
{
return true;
}
bool CivProjInpDbHelper::getTags(CivTags& tags)
{
return true;
}
...@@ -5,11 +5,10 @@ ...@@ -5,11 +5,10 @@
/** /**
* *
*/ */
class CivProjInpDbHelper: public CivInpHelperAbs class INPDLLEXPORT CivProjInpDbHelper: public CivInpHelperAbs
{ {
public: public:
explicit CivProjInpDbHelper(CivConnection* dbConn); explicit CivProjInpDbHelper(const std::string& uri);
~CivProjInpDbHelper(); ~CivProjInpDbHelper();
bool getNode(CivNode& node)override; bool getNode(CivNode& node)override;
...@@ -18,16 +17,6 @@ public: ...@@ -18,16 +17,6 @@ public:
bool getValve(CivValve& valve) override; bool getValve(CivValve& valve) override;
bool getPumps(CivPumps& pump) override; bool getPumps(CivPumps& pump) override;
bool getReservoirs(CivReservoirs& reservoirs) override; bool getReservoirs(CivReservoirs& reservoirs) override;
bool getEmitters(CivEmitters& emitter) override;
bool getCoordinates(CivCoordinates& coord) override; bool getCoordinates(CivCoordinates& coord) override;
bool getMixing(CivMixing& mixing) override;
bool getParameter(std::vector<CivParameter>& param) override;
bool getPatterns(CivPatterns& patterns) override;
bool getCurves(CivCurves& curves) override;
bool getDemands(CivDemands& demands) override;
bool getSources(CivSources& sources) override;
bool getStatus(CivStatus& status) override;
bool getQuality(CivQuality& quality) override; bool getQuality(CivQuality& quality) override;
bool getLabels(CivLabels& labels) override;
bool getTags(CivTags& tags) override;
}; };
#ifndef CIVTABLETEMP_H #ifndef CIVTABLEFIELD_H
#define CIVTABLETEMP_H #define CIVTABLEFIELD_H
#include<string> #include<string>
#include<vector> #include<vector>
#include<map> #include<map>
#include<string>
#include "CivTypes.h" #include "CivTypes.h"
#define Str std::string
/** /**
节点表模板 节点表模板
*/ */
...@@ -67,7 +70,6 @@ typedef struct PipeTableFields ...@@ -67,7 +70,6 @@ typedef struct PipeTableFields
/** /**
水泵 水泵
*/ */
typedef struct PumpTableFileds typedef struct PumpTableFileds
{ {
Str startPoint = "起始节点"; Str startPoint = "起始节点";
...@@ -88,6 +90,7 @@ typedef struct PumpTableFileds ...@@ -88,6 +90,7 @@ typedef struct PumpTableFileds
Str quality = "水质"; Str quality = "水质";
Str status = "状态"; Str status = "状态";
} PumpTable; } PumpTable;
/** /**
水池 水池
*/ */
...@@ -137,8 +140,6 @@ typedef struct ResourcesTableFileds ...@@ -137,8 +140,6 @@ typedef struct ResourcesTableFileds
Str quality = "水质"; Str quality = "水质";
}ResourcesTable; }ResourcesTable;
/** /**
阀门 阀门
*/ */
...@@ -397,7 +398,7 @@ typedef struct MonitorQualityTableField ...@@ -397,7 +398,7 @@ typedef struct MonitorQualityTableField
}MonitorQualityTable; }MonitorQualityTable;
#endif // !CIVTABLETEMP_H #endif // !CIVTABLEFIELD_H
...@@ -6,288 +6,24 @@ ...@@ -6,288 +6,24 @@
#include <vector> #include <vector>
#include <set> #include <set>
typedef std::string Str; // 水力模型表名
typedef const std::string& StrQuote;
#define Tables std::vector<Str>
#define PIPELINE Str("管段") #define PIPELINE Str("管段")
#define PIPENODE Str("节点") #define PIPENODE Str("节点")
#define RESIVOIR Str("水库") #define RESIVOIR Str("水库")
#define TANK Str("水池") #define TANK Str("水池")
#define PUMP Str("水泵") #define PUMP Str("水泵")
#define VALVE Str("阀门") #define VALVE Str("阀门")
#define NODERESULTTABLE Str("节点模拟值")
#define NODERESULTTABLE Str("__node_result__") #define PIPERESULTTABLE Str("管段模拟值")
#define PIPERESULTTABLE Str("__pipe_result__") #define PATTERNTABLE Str("水力模式")
#define PATTERNTABLE Str("__pattern__") #define CURVETABLE Str("曲线")
#define CURVETABLE Str("__curve__") #define OPTIONTTABLE Str("模型参数")
#define OPTIONTTABLE Str("__parameter__") #define PROJTABLE Str("方案表")
#define PROJNODETABLE Str("方案点设备")
/** #define PROJPIPETABLE Str("方案线设备")
方案规划相关表定义 #define PRESSURETABLE Str("压力监测点")
*/ #define FLOWTABLE Str("流量监测点")
#define PROJTABLE Str("__proj__") #define QUALITYTABLE Str("水质监测点")
#define PROJNODETABLE Str("__proj_node__")
#define PROJPIPETABLE Str("__proj_pipe__")
/*
监测点表系列
*/
#define PRESSURETABLE Str("__monitor_pressure__")
#define FLOWTABLE Str("__monitor_flow__")
#define QUALITYTABLE Str("__monitor_quality__")
#define PRV_TYPE Str("稳压阀")
#define PSV_TYPE Str("减压阀")
#define PBV_TYPE Str("压力制动阀")
#define FCV_TYPE Str("流量控制阀")
#define TCV_TYPE Str("节流控制阀")
#define GPV_TYPE Str("常规阀门")
// 管点
#define Node std::map<Str,Str>
#define Nodes std::vector<Node>
// 管线集合
#define Componet std::map<Str,Str>
#define Componets std::vector<Componet>
// 字段过滤
#define FiledFilter std::map<Str,std::set<Str>>
// 组件类型
enum SectType {
_TITLE, _JUNCTIONS, _RESERVOIRS, _TANKS, _PIPES, _PUMPS,
_VALVES, _CONTROLS, _RULES, _DEMANDS, _SOURCES, _EMITTERS,
_PATTERNS, _CURVES, _QUALITY, _STATUS, _ROUGHNESS, _ENERGY,
_REACTIONS, _MIXING, _REPORT, _TIMES, _OPTIONS,
_COORDS, _VERTICES, _LABELS, _BACKDROP, _TAGS, _END
};
// 阀门类型
enum ValvesType
{
PRV, /* 减压阀 */
PSV, /* 稳压阀 */
PBV, /* 压力制动阀 */
FCV, /* 流量控制阀 */
TCV, /*节流控制阀 */
GPV /* 常规阀门 */
};
// 水泵参数
enum PumpParameter
{
POWER, // 定速能量水泵的功率数值,hp(kW)
HEAD, // 描述了水泵扬程与流量关系的曲线ID
SPEED, // 相对速度设置(额定速度为1.0,0意味着水泵关闭)
PATTERN // 时间模式的ID,描述了速度设置怎样随时间变化
};
// [REPORT]
// 描述模拟生成的输出报表内容。
struct Report {
Str PAGESIZES;
Str NODES; // NONE/ALL/node1 node2 ...
Str LINKS; // NONE/ALL/link1 link2 ...
Str STATUS;
Str SUMMARY; //
Str ENERGY;
};
/****************************** 管网物理组件,参数字段****************************************************/
// 水泵
//[PUMPS]
//; ID Node1 Node2 Parameters
struct PumpFields {
/**
* POWER——定速能量水泵的功率数值,hp(kW)
* HEAD——描述了水泵扬程与流量关系的曲线ID
* SPEED——相对速度设置(额定速度为1.0,0意味着水泵关闭)
* PATTERN——时间模式的ID,描述了速度设置怎样随时间变化
*/
Str ID = "编号";
Str node1 = "本点号"; // 与水泵连接的输入段本点号
Str node2 = "上点号"; // 水泵连接的下游管段
Str power = "功率"; // 定速能量水泵的功率数值,hp(kW)
Str head = "扬程曲线";
Str speed = "速度"; // 相对速度设置(额定速度为1.0,0意味着水泵关闭)
Str pattern = "水泵曲线";// 时间模式的ID,描述了速度设置怎样随时间变化
};
//[VALVES]
//; ID Node1 Node2 Diameter Type Setting MinorLoss
struct ValvesFields {
Str ID = "编号"; // 水泵表的本点号
Str node1 = "上点号"; // 与水泵连接的输入段本点号
Str node2 = "本点号"; // 水泵连接的下游管段
Str Diameter = "管径";// 直径
Str type = "类型"; // 阀门类型
Str setting = "参数设置"; // 不同阀门对应不同参数
Str minorLoss = "局部损失系数"; //
};
// 水库字段
struct ResivoirFields {
Str ID = "本点号";
Str Elev = "高程";
Str Head = "水头";
Str X_Coord = "横坐标";
Str Y_Coord = "纵坐标";
Str Pattern = "水头模式曲";
Str Flow = "流出流量";
};
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
struct PipeFields {
Str ID = "编号";
Str Node1 = Str("上点号");
Str Node2 = Str("本点号");
Str Length = Str("管长");
Str Diameter = Str("管径"); // 管径
Str Roughness = Str("摩阻系数"); //
Str MinorLoss = Str("局部水头损");
Str Status = Str("状态");
};
// 节点
struct JunctionsFields {
Str ID = "本点号";
Str Elev = "高程";
Str Demand = "需水量";
Str Pattern = "需水量模式";
Str X_Coord = "横坐标";
Str Y_Coord = "纵坐标";
Str InitQual = "初始水质";
};
// 模式表字段
struct PatternFields {
Str Name = "模式名";
Str Value = "值";
Str NetName = "管网名";
};
// 曲线定义表
struct CurvesFields {
Str Label = "曲线名";
Str XCoord = "x";
Str YCoord = "y";
Str Type = "类型";
};
// 参数选项表
struct ParameterFileds {
Str name = "参数名";
Str val = "参数值";
Str type = "参数类型";/*
[REACTIONS]
[SOURCES]
[MIXING]
[OPTIONS]
[TIMES]
[REPORT]
*/
Str netName = "管网名";
};
// 水池
//[TANKS] ;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
struct TanksFields {
Str ID = "本点号";
Str Elev = "高程";
Str InitLevel = "初始水位";
Str MinLevel = "最低水位";
Str MaxLevel = "最高水位";
Str Diameter = "直径";
Str MinVol = "容量";
Str VolCurve = "容积曲线";
Str X_Coord = "横坐标";
Str Y_Coord = "纵坐标";
};
/********************************end **************************************************/
struct NodeFieldName
{
Str Number = "本点号";
Str dFlow = "流量";
Str dHead = "水头";
Str dPressure = "压力";
Str dElevation = "标高";
Str dDemand = "实际需水量";
Str dTankVolume = "水池容量";
Str dTankMaxVolume = "水池最大容量";
Str dTankLevel = "液位高度";
Str dQuality = "水质";
Str dDate = "日期";
Str dInterval = "时段";
Str dModifyTime = "修改时间";
};
struct LinkFiledName
{
Str szNo = "编号";
Str dFlow = "流量";
Str nFlowDirect = "流向";
Str dVelocity = "流速";
Str dHeadloss = "水头损失";
Str dUnitHeadloss = "单位水头损";
Str dFromNodHeadloss = "上点水头";
Str dToNodHeadloss = "本点水头";
Str dLocalHeadloss = "局部水头损";
Str dFrictionHeadloss = "摩擦水头损";
Str szStatus = "状态";
Str dQuality = "水质";
Str dDate = "日期";
Str dInterval = "时段";
Str dModifyTime = "修改时间";
};
// 水力计算管点结果缓存
struct NodeResultItem
{
char szNo[32]; // 本点号
float dFlow; // 流量
float dHead; // 水头
float dPressure; // 压力
float dElevation; // 标高
float dDemand; // 实际需水量
float dTankVolume; // 水池容量
float dTankMaxVolume; // 水池最大容量
float dTankLevel; // 液位高度
float dQuality;// 水质
char dDate[32];// 日期
int dInterval; // 时段
};
// 水力计算管线结果缓存
struct LinkResultItem
{
char szNo[32]; // 编号
float dFlow; // 流量
short nFlowDirect; // 流向
float dVelocity; // 流速
float dHeadloss; // 水头损失
float dUnitHeadloss; // 单位水头损失
float dFromNodHeadloss; // 上点水头
float dToNodHeadloss; // 本点水头
float dLocalHeadloss; // 局部水头损失
float dFrictionHeadloss; // 摩擦水头损失
float dQuality;// 水质
char szStatus[20]; // 状态
char dDate[32];// 日期
int dInterval; // 时段
};
#define NodeResultItems std::map<Str, NodeResultItem>
#define LinkResultItems std::map<Str, LinkResultItem>
#endif // !CIVTYPES_H #endif // !CIVTYPES_H
......
...@@ -151,6 +151,9 @@ ...@@ -151,6 +151,9 @@
<PostBuildEvent> <PostBuildEvent>
<Command>copy CivTypes.h $(OutDir)..\include /y <Command>copy CivTypes.h $(OutDir)..\include /y
copy CivAssembly.h $(OutDir)..\include /y copy CivAssembly.h $(OutDir)..\include /y
copy CivInpHelperAbs.h $(OutDir)..\include /y
copy CivInpDbHelper.h $(OutDir)..\include /y
copy CivProjInpDbHelper.h $(OutDir)..\include /y
</Command> </Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
...@@ -163,7 +166,7 @@ copy CivAssembly.h $(OutDir)..\include /y ...@@ -163,7 +166,7 @@ copy CivAssembly.h $(OutDir)..\include /y
<ClInclude Include="CivPgDbConnection.h" /> <ClInclude Include="CivPgDbConnection.h" />
<ClInclude Include="CivProjInpDbHelper.h" /> <ClInclude Include="CivProjInpDbHelper.h" />
<ClInclude Include="CivSimuResDbHelper.h" /> <ClInclude Include="CivSimuResDbHelper.h" />
<ClInclude Include="CivTableTemp.h" /> <ClInclude Include="CivTableFields.h" />
<ClInclude Include="CivTrackingResultCache.h" /> <ClInclude Include="CivTrackingResultCache.h" />
<ClInclude Include="CivTypes.h" /> <ClInclude Include="CivTypes.h" />
</ItemGroup> </ItemGroup>
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
<ClInclude Include="CivTypes.h"> <ClInclude Include="CivTypes.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivTableTemp.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivCommonUtils.h"> <ClInclude Include="CivCommonUtils.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
...@@ -48,6 +45,9 @@ ...@@ -48,6 +45,9 @@
<ClInclude Include="CivSimuResDbHelper.h"> <ClInclude Include="CivSimuResDbHelper.h">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivTableFields.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CivCommonUtils.cpp"> <ClCompile Include="CivCommonUtils.cpp">
......
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