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
125f003e
Commit
125f003e
authored
Aug 10, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口重写
parent
e70c7e93
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
624 additions
and
1591 deletions
+624
-1591
CivBaseInpBuilder.cpp
pandaAnalysis/CivBaseInpBuilder.cpp
+62
-83
CivBaseInpBuilder.h
pandaAnalysis/CivBaseInpBuilder.h
+1
-2
CivGraphFactory.cpp
pandaAnalysis/CivGraphFactory.cpp
+2
-3
CivGraphFactory.h
pandaAnalysis/CivGraphFactory.h
+2
-2
CivHydrCompute.cpp
pandaAnalysis/CivHydrCompute.cpp
+27
-29
CivHydrFuncInter.cpp
pandaAnalysis/CivHydrFuncInter.cpp
+9
-186
CivHydrSimulation.cpp
pandaAnalysis/CivHydrSimulation.cpp
+0
-24
CivInpBuilder.cpp
pandaAnalysis/CivInpBuilder.cpp
+36
-199
CivInpBuilder.h
pandaAnalysis/CivInpBuilder.h
+61
-26
CivInpConvertor.cpp
pandaAnalysis/CivInpConvertor.cpp
+52
-1
CivInpConvertor.h
pandaAnalysis/CivInpConvertor.h
+25
-3
CivInpDirector.cpp
pandaAnalysis/CivInpDirector.cpp
+2
-2
CivInpDirector.h
pandaAnalysis/CivInpDirector.h
+3
-3
CivNewInp.cpp
pandaAnalysis/CivNewInp.cpp
+4
-61
CivNewInp.h
pandaAnalysis/CivNewInp.h
+2
-12
CivProjInpBuilder.cpp
pandaAnalysis/CivProjInpBuilder.cpp
+14
-8
CivProjInpBuilder.h
pandaAnalysis/CivProjInpBuilder.h
+30
-23
CivSimuResStruct.h
pandaAnalysis/CivSimuResStruct.h
+39
-0
CivSimulResultCache.cpp
pandaAnalysis/CivSimulResultCache.cpp
+4
-25
CivSimulResultCache.h
pandaAnalysis/CivSimulResultCache.h
+3
-11
CivTrackingAnalysis.cpp
pandaAnalysis/CivTrackingAnalysis.cpp
+72
-73
CivTrackingAnalysis.h
pandaAnalysis/CivTrackingAnalysis.h
+8
-10
pandaAnalysis.vcxproj
pandaAnalysis/pandaAnalysis.vcxproj
+1
-0
pandaAnalysis.vcxproj.filters
pandaAnalysis/pandaAnalysis.vcxproj.filters
+4
-0
CivAssembly.h
pandaDbManager/CivAssembly.h
+2
-0
CivConnection.h
pandaDbManager/CivConnection.h
+2
-2
CivDbConn.cpp
pandaDbManager/CivDbConn.cpp
+0
-25
CivDbConn.h
pandaDbManager/CivDbConn.h
+0
-114
CivInpDbHelper.cpp
pandaDbManager/CivInpDbHelper.cpp
+9
-140
CivInpDbHelper.h
pandaDbManager/CivInpDbHelper.h
+4
-14
CivInpHelperAbs.cpp
pandaDbManager/CivInpHelperAbs.cpp
+86
-42
CivInpHelperAbs.h
pandaDbManager/CivInpHelperAbs.h
+26
-22
CivPgConn.cpp
pandaDbManager/CivPgConn.cpp
+0
-0
CivPgConn.h
pandaDbManager/CivPgConn.h
+0
-93
CivPgDbConnection.cpp
pandaDbManager/CivPgDbConnection.cpp
+1
-1
CivPgDbConnection.h
pandaDbManager/CivPgDbConnection.h
+1
-1
CivProjInpDbHelper.cpp
pandaDbManager/CivProjInpDbHelper.cpp
+2
-52
CivProjInpDbHelper.h
pandaDbManager/CivProjInpDbHelper.h
+2
-13
CivTableFields.h
pandaDbManager/CivTableFields.h
+7
-6
CivTypes.h
pandaDbManager/CivTypes.h
+12
-276
pandaDbManager.vcxproj
pandaDbManager/pandaDbManager.vcxproj
+4
-1
pandaDbManager.vcxproj.filters
pandaDbManager/pandaDbManager.vcxproj.filters
+3
-3
No files found.
pandaAnalysis/CivBaseInpBuilder.cpp
View file @
125f003e
...
...
@@ -3,35 +3,25 @@
#include "CivInpBuilder.h"
#include "CivTypes.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
(
)
:
CivInpBuilder
(
)
mNewInp
(
new
CivNewInp
()
)
CivBaseInpBuilder
::
CivBaseInpBuilder
(
const
std
::
string
&
uri
)
:
CivInpBuilder
(
uri
)
{
mHelper
=
new
CivInpDbHelper
(
uri
);
}
CivBaseInpBuilder
::~
CivBaseInpBuilder
()
{
delete
mNewInp
;
}
CivNewInp
*
CivBaseInpBuilder
::
getNewInp
()
{
return
mNewInp
;
}
CivBaseInpBuilder
::
CivBaseInpBuilder
()
{
}
void
CivBaseInpBuilder
::
buildNode
()
{
CivNode
node
;
if
(
!
m
DbConn
->
getNode
(
node
))
if
(
!
m
Helper
->
getNode
(
node
))
return
;
mNewInp
->
setNode
(
node
);
...
...
@@ -39,10 +29,10 @@ void CivBaseInpBuilder::buildNode()
void
CivBaseInpBuilder
::
buildPipe
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivPipe
pipe
;
if
(
!
m
DbConn
->
getPipe
(
pipe
))
CivPipe
pipe
;
if
(
!
m
Helper
->
getPipe
(
pipe
))
return
;
mNewInp
->
setPipes
(
pipe
);
...
...
@@ -50,10 +40,10 @@ void CivBaseInpBuilder::buildPipe()
void
CivBaseInpBuilder
::
buildTank
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivTank
tank
;
if
(
!
m
DbConn
->
getTank
(
tank
))
CivTank
tank
;
if
(
!
m
Helper
->
getTank
(
tank
))
return
;
mNewInp
->
setTank
(
tank
);
...
...
@@ -61,10 +51,10 @@ void CivBaseInpBuilder::buildTank()
void
CivBaseInpBuilder
::
buildVavle
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivValve
valve
;
if
(
!
m
DbConn
->
getValve
(
valve
))
CivValve
valve
;
if
(
!
m
Helper
->
getValve
(
valve
))
return
;
mNewInp
->
setValves
(
valve
);
...
...
@@ -72,10 +62,10 @@ void CivBaseInpBuilder::buildVavle()
void
CivBaseInpBuilder
::
buildPump
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivPumps
valve
;
if
(
!
m
DbConn
->
getPumps
(
valve
))
CivPumps
valve
;
if
(
!
m
Helper
->
getPumps
(
valve
))
return
;
mNewInp
->
setPumps
(
valve
);
...
...
@@ -83,10 +73,10 @@ void CivBaseInpBuilder::buildPump()
void
CivBaseInpBuilder
::
buildReservoir
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivReservoirs
res
;
if
(
!
m
DbConn
->
getReservoirs
(
res
))
CivReservoirs
res
;
if
(
!
m
Helper
->
getReservoirs
(
res
))
return
;
mNewInp
->
setReservoirs
(
res
);
...
...
@@ -94,10 +84,10 @@ void CivBaseInpBuilder::buildReservoir()
void
CivBaseInpBuilder
::
buildEmitter
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivEmitters
emmiters
;
if
(
!
m
DbConn
->
getEmitters
(
emmiters
))
if
(
!
m
Helper
->
getEmitters
(
emmiters
))
return
;
mNewInp
->
setEmitters
(
emmiters
);
...
...
@@ -105,37 +95,21 @@ void CivBaseInpBuilder::buildEmitter()
void
CivBaseInpBuilder
::
buildPatterns
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivPatterns
pattern
;
if
(
!
m
DbConn
->
getPatterns
(
pattern
))
CivPatterns
pattern
;
if
(
!
m
Helper
->
getPatterns
(
pattern
))
return
;
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
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivCoordinates
coords
;
if
(
!
m
DbConn
->
getCoordinates
(
coords
))
CivCoordinates
coords
;
if
(
!
m
Helper
->
getCoordinates
(
coords
))
return
;
mNewInp
->
setCoordnates
(
coords
);
...
...
@@ -148,10 +122,10 @@ void CivBaseInpBuilder::buildVertices()
void
CivBaseInpBuilder
::
buildLabels
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivLabels
labels
;
if
(
!
m
DbConn
->
getLabels
(
labels
))
CivLabels
labels
;
if
(
!
m
Helper
->
getLabels
(
labels
))
return
;
mNewInp
->
setLabels
(
labels
);
...
...
@@ -159,10 +133,10 @@ void CivBaseInpBuilder::buildLabels()
void
CivBaseInpBuilder
::
buildTags
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivTags
tag
;
if
(
!
m
DbConn
->
getTags
(
tag
))
CivTags
tag
;
if
(
!
m
Helper
->
getTags
(
tag
))
return
;
mNewInp
->
setTags
(
tag
);
...
...
@@ -175,22 +149,27 @@ void CivBaseInpBuilder::buildBackDrop()
void
CivBaseInpBuilder
::
buildQuality
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivQuality
quality
;
if
(
!
mDbConn
->
getQuality
(
quality
))
if
(
mResetToZero
)
{
mNewInp
->
setQuality
(
mInitQuality
);
return
;
}
CivQuality
quality
;
if
(
!
mHelper
->
getQuality
(
quality
));
return
;
mNewInp
->
setQuality
(
quality
);
}
void
CivBaseInpBuilder
::
buildSources
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivSources
sources
;
if
(
!
m
DbConn
->
getSources
(
sources
))
CivSources
sources
;
if
(
!
m
Helper
->
getSources
(
sources
))
return
;
mNewInp
->
setSources
(
sources
);
...
...
@@ -198,10 +177,10 @@ void CivBaseInpBuilder::buildSources()
void
CivBaseInpBuilder
::
buildMixing
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivMixing
mixing
;
if
(
!
m
DbConn
->
getMixing
(
mixing
))
CivMixing
mixing
;
if
(
!
m
Helper
->
getMixing
(
mixing
))
return
;
mNewInp
->
setMixing
(
mixing
);
...
...
@@ -209,21 +188,21 @@ void CivBaseInpBuilder::buildMixing()
void
CivBaseInpBuilder
::
buildCurves
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
/*
CivCurves curves;
if (!mDbConn
->getCurves(curves))
return;
CivCurves
curves
;
if
(
!
mHelper
->
getCurves
(
curves
))
return
;
mNewInp->setCurves(curves);*/
mNewInp
->
setCurves
(
curves
);
}
void
CivBaseInpBuilder
::
buildStatus
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivStatus
status
;
if
(
!
m
DbConn
->
getStatus
(
status
))
CivStatus
status
;
if
(
!
m
Helper
->
getStatus
(
status
))
return
;
mNewInp
->
setStatus
(
status
);
...
...
@@ -241,10 +220,10 @@ void CivBaseInpBuilder::buildRules()
void
CivBaseInpBuilder
::
buildDemands
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
CivDemands
mand
;
if
(
!
m
DbConn
->
getDemands
(
mand
))
CivDemands
mand
;
if
(
!
m
Helper
->
getDemands
(
mand
))
return
;
mNewInp
->
setDemands
(
mand
);
...
...
pandaAnalysis/CivBaseInpBuilder.h
View file @
125f003e
...
...
@@ -7,7 +7,7 @@
class
CivBaseInpBuilder
:
public
CivInpBuilder
{
public
:
explicit
CivBaseInpBuilder
();
explicit
CivBaseInpBuilder
(
const
std
::
string
&
uri
);
~
CivBaseInpBuilder
();
virtual
void
buildNode
();
...
...
@@ -18,7 +18,6 @@ public:
virtual
void
buildReservoir
();
virtual
void
buildEmitter
();
virtual
void
buildPatterns
();
virtual
void
buildParamter
();
virtual
void
buildCoordnates
();
virtual
void
buildVertices
();
virtual
void
buildLabels
();
...
...
pandaAnalysis/CivGraphFactory.cpp
View file @
125f003e
#include "CivGraphFactory.h"
#include "CivGraphList.h"
#include "CivDbConn.h"
#include "CivPgConn.h"
#include "CivInpDbHelper.h"
#include "CivTrackingResultCache.h"
CivGraphFactory
::
CivGraphFactory
()
...
...
@@ -9,7 +8,7 @@ CivGraphFactory::CivGraphFactory()
}
bool
CivGraphFactory
::
initGraph
(
Civ
DbConn
*
dbConn
,
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
)
bool
CivGraphFactory
::
initGraph
(
Civ
InpDbHelper
*
dbConn
,
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
)
{
if
(
graph
==
nullptr
)
return
false
;
...
...
pandaAnalysis/CivGraphFactory.h
View file @
125f003e
...
...
@@ -4,9 +4,9 @@
#include "CivGraphList.h"
// 声明模板图类型
class
CivDbConn
;
class
CivGraphJunction
;
class
CivGraphEdage
;
class
CivInpDbHelper
;
class
CivGraphFactory
{
...
...
@@ -18,5 +18,5 @@ public:
*@param dbConn 数据库连接
*@param graph 有向图
*/
bool
initGraph
(
Civ
DbConn
*
dbConn
,
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
);
bool
initGraph
(
Civ
InpDbHelper
*
dbConn
,
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
);
};
pandaAnalysis/CivHydrCompute.cpp
View file @
125f003e
#include "CivHydrCompute.h"
#include "Civ
Types
.h"
#include "Civ
SimuResStruct
.h"
CivHydrCompute
::
CivHydrCompute
(
char
*
inp
,
char
*
rptFile
,
char
*
binFile
)
:
mInpFile
(
inp
),
mRptFile
(
rptFile
),
mBinFile
(
binFile
)
...
...
@@ -160,7 +160,6 @@ bool CivHydrCompute::hdyrCompute()
void
CivHydrCompute
::
getNodeResult
(
short
time
)
{
// 计算节点
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
...
...
@@ -171,31 +170,33 @@ void CivHydrCompute::getNodeResult(short time)
ENgetlinktype
(
i
,
typeCode
);
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
;
}
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
;
// 编号
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
;
// nodeItem.dInterval = time;
// 放到缓存类中
//mResultCache.addNodeItems(nodeItem);
...
...
@@ -229,8 +230,7 @@ void CivHydrCompute::getLinkResult(short time)
ENgetlinkid
(
i
,
linkItem
.
szNo
);
// 流量
ENgetlinkvalue
(
i
,
EN_FLOW
,
&
linkItem
.
dFlow
);
// 流向
linkItem
.
nFlowDirect
=
(
linkItem
.
dFlow
>=
0
)
?
0
:
1
;
// 流速
ENgetlinkvalue
(
i
,
EN_VELOCITY
,
&
linkItem
.
dVelocity
);
// 水头损失
...
...
@@ -244,12 +244,10 @@ void CivHydrCompute::getLinkResult(short time)
else
strcpy_s
(
linkItem
.
szStatus
,
"开启"
);
linkItem
.
dInterval
=
time
;
//
linkItem.dInterval = time;
// 放到缓存类中
// mResultCache.addLinkItems(linkItem);
}
}
void
CivHydrCompute
::
getNodeQuality
(
short
time
)
...
...
pandaAnalysis/CivHydrFuncInter.cpp
View file @
125f003e
#include "CivHydrFuncInter.h"
#include "CivSysLog.h"
#include "CivTableTemp.h"
#include "CivPgConn.h"
#include "CivHydrSimulation.h"
#include "CivTrackingAnalysis.h"
bool
FUNEXPORT
modelMatation
(
char
*
uri
)
{
// 创建数据库连接
CivDbConn
*
pgConn
=
new
CivPgConn
(
uri
);
pgConn
->
checkHyDrNetTable
();
delete
pgConn
;
return
true
;
}
bool
FUNEXPORT
hdyrSimulation
(
char
*
uri
)
{
// 创建数据库连接
CivDbConn
*
pgConn
=
new
CivPgConn
(
uri
);
// 模拟计算对象
CivHydrSimulation
*
mHyDr
=
new
CivHydrSimulation
(
pgConn
);
//开始模拟
int
flag
=
mHyDr
->
hdyrSimulation
();
delete
mHyDr
;
delete
pgConn
;
return
flag
;
return
true
;
}
bool
FUNEXPORT
qualitySimulation
(
char
*
uri
)
{
// 创建数据库连接
CivDbConn
*
pgConn
=
new
CivPgConn
(
uri
);
// 模拟计算对象
CivHydrSimulation
*
mHyDr
=
new
CivHydrSimulation
();
mHyDr
->
registDb
(
pgConn
);
//开始模拟
int
flag
=
mHyDr
->
qualitySimulation
();
delete
pgConn
;
delete
mHyDr
;
return
flag
;
return
true
;
}
bool
FUNEXPORT
trackingSimulation
(
char
*
uri
,
char
*
sN
,
int
hours
,
char
*
result
)
{
// 创建数据库连接
CivDbConn
*
pgConn
=
new
CivPgConn
(
uri
);
// 模拟计算对象
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
;
return
true
;
}
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
;
}
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
;
}
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
;
}
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
;
}
\ No newline at end of file
pandaAnalysis/CivHydrSimulation.cpp
View file @
125f003e
#include "CivHydrSimulation.h"
#include "CivPgConn.h"
#include "CivNewInp.h"
#include "CivBuilder.h"
#include "CivInpDirector.h"
#include "CivSysLog.h"
#include "epanet2.h"
...
...
@@ -26,28 +24,6 @@ bool CivHydrSimulation::hdyrSimulation()
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
;
}
...
...
pandaAnalysis/CivInpBuilder.cpp
View file @
125f003e
...
...
@@ -4,118 +4,64 @@
#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
()
{
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
);
}
CivInpBuilder
::
CivInpBuilder
()
{
}
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
()
void
CivInpBuilder
::
setTimes
(
const
std
::
string
&
name
,
const
std
::
string
&
val
)
{
ASSERT
(
mDbConn
,
mNewInp
)
CivPumps
valve
;
if
(
!
mDbConn
->
getPumps
(
valve
))
return
;
mNewInp
->
setPumps
(
valve
);
CivParameter
::
ParamTable
table
=
{
name
,
val
};
mTimes
.
addItem
(
table
);
}
void
CivInpBuilder
::
buildReservoir
()
void
CivInpBuilder
::
setReport
(
const
std
::
string
&
name
,
const
std
::
string
&
val
)
{
ASSERT
(
mDbConn
,
mNewInp
)
CivReservoirs
res
;
if
(
!
mDbConn
->
getReservoirs
(
res
))
return
;
mNewInp
->
setReservoirs
(
res
);
CivParameter
::
ParamTable
table
=
{
name
,
val
};
mReport
.
addItem
(
table
);
}
void
CivInpBuilder
::
buildEmitter
()
void
CivInpBuilder
::
setReaction
(
const
std
::
string
&
name
,
const
std
::
string
&
val
)
{
ASSERT
(
mDbConn
,
mNewInp
)
CivEmitters
emmiters
;
if
(
!
mDbConn
->
getEmitters
(
emmiters
))
return
;
mNewInp
->
setEmitters
(
emmiters
);
CivParameter
::
ParamTable
table
=
{
name
,
val
};
mReactions
.
addItem
(
table
);
}
void
CivInpBuilder
::
buildPatterns
()
std
::
string
CivInpBuilder
::
getNewInp
()
{
ASSERT
(
mDbConn
,
mNewInp
)
CivPatterns
pattern
;
if
(
!
mDbConn
->
getPatterns
(
pattern
))
return
;
std
::
string
inpFile
=
"test.inp"
;
if
(
mNewInp
->
writeToFile
(
inpFile
))
return
NULL
;
mNewInp
->
setPatterns
(
pattern
)
;
return
inpFile
;
}
void
CivInpBuilder
::
buildParamter
()
{
ASSERT
(
m
DbConn
,
mNewInp
)
ASSERT
(
m
Helper
,
mNewInp
);
std
::
vector
<
CivParameter
>
parameters
;
if
(
!
m
DbConn
->
getParameter
(
parameters
))
if
(
!
m
Helper
->
getParameter
(
parameters
))
return
;
size_t
total
=
parameters
.
size
();
...
...
@@ -123,125 +69,15 @@ void CivInpBuilder::buildParamter()
{
CivParameter
param
=
parameters
[
i
];
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
)
CivMixing
mixing
;
if
(
!
mDbConn
->
getMixing
(
mixing
))
return
;
mNewInp
->
setMixing
(
mixing
);
mResetToZero
=
true
;
}
void
CivInpBuilder
::
buildCurves
(
)
void
CivInpBuilder
::
setQuality
(
const
std
::
string
&
name
,
const
std
::
string
&
val
)
{
ASSERT
(
mDbConn
,
mNewInp
)
/*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
);
mInitQuality
.
addItem
({
name
,
val
});
}
\ No newline at end of file
pandaAnalysis/CivInpBuilder.h
View file @
125f003e
#ifndef _CIVINPEXPOTER_H
#define _CIVINPEXPOTER_H
#include "CivNewInp.h"
#include "CivInpHelperAbs.h"
/**
* 抽象建造者
...
...
@@ -8,37 +9,71 @@
class
CivInpBuilder
{
public
:
explicit
CivInpBuilder
();
explicit
CivInpBuilder
(
const
std
::
string
&
uri
);
virtual
~
CivInpBuilder
();
virtual
void
buildNode
();
virtual
void
buildPipe
();
virtual
void
buildTank
();
virtual
void
buildVavle
();
virtual
void
buildPump
();
virtual
void
buildReservoir
();
virtual
void
buildEmitter
();
virtual
void
buildPatterns
();
virtual
void
buildParamter
();
virtual
void
buildCoordnates
();
virtual
void
buildVertices
();
virtual
void
buildLabels
();
virtual
void
buildTags
();
virtual
void
buildBackDrop
();
virtual
void
buildQuality
();
virtual
void
buildSources
();
virtual
void
buildMixing
();
virtual
void
buildCurves
();
virtual
void
buildStatus
();
virtual
void
buildControls
();
virtual
void
buildRules
();
virtual
void
buildDemands
();
CivNewInp
*
getNewInp
();
/**
*@brief 设置选择项值
*/
void
setOption
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
/**
*@brief 设置模拟时间选项
*/
void
setTimes
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
/**
*@brief 设置输出报告选项
*/
void
setReport
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
/**
*@brief 设置反应系数选项
*/
void
setReaction
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
void
setQuality
(
const
std
::
string
&
name
,
const
std
::
string
&
val
);
void
resetAllToZero
();
/**
*@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
:
CivParameter
mOptions
;
CivParameter
mTimes
;
CivParameter
mReactions
;
CivParameter
mReport
;
CivQuality
mInitQuality
;
// 节点的初始水质
CivNewInp
*
mNewInp
;
CivInpHelperAbs
*
mHelper
;
bool
mResetToZero
=
false
;;
std
::
string
mUri
;
};
#endif // !_CIVINPEXPOTER_H
...
...
pandaAnalysis/CivInpConvertor.cpp
View file @
125f003e
#include "CivInpConvertor.h"
#include "CivProjInpBuilder.h"
#include "CivInpDirector.h"
#include "CivBaseInpBuilder.h"
CivInpConvertor
::
CivInpConvertor
(
const
std
::
string
&
uri
)
:
mUri
(
uri
)
{
}
...
...
@@ -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
pandaAnalysis/CivInpConvertor.h
View file @
125f003e
#pragma once
#include <string>
#include "CivInpBuilder.h"
/**
管网数据库数据转inp文件中转器
管网数据库数据转inp文件中转器
*/
class
CivInpConvertor
{
public
:
explicit
CivInpConvertor
(
const
std
::
string
&
uri
);
~
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
pandaAnalysis/CivInpDirector.cpp
View file @
125f003e
#include "CivInpDirector.h"
#include "CivBuilder.h"
#include "Civ
Inp
Builder.h"
void
CivInpDirector
::
setBuilder
(
CivBuilder
*
builder
)
void
CivInpDirector
::
setBuilder
(
Civ
Inp
Builder
*
builder
)
{
mBuilder
=
builder
;
}
...
...
pandaAnalysis/CivInpDirector.h
View file @
125f003e
#ifndef CIVINPDIRECTOR_H
#define CIVINPDIRECTOR_H
class
CivBuilder
;
class
Civ
Inp
Builder
;
// ָ
class
CivInpDirector
{
public
:
void
setBuilder
(
CivBuilder
*
builder
);
void
setBuilder
(
Civ
Inp
Builder
*
builder
);
void
create
();
private
:
CivBuilder
*
mBuilder
;
Civ
Inp
Builder
*
mBuilder
;
};
...
...
pandaAnalysis/CivNewInp.cpp
View file @
125f003e
...
...
@@ -18,18 +18,7 @@ CivNewInp::~CivNewInp()
}
void
CivNewInp
::
setQualityType
(
QualityAnalyType
type
,
const
std
::
string
&
qualityName
)
{
mQualityType
=
type
;
mQualityName
=
qualityName
;
}
void
CivNewInp
::
setDuration
(
int
duration
)
{
mDuration
=
duration
;
}
bool
CivNewInp
::
writeToFile
(
char
*
fileName
)
bool
CivNewInp
::
writeToFile
(
const
std
::
string
&
fileName
)
{
// 检查是否存在值
std
::
string
res
=
mTextStream
.
str
();
...
...
@@ -320,23 +309,8 @@ void CivNewInp::setQuality(const CivQuality& quality)
for
(
auto
iter
=
tables
.
rbegin
();
iter
!=
tables
.
rend
();
iter
++
)
{
CivQuality
::
Table
table
=
*
iter
;
writeStringFormat
(
table
.
ID
);
if
(
mQualityType
==
ANALYSIS_TRACE
)
{
if
(
table
.
ID
==
mQualityName
)
{
writeString
(
"1"
);
continue
;
}
else
{
writeString
(
"0"
);
}
}
else
{
writeString
(
table
.
InitQuality
);
}
writeStringFormat
(
table
.
ID
);
writeString
(
table
.
InitQuality
);
}
writeString
(
""
);
}
...
...
@@ -423,28 +397,6 @@ void CivNewInp::setOptions(const CivParameter& params)
CivParameter
::
ParamTable
table
=
*
iter
;
std
::
string
strName
=
table
.
name
;
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
);
writeString
(
strValue
);
}
...
...
@@ -465,16 +417,7 @@ void CivNewInp::setTimes(const CivParameter& params)
{
CivParameter
::
ParamTable
table
=
*
iter
;
writeStringFormat
(
table
.
name
);
if
(
mDuration
>-
1
&&
table
.
name
==
"Duration"
)
{
writeString
(
std
::
to_string
(
mDuration
));
}
else
{
writeString
(
table
.
val
);
}
writeString
(
table
.
val
);
}
writeString
(
""
);
}
...
...
pandaAnalysis/CivNewInp.h
View file @
125f003e
...
...
@@ -32,12 +32,7 @@ public:
explicit
CivNewInp
();
~
CivNewInp
();
bool
writeToFile
(
char
*
fileName
);
/**
管网组件
*/
void
setQualityType
(
QualityAnalyType
type
,
const
std
::
string
&
qualityName
);
void
setDuration
(
int
duration
);
bool
writeToFile
(
const
std
::
string
&
fileName
);
void
setTtitle
(
const
std
::
string
&
title
);
void
setNode
(
const
CivNode
&
node
);
void
setPipes
(
const
CivPipe
&
pipes
);
...
...
@@ -84,12 +79,7 @@ private:
std
::
string
currentTime
();
private
:
std
::
ostringstream
mTextStream
;
QualityAnalyType
mQualityType
=
ANALYSIS_AGE
;
//水质分析类型, 默认水龄
std
::
string
mQualityName
;
// 追踪的节点名 或者化合物名
int
mDuration
=
-
1
;
std
::
ostringstream
mTextStream
;
std
::
map
<
std
::
string
,
void
(
CivNewInp
::*
)(
const
CivParameter
&
)
>
mParamMap
;
// 参数类型映射
};
#endif // !CIVNEWINP_H
...
...
pandaAnalysis/CivProjInpBuilder.cpp
View file @
125f003e
#include "CivProjInpBuilder.h"
#include "CivProjInpDbHelper.h"
CivProjInpBuilder
::
CivProjInpBuilder
(
const
std
::
string
&
uri
)
:
CivInpBuilder
(
uri
)
{
mHelper
=
new
CivProjInpDbHelper
(
uri
);
}
CivProjInpBuilder
::~
CivProjInpBuilder
()
{
}
void
CivProjInpBuilder
::
buildNode
()
{
...
...
@@ -40,10 +51,6 @@ void CivProjInpBuilder::buildPatterns()
}
void
CivProjInpBuilder
::
buildParamter
()
{
}
void
CivProjInpBuilder
::
buildCoordnates
()
{
...
...
@@ -109,7 +116,7 @@ void CivProjInpBuilder::buildDemands()
}
CivNewInp
*
getNewInp
(
)
void
CivProjInpBuilder
::
setProjCode
(
const
std
::
string
&
projCode
)
{
}
\ No newline at end of file
mProjCode
=
projCode
;
}
pandaAnalysis/CivProjInpBuilder.h
View file @
125f003e
...
...
@@ -4,29 +4,36 @@
/**
ģתinpļ
*/
class
CivProjInpBuilder
:
public
CivInpBuilder
class
CivProjInpBuilder
:
public
CivInpBuilder
{
public
:
virtual
void
buildNode
();
virtual
void
buildPipe
();
virtual
void
buildTank
();
virtual
void
buildVavle
();
virtual
void
buildPump
();
virtual
void
buildReservoir
();
virtual
void
buildEmitter
();
virtual
void
buildPatterns
()
;
virtual
void
buildParamter
()
;
virtual
void
buildCoordnates
()
;
virtual
void
buildVertices
()
;
virtual
void
buildLabels
()
;
virtual
void
buildTags
()
;
virtual
void
buildBackDrop
()
;
virtual
void
buildQuality
()
;
virtual
void
buildSources
()
;
virtual
void
buildMixing
()
;
virtual
void
buildCurves
()
;
virtual
void
buildStatus
()
;
virtual
void
buildControls
()
;
virtual
void
buildRules
()
;
virtual
void
buildDemands
()
;
explicit
CivProjInpBuilder
(
const
std
::
string
&
uri
);
~
CivProjInpBuilder
();
/**/
void
setProjCode
(
const
std
::
string
&
projCode
);
void
buildNode
()
override
;
void
buildPipe
()
override
;
void
buildTank
()
override
;
void
buildVavle
()
override
;
void
buildPump
()
override
;
void
buildReservoir
()
override
;
void
buildEmitter
()
override
;
void
buildPatterns
()
override
;
void
buildCoordnates
()
override
;
void
buildVertices
()
override
;
void
buildLabels
()
override
;
void
buildTags
()
override
;
void
buildBackDrop
()
override
;
void
buildQuality
()
override
;
void
buildSources
()
override
;
void
buildMixing
()
override
;
void
buildCurves
()
override
;
void
buildStatus
()
override
;
void
buildControls
()
override
;
void
buildRules
()
override
;
void
buildDemands
()
override
;
private
:
std
::
string
mProjCode
;
};
pandaAnalysis/CivSimuResStruct.h
0 → 100644
View file @
125f003e
#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>
pandaAnalysis/CivSimulResultCache.cpp
View file @
125f003e
#include "CivSimulResultCache.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
())
return
;
...
...
@@ -14,26 +13,7 @@ void CivSimulResultCache::addNodeQuality(float quality, int interval, Str sNo)
mNodeItemsMap
[
interval
][
sNo
].
dQuality
=
quality
;
}
bool
CivSimulResultCache
::
updateToDb
(
CivDbConn
*
dbConn
)
{
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
)
void
CivSimulResultCache
::
addLinkQuality
(
float
quality
,
int
interval
,
const
std
::
string
&
sNo
)
{
if
(
mLinkItemsMap
.
find
(
interval
)
==
mLinkItemsMap
.
end
())
return
;
...
...
@@ -47,12 +27,12 @@ void CivSimulResultCache::addLinkQuality(float quality, int interval, Str sNo)
void
CivSimulResultCache
::
addNodeItems
(
const
NodeResultItem
&
nodeItem
)
{
mNodeItemsMap
[
nodeItem
.
dInterval
][
nodeItem
.
szNo
]
=
nodeItem
;
//
mNodeItemsMap[nodeItem.dInterval][nodeItem.szNo] = nodeItem;
}
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
)
...
...
@@ -64,7 +44,6 @@ void CivSimulResultCache::getResultByTime(int time, NodeResultItems& nodeItems,
auto
linkIter
=
mLinkItemsMap
.
find
(
time
);
if
(
nodeIter
==
mNodeItemsMap
.
end
()
||
linkIter
==
mLinkItemsMap
.
end
())
{
CivSysLog
::
getInstance
()
->
error
(
"存储数据出错了,找不到该对应时段的值"
,
"CivSimulResultCache"
,
__FUNCTION__
);
return
;
}
...
...
pandaAnalysis/CivSimulResultCache.h
View file @
125f003e
...
...
@@ -2,9 +2,7 @@
#define CIVSIMULRESULTCACHE_H
#include <map>
#include "CivTypes.h"
class
CivDbConn
;
#include "CivSimuResStruct.h"
/**
模拟结果缓存类
...
...
@@ -18,7 +16,7 @@ public:
*@param interval:模拟第几次
*@param sNo:本点号
*/
void
addNodeQuality
(
float
quality
,
int
interval
,
Str
sNo
);
void
addNodeQuality
(
float
quality
,
int
interval
,
const
std
::
string
&
sNo
);
/**
*@brief 缓存管线水质
...
...
@@ -26,7 +24,7 @@ public:
*@param interval:模拟第几次
*@param sNo:管线编号
*/
void
addLinkQuality
(
float
quality
,
int
interval
,
Str
sNo
);
void
addLinkQuality
(
float
quality
,
int
interval
,
const
std
::
string
&
sNo
);
/**
*@brief 缓存节点水力模拟情况
...
...
@@ -45,12 +43,6 @@ public:
*/
void
clear
();
/**
*@brief 缓存数据更新到数据库
*@param dbConn:数据库连接对象
*/
bool
updateToDb
(
CivDbConn
*
dbConn
);
/**
*@brief 根据时段获取
*@param time 时段
...
...
pandaAnalysis/CivTrackingAnalysis.cpp
View file @
125f003e
...
...
@@ -2,10 +2,9 @@
#include "CivSimulResultCache.h"
#include "CivHydrSimulation.h"
#include "CivGraphFactory.h"
#include "CivDbConn.h"
CivTrackingAnalysis
::
CivTrackingAnalysis
()
:
mGraph
(
new
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>
())
CivTrackingAnalysis
::
CivTrackingAnalysis
(
const
std
::
string
&
uri
)
:
mGraph
(
new
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>
())
,
mUri
(
uri
)
{
}
...
...
@@ -15,86 +14,86 @@ CivTrackingAnalysis::~CivTrackingAnalysis()
delete
mGraph
;
}
bool
CivTrackingAnalysis
::
createGraphFrom
(
CivDbConn
*
dbConn
)
bool
CivTrackingAnalysis
::
createGraphFrom
()
{
if
(
dbConn
==
nullptr
)
return
false
;
CivHydrSimulation
simulation
;
simulation
.
registDb
(
dbConn
);
//
CivHydrSimulation simulation;
//
simulation.registDb(dbConn);
if
(
!
simulation
.
hdyrInstantSimulation
())
return
false
;
//
if (!simulation.hdyrInstantSimulation())
//
return false;
NodeResultItems
nodeItems
;
LinkResultItems
linkItems
;
simulation
.
getDataByTime
(
0
,
nodeItems
,
linkItems
);
if
(
nodeItems
.
size
()
<=
0
)
return
false
;
//NodeResultItems nodeItems;
//LinkResultItems linkItems;
//simulation.getDataByTime(0, nodeItems, linkItems);
// 顶点坐标
CivCoordinates
coords
;
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
);
}
//if (nodeItems.size() <= 0)
// return false;
// 管段
CivPipe
civPipe
;
dbConn
->
getPipe
(
civPipe
);
//// 顶点坐标
//CivCoordinates coords;
//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
++
)
{
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
);
}
//std::list<CivPipe::PipesTable> pipesTableLis = civPipe.mTables;
//std::list<CivPipe::PipesTable>::iterator pIter;
}
//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
;
}
...
...
pandaAnalysis/CivTrackingAnalysis.h
View file @
125f003e
#pragma once
#include "CivHydDataType.h"
#include "CivGraphList.h"
#include "CivTrackingResultCache.h"
...
...
@@ -7,20 +6,12 @@
#define ALGORITHMEXPORT __declspec(dllexport)
class
CivDbConn
;
class
ALGORITHMEXPORT
CivTrackingAnalysis
{
public
:
explicit
CivTrackingAnalysis
();
explicit
CivTrackingAnalysis
(
const
std
::
string
&
uri
);
~
CivTrackingAnalysis
();
/**
*@brief 根据数据库管网构建管网有向图
*@param dbConn 数据库连接
*/
bool
createGraphFrom
(
CivDbConn
*
dbConn
);
/**
*@brief 追踪节点上游路径
*@param sN 节点本点号
...
...
@@ -43,6 +34,12 @@ public:
bool
waterSupplyScopeAnalysis
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
);
private
:
/**
*@brief 根据数据库管网构建管网有向图
*@param uri 数据库连接地址
*/
bool
createGraphFrom
();
/**
*@brief 节点和管段集合信息转换成json字符串
*@param junctions 节点信息集合
...
...
@@ -83,5 +80,6 @@ private:
std
::
vector
<
CivGraphEdage
>&
pipes
);
private
:
std
::
string
mUri
;
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
mGraph
;
// 管网有向图
};
pandaAnalysis/pandaAnalysis.vcxproj
View file @
125f003e
...
...
@@ -189,6 +189,7 @@
<ClInclude
Include=
"CivProjManager.h"
/>
<ClInclude
Include=
"CivProjSimulation.h"
/>
<ClInclude
Include=
"CivSimulResultCache.h"
/>
<ClInclude
Include=
"CivSimuResStruct.h"
/>
<ClInclude
Include=
"CivTrackingAnalysis.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
...
...
pandaAnalysis/pandaAnalysis.vcxproj.filters
View file @
125f003e
...
...
@@ -125,5 +125,8 @@
<ClInclude
Include=
"CivBaseInpBuilder.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivSimuResStruct.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
pandaDbManager/CivAssembly.h
View file @
125f003e
...
...
@@ -6,6 +6,8 @@
#define DBEXPORT __declspec(dllexport)
#define Str std::string
class
CivAssembly
;
class
CivNode
;
class
CivPipe
;
...
...
pandaDbManager/CivConnection.h
View file @
125f003e
...
...
@@ -7,7 +7,7 @@
/**
数据库连接类
*/
class
CivConnection
class
CivConnection
{
public
:
CivConnection
();
...
...
@@ -16,7 +16,7 @@ public:
/**
*@brief 建立数据,与具体的数据有关子类实现
*/
virtual
bool
connect
(
const
std
::
string
url
)
=
0
;
virtual
bool
connect
(
const
std
::
string
&
url
)
=
0
;
/**
*@brief 关闭数据,与具体的数据有关子类实现
...
...
pandaDbManager/CivDbConn.cpp
deleted
100644 → 0
View file @
e70c7e93
#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
;
}
pandaDbManager/CivDbConn.h
deleted
100644 → 0
View file @
e70c7e93
#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
pandaDbManager/CivInpDbHelper.cpp
View file @
125f003e
#include "CivInpDbHelper.h"
#include "CivTable
Temp
.h"
#include "CivTable
Fields
.h"
#include "CivConnection.h"
#include "CivPgDbConnection.h"
CivInpDbHelper
::
CivInpDbHelper
(
CivConnection
*
dbConn
)
:
CivInpHelperAbs
(
dbConn
)
CivInpDbHelper
::
CivInpDbHelper
(
const
std
::
string
&
uri
)
:
CivInpHelperAbs
(
uri
)
{
}
...
...
@@ -214,11 +214,6 @@ bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
return
true
;
}
bool
CivInpDbHelper
::
getEmitters
(
CivEmitters
&
emitter
)
{
return
true
;
}
bool
CivInpDbHelper
::
getCoordinates
(
CivCoordinates
&
coord
)
{
JunctionTable
nodeTable
;
...
...
@@ -250,132 +245,16 @@ bool CivInpDbHelper::getCoordinates(CivCoordinates& coord)
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
)
{
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
;
mDbConn
->
query
(
PIPENODE
,
fields
,
resultVector
);
...
...
@@ -395,12 +274,3 @@ bool CivInpDbHelper::getQuality(CivQuality& quality)
return
true
;
}
bool
CivInpDbHelper
::
getLabels
(
CivLabels
&
labels
)
{
return
true
;
}
bool
CivInpDbHelper
::
getTags
(
CivTags
&
tags
)
{
return
true
;
}
\ No newline at end of file
pandaDbManager/CivInpDbHelper.h
View file @
125f003e
...
...
@@ -4,12 +4,12 @@
#include <memory>
/**
从数据库获取inp文件相关的类
从数据库获取inp文件相关的类
*/
class
CivInpDbHelper
:
public
CivInpHelperAbs
class
INPDLLEXPORT
CivInpDbHelper
:
public
CivInpHelperAbs
{
public
:
explicit
CivInpDbHelper
(
CivConnection
*
dbConn
);
explicit
CivInpDbHelper
(
const
std
::
string
&
uri
);
~
CivInpDbHelper
();
bool
getNode
(
CivNode
&
node
)
override
;
...
...
@@ -18,16 +18,6 @@ public:
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
;
bool
getQuality
(
CivQuality
&
quality
)
override
;
};
pandaDbManager/CivInpHelperAbs.cpp
View file @
125f003e
#include "CivInpHelperAbs.h"
#include "CivConnection.h"
#include "CivTableTemp.h"
#include "CivPgDbConnection.h"
#include "CivTableFields.h"
CivInpHelperAbs
::
CivInpHelperAbs
(
CivConnection
*
dbConn
)
:
mDbConn
(
dbConn
)
CivInpHelperAbs
::
CivInpHelperAbs
(
const
std
::
string
&
uri
)
{
mDbConn
=
new
CivPgDbConnection
();
mDbConn
->
connect
(
uri
);
}
CivInpHelperAbs
::~
CivInpHelperAbs
()
{
mDbConn
->
disconnect
();
delete
mDbConn
;
}
bool
CivInpHelperAbs
::
get
Node
(
CivNode
&
node
)
bool
CivInpHelperAbs
::
get
Emitters
(
CivEmitters
&
emitter
)
{
return
true
;
}
bool
CivInpHelperAbs
::
get
Pipe
(
CivPipe
&
pipes
)
bool
CivInpHelperAbs
::
get
Mixing
(
CivMixing
&
mixing
)
{
return
true
;
}
bool
CivInpHelperAbs
::
get
Tank
(
CivTank
&
tank
s
)
bool
CivInpHelperAbs
::
get
Parameter
(
std
::
vector
<
CivParameter
>&
param
s
)
{
return
true
;
}
ParametorTable
restemTable
;
bool
CivInpHelperAbs
::
getValve
(
CivValve
&
valves
)
{
return
true
;
}
std
::
vector
<
std
::
string
>
fields
=
{
restemTable
.
name
,
restemTable
.
val
,
restemTable
.
type
};
bool
CivInpHelperAbs
::
getPumps
(
CivPumps
&
pumps
)
{
return
true
;
}
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
OPTIONTTABLE
,
fields
,
resultVector
);
bool
CivInpHelperAbs
::
getReservoirs
(
CivReservoirs
&
reservoirs
)
{
return
true
;
}
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
;
bool
CivInpHelperAbs
::
getEmitters
(
CivEmitters
&
emitter
)
{
return
true
;
}
std
::
string
type
=
map
.
find
(
fields
[
2
])
->
second
;
tempMap
[
type
].
push_back
(
pTable
);
}
bool
CivInpHelperAbs
::
getCoordinates
(
CivCoordinates
&
coord
)
{
return
true
;
}
// 遍历临时存储的数据拼接参数对象
for
(
auto
iter
=
tempMap
.
begin
();
iter
!=
tempMap
.
end
();
iter
++
)
{
CivParameter
param
;
std
::
string
type
=
iter
->
first
;
std
::
vector
<
CivParameter
::
ParamTable
>
paramTables
=
iter
->
second
;
bool
CivInpHelperAbs
::
getMixing
(
CivMixing
&
mixing
)
{
return
true
;
}
param
.
setType
(
type
);
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
;
}
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
;
}
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
;
}
...
...
@@ -92,11 +141,6 @@ bool CivInpHelperAbs::getStatus(CivStatus& status)
return
true
;
}
bool
CivInpHelperAbs
::
getQuality
(
CivQuality
&
quality
)
{
return
true
;
}
bool
CivInpHelperAbs
::
getLabels
(
CivLabels
&
labels
)
{
return
true
;
...
...
pandaDbManager/CivInpHelperAbs.h
View file @
125f003e
...
...
@@ -3,35 +3,39 @@
class
CivConnection
;
#define INPDLLEXPORT __declspec(dllexport)
/**
תinpݿ
转inp操作数据库类
*/
class
CivInpHelperAbs
class
INPDLLEXPORT
CivInpHelperAbs
{
public
:
explicit
CivInpHelperAbs
(
CivConnection
*
dbConn
);
explicit
CivInpHelperAbs
(
const
std
::
string
&
uri
);
virtual
~
CivInpHelperAbs
();
virtual
bool
getNode
(
CivNode
&
node
)
;
virtual
bool
getPipe
(
CivPipe
&
pipe
)
;
virtual
bool
getTank
(
CivTank
&
tank
)
;
virtual
bool
getValve
(
CivValve
&
valve
)
;
virtual
bool
getPumps
(
CivPumps
&
pump
)
;
virtual
bool
getReservoirs
(
CivReservoirs
&
reservoirs
)
;
virtual
bool
getEmitters
(
CivEmitters
&
emitter
)
;
virtual
bool
getCoordinates
(
CivCoordinates
&
coord
)
;
virtual
bool
getMixing
(
CivMixing
&
mixing
)
;
virtual
bool
getParameter
(
std
::
vector
<
CivParameter
>&
param
)
;
virtual
bool
getPatterns
(
CivPatterns
&
patterns
)
;
virtual
bool
getCurves
(
CivCurves
&
curves
)
;
virtual
bool
getDemands
(
CivDemands
&
demands
)
;
virtual
bool
getSources
(
CivSources
&
sources
)
;
virtual
bool
getStatus
(
CivStatus
&
status
)
;
virtual
bool
getQuality
(
CivQuality
&
quality
)
;
virtual
bool
getLabels
(
CivLabels
&
labels
)
;
virtual
bool
getTags
(
CivTags
&
tags
)
;
// 组件需要重载
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
getCoordinates
(
CivCoordinates
&
coord
)
=
0
;
virtual
bool
getQuality
(
CivQuality
&
quality
)
=
0
;
// 不要重载函数
bool
getPatterns
(
CivPatterns
&
patterns
)
;
bool
getCurves
(
CivCurves
&
curves
)
;
bool
getDemands
(
CivDemands
&
demands
)
;
bool
getSources
(
CivSources
&
sources
)
;
bool
getStatus
(
CivStatus
&
status
)
;
bool
getLabels
(
CivLabels
&
labels
)
;
bool
getTags
(
CivTags
&
tags
)
;
bool
getMixing
(
CivMixing
&
mixing
);
bool
getParameter
(
std
::
vector
<
CivParameter
>&
param
);
bool
getEmitters
(
CivEmitters
&
emitter
);
protected
:
CivConnection
*
mDbConn
;
std
::
map
<
std
::
string
,
std
::
map
<
std
::
string
,
std
::
string
>>
mCacheMap
;
};
pandaDbManager/CivPgConn.cpp
deleted
100644 → 0
View file @
e70c7e93
This diff is collapsed.
Click to expand it.
pandaDbManager/CivPgConn.h
deleted
100644 → 0
View file @
e70c7e93
#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
pandaDbManager/CivPgDbConnection.cpp
View file @
125f003e
...
...
@@ -11,7 +11,7 @@ CivPgDbConnection::~CivPgDbConnection()
disconnect
();
}
bool
CivPgDbConnection
::
connect
(
const
std
::
string
url
)
bool
CivPgDbConnection
::
connect
(
const
std
::
string
&
url
)
{
disconnect
();
...
...
pandaDbManager/CivPgDbConnection.h
View file @
125f003e
...
...
@@ -17,7 +17,7 @@ public:
/**
*@brief 建立数据,与具体的数据有关子类实现
*/
virtual
bool
connect
(
const
std
::
string
url
);
virtual
bool
connect
(
const
std
::
string
&
url
);
/**
*@brief 关闭数据,与具体的数据有关子类实现
...
...
pandaDbManager/CivProjInpDbHelper.cpp
View file @
125f003e
#include "CivProjInpDbHelper.h"
#include "CivConnection.h"
CivProjInpDbHelper
::
CivProjInpDbHelper
(
CivConnection
*
dbConn
)
:
CivInpHelperAbs
(
dbConn
)
CivProjInpDbHelper
::
CivProjInpDbHelper
(
const
std
::
string
&
uri
)
:
CivInpHelperAbs
(
uri
)
{
}
CivProjInpDbHelper
::~
CivProjInpDbHelper
()
...
...
@@ -42,63 +41,14 @@ bool CivProjInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
return
true
;
}
bool
CivProjInpDbHelper
::
getEmitters
(
CivEmitters
&
emitter
)
{
return
true
;
}
bool
CivProjInpDbHelper
::
getCoordinates
(
CivCoordinates
&
coord
)
{
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
)
{
return
true
;
}
bool
CivProjInpDbHelper
::
getLabels
(
CivLabels
&
labels
)
{
return
true
;
}
bool
CivProjInpDbHelper
::
getTags
(
CivTags
&
tags
)
{
return
true
;
}
pandaDbManager/CivProjInpDbHelper.h
View file @
125f003e
...
...
@@ -5,11 +5,10 @@
/**
*
*/
class
CivProjInpDbHelper
:
public
CivInpHelperAbs
class
INPDLLEXPORT
CivProjInpDbHelper
:
public
CivInpHelperAbs
{
public
:
explicit
CivProjInpDbHelper
(
CivConnection
*
dbConn
);
explicit
CivProjInpDbHelper
(
const
std
::
string
&
uri
);
~
CivProjInpDbHelper
();
bool
getNode
(
CivNode
&
node
)
override
;
...
...
@@ -18,16 +17,6 @@ public:
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
;
};
pandaDbManager/CivTable
Temp
.h
→
pandaDbManager/CivTable
Fields
.h
View file @
125f003e
#ifndef CIVTABLE
TEMP
_H
#define CIVTABLE
TEMP
_H
#ifndef CIVTABLE
FIELD
_H
#define CIVTABLE
FIELD
_H
#include<string>
#include<vector>
#include<map>
#include<string>
#include "CivTypes.h"
#define Str std::string
/**
节点表模板
*/
...
...
@@ -67,7 +70,6 @@ typedef struct PipeTableFields
/**
水泵
*/
typedef
struct
PumpTableFileds
{
Str
startPoint
=
"起始节点"
;
...
...
@@ -88,6 +90,7 @@ typedef struct PumpTableFileds
Str
quality
=
"水质"
;
Str
status
=
"状态"
;
}
PumpTable
;
/**
水池
*/
...
...
@@ -137,8 +140,6 @@ typedef struct ResourcesTableFileds
Str
quality
=
"水质"
;
}
ResourcesTable
;
/**
阀门
*/
...
...
@@ -397,7 +398,7 @@ typedef struct MonitorQualityTableField
}
MonitorQualityTable
;
#endif // !CIVTABLE
TEMP
_H
#endif // !CIVTABLE
FIELD
_H
pandaDbManager/CivTypes.h
View file @
125f003e
...
...
@@ -6,288 +6,24 @@
#include <vector>
#include <set>
typedef
std
::
string
Str
;
typedef
const
std
::
string
&
StrQuote
;
#define Tables std::vector<Str>
// 水力模型表名
#define PIPELINE Str("管段")
#define PIPENODE Str("节点")
#define RESIVOIR Str("水库")
#define TANK Str("水池")
#define PUMP Str("水泵")
#define VALVE Str("阀门")
#define NODERESULTTABLE Str("__node_result__")
#define PIPERESULTTABLE Str("__pipe_result__")
#define PATTERNTABLE Str("__pattern__")
#define CURVETABLE Str("__curve__")
#define OPTIONTTABLE Str("__parameter__")
/**
方案规划相关表定义
*/
#define PROJTABLE Str("__proj__")
#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>
#define NODERESULTTABLE Str("节点模拟值")
#define PIPERESULTTABLE Str("管段模拟值")
#define PATTERNTABLE Str("水力模式")
#define CURVETABLE Str("曲线")
#define OPTIONTTABLE Str("模型参数")
#define PROJTABLE Str("方案表")
#define PROJNODETABLE Str("方案点设备")
#define PROJPIPETABLE Str("方案线设备")
#define PRESSURETABLE Str("压力监测点")
#define FLOWTABLE Str("流量监测点")
#define QUALITYTABLE Str("水质监测点")
#endif // !CIVTYPES_H
...
...
pandaDbManager/pandaDbManager.vcxproj
View file @
125f003e
...
...
@@ -151,6 +151,9 @@
<PostBuildEvent>
<Command>
copy CivTypes.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>
</PostBuildEvent>
</ItemDefinitionGroup>
...
...
@@ -163,7 +166,7 @@ copy CivAssembly.h $(OutDir)..\include /y
<ClInclude
Include=
"CivPgDbConnection.h"
/>
<ClInclude
Include=
"CivProjInpDbHelper.h"
/>
<ClInclude
Include=
"CivSimuResDbHelper.h"
/>
<ClInclude
Include=
"CivTable
Temp
.h"
/>
<ClInclude
Include=
"CivTable
Fields
.h"
/>
<ClInclude
Include=
"CivTrackingResultCache.h"
/>
<ClInclude
Include=
"CivTypes.h"
/>
</ItemGroup>
...
...
pandaDbManager/pandaDbManager.vcxproj.filters
View file @
125f003e
...
...
@@ -18,9 +18,6 @@
<ClInclude
Include=
"CivTypes.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivTableTemp.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivCommonUtils.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
...
...
@@ -48,6 +45,9 @@
<ClInclude
Include=
"CivSimuResDbHelper.h"
>
<Filter>
源文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivTableFields.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivCommonUtils.cpp"
>
...
...
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