Commit 6e13faf4 authored by 刘乐's avatar 刘乐

水力模型文档更新,数据库连接修复

parent b5aaae5e
......@@ -36,7 +36,7 @@ void CivConTrackTest::test(char* uri)
*/
void CivConGetDataTest::test(char* uri)
{
const char* date = "2020-07-13";
const char* date = "2020-07-17";
char* dates = const_cast<char*>(date);
const char* interval = "4";
......
#pragma once
/*
/**
ͼ
*/
template<class Item>
......
......@@ -238,11 +238,11 @@ void CivInpBuilder::buildCurves()
{
ASSERT(mDbConn, mNewInp)
CivCurves curves;
/*CivCurves curves;
if (!mDbConn->getCurves(curves))
return;
mNewInp->setCurves(curves);
mNewInp->setCurves(curves);*/
}
void CivInpBuilder::buildStatus()
......
......@@ -57,6 +57,7 @@ bool DLLEXPORT getDataByInterval(char* uri, char* date, char* interval)
delete dbConn;
return false;
}
delete dbConn;
return true;
}
......
......@@ -269,6 +269,7 @@ bool CivHydrSimulation::qualitySimulation()
bool CivHydrSimulation::trackingSimulation(char* snNode, int hour)
{
CivSysLog::getInstance()->error("开始水质分析计算", "qualitySimulation", __FUNCTION__);
setQualityAnalyType(ANALYSIS_TRACE);
if (!convertInp(ANALYSIS_TRACE, snNode))
{
CivSysLog::getInstance()->error("写入inp文件失败", "qualitySimulation", __FUNCTION__);
......@@ -605,10 +606,15 @@ void CivHydrSimulation::getNodeQuality(short time)
// 编号
ENgetnodeid(i, No);
float* quality = (float*)malloc(sizeof(float));
// 水质
ENgetnodevalue(i, EN_QUALITY, quality);
mResultCache.addNodeQuality(*quality, time, No);
int trueQuality = *quality;
if (mQuaLityType == ANALYSIS_TRACE)
trueQuality *= 100;
mResultCache.addNodeQuality(trueQuality, time, No);
free(quality);
}
}
......@@ -633,7 +639,12 @@ void CivHydrSimulation::getLinkQuality(short time)
// 水质
ENgetlinkvalue(i, EN_LINKQUAL, quality);
mResultCache.addLinkQuality(*quality, time, lnkNo);
int trueQuality = *quality;
if (mQuaLityType == ANALYSIS_TRACE)
trueQuality *= 100;
mResultCache.addLinkQuality(trueQuality, time, lnkNo);
}
free(typeCode);
free(quality);
......
......@@ -74,6 +74,8 @@ public:
*/
bool brushingResult();
void setQualityAnalyType(QualityAnalyType analyType) { mQuaLityType = analyType; }
/*
inp文件名,输出文件名,二进制文件名设置和获取
*/
......@@ -98,7 +100,7 @@ private:
private:
CivDbConn* mDbConn;
CivSimulResultCache mResultCache; // 存储模拟结果缓存类
QualityAnalyType mQuaLityType = ANALYSIS_RESERVE;
std::string mInpFile; // inp文件名
std::string mRptFile; // 报告文件名
std::string mBinFile;// 二进制文件名
......
......@@ -4,6 +4,7 @@
CivDbConn::CivDbConn()
{
mIsOpen = false;
}
CivDbConn::~CivDbConn()
......
......@@ -14,7 +14,7 @@ CivPgConn::CivPgConn(char* uri)
CivPgConn::~CivPgConn()
{
if (mConn != NULL)
if (mConn != nullptr)
{
PQfinish(mConn);
}
......@@ -22,9 +22,6 @@ CivPgConn::~CivPgConn()
bool CivPgConn::deleteByField(StrQuote table, StrQuote filedName, StrQuote fieldValue)
{
if (!isValid())
return false;
char delSql[256] = "delete from public.\"";
strcat_s(delSql, table.c_str());
strcat_s(delSql, "\" where ");
......@@ -47,9 +44,6 @@ bool CivPgConn::deleteByField(StrQuote table, StrQuote filedName, StrQuote field
bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval)
{
if (!isValid())
return false;
std::stringstream os;
NodeFieldName filedNames;
......@@ -57,11 +51,14 @@ bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval)
<< PIPENODE << " AS tb1 set ("
<< "总水头"<< ","
<< "压力"<< ","
<< "实际需水量"
<< "实际需水量"<<","
<<"水质"
<< ")=( "
<< "tb2." << filedNames.dHead << ","
<< "tb2." << filedNames.dPressure << ","
<< "tb2." << filedNames.dDemand<< ")" << " from "
<< "tb2." << filedNames.dDemand <<","
<< "tb2." << filedNames.dQuality << ")"
<< " from "
<< NODERESULTTABLE<< " AS tb2 where tb1."
<< filedNames.Number << "= tb2."
<<filedNames.Number << " AND tb2."
......@@ -84,9 +81,6 @@ bool CivPgConn::updateNodeByInterval(StrQuote currDate, StrQuote interval)
bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval)
{
if (!isValid())
return false;
std::stringstream os;
LinkFiledName filedNames;
......@@ -99,7 +93,8 @@ bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval)
<< "摩擦水头损"<< ","
<< "上点水头"<< ","
<< "本点水头"<< ","
<< "局部水头损"
<< "局部水头损"<<","
<<"水质"
<< ")=( "
<< "tb2." << filedNames.dFlow<< ","
<< "tb2." << filedNames.dVelocity<< ","
......@@ -108,7 +103,9 @@ bool CivPgConn::updateLinkByInterval(StrQuote currDate, StrQuote interval)
<< "tb2." << filedNames.dFrictionHeadloss<< ","
<< "tb2." << filedNames.dFromNodHeadloss<< ","
<< "tb2." << filedNames.dToNodHeadloss<< ","
<< "tb2." << filedNames.dLocalHeadloss<< ")" << " from "
<< "tb2." << filedNames.dLocalHeadloss<<","
<<" tb2."<< filedNames.dQuality<< ")"
<< " from "
<< PIPERESULTTABLE<< " AS tb2 where tb1."
<< filedNames.szNo<< "= tb2."
<< filedNames.szNo<< " AND tb2."
......@@ -324,9 +321,9 @@ bool CivPgConn::execSql(StrQuote sql)
if (sql.empty())
return false;
if (!open())
return false;
if (!isValid())
open();
mResult = PQexec(mConn, sql.c_str());
char* error = PQresultErrorMessage(mResult);
std::string errorStr = error;
......@@ -483,6 +480,7 @@ bool CivPgConn::getTank(CivTank& tank)
bool CivPgConn::getValve(CivValve& valve)
{
CivValveTableTemp::ValveTable vaveTable;
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
......@@ -532,6 +530,7 @@ bool CivPgConn::getValve(CivValve& valve)
bool CivPgConn::getPumps(CivPumps& pump)
{
CivPumpTableTemp::PumpTable pmTable;
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
......@@ -946,7 +945,6 @@ bool CivPgConn::getValuesFromTableByCondition(
void CivPgConn::checkHyDrNetTable()
{
// 创建曲线表
CivCurveTableTemp temp;
if (!tableExist(temp.name()))
......
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