Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hydraulicModel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘乐
hydraulicModel
Commits
3dbc7070
Commit
3dbc7070
authored
Jul 07, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1, 新街口
parent
7a7924a1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
296 additions
and
117 deletions
+296
-117
main.cpp
funcDemo/main.cpp
+2
-11
CivBuilder.cpp
pandaAnalysis/CivBuilder.cpp
+18
-32
CivHydrCalc.cpp
pandaAnalysis/CivHydrCalc.cpp
+15
-32
CivHydrFuncInter.cpp
pandaAnalysis/CivHydrFuncInter.cpp
+61
-4
CivHydrFuncInter.h
pandaAnalysis/CivHydrFuncInter.h
+7
-2
CivHydrSimulation.cpp
pandaAnalysis/CivHydrSimulation.cpp
+0
-0
CivHydrSimulation.h
pandaAnalysis/CivHydrSimulation.h
+63
-0
CivInp.cpp
pandaAnalysis/CivInp.cpp
+1
-1
CivInpDirector.cpp
pandaAnalysis/CivInpDirector.cpp
+2
-2
CivNewInp.cpp
pandaAnalysis/CivNewInp.cpp
+19
-2
CivSimulResultCache.cpp
pandaAnalysis/CivSimulResultCache.cpp
+32
-0
CivSimulResultCache.h
pandaAnalysis/CivSimulResultCache.h
+1
-1
pandaAnalysis.vcxproj
pandaAnalysis/pandaAnalysis.vcxproj
+2
-0
pandaAnalysis.vcxproj.filters
pandaAnalysis/pandaAnalysis.vcxproj.filters
+7
-0
CivDbConn.cpp
pandaDbManager/CivDbConn.cpp
+1
-0
CivDbConn.h
pandaDbManager/CivDbConn.h
+3
-3
CivPgConn.cpp
pandaDbManager/CivPgConn.cpp
+58
-23
CivPgConn.h
pandaDbManager/CivPgConn.h
+2
-2
CivTableTemp.h
pandaDbManager/CivTableTemp.h
+2
-2
水力模型.docx
建模文档/水力模型.docx
+0
-0
No files found.
funcDemo/main.cpp
View file @
3dbc7070
...
@@ -14,17 +14,8 @@ int main(int argc, char* argv[])
...
@@ -14,17 +14,8 @@ int main(int argc, char* argv[])
const
char
*
uri
=
"host=192.168.19.100 port=5432 dbname=JinXian user=postgres password=admin"
;
const
char
*
uri
=
"host=192.168.19.100 port=5432 dbname=JinXian user=postgres password=admin"
;
char
*
findUri
=
const_cast
<
char
*>
(
uri
);
char
*
findUri
=
const_cast
<
char
*>
(
uri
);
int
succ
=
hdyrSimulation
(
findUri
);
char
net
[
128
];
std
::
cout
<<
succ
<<
std
::
endl
;
char
flag
[
128
];
const
char
*
file
=
"test.inp"
;
const
char
netName
[
128
]
=
"水力模型管网"
;
strcpy_s
(
net
,
"水力模型管网"
);
strcpy_s
(
flag
,
"QUALITY"
);
bool
msg
=
simulation
(
findUri
,
net
,
flag
);
std
::
cout
<<
msg
<<
std
::
endl
;
/*const char* date = "2020-07-02";
/*const char* date = "2020-07-02";
char* dates = const_cast<char*>(date);
char* dates = const_cast<char*>(date);
...
...
pandaAnalysis/CivBuilder.cpp
View file @
3dbc7070
...
@@ -24,12 +24,14 @@ CivInpBuilder::CivInpBuilder()
...
@@ -24,12 +24,14 @@ CivInpBuilder::CivInpBuilder()
:
mDbConn
(
nullptr
)
:
mDbConn
(
nullptr
)
{
{
mNewInp
=
new
CivNewInp
();
mNewInp
=
new
CivNewInp
();
mNewInp
->
setTtitle
(
""
);
}
}
CivInpBuilder
::
CivInpBuilder
(
CivDbConn
*
dbConn
)
CivInpBuilder
::
CivInpBuilder
(
CivDbConn
*
dbConn
)
:
mDbConn
(
dbConn
)
:
mDbConn
(
dbConn
)
{
{
mNewInp
=
new
CivNewInp
();
mNewInp
=
new
CivNewInp
();
mNewInp
->
setTtitle
(
""
);
}
}
CivInpBuilder
::~
CivInpBuilder
()
CivInpBuilder
::~
CivInpBuilder
()
...
@@ -52,8 +54,7 @@ void CivInpBuilder::buildNode()
...
@@ -52,8 +54,7 @@ void CivInpBuilder::buildNode()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivNode
node
;
CivNode
node
;
bool
succ
=
mDbConn
->
getNode
(
node
);
if
(
!
mDbConn
->
getNode
(
node
))
if
(
succ
)
return
;
return
;
mNewInp
->
setNode
(
node
);
mNewInp
->
setNode
(
node
);
...
@@ -64,8 +65,7 @@ void CivInpBuilder::buildPipe()
...
@@ -64,8 +65,7 @@ void CivInpBuilder::buildPipe()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivPipe
pipe
;
CivPipe
pipe
;
bool
succ
=
mDbConn
->
getPipe
(
pipe
);
if
(
!
mDbConn
->
getPipe
(
pipe
))
if
(
succ
)
return
;
return
;
mNewInp
->
setPipes
(
pipe
);
mNewInp
->
setPipes
(
pipe
);
...
@@ -76,8 +76,7 @@ void CivInpBuilder::buildTank()
...
@@ -76,8 +76,7 @@ void CivInpBuilder::buildTank()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivTank
tank
;
CivTank
tank
;
bool
succ
=
mDbConn
->
getTank
(
tank
);
if
(
!
mDbConn
->
getTank
(
tank
))
if
(
succ
)
return
;
return
;
mNewInp
->
setTank
(
tank
);
mNewInp
->
setTank
(
tank
);
...
@@ -88,8 +87,7 @@ void CivInpBuilder::buildVavle()
...
@@ -88,8 +87,7 @@ void CivInpBuilder::buildVavle()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivValve
valve
;
CivValve
valve
;
bool
succ
=
mDbConn
->
getValve
(
valve
);
if
(
!
mDbConn
->
getValve
(
valve
))
if
(
succ
)
return
;
return
;
mNewInp
->
setValves
(
valve
);
mNewInp
->
setValves
(
valve
);
...
@@ -100,8 +98,7 @@ void CivInpBuilder::buildPump()
...
@@ -100,8 +98,7 @@ void CivInpBuilder::buildPump()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivPumps
valve
;
CivPumps
valve
;
bool
succ
=
mDbConn
->
getPumps
(
valve
);
if
(
!
mDbConn
->
getPumps
(
valve
))
if
(
succ
)
return
;
return
;
mNewInp
->
setPumps
(
valve
);
mNewInp
->
setPumps
(
valve
);
...
@@ -112,8 +109,7 @@ void CivInpBuilder::buildReservoir()
...
@@ -112,8 +109,7 @@ void CivInpBuilder::buildReservoir()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivReservoirs
res
;
CivReservoirs
res
;
bool
succ
=
mDbConn
->
getReservoirs
(
res
);
if
(
!
mDbConn
->
getReservoirs
(
res
))
if
(
succ
)
return
;
return
;
mNewInp
->
setReservoirs
(
res
);
mNewInp
->
setReservoirs
(
res
);
...
@@ -124,8 +120,7 @@ void CivInpBuilder::buildEmitter()
...
@@ -124,8 +120,7 @@ void CivInpBuilder::buildEmitter()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivEmitters
emmiters
;
CivEmitters
emmiters
;
bool
succ
=
mDbConn
->
getEmitters
(
emmiters
);
if
(
!
mDbConn
->
getEmitters
(
emmiters
))
if
(
succ
)
return
;
return
;
mNewInp
->
setEmitters
(
emmiters
);
mNewInp
->
setEmitters
(
emmiters
);
...
@@ -168,8 +163,7 @@ void CivInpBuilder::buildCoordnates()
...
@@ -168,8 +163,7 @@ void CivInpBuilder::buildCoordnates()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivCoordinates
coords
;
CivCoordinates
coords
;
bool
succ
=
mDbConn
->
getCoordinates
(
coords
);
if
(
!
mDbConn
->
getCoordinates
(
coords
))
if
(
succ
)
return
;
return
;
mNewInp
->
setCoordnates
(
coords
);
mNewInp
->
setCoordnates
(
coords
);
...
@@ -185,8 +179,7 @@ void CivInpBuilder::buildLabels()
...
@@ -185,8 +179,7 @@ void CivInpBuilder::buildLabels()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivLabels
labels
;
CivLabels
labels
;
bool
succ
=
mDbConn
->
getLabels
(
labels
);
if
(
!
mDbConn
->
getLabels
(
labels
))
if
(
succ
)
return
;
return
;
mNewInp
->
setLabels
(
labels
);
mNewInp
->
setLabels
(
labels
);
...
@@ -197,8 +190,7 @@ void CivInpBuilder::buildTags()
...
@@ -197,8 +190,7 @@ void CivInpBuilder::buildTags()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivTags
tag
;
CivTags
tag
;
bool
succ
=
mDbConn
->
getTags
(
tag
);
if
(
!
mDbConn
->
getTags
(
tag
))
if
(
succ
)
return
;
return
;
mNewInp
->
setTags
(
tag
);
mNewInp
->
setTags
(
tag
);
...
@@ -214,8 +206,7 @@ void CivInpBuilder::buildQuality()
...
@@ -214,8 +206,7 @@ void CivInpBuilder::buildQuality()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivQuality
quality
;
CivQuality
quality
;
bool
succ
=
mDbConn
->
getQuality
(
quality
);
if
(
!
mDbConn
->
getQuality
(
quality
))
if
(
succ
)
return
;
return
;
mNewInp
->
setQuality
(
quality
);
mNewInp
->
setQuality
(
quality
);
...
@@ -226,8 +217,7 @@ void CivInpBuilder::buildSources()
...
@@ -226,8 +217,7 @@ void CivInpBuilder::buildSources()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivSources
sources
;
CivSources
sources
;
bool
succ
=
mDbConn
->
getSources
(
sources
);
if
(
!
mDbConn
->
getSources
(
sources
))
if
(
succ
)
return
;
return
;
mNewInp
->
setSources
(
sources
);
mNewInp
->
setSources
(
sources
);
...
@@ -238,8 +228,7 @@ void CivInpBuilder::buildMixing()
...
@@ -238,8 +228,7 @@ void CivInpBuilder::buildMixing()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivMixing
mixing
;
CivMixing
mixing
;
bool
succ
=
mDbConn
->
getMixing
(
mixing
);
if
(
!
mDbConn
->
getMixing
(
mixing
))
if
(
succ
)
return
;
return
;
mNewInp
->
setMixing
(
mixing
);
mNewInp
->
setMixing
(
mixing
);
...
@@ -250,8 +239,7 @@ void CivInpBuilder::buildCurves()
...
@@ -250,8 +239,7 @@ void CivInpBuilder::buildCurves()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivCurves
curves
;
CivCurves
curves
;
bool
succ
=
mDbConn
->
getCurves
(
curves
);
if
(
!
mDbConn
->
getCurves
(
curves
))
if
(
succ
)
return
;
return
;
mNewInp
->
setCurves
(
curves
);
mNewInp
->
setCurves
(
curves
);
...
@@ -262,8 +250,7 @@ void CivInpBuilder::buildStatus()
...
@@ -262,8 +250,7 @@ void CivInpBuilder::buildStatus()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivStatus
status
;
CivStatus
status
;
bool
succ
=
mDbConn
->
getStatus
(
status
);
if
(
!
mDbConn
->
getStatus
(
status
))
if
(
succ
)
return
;
return
;
mNewInp
->
setStatus
(
status
);
mNewInp
->
setStatus
(
status
);
...
@@ -284,8 +271,7 @@ void CivInpBuilder::buildDemands()
...
@@ -284,8 +271,7 @@ void CivInpBuilder::buildDemands()
ASSERT
(
mDbConn
,
mNewInp
)
ASSERT
(
mDbConn
,
mNewInp
)
CivDemands
mand
;
CivDemands
mand
;
bool
succ
=
mDbConn
->
getDemands
(
mand
);
if
(
!
mDbConn
->
getDemands
(
mand
))
if
(
succ
)
return
;
return
;
mNewInp
->
setDemands
(
mand
);
mNewInp
->
setDemands
(
mand
);
...
...
pandaAnalysis/CivHydrCalc.cpp
View file @
3dbc7070
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
#include <time.h>
#include <time.h>
#include "CivBuilder.h"
#include "CivBuilder.h"
#include "CivInpDirector.h"
#include "CivInpDirector.h"
#include"CivDbConn.h"
#include
"CivDbConn.h"
#include"CivPgConn.h"
#include
"CivPgConn.h"
#include <iostream>
#include <iostream>
CivHydrCalc
::
CivHydrCalc
(
char
*
uri
,
std
::
string
netName
)
CivHydrCalc
::
CivHydrCalc
(
char
*
uri
,
std
::
string
netName
)
...
@@ -229,36 +229,18 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
...
@@ -229,36 +229,18 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
bool
CivHydrCalc
::
exportInp
(
char
*
fileName
)
bool
CivHydrCalc
::
exportInp
(
char
*
fileName
)
{
{
//
//
1 ,获取管网组件
//1 ,获取管网组件
//
if (!mDbConn)
if
(
!
mDbConn
)
//
return false;
return
false
;
//if (!mDbConn->open())
if
(
!
mDbConn
->
open
())
// return false;
CivBuilder
*
builder
=
new
CivInpBuilder
();
builder
->
registDb
(
mPgConn
);
CivInpDirector
director
;
director
.
setBuilder
(
builder
);
director
.
create
();
CivNewInp
*
newInp
=
builder
->
getNewInp
();
if
(
!
newInp
->
writeToFile
(
fileName
))
{
delete
builder
;
delete
newInp
;
return
false
;
return
false
;
}
///*bool pattern = mDbConn->createTable(*CivPatternTableTemp());
delete
builder
;
//bool cii = mDbConn->createTable(OPTIONTTABLE, "public", CivTableTemp::PARAMETER_TABLE);
delete
newInp
;
//bool curve = mDbConn->createTable(CURVETABLE, "public", CivTableTemp::CURVE_TABLE);
return
true
;
//bool node = mDbConn->createTable(NODERESULTTABLE, "public", CivTableTemp::NODE_TABLE);
/*bool pattern = mDbConn->createTable(*CivPatternTableTemp());
//bool link = mDbConn->createTable(PIPERESULTTABLE, "public", CivTableTemp::PIPE_TABLE);*/
bool cii = mDbConn->createTable(OPTIONTTABLE, "public", CivTableTemp::PARAMETER_TABLE);
bool curve = mDbConn->createTable(CURVETABLE, "public", CivTableTemp::CURVE_TABLE);
bool node = mDbConn->createTable(NODERESULTTABLE, "public", CivTableTemp::NODE_TABLE);
bool link = mDbConn->createTable(PIPERESULTTABLE, "public", CivTableTemp::PIPE_TABLE);*/
// 获取表格
// 获取表格
Tables
tables
=
mDbConn
->
getTables
(
mNetname
);
Tables
tables
=
mDbConn
->
getTables
(
mNetname
);
...
@@ -312,7 +294,7 @@ bool CivHydrCalc::exportInp(char* fileName)
...
@@ -312,7 +294,7 @@ bool CivHydrCalc::exportInp(char* fileName)
civInp
.
setTimeStart
(
"REPORT"
,
1
);
civInp
.
setTimeStart
(
"REPORT"
,
1
);
civInp
.
writeToFile
(
fileName
);
civInp
.
writeToFile
(
fileName
);
return
tru
e
;
return
fals
e
;
}
}
void
CivHydrCalc
::
assemble
(
const
std
::
string
&
table
,
CivInp
&
inp
)
void
CivHydrCalc
::
assemble
(
const
std
::
string
&
table
,
CivInp
&
inp
)
...
@@ -776,4 +758,4 @@ void CivHydrCalc::getLinkQuality(short time)
...
@@ -776,4 +758,4 @@ void CivHydrCalc::getLinkQuality(short time)
}
}
free
(
typeCode
);
free
(
typeCode
);
free
(
quality
);
free
(
quality
);
}
}
\ No newline at end of file
pandaAnalysis/CivHydrFuncInter.cpp
View file @
3dbc7070
...
@@ -39,10 +39,10 @@ bool DLLEXPORT hdySimulation(char* uri, char* netName)
...
@@ -39,10 +39,10 @@ bool DLLEXPORT hdySimulation(char* uri, char* netName)
return
true
;
return
true
;
}
}
bool
DLLEXPORT
qualitySimulation
(
char
*
uri
,
char
*
netName
,
char
*
type
)
//
bool DLLEXPORT qualitySimulation(char* uri, char* netName, char* type)
{
//
{
return
true
;
//
return true;
}
//
}
bool
DLLEXPORT
qualityTrackingSimulation
(
char
*
uri
,
char
*
netName
,
char
*
nodeSn
,
char
*
time
)
bool
DLLEXPORT
qualityTrackingSimulation
(
char
*
uri
,
char
*
netName
,
char
*
nodeSn
,
char
*
time
)
{
{
...
@@ -61,5 +61,61 @@ bool DLLEXPORT getDataByInterval(char* uri, char* date, char* interval)
...
@@ -61,5 +61,61 @@ bool DLLEXPORT getDataByInterval(char* uri, char* date, char* interval)
std
::
cout
<<
flag
<<
std
::
endl
;
std
::
cout
<<
flag
<<
std
::
endl
;
//flag = calc->getDataByInterval(date, interval);
//flag = calc->getDataByInterval(date, interval);
delete
calc
;
delete
calc
;
return
flag
;
}
#include "CivPgConn.h"
#include "CivHydrSimulation.h"
int
DLLEXPORT
hdyrSimulation
(
char
*
uri
)
{
// 创建数据库连接
CivDbConn
*
pgConn
=
new
CivPgConn
(
uri
);
// 模拟计算对象
CivHydrSimulation
*
mHyDr
=
new
CivHydrSimulation
();
mHyDr
->
registDb
(
pgConn
);
//开始模拟
int
flag
=
mHyDr
->
hdyrSimulation
();
/* delete mHyDr;
delete pgConn;*/
return
flag
;
}
int
DLLEXPORT
qualitySimulation
(
char
*
uri
)
{
// 创建数据库连接
CivPgConn
*
pgConn
=
new
CivPgConn
(
uri
);
// 模拟计算对象
CivHydrSimulation
*
mHyDr
=
new
CivHydrSimulation
();
mHyDr
->
registDb
(
pgConn
);
//开始模拟
int
flag
=
mHyDr
->
qualitySimulation
();
delete
pgConn
;
delete
mHyDr
;
return
flag
;
}
int
DLLEXPORT
trackingSimulation
(
char
*
uri
,
char
*
sN
)
{
// 创建数据库连接
CivPgConn
*
pgConn
=
new
CivPgConn
(
uri
);
// 模拟计算对象
CivHydrSimulation
*
mHyDr
=
new
CivHydrSimulation
();
mHyDr
->
registDb
(
pgConn
);
//开始模拟
int
flag
=
mHyDr
->
trackingSimulation
(
sN
);
delete
pgConn
;
delete
mHyDr
;
return
flag
;
return
flag
;
}
}
\ No newline at end of file
pandaAnalysis/CivHydrFuncInter.h
View file @
3dbc7070
...
@@ -5,6 +5,11 @@
...
@@ -5,6 +5,11 @@
#if defined(__cplusplus)
#if defined(__cplusplus)
extern
"C"
{
extern
"C"
{
#endif
#endif
int
DLLEXPORT
hdyrSimulation
(
char
*
uri
);
int
DLLEXPORT
qualitySimulation
(
char
*
uri
);
int
DLLEXPORT
trackingSimulation
(
char
*
uri
,
char
*
sN
);
/**
/**
*@brief 模拟计算
*@brief 模拟计算
*@uri: 管网数据库连接
*@uri: 管网数据库连接
...
@@ -12,7 +17,7 @@ extern "C" {
...
@@ -12,7 +17,7 @@ extern "C" {
*@flag: 标记
*@flag: 标记
*/
*/
bool
DLLEXPORT
simulation
(
char
*
uri
,
char
*
netName
,
char
*
flag
);
bool
DLLEXPORT
simulation
(
char
*
uri
,
char
*
netName
,
char
*
flag
);
/**
/**
*@brief 水力模拟计算
*@brief 水力模拟计算
*@uri: 管网数据库连接
*@uri: 管网数据库连接
...
@@ -26,7 +31,7 @@ extern "C" {
...
@@ -26,7 +31,7 @@ extern "C" {
*@netName: 管网名
*@netName: 管网名
*@type: 水质模拟类型选择,水龄,追踪,化学成分
*@type: 水质模拟类型选择,水龄,追踪,化学成分
*/
*/
bool
DLLEXPORT
qualitySimulation
(
char
*
uri
,
char
*
netName
,
char
*
type
);
//
bool DLLEXPORT qualitySimulation(char* uri, char* netName, char* type);
/**
/**
*@brief 水质追踪模拟计算
*@brief 水质追踪模拟计算
...
...
pandaAnalysis/CivHydrSimulation.cpp
0 → 100644
View file @
3dbc7070
This diff is collapsed.
Click to expand it.
pandaAnalysis/CivHydrSimulation.h
0 → 100644
View file @
3dbc7070
#pragma once
#include "CivSimulResultCache.h"
class
CivDbConn
;
/**
水力模拟计算类
*/
class
CivHydrSimulation
{
public
:
explicit
CivHydrSimulation
();
explicit
CivHydrSimulation
(
CivDbConn
*
dbConn
);
~
CivHydrSimulation
();
/**
*@biref 注册数据库
*/
void
registDb
(
CivDbConn
*
dbConn
);
/**
*@brief 水力模拟
*/
int
hdyrSimulation
();
/**
*@brief 水质模拟,水龄,化学物质
*/
int
qualitySimulation
();
/**
*@brief 追踪分析,本质仍然式水质分析
*@snNode:追踪的节点号
*/
int
trackingSimulation
(
char
*
snNode
);
/**
*@导出inp文件
*/
bool
convertInp
();
inline
char
*
getInpFile
();
inline
void
setInpFile
(
const
std
::
string
&
inpFile
);
inline
char
*
getRptFile
();
inline
void
setRptFile
(
const
std
::
string
&
rptFile
);
inline
char
*
getBinFile
();
inline
void
setBinFile
(
const
std
::
string
&
binFile
);
private
:
void
getNodeResult
(
short
time
);
void
getLinkResult
(
short
time
);
void
getNodeQuality
(
short
time
);
void
getLinkQuality
(
short
time
);
private
:
CivDbConn
*
mDbConn
;
CivSimulResultCache
mResultCache
;
// 存储模拟结果缓存类
std
::
string
mInpFile
;
// inp文件名
std
::
string
mRptFile
;
// 报告文件名
std
::
string
mBinFile
;
// 二进制文件名
};
pandaAnalysis/CivInp.cpp
View file @
3dbc7070
...
@@ -412,7 +412,7 @@ void CivInp::writeString(const std::string& s)
...
@@ -412,7 +412,7 @@ void CivInp::writeString(const std::string& s)
void
CivInp
::
setPattern
(
StrQuote
pId
,
std
::
vector
<
Str
>
pValue
)
void
CivInp
::
setPattern
(
StrQuote
pId
,
std
::
vector
<
Str
>
pValue
)
{
{
}
}
void
CivInp
::
setOption
(
Options
options
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
others
)
void
CivInp
::
setOption
(
Options
options
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
others
)
...
...
pandaAnalysis/CivInpDirector.cpp
View file @
3dbc7070
...
@@ -12,10 +12,10 @@ void CivInpDirector::create()
...
@@ -12,10 +12,10 @@ void CivInpDirector::create()
if
(
mBuilder
==
NULL
)
if
(
mBuilder
==
NULL
)
return
;
return
;
mBuilder
->
buildNode
();
mBuilder
->
buildPipe
();
mBuilder
->
buildTank
();
mBuilder
->
buildTank
();
mBuilder
->
buildReservoir
();
mBuilder
->
buildReservoir
();
mBuilder
->
buildNode
();
mBuilder
->
buildPipe
();
mBuilder
->
buildPump
();
mBuilder
->
buildPump
();
mBuilder
->
buildVavle
();
mBuilder
->
buildVavle
();
mBuilder
->
buildEmitter
();
mBuilder
->
buildEmitter
();
...
...
pandaAnalysis/CivNewInp.cpp
View file @
3dbc7070
...
@@ -70,6 +70,7 @@ void CivNewInp::setNode(const CivNode& node)
...
@@ -70,6 +70,7 @@ void CivNewInp::setNode(const CivNode& node)
writeStringFormat
(
nodeTable
.
Demand
);
writeStringFormat
(
nodeTable
.
Demand
);
writeString
(
nodeTable
.
PatternId
);
writeString
(
nodeTable
.
PatternId
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setPipes
(
const
CivPipe
&
pipes
)
void
CivNewInp
::
setPipes
(
const
CivPipe
&
pipes
)
...
@@ -91,6 +92,7 @@ void CivNewInp::setPipes(const CivPipe& pipes)
...
@@ -91,6 +92,7 @@ void CivNewInp::setPipes(const CivPipe& pipes)
writeStringFormat
(
pipesTable
.
MinorLoss
);
writeStringFormat
(
pipesTable
.
MinorLoss
);
writeString
(
pipesTable
.
Status
);
writeString
(
pipesTable
.
Status
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setTank
(
const
CivTank
&
tank
)
void
CivNewInp
::
setTank
(
const
CivTank
&
tank
)
...
@@ -112,6 +114,7 @@ void CivNewInp::setTank(const CivTank& tank)
...
@@ -112,6 +114,7 @@ void CivNewInp::setTank(const CivTank& tank)
writeStringFormat
(
table
.
MinVol
);
writeStringFormat
(
table
.
MinVol
);
writeString
(
table
.
VolCurve
);
writeString
(
table
.
VolCurve
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setValves
(
const
CivValve
&
valve
)
void
CivNewInp
::
setValves
(
const
CivValve
&
valve
)
...
@@ -132,6 +135,7 @@ void CivNewInp::setValves(const CivValve& valve)
...
@@ -132,6 +135,7 @@ void CivNewInp::setValves(const CivValve& valve)
writeStringFormat
(
table
.
Setting
);
writeStringFormat
(
table
.
Setting
);
writeString
(
table
.
MinorLoss
);
writeString
(
table
.
MinorLoss
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setPumps
(
const
CivPumps
&
pumps
)
void
CivNewInp
::
setPumps
(
const
CivPumps
&
pumps
)
...
@@ -149,6 +153,7 @@ void CivNewInp::setPumps(const CivPumps& pumps)
...
@@ -149,6 +153,7 @@ void CivNewInp::setPumps(const CivPumps& pumps)
writeStringFormat
(
table
.
Node2
);
writeStringFormat
(
table
.
Node2
);
writeString
(
table
.
Parameters
);
writeString
(
table
.
Parameters
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setEmitters
(
const
CivEmitters
&
mitters
)
void
CivNewInp
::
setEmitters
(
const
CivEmitters
&
mitters
)
...
@@ -165,6 +170,7 @@ void CivNewInp::setEmitters(const CivEmitters& mitters)
...
@@ -165,6 +170,7 @@ void CivNewInp::setEmitters(const CivEmitters& mitters)
writeStringFormat
(
table
.
ID
);
writeStringFormat
(
table
.
ID
);
writeString
(
table
.
coeff
);
writeString
(
table
.
coeff
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setReservoirs
(
const
CivReservoirs
&
res
)
void
CivNewInp
::
setReservoirs
(
const
CivReservoirs
&
res
)
...
@@ -183,6 +189,7 @@ void CivNewInp::setReservoirs(const CivReservoirs& res)
...
@@ -183,6 +189,7 @@ void CivNewInp::setReservoirs(const CivReservoirs& res)
writeStringFormat
(
table
.
Head
);
writeStringFormat
(
table
.
Head
);
writeString
(
table
.
Pattern
);
writeString
(
table
.
Pattern
);
}
}
writeString
(
""
);
}
}
// 系统运行
// 系统运行
...
@@ -202,7 +209,7 @@ void CivNewInp::setCurves(const CivCurves& cureves)
...
@@ -202,7 +209,7 @@ void CivNewInp::setCurves(const CivCurves& cureves)
writeStringFormat
(
table
.
XCoord
);
writeStringFormat
(
table
.
XCoord
);
writeString
(
table
.
YCoord
);
writeString
(
table
.
YCoord
);
}
}
writeString
(
""
);
}
}
...
@@ -221,6 +228,7 @@ void CivNewInp::setPatterns(const CivPatterns& patterns)
...
@@ -221,6 +228,7 @@ void CivNewInp::setPatterns(const CivPatterns& patterns)
writeStringFormat
(
table
.
name
);
writeStringFormat
(
table
.
name
);
writeString
(
table
.
val
);
writeString
(
table
.
val
);
}
}
writeString
(
""
);
}
}
...
@@ -238,6 +246,7 @@ void CivNewInp::setStatus(const CivStatus& status)
...
@@ -238,6 +246,7 @@ void CivNewInp::setStatus(const CivStatus& status)
writeStringFormat
(
table
.
ID
);
writeStringFormat
(
table
.
ID
);
writeString
(
table
.
Setting
);
writeString
(
table
.
Setting
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setControls
(
const
std
::
string
&
control
)
void
CivNewInp
::
setControls
(
const
std
::
string
&
control
)
...
@@ -269,6 +278,7 @@ void CivNewInp::setDemands(const CivDemands& demands)
...
@@ -269,6 +278,7 @@ void CivNewInp::setDemands(const CivDemands& demands)
writeStringFormat
(
table
.
PatternId
);
writeStringFormat
(
table
.
PatternId
);
writeString
(
table
.
DemandType
);
writeString
(
table
.
DemandType
);
}
}
writeString
(
""
);
}
}
// 水质
// 水质
...
@@ -284,8 +294,9 @@ void CivNewInp::setQuality(const CivQuality& quality)
...
@@ -284,8 +294,9 @@ void CivNewInp::setQuality(const CivQuality& quality)
{
{
CivQuality
::
Table
table
=
*
iter
;
CivQuality
::
Table
table
=
*
iter
;
writeStringFormat
(
table
.
ID
);
writeStringFormat
(
table
.
ID
);
writeString
Format
(
table
.
InitQuality
);
writeString
(
table
.
InitQuality
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setSources
(
const
CivSources
&
sources
)
void
CivNewInp
::
setSources
(
const
CivSources
&
sources
)
...
@@ -305,6 +316,7 @@ void CivNewInp::setSources(const CivSources& sources)
...
@@ -305,6 +316,7 @@ void CivNewInp::setSources(const CivSources& sources)
writeStringFormat
(
table
.
Quality
);
writeStringFormat
(
table
.
Quality
);
writeString
(
table
.
Pattern
);
writeString
(
table
.
Pattern
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setMixing
(
const
CivMixing
&
mixing
)
void
CivNewInp
::
setMixing
(
const
CivMixing
&
mixing
)
...
@@ -322,6 +334,7 @@ void CivNewInp::setMixing(const CivMixing& mixing)
...
@@ -322,6 +334,7 @@ void CivNewInp::setMixing(const CivMixing& mixing)
writeStringFormat
(
table
.
hyModel
);
writeStringFormat
(
table
.
hyModel
);
writeString
(
table
.
volume
);
writeString
(
table
.
volume
);
}
}
writeString
(
""
);
}
}
// 选项和报表
// 选项和报表
...
@@ -340,6 +353,7 @@ void CivNewInp::setParamter(const CivParameter& params,const std::string& type)
...
@@ -340,6 +353,7 @@ void CivNewInp::setParamter(const CivParameter& params,const std::string& type)
writeStringFormat
(
table
.
name
);
writeStringFormat
(
table
.
name
);
writeString
(
table
.
val
);
writeString
(
table
.
val
);
}
}
writeString
(
""
);
}
}
//管网地图/标签
//管网地图/标签
...
@@ -359,6 +373,7 @@ void CivNewInp::setCoordnates(const CivCoordinates& coords)
...
@@ -359,6 +373,7 @@ void CivNewInp::setCoordnates(const CivCoordinates& coords)
writeStringFormat
(
table
.
XCoord
);
writeStringFormat
(
table
.
XCoord
);
writeString
(
table
.
YCoord
);
writeString
(
table
.
YCoord
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setVertices
()
void
CivNewInp
::
setVertices
()
...
@@ -384,6 +399,7 @@ void CivNewInp::setLabels(const CivLabels& labels)
...
@@ -384,6 +399,7 @@ void CivNewInp::setLabels(const CivLabels& labels)
writeStringFormat
(
table
.
Label
);
writeStringFormat
(
table
.
Label
);
writeStringFormat
(
table
.
ID
);
writeStringFormat
(
table
.
ID
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
setBackDrop
()
void
CivNewInp
::
setBackDrop
()
...
@@ -408,6 +424,7 @@ void CivNewInp::setTags(const CivTags& tags)
...
@@ -408,6 +424,7 @@ void CivNewInp::setTags(const CivTags& tags)
writeStringFormat
(
table
.
Id
);
writeStringFormat
(
table
.
Id
);
writeString
(
table
.
Label
);
writeString
(
table
.
Label
);
}
}
writeString
(
""
);
}
}
void
CivNewInp
::
writeString
(
const
std
::
string
&
s
)
void
CivNewInp
::
writeString
(
const
std
::
string
&
s
)
...
...
pandaAnalysis/CivSimulResultCache.cpp
View file @
3dbc7070
...
@@ -35,6 +35,38 @@ void CivSimulResultCache::addLinkItems(const LinkResultItem& linkItem)
...
@@ -35,6 +35,38 @@ void CivSimulResultCache::addLinkItems(const LinkResultItem& linkItem)
mLinkItemsMap
[
linkItem
.
dInterval
][
linkItem
.
szNo
]
=
linkItem
;
mLinkItemsMap
[
linkItem
.
dInterval
][
linkItem
.
szNo
]
=
linkItem
;
}
}
bool
CivSimulResultCache
::
updateToDb
(
CivDbConn
*
dbConn
)
{
CivSysLog
::
getInstance
()
->
error
(
"开始写入数据库"
,
"CivSimulResultCache"
,
__FUNCTION__
);
if
(
dbConn
==
nullptr
)
{
CivSysLog
::
getInstance
()
->
error
(
"dbConn == nullptr"
,
"CivSimulResultCache"
,
__FUNCTION__
);
return
false
;
}
for
(
auto
iter
=
mNodeItemsMap
.
begin
();
iter
!=
mNodeItemsMap
.
end
();
iter
++
)
{
NodeResultItems
nodeItems
=
iter
->
second
;
if
(
!
dbConn
->
updateNode
(
nodeItems
))
{
CivSysLog
::
getInstance
()
->
error
(
"存储节点数据失败"
,
"CivSimulResultCache"
,
__FUNCTION__
);
}
}
for
(
auto
iter
=
mLinkItemsMap
.
begin
();
iter
!=
mLinkItemsMap
.
end
();
iter
++
)
{
LinkResultItems
nodeItems
=
iter
->
second
;
if
(
!
dbConn
->
updateLink
(
nodeItems
))
{
CivSysLog
::
getInstance
()
->
error
(
"存储管段数据失败"
,
"CivSimulResultCache"
,
__FUNCTION__
);
}
}
CivSysLog
::
getInstance
()
->
error
(
"写入数据库完成"
,
"CivSimulResultCache"
,
__FUNCTION__
);
clear
();
return
true
;
}
bool
CivSimulResultCache
::
updateToDb
(
CivDbConnection
*
dbConn
)
bool
CivSimulResultCache
::
updateToDb
(
CivDbConnection
*
dbConn
)
{
{
CivSysLog
::
getInstance
()
->
error
(
"开始写入数据库"
,
"CivSimulResultCache"
,
__FUNCTION__
);
CivSysLog
::
getInstance
()
->
error
(
"开始写入数据库"
,
"CivSimulResultCache"
,
__FUNCTION__
);
...
...
pandaAnalysis/CivSimulResultCache.h
View file @
3dbc7070
...
@@ -50,7 +50,7 @@ public:
...
@@ -50,7 +50,7 @@ public:
*@dbConn:数据库连接对象
*@dbConn:数据库连接对象
*/
*/
bool
updateToDb
(
CivDbConnection
*
dbConn
);
bool
updateToDb
(
CivDbConnection
*
dbConn
);
bool
updateToDb
(
CivDbConn
*
dbConn
);
private
:
private
:
std
::
map
<
int
,
NodeResultItems
>
mNodeItemsMap
;
// 模拟
std
::
map
<
int
,
NodeResultItems
>
mNodeItemsMap
;
// 模拟
std
::
map
<
int
,
LinkResultItems
>
mLinkItemsMap
;
// 计算的
std
::
map
<
int
,
LinkResultItems
>
mLinkItemsMap
;
// 计算的
...
...
pandaAnalysis/pandaAnalysis.vcxproj
View file @
3dbc7070
...
@@ -155,6 +155,7 @@
...
@@ -155,6 +155,7 @@
<ClCompile
Include=
"..\pandaDbManager\CivCommonUtils.cpp"
/>
<ClCompile
Include=
"..\pandaDbManager\CivCommonUtils.cpp"
/>
<ClCompile
Include=
"CivHydrCalc.cpp"
/>
<ClCompile
Include=
"CivHydrCalc.cpp"
/>
<ClCompile
Include=
"CivHydrFuncInter.cpp"
/>
<ClCompile
Include=
"CivHydrFuncInter.cpp"
/>
<ClCompile
Include=
"CivHydrSimulation.cpp"
/>
<ClCompile
Include=
"CivInp.cpp"
/>
<ClCompile
Include=
"CivInp.cpp"
/>
<ClCompile
Include=
"CivBuilder.cpp"
/>
<ClCompile
Include=
"CivBuilder.cpp"
/>
<ClCompile
Include=
"CivInpDirector.cpp"
/>
<ClCompile
Include=
"CivInpDirector.cpp"
/>
...
@@ -164,6 +165,7 @@
...
@@ -164,6 +165,7 @@
<ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivHydrCalc.h"
/>
<ClInclude
Include=
"CivHydrCalc.h"
/>
<ClInclude
Include=
"CivHydrFuncInter.h"
/>
<ClInclude
Include=
"CivHydrFuncInter.h"
/>
<ClInclude
Include=
"CivHydrSimulation.h"
/>
<ClInclude
Include=
"CivInp.h"
/>
<ClInclude
Include=
"CivInp.h"
/>
<ClInclude
Include=
"CivBuilder.h"
/>
<ClInclude
Include=
"CivBuilder.h"
/>
<ClInclude
Include=
"CivInpDirector.h"
/>
<ClInclude
Include=
"CivInpDirector.h"
/>
...
...
pandaAnalysis/pandaAnalysis.vcxproj.filters
View file @
3dbc7070
...
@@ -39,6 +39,9 @@
...
@@ -39,6 +39,9 @@
<ClCompile
Include=
"CivSimulResultCache.cpp"
>
<ClCompile
Include=
"CivSimulResultCache.cpp"
>
<Filter>
源文件
</Filter>
<Filter>
源文件
</Filter>
</ClCompile>
</ClCompile>
<ClCompile
Include=
"CivHydrSimulation.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivHydrCalc.h"
>
<ClInclude
Include=
"CivHydrCalc.h"
>
...
@@ -65,5 +68,8 @@
...
@@ -65,5 +68,8 @@
<ClInclude
Include=
"CivMiddlewareQuery.h"
>
<ClInclude
Include=
"CivMiddlewareQuery.h"
>
<Filter>
头文件
</Filter>
<Filter>
头文件
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"CivHydrSimulation.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
pandaDbManager/CivDbConn.cpp
View file @
3dbc7070
...
@@ -8,6 +8,7 @@ CivDbConn::CivDbConn()
...
@@ -8,6 +8,7 @@ CivDbConn::CivDbConn()
CivDbConn
::~
CivDbConn
()
CivDbConn
::~
CivDbConn
()
{
{
}
}
bool
CivDbConn
::
isValid
()
const
bool
CivDbConn
::
isValid
()
const
...
...
pandaDbManager/CivDbConn.h
View file @
3dbc7070
...
@@ -62,7 +62,7 @@ public:
...
@@ -62,7 +62,7 @@ public:
bool
isValid
()
const
;
bool
isValid
()
const
;
private
:
/**
/**
*@brief 根据字段值条件删除数据
*@brief 根据字段值条件删除数据
*@table:表
*@table:表
...
@@ -88,12 +88,12 @@ private:
...
@@ -88,12 +88,12 @@ private:
// 获取当前执行错误信息
// 获取当前执行错误信息
Str
getLastError
()
const
;
Str
getLastError
()
const
;
private
:
/**
/**
*@brief 执行sql语句
*@brief 执行sql语句
*@sql: 需要执行的sql语句
*@sql: 需要执行的sql语句
*/
*/
virtual
bool
execSql
(
Str
sql
)
=
0
;
virtual
bool
execSql
(
Str
Quote
sql
)
=
0
;
protected
:
protected
:
bool
mIsOpen
=
false
;
// 数据库连接信息
bool
mIsOpen
=
false
;
// 数据库连接信息
...
...
pandaDbManager/CivPgConn.cpp
View file @
3dbc7070
#include "CivPgConn.h"
#include "CivPgConn.h"
#include "CivCommonUtils.h"
#include "CivCommonUtils.h"
#include<iostream>
CivPgConn
::
CivPgConn
(
char
*
uri
)
CivPgConn
::
CivPgConn
(
char
*
uri
)
:
mUri
(
uri
),
CivDbConn
()
:
mUri
(
uri
),
CivDbConn
()
...
@@ -10,7 +11,7 @@ CivPgConn::CivPgConn(char* uri)
...
@@ -10,7 +11,7 @@ CivPgConn::CivPgConn(char* uri)
CivPgConn
::~
CivPgConn
()
CivPgConn
::~
CivPgConn
()
{
{
close
();
}
}
bool
CivPgConn
::
open
()
bool
CivPgConn
::
open
()
...
@@ -28,14 +29,15 @@ bool CivPgConn::open()
...
@@ -28,14 +29,15 @@ bool CivPgConn::open()
void
CivPgConn
::
close
()
void
CivPgConn
::
close
()
{
{
if
(
mConn
!=
NULL
)
if
(
mConn
!=
NULL
)
{
PQfinish
(
mConn
);
PQfinish
(
mConn
);
}
mIsOpen
=
false
;
mIsOpen
=
false
;
}
}
bool
CivPgConn
::
tableExist
(
StrQuote
tableName
)
bool
CivPgConn
::
tableExist
(
StrQuote
tableName
)
{
{
char
sql
[
256
]
=
"select count(*) from pg_class where relname = '"
;
char
sql
[
256
]
=
"select count(*) from pg_class where relname = '"
;
strcat_s
(
sql
,
tableName
.
c_str
());
strcat_s
(
sql
,
tableName
.
c_str
());
strcat_s
(
sql
,
"'"
);
strcat_s
(
sql
,
"'"
);
...
@@ -50,7 +52,7 @@ bool CivPgConn::tableExist(StrQuote tableName)
...
@@ -50,7 +52,7 @@ bool CivPgConn::tableExist(StrQuote tableName)
return
number
>
0
?
true
:
false
;
return
number
>
0
?
true
:
false
;
}
}
bool
CivPgConn
::
execSql
(
Str
sql
)
bool
CivPgConn
::
execSql
(
Str
Quote
sql
)
{
{
if
(
sql
.
empty
())
if
(
sql
.
empty
())
return
false
;
return
false
;
...
@@ -65,6 +67,7 @@ bool CivPgConn::execSql(Str sql)
...
@@ -65,6 +67,7 @@ bool CivPgConn::execSql(Str sql)
if
(
!
errorStr
.
empty
())
if
(
!
errorStr
.
empty
())
{
{
mLastError
=
error
;
mLastError
=
error
;
std
::
cout
<<
errorStr
<<
std
::
endl
;
PQclear
(
mResult
);
PQclear
(
mResult
);
return
false
;
return
false
;
}
}
...
@@ -82,10 +85,12 @@ bool CivPgConn::getNode(CivNode& node)
...
@@ -82,10 +85,12 @@ bool CivPgConn::getNode(CivNode& node)
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
nodeTable
.
elev
.
c_str
());
strcat_s
(
sql
,
nodeTable
.
elev
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
nodeTable
.
pattern
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
nodeTable
.
demand
.
c_str
());
strcat_s
(
sql
,
nodeTable
.
demand
.
c_str
());
strcat_s
(
sql
,
" from 节点"
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
nodeTable
.
pattern
.
c_str
());
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
PIPENODE
.
c_str
());
strcat_s
(
sql
,
"
\"
"
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
if
(
!
execSql
(
utf8Sql
))
if
(
!
execSql
(
utf8Sql
))
...
@@ -174,7 +179,9 @@ bool CivPgConn::getTank(CivTank& tank)
...
@@ -174,7 +179,9 @@ bool CivPgConn::getTank(CivTank& tank)
strcat_s
(
sql
,
tankTable
.
capacity
.
c_str
());
strcat_s
(
sql
,
tankTable
.
capacity
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
tankTable
.
volCurve
.
c_str
());
strcat_s
(
sql
,
tankTable
.
volCurve
.
c_str
());
strcat_s
(
sql
,
" from 水池"
);
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
TANK
.
c_str
());
strcat_s
(
sql
,
"
\"
"
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
if
(
!
execSql
(
utf8Sql
))
if
(
!
execSql
(
utf8Sql
))
...
@@ -219,7 +226,9 @@ bool CivPgConn::getValve(CivValve& valve)
...
@@ -219,7 +226,9 @@ bool CivPgConn::getValve(CivValve& valve)
strcat_s
(
sql
,
vaveTable
.
setting
.
c_str
());
strcat_s
(
sql
,
vaveTable
.
setting
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
vaveTable
.
loss
.
c_str
());
strcat_s
(
sql
,
vaveTable
.
loss
.
c_str
());
strcat_s
(
sql
,
" from 阀门"
);
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
VALVE
.
c_str
());
strcat_s
(
sql
,
"
\"
"
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
if
(
!
execSql
(
utf8Sql
))
if
(
!
execSql
(
utf8Sql
))
...
@@ -257,7 +266,9 @@ bool CivPgConn::getPumps(CivPumps& pump)
...
@@ -257,7 +266,9 @@ bool CivPgConn::getPumps(CivPumps& pump)
strcat_s
(
sql
,
pmTable
.
endPoint
.
c_str
());
strcat_s
(
sql
,
pmTable
.
endPoint
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
pmTable
.
headCurve
.
c_str
());
strcat_s
(
sql
,
pmTable
.
headCurve
.
c_str
());
strcat_s
(
sql
,
" from 水泵"
);
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
PUMP
.
c_str
());
strcat_s
(
sql
,
"
\"
"
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
if
(
!
execSql
(
utf8Sql
))
if
(
!
execSql
(
utf8Sql
))
...
@@ -290,7 +301,9 @@ bool CivPgConn::getReservoirs(CivReservoirs& reservoirs)
...
@@ -290,7 +301,9 @@ bool CivPgConn::getReservoirs(CivReservoirs& reservoirs)
strcat_s
(
sql
,
restemTable
.
head
.
c_str
());
strcat_s
(
sql
,
restemTable
.
head
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
restemTable
.
headPattern
.
c_str
());
strcat_s
(
sql
,
restemTable
.
headPattern
.
c_str
());
strcat_s
(
sql
,
" from public.
\"
__pattern__
\"
"
);
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
RESIVOIR
.
c_str
());
strcat_s
(
sql
,
"
\"
"
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
if
(
!
execSql
(
utf8Sql
))
if
(
!
execSql
(
utf8Sql
))
...
@@ -320,16 +333,37 @@ bool CivPgConn::getCoordinates(CivCoordinates& coord)
...
@@ -320,16 +333,37 @@ bool CivPgConn::getCoordinates(CivCoordinates& coord)
{
{
CivJunctionTableTemp
::
JunctionTable
nodeTable
;
CivJunctionTableTemp
::
JunctionTable
nodeTable
;
char
sql
[
256
]
=
"select "
;
char
sql
[
512
]
=
"select "
;
strcat_s
(
sql
,
nodeTable
.
thePoint
.
c_str
());
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
thePoint
)
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
nodeTable
.
xCoord
.
c_str
());
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
xCoord
)
.
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
nodeTable
.
yCoord
.
c_str
());
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
yCoord
).
c_str
());
strcat_s
(
sql
,
" from 节点"
);
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
TransUTFCoding
(
PIPENODE
).
c_str
());
strcat_s
(
sql
,
"
\"
"
);
std
::
string
utf8Sql
=
TransUTFCoding
(
sql
);
strcat_s
(
sql
,
" UNION select "
);
if
(
!
execSql
(
utf8Sql
))
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
thePoint
).
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
xCoord
).
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
yCoord
).
c_str
());
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
TransUTFCoding
(
TANK
).
c_str
());
strcat_s
(
sql
,
"
\"
"
);
strcat_s
(
sql
,
" UNION select "
);
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
thePoint
).
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
xCoord
).
c_str
());
strcat_s
(
sql
,
","
);
strcat_s
(
sql
,
TransUTFCoding
(
nodeTable
.
yCoord
).
c_str
());
strcat_s
(
sql
,
" from public.
\"
"
);
strcat_s
(
sql
,
TransUTFCoding
(
RESIVOIR
).
c_str
());
strcat_s
(
sql
,
"
\"
"
);
if
(
!
execSql
(
sql
))
return
false
;
return
false
;
int
rows
=
PQntuples
(
mResult
);
int
rows
=
PQntuples
(
mResult
);
...
@@ -337,7 +371,7 @@ bool CivPgConn::getCoordinates(CivCoordinates& coord)
...
@@ -337,7 +371,7 @@ bool CivPgConn::getCoordinates(CivCoordinates& coord)
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
{
CivCoordinates
::
CoordTable
coordTable
;
CivCoordinates
::
CoordTable
coordTable
;
node
Table
.
ID
=
PQgetvalue
(
mResult
,
i
,
0
);
coord
Table
.
ID
=
PQgetvalue
(
mResult
,
i
,
0
);
coordTable
.
XCoord
=
PQgetvalue
(
mResult
,
i
,
1
);
coordTable
.
XCoord
=
PQgetvalue
(
mResult
,
i
,
1
);
coordTable
.
YCoord
=
PQgetvalue
(
mResult
,
i
,
2
);
coordTable
.
YCoord
=
PQgetvalue
(
mResult
,
i
,
2
);
...
@@ -421,11 +455,12 @@ bool CivPgConn::getPatterns(CivPatterns& patterns)
...
@@ -421,11 +455,12 @@ bool CivPgConn::getPatterns(CivPatterns& patterns)
int
columns
=
PQnfields
(
mResult
);
int
columns
=
PQnfields
(
mResult
);
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
typeMap
;
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
typeMap
;
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
{
char
*
name
=
PQgetvalue
(
mResult
,
i
,
0
);
char
*
val
=
PQgetvalue
(
mResult
,
i
,
2
);
char
*
val
=
PQgetvalue
(
mResult
,
i
,
1
);
char
*
type
=
PQgetvalue
(
mResult
,
i
,
3
);
char
*
type
=
PQgetvalue
(
mResult
,
i
,
2
);
typeMap
[
type
].
push_back
(
name
);
typeMap
[
type
].
push_back
(
val
);
typeMap
[
type
].
push_back
(
val
);
}
}
...
...
pandaDbManager/CivPgConn.h
View file @
3dbc7070
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <libpq-fe.h>
#include <libpq-fe.h>
#include "CivDbConn.h"
#include "CivDbConn.h"
/**
/**
postgress 数据库
postgress 数据库
*/
*/
...
@@ -12,7 +13,6 @@ public:
...
@@ -12,7 +13,6 @@ public:
CivPgConn
(
char
*
uri
);
CivPgConn
(
char
*
uri
);
~
CivPgConn
();
~
CivPgConn
();
private
:
/**
/**
*@brief 连接数据库,与具体的数据有关子类实现
*@brief 连接数据库,与具体的数据有关子类实现
*/
*/
...
@@ -33,7 +33,7 @@ private:
...
@@ -33,7 +33,7 @@ private:
*@brief 执行sql语句
*@brief 执行sql语句
*@sql: 需要执行的sql语句
*@sql: 需要执行的sql语句
*/
*/
virtual
bool
execSql
(
Str
sql
);
virtual
bool
execSql
(
Str
Quote
sql
);
virtual
bool
getNode
(
CivNode
&
node
)
;
virtual
bool
getNode
(
CivNode
&
node
)
;
virtual
bool
getPipe
(
CivPipe
&
pipe
)
;
virtual
bool
getPipe
(
CivPipe
&
pipe
)
;
virtual
bool
getTank
(
CivTank
&
tank
)
;
virtual
bool
getTank
(
CivTank
&
tank
)
;
...
...
pandaDbManager/CivTableTemp.h
View file @
3dbc7070
...
@@ -117,8 +117,8 @@ public:
...
@@ -117,8 +117,8 @@ public:
Str
ID
=
"id"
;
Str
ID
=
"id"
;
Str
geom
=
"geom"
;
Str
geom
=
"geom"
;
Str
snNo
=
"编号"
;
Str
snNo
=
"编号"
;
Str
thePoint
=
"
上
点号"
;
Str
thePoint
=
"
本
点号"
;
Str
lastPoint
=
"
本
点号"
;
Str
lastPoint
=
"
上
点号"
;
Str
length
=
"管长"
;
Str
length
=
"管长"
;
Str
material
=
"管材"
;
Str
material
=
"管材"
;
Str
diameter
=
"管径"
;
Str
diameter
=
"管径"
;
...
...
建模文档/水力模型.docx
View file @
3dbc7070
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment