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
7a2c9a7e
Commit
7a2c9a7e
authored
Jun 24, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,水力模型水质模拟
parent
6f8296c6
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
514 additions
and
191 deletions
+514
-191
EPNAET2.vcxproj
EPNAET2/EPNAET2.vcxproj
+4
-3
main.cpp
funcDemo/main.cpp
+6
-6
CivAssembly.cpp
pandaAnalysis/CivAssembly.cpp
+1
-1
CivAssembly.h
pandaAnalysis/CivAssembly.h
+4
-0
CivBuilder.cpp
pandaAnalysis/CivBuilder.cpp
+85
-8
CivBuilder.h
pandaAnalysis/CivBuilder.h
+45
-14
CivHydrCalc.cpp
pandaAnalysis/CivHydrCalc.cpp
+86
-37
CivHydrCalc.h
pandaAnalysis/CivHydrCalc.h
+15
-0
CivHydrFuncInter.cpp
pandaAnalysis/CivHydrFuncInter.cpp
+6
-6
CivInpDirector.cpp
pandaAnalysis/CivInpDirector.cpp
+8
-7
CivInpDirector.h
pandaAnalysis/CivInpDirector.h
+2
-0
CivSimulResultCache.cpp
pandaAnalysis/CivSimulResultCache.cpp
+62
-0
CivSimulResultCache.h
pandaAnalysis/CivSimulResultCache.h
+58
-0
pandaAnalysis.vcxproj
pandaAnalysis/pandaAnalysis.vcxproj
+2
-0
pandaAnalysis.vcxproj.filters
pandaAnalysis/pandaAnalysis.vcxproj.filters
+7
-0
CivDbConn.cpp
pandaDbManager/CivDbConn.cpp
+93
-93
CivDbConn.h
pandaDbManager/CivDbConn.h
+2
-2
CivDbConnection.cpp
pandaDbManager/CivDbConnection.cpp
+16
-10
CivDbConnection.h
pandaDbManager/CivDbConnection.h
+9
-0
CivPgConn.h
pandaDbManager/CivPgConn.h
+1
-1
CivTypes.h
pandaDbManager/CivTypes.h
+2
-3
水力模型.docx
建模文档/水力模型.docx
+0
-0
No files found.
EPNAET2/EPNAET2.vcxproj
View file @
7a2c9a7e
...
...
@@ -49,7 +49,7 @@
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
fals
e
</WholeProgramOptimization>
<WholeProgramOptimization>
tru
e
</WholeProgramOptimization>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
...
...
@@ -142,13 +142,14 @@ copy epanet2.h $(OutDir)..\include /y</Command>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
_CRT_SECURE_NO_WARNINGS
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<Optimization>
Disabled
</Optimization>
<Optimization>
MaxSpeed
</Optimization>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
fals
e
</GenerateDebugInformation>
<GenerateDebugInformation>
tru
e
</GenerateDebugInformation>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<ImportLibrary>
$(OutDir)..\lib\$(TargetName).lib
</ImportLibrary>
...
...
funcDemo/main.cpp
View file @
7a2c9a7e
...
...
@@ -21,17 +21,17 @@ int main(int argc, char* argv[])
const
char
netName
[
128
]
=
"水力模型管网"
;
strcpy_s
(
net
,
"水力模型管网"
);
strcpy_s
(
flag
,
"
HD
Y"
);
strcpy_s
(
flag
,
"
QUALIT
Y"
);
//
bool msg = simulation(findUri, net, flag);
//
std::cout << msg << std::endl;
const
char
*
date
=
"2020-06-19"
;
bool
msg
=
simulation
(
findUri
,
net
,
flag
);
std
::
cout
<<
msg
<<
std
::
endl
;
getchar
();
/*
const char* date = "2020-06-19";
char* dates = const_cast<char*>(date);
const char* interval = "0";
char* intervals = const_cast<char*>(interval);
getDataByInterval
(
findUri
,
dates
,
intervals
);
getDataByInterval(findUri, dates, intervals);
*/
// std::cout << flag << std::endl;
return
0
;
...
...
pandaAnalysis/CivAssembly.cpp
View file @
7a2c9a7e
...
...
@@ -12,7 +12,7 @@ void CivNode::addItem(NodeTable table)
void
CivNode
::
addItems
(
std
::
list
<
NodeTable
>
tables
)
{
//mTables.merge(tables);
//
mTables.merge(tables);
}
void
CivPipe
::
addItem
(
PipesTable
table
)
...
...
pandaAnalysis/CivAssembly.h
View file @
7a2c9a7e
...
...
@@ -10,6 +10,10 @@ class CivTank;
class
CivValve
;
class
CivPumps
;
class
CivEmitters
;
class
CivCoordinates
;
class
CivMixing
;
class
CivLabels
;
class
CivTags
;
/**
管网基本组件
...
...
pandaAnalysis/CivBuilder.cpp
View file @
7a2c9a7e
...
...
@@ -386,37 +386,37 @@ void CivInpBuilder::builder(StrQuote table, CivInp& inp)
}
}
void
CivInpBuilder
::
build
er
Node
()
void
CivInpBuilder
::
buildNode
()
{
mDbConn
->
getComponets
(
PIPENODE
);
}
void
CivInpBuilder
::
build
er
Pipe
()
void
CivInpBuilder
::
buildPipe
()
{
}
void
CivInpBuilder
::
build
er
Tank
()
void
CivInpBuilder
::
buildTank
()
{
}
void
CivInpBuilder
::
build
er
Vavle
()
void
CivInpBuilder
::
buildVavle
()
{
}
void
CivInpBuilder
::
build
er
Pump
()
void
CivInpBuilder
::
buildPump
()
{
}
void
CivInpBuilder
::
build
er
Reservoir
()
void
CivInpBuilder
::
buildReservoir
()
{
}
void
CivInpBuilder
::
build
er
Emitter
()
void
CivInpBuilder
::
buildEmitter
()
{
}
...
...
@@ -425,3 +425,79 @@ CivNewInp* CivInpBuilder::getNewInp()
{
}
void
CivInpBuilder
::
buildPatterns
()
{
}
void
CivInpBuilder
::
buildParamter
()
{
}
void
CivInpBuilder
::
buildCoordnates
()
{
}
void
CivInpBuilder
::
buildVertices
()
{
}
void
CivInpBuilder
::
buildLabels
()
{
}
void
CivInpBuilder
::
buildTags
()
{
}
void
CivInpBuilder
::
buildBackDrop
()
{
}
void
CivInpBuilder
::
buildQuality
()
{
}
void
CivInpBuilder
::
buildSources
()
{
}
void
CivInpBuilder
::
buildMixing
()
{
}
void
CivInpBuilder
::
buildCurves
()
{
}
void
CivInpBuilder
::
buildStatus
()
{
}
void
CivInpBuilder
::
buildControls
()
{
}
void
CivInpBuilder
::
buildRules
()
{
}
void
CivInpBuilder
::
buildDemands
()
{
}
\ No newline at end of file
pandaAnalysis/CivBuilder.h
View file @
7a2c9a7e
...
...
@@ -10,13 +10,29 @@
class
CivBuilder
{
public
:
virtual
void
builderNode
()
=
0
;
virtual
void
builderPipe
()
=
0
;
virtual
void
builderTank
()
=
0
;
virtual
void
builderVavle
()
=
0
;
virtual
void
builderPump
()
=
0
;
virtual
void
builderReservoir
()
=
0
;
virtual
void
builderEmitter
()
=
0
;
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
buildParamter
()
=
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
;
virtual
CivNewInp
*
getNewInp
()
=
0
;
};
...
...
@@ -46,13 +62,28 @@ public:
*/
void
builder
(
StrQuote
table
,
CivInp
&
inp
);
virtual
void
builderNode
();
virtual
void
builderPipe
();
virtual
void
builderTank
()
;
virtual
void
builderVavle
();
virtual
void
builderPump
();
virtual
void
builderReservoir
()
;
virtual
void
builderEmitter
();
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
();
virtual
CivNewInp
*
getNewInp
();
private
:
...
...
pandaAnalysis/CivHydrCalc.cpp
View file @
7a2c9a7e
...
...
@@ -98,53 +98,51 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
if
(
!
exportInp
(
inpFile
))
return
false
;
short
hydCode
=
1
;
// 运行水质运算需要先进行水力运算,没有直接采用ENSolveH 是为了考虑减压阀的压力曲线设置
long
t
(
0
),
tstep
(
0
);
int
iTime
(
0
);
int
errcode
=
0
;
errcode
=
ENopen
(
inpFile
,
rptFile
,
binOutFile
);
if
(
errcode
>
0
)
{
ENclose
();
return
false
;
}
if
(
ENopenH
()
>
0
)
errcode
=
ENopenH
();
if
(
errcode
>
0
)
{
ENclose
();
return
false
;
}
if
(
ENinitH
(
0
)
>
0
)
// 根据类型 更改值
errcode
=
ENinitH
(
EN_SAVE
);
if
(
errcode
>
0
)
{
ENcloseH
();
ENclose
();
return
false
;
}
float
dHStep
;
ENGetVal
(
4
,
&
dHStep
);
bool
isFirst
=
true
;
// 计算
do
{
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
/*for (int i = 1; i <= nLinkCount; i++)
{
int linkType;
char id[128] = "";
ENgetlinktype(i, &linkType);
ENgetlinkid(i, id);
}*/
if
(
ENrunH
(
&
t
)
>
100
)
// errcode > 100 是错误
errcode
=
ENrunH
(
&
t
);
// errcode > 100 是错误
if
(
errcode
>
100
)
{
ENopenQ
();
ENclose
();
return
false
;
}
ENnextH
(
&
tstep
);
if
(
isFirst
)
{
mDbConn
->
deleteByDate
(
NODERESULTTABLE
,
"日期"
,
CurrentDate
);
...
...
@@ -154,18 +152,14 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
// 获取当前节点和管段数据
getNodeResult
(
iTime
);
getLinkResult
(
iTime
);
ENnextH
(
&
tstep
);
iTime
++
;
}
while
(
tstep
>
0
);
// 更新管网数据库数据
(
void
)
mDbConn
->
updateNodeByInterval
(
CurrentDate
,
"0"
);
(
void
)
mDbConn
->
updateLinkByInterval
(
CurrentDate
,
"0"
);
}
while
(
tstep
>
0
);
ENcloseH
();
// 运行水质运算需要先进行水力运算
errcode
=
0
;
// 进行水质分析
ENopenQ
();
ENinitQ
(
1
);
...
...
@@ -173,8 +167,6 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
t
=
0
;
tstep
=
0
;
iTime
=
0
;
errcode
=
0
;
do
{
errcode
=
ENrunQ
(
&
t
);
// errcode > 100 是错误
...
...
@@ -185,7 +177,9 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
return
false
;
}
// 存储水质计算结果
// 获取水质模拟结果
getNodeQuality
(
iTime
);
getLinkQuality
(
iTime
);
ENstepQ
(
&
tstep
);
...
...
@@ -196,6 +190,16 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
ENcloseQ
();
ENclose
();
// 更新数据
if
(
mResultCache
.
updateToDb
(
mDbConn
))
return
false
;
// 更新管网数据库数据
(
void
)
mDbConn
->
updateNodeByInterval
(
CurrentDate
,
"0"
);
(
void
)
mDbConn
->
updateLinkByInterval
(
CurrentDate
,
"0"
);
return
true
;
}
...
...
@@ -577,7 +581,6 @@ void CivHydrCalc::getNodeResult(short time)
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
NodeResultItems
nodeItems
;
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
NodeResultItem
nodeItem
;
...
...
@@ -599,14 +602,14 @@ void CivHydrCalc::getNodeResult(short time)
ENgetnodevalue
(
i
,
EN_MAXVOLUME
,
&
nodeItem
.
dTankMaxVolume
);
// 液位高度
ENgetnodevalue
(
i
,
EN_TANKLEVEL
,
&
nodeItem
.
dTankLevel
);
// 水质
ENgetnodevalue
(
i
,
EN_QUALITY
,
&
nodeItem
.
dQuality
);
//
//
水质
//
ENgetnodevalue(i, EN_QUALITY, &nodeItem.dQuality);
nodeItem
.
dInterval
=
time
;
nodeItems
.
push_back
(
nodeItem
);
// 放到缓存类中
mResultCache
.
addNodeItems
(
nodeItem
);
}
mDbConn
->
updateNode
(
nodeItems
);
}
void
CivHydrCalc
::
getLinkResult
(
short
time
)
...
...
@@ -614,7 +617,6 @@ void CivHydrCalc::getLinkResult(short time)
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
LinkResultItems
linkItems
;
for
(
int
i
=
1
;
i
<=
nLinkCount
;
i
++
)
{
LinkResultItem
linkItem
;
...
...
@@ -651,8 +653,7 @@ void CivHydrCalc::getLinkResult(short time)
ENgetnodevalue
(
node1
,
EN_HEAD
,
&
linkItem
.
dFromNodHeadloss
);
// 本点水头
ENgetnodevalue
(
node2
,
EN_HEAD
,
&
linkItem
.
dToNodHeadloss
);
// 水质
ENgetlinkvalue
(
i
,
EN_LINKQUAL
,
&
linkItem
.
dQuality
);
// 局部水头损失
float
fCoeff
;
ENgetlinkvalue
(
i
,
EN_MINORLOSS
,
&
fCoeff
);
...
...
@@ -671,8 +672,56 @@ void CivHydrCalc::getLinkResult(short time)
strcpy_s
(
linkItem
.
szStatus
,
"开启"
);
linkItem
.
dInterval
=
time
;
// 放到缓存类中
mResultCache
.
addLinkItems
(
linkItem
);
}
}
void
CivHydrCalc
::
getNodeQuality
(
short
time
)
{
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
char
No
[
35
];
// 编号
ENgetnodeid
(
i
,
No
);
float
*
quality
=
(
float
*
)
malloc
(
sizeof
(
float
));
// 水质
ENgetnodevalue
(
i
,
EN_QUALITY
,
quality
);
mResultCache
.
addNodeQuality
(
*
quality
,
time
,
No
);
free
(
quality
);
}
}
void
CivHydrCalc
::
getLinkQuality
(
short
time
)
{
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
for
(
int
i
=
1
;
i
<=
nLinkCount
;
i
++
)
{
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
ENgetlinktype
(
i
,
typeCode
);
if
(
*
typeCode
!=
EN_PIPE
)
{
free
(
typeCode
);
continue
;
}
free
(
typeCode
);
char
lnkNo
[
35
];
// 编号
ENgetlinkid
(
i
,
lnkNo
);
float
*
quality
=
(
float
*
)
malloc
(
sizeof
(
float
));
// 水质
ENgetlinkvalue
(
i
,
EN_LINKQUAL
,
quality
);
linkItems
.
push_back
(
linkItem
);
mResultCache
.
addLinkQuality
(
*
quality
,
time
,
lnkNo
);
free
(
quality
);
}
mDbConn
->
updateLink
(
linkItems
);
}
pandaAnalysis/CivHydrCalc.h
View file @
7a2c9a7e
...
...
@@ -2,6 +2,7 @@
#include<string>
#include<set>
#include "CivInp.h"
#include "CivSimulResultCache.h"
class
CivDbConnection
;
...
...
@@ -58,9 +59,23 @@ private:
*/
void
getLinkResult
(
short
time
);
/*
*@brief 获取节点的水质计算结果
*@time: 时间
*/
void
getNodeQuality
(
short
time
);
/*
*@brief 获取管线水值计算结果
*@time: 时间
*/
void
getLinkQuality
(
short
time
);
private
:
CivDbConnection
*
mDbConn
;
std
::
string
mNetname
;
CivSimulResultCache
mResultCache
;
// 存储模拟结果缓存类
};
pandaAnalysis/CivHydrFuncInter.cpp
View file @
7a2c9a7e
...
...
@@ -4,13 +4,13 @@
bool
DLLEXPORT
simulation
(
char
*
uri
,
char
*
netName
,
char
*
flag
)
{
char
fileName
[
2
0
];
char
rptR
[
2
0
];
char
outBinFile
[
2
0
];
char
fileName
[
2
56
];
char
rptR
[
2
56
];
char
outBinFile
[
2
56
];
strcpy_s
(
fileName
,
"test.inp"
);
strcpy_s
(
rptR
,
"test.rpt"
);
strcpy_s
(
outBinFile
,
"test.bin"
);
strcpy_s
(
fileName
,
"
E:
\\
work
\\
workspace
\\
hydraulicModelCode
\\
hydraulicModel
\\
funcDemo
\\
test.inp"
);
strcpy_s
(
rptR
,
"
E:
\\
work
\\
workspace
\\
hydraulicModelCode
\\
hydraulicModel
\\
funcDemo
\\
test.rpt"
);
strcpy_s
(
outBinFile
,
"
E:
\\
work
\\
workspace
\\
hydraulicModelCode
\\
hydraulicModel
\\
funcDemo
\\
test.bin"
);
CivHydrCalc
*
calc
=
new
CivHydrCalc
(
uri
,
netName
);
...
...
pandaAnalysis/CivInpDirector.cpp
View file @
7a2c9a7e
...
...
@@ -3,11 +3,11 @@
void
CivInpDirector
::
create
(
CivBuilder
*
builder
)
{
builder
->
build
er
Node
();
builder
->
build
er
Pipe
();
builder
->
build
er
Tank
();
builder
->
build
er
Reservoir
();
builder
->
build
er
Pump
();
builder
->
build
er
Vavle
();
builder
->
build
er
Emitter
();
builder
->
buildNode
();
builder
->
buildPipe
();
builder
->
buildTank
();
builder
->
buildReservoir
();
builder
->
buildPump
();
builder
->
buildVavle
();
builder
->
buildEmitter
();
}
\ No newline at end of file
pandaAnalysis/CivInpDirector.h
View file @
7a2c9a7e
...
...
@@ -9,5 +9,7 @@ class CivInpDirector
public
:
void
create
(
CivBuilder
*
builder
);
};
#endif // !CIVINPDIRECTOR_H
pandaAnalysis/CivSimulResultCache.cpp
0 → 100644
View file @
7a2c9a7e
#include "CivSimulResultCache.h"
void
CivSimulResultCache
::
addNodeQuality
(
float
quality
,
int
interval
,
Str
sNo
)
{
if
(
mNodeItemsMap
.
find
(
interval
)
==
mNodeItemsMap
.
end
())
return
;
auto
nodeMap
=
mNodeItemsMap
.
find
(
interval
)
->
second
;
if
(
nodeMap
.
find
(
sNo
)
==
nodeMap
.
end
())
return
;
mNodeItemsMap
[
interval
][
sNo
].
dQuality
=
quality
;
}
void
CivSimulResultCache
::
addLinkQuality
(
float
quality
,
int
interval
,
Str
sNo
)
{
if
(
mLinkItemsMap
.
find
(
interval
)
==
mLinkItemsMap
.
end
())
return
;
auto
linkMap
=
mLinkItemsMap
.
find
(
interval
)
->
second
;
if
(
linkMap
.
find
(
sNo
)
==
linkMap
.
end
())
return
;
mLinkItemsMap
[
interval
][
sNo
].
dQuality
=
quality
;
}
void
CivSimulResultCache
::
addNodeItems
(
const
NodeResultItem
&
nodeItem
)
{
mNodeItemsMap
[
nodeItem
.
dInterval
][
nodeItem
.
szNo
]
=
nodeItem
;
}
void
CivSimulResultCache
::
addLinkItems
(
const
LinkResultItem
&
linkItem
)
{
mLinkItemsMap
[
linkItem
.
dInterval
][
linkItem
.
szNo
]
=
linkItem
;
}
bool
CivSimulResultCache
::
updateToDb
(
CivDbConnection
*
dbConn
)
{
if
(
dbConn
==
nullptr
)
return
false
;
for
(
auto
iter
=
mNodeItemsMap
.
begin
();
iter
!=
mNodeItemsMap
.
end
();
iter
++
)
{
NodeResultItems
nodeItems
=
iter
->
second
;
dbConn
->
updateNode
(
nodeItems
);
}
for
(
auto
iter
=
mLinkItemsMap
.
begin
();
iter
!=
mLinkItemsMap
.
end
();
iter
++
)
{
LinkResultItems
nodeItems
=
iter
->
second
;
dbConn
->
updateLink
(
nodeItems
);
}
clear
();
return
true
;
}
void
CivSimulResultCache
::
clear
()
{
mLinkItemsMap
.
clear
();
mNodeItemsMap
.
clear
();
}
pandaAnalysis/CivSimulResultCache.h
0 → 100644
View file @
7a2c9a7e
#ifndef CIVSIMULRESULTCACHE_H
#define CIVSIMULRESULTCACHE_H
#include <map>
#include "CivDbConn.h"
#include "CivDbConnection.h"
#include "CivTypes.h"
/**
模拟结果缓存类
*/
class
CivSimulResultCache
{
public
:
/**
*@brief 缓存节点水质
*@quality:存储的值
*@interval:模拟第几次
*@sNo:本点号
*/
void
addNodeQuality
(
float
quality
,
int
interval
,
Str
sNo
);
/**
*@brief 缓存管线水质
*@quality:存储的值
*@interval:模拟第几次
*@sNo:管线编号
*/
void
addLinkQuality
(
float
quality
,
int
interval
,
Str
sNo
);
/**
*@brief 缓存节点水力模拟情况
*@nodeItem:节点水力结果值
*/
void
addNodeItems
(
const
NodeResultItem
&
nodeItem
);
/**
*@brief 缓存管线水力模拟情况
*@linkItem:管线模拟结果
*/
void
addLinkItems
(
const
LinkResultItem
&
linkItem
);
/**
*@brief 释放缓存的结果值
*/
void
clear
();
/**
*@brief 缓存数据更新到数据库
*@dbConn:数据库连接对象
*/
bool
updateToDb
(
CivDbConnection
*
dbConn
);
private
:
std
::
map
<
int
,
NodeResultItems
>
mNodeItemsMap
;
// 模拟
std
::
map
<
int
,
LinkResultItems
>
mLinkItemsMap
;
// 计算的
};
#endif // !CIVSIMULRESULTCACHE_H
pandaAnalysis/pandaAnalysis.vcxproj
View file @
7a2c9a7e
...
...
@@ -160,6 +160,7 @@
<ClCompile
Include=
"CivBuilder.cpp"
/>
<ClCompile
Include=
"CivInpDirector.cpp"
/>
<ClCompile
Include=
"CivNewInp.cpp"
/>
<ClCompile
Include=
"CivSimulResultCache.cpp"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivAssembly.h"
/>
...
...
@@ -169,6 +170,7 @@
<ClInclude
Include=
"CivBuilder.h"
/>
<ClInclude
Include=
"CivInpDirector.h"
/>
<ClInclude
Include=
"CivNewInp.h"
/>
<ClInclude
Include=
"CivSimulResultCache.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
...
...
pandaAnalysis/pandaAnalysis.vcxproj.filters
View file @
7a2c9a7e
...
...
@@ -39,6 +39,9 @@
<ClCompile
Include=
"CivNewInp.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivSimulResultCache.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivHydrCalc.h"
>
...
...
@@ -62,5 +65,8 @@
<ClInclude
Include=
"CivInpDirector.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivSimulResultCache.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
pandaDbManager/CivDbConn.cpp
View file @
7a2c9a7e
...
...
@@ -178,36 +178,36 @@ bool CivDbConn::updateNode(const NodeResultItems& nodeItems)
os
.
clear
();
os
.
str
(
""
);
// 2, 参数值
size_t
total
=
nodeItems
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
NodeResultItem
item
=
nodeItems
[
i
];
os
<<
"('"
<<
item
.
szNo
<<
"',"
;
os
<<
item
.
dDemand
<<
","
;
os
<<
item
.
dHead
<<
","
;
os
<<
item
.
dElevation
<<
","
;
os
<<
item
.
dPressure
<<
","
;
os
<<
item
.
dTankLevel
<<
","
;
os
<<
item
.
dTankMaxVolume
<<
","
;
os
<<
item
.
dTankVolume
<<
","
;
os
<<
"'"
<<
CurrentDate
<<
"',"
;
os
<<
item
.
dInterval
<<
","
;
os
<<
"'"
<<
CurrentTime
<<
"'"
;
if
(
i
==
(
total
-
1
))
{
os
<<
")"
;
}
else
{
os
<<
"),"
;
}
}
std
::
string
sql
=
TransUTFCoding
(
preSql
)
+
os
.
str
();
os
.
clear
();
os
.
str
(
""
);
if
(
!
execSql
(
sql
))
return
false
;
//
//
2, 参数值
//
size_t total = nodeItems.size();
//
for (int i = 0; i < total; i++)
//
{
//
NodeResultItem item = nodeItems[i];
//
os << "('" << item.szNo << "',";
//
os << item.dDemand << ",";
//
os << item.dHead << ",";
//
os << item.dElevation << ",";
//
os << item.dPressure << ",";
//
os << item.dTankLevel << ",";
//
os << item.dTankMaxVolume << ",";
//
os << item.dTankVolume << ",";
//
os << "'" << CurrentDate << "',";
//
os << item.dInterval << ",";
//
os << "'" << CurrentTime << "'";
//
if (i == (total - 1))
//
{
//
os << ")";
//
}
//
else
//
{
//
os << "),";
//
}
//
}
//
std::string sql = TransUTFCoding(preSql) + os.str();
//
os.clear();
//
os.str("");
//
if (!execSql(sql))
//
return false;
}
return
true
;
...
...
@@ -218,69 +218,69 @@ bool CivDbConn::updateLink(const LinkResultItems& lineItems)
if
(
!
isValid
())
return
false
;
std
::
stringstream
os
;
LinkFiledName
filedNames
;
std
::
string
currData
=
CurrentDate
;
if
(
createTable
(
PIPERESULTTABLE
,
"public"
,
CivTableTemp
::
PIPE_TABLE
))
{
os
<<
"INSERT INTO public."
<<
PIPERESULTTABLE
<<
"( "
;
os
<<
filedNames
.
szNo
<<
","
;
os
<<
filedNames
.
dFlow
<<
","
;
os
<<
filedNames
.
nFlowDirect
<<
","
;
os
<<
filedNames
.
dVelocity
<<
","
;
os
<<
filedNames
.
dHeadloss
<<
","
;
os
<<
filedNames
.
dUnitHeadloss
<<
","
;
os
<<
filedNames
.
dFromNodHeadloss
<<
","
;
os
<<
filedNames
.
dToNodHeadloss
<<
","
;
os
<<
filedNames
.
dLocalHeadloss
<<
","
;
os
<<
filedNames
.
dFrictionHeadloss
<<
","
;
os
<<
filedNames
.
szStatus
<<
","
;
os
<<
filedNames
.
dDate
<<
","
;
os
<<
filedNames
.
dInterval
<<
","
;
os
<<
filedNames
.
dModifyTime
;
os
<<
") VALUES"
;
std
::
string
preSql
=
os
.
str
();
os
.
clear
();
os
.
str
(
""
);
// 2, 参数值
size_t
total
=
lineItems
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
LinkResultItem
item
=
lineItems
[
i
];
os
<<
"('"
<<
item
.
szNo
<<
"'"
<<
","
;
os
<<
item
.
dFlow
<<
","
;
os
<<
item
.
nFlowDirect
<<
","
;
os
<<
item
.
dVelocity
<<
","
;
os
<<
item
.
dHeadloss
<<
","
;
os
<<
item
.
dUnitHeadloss
<<
","
;
os
<<
item
.
dFromNodHeadloss
<<
","
;
os
<<
item
.
dToNodHeadloss
<<
","
;
os
<<
item
.
dLocalHeadloss
<<
","
;
os
<<
item
.
dFrictionHeadloss
<<
","
;
os
<<
"'"
<<
TransUTFCoding
(
item
.
szStatus
)
<<
"'"
<<
","
;
os
<<
"'"
<<
CurrentDate
<<
"',"
;
os
<<
item
.
dInterval
<<
","
;
os
<<
"'"
<<
CurrentTime
<<
"'"
;
if
(
i
==
(
total
-
1
))
os
<<
")"
;
else
os
<<
"),"
;
}
std
::
string
utf8Sql
=
TransUTFCoding
(
preSql
);
std
::
string
sql
=
utf8Sql
+
os
.
str
();
os
.
clear
();
os
.
str
(
""
);
if
(
!
execSql
(
sql
))
return
false
;
}
//
std::stringstream os;
//
LinkFiledName filedNames;
//
std::string currData = CurrentDate;
//
if (createTable(PIPERESULTTABLE, "public", CivTableTemp::PIPE_TABLE))
//
{
//
os << "INSERT INTO public." << PIPERESULTTABLE << "( ";
//
os << filedNames.szNo << ",";
//
os << filedNames.dFlow << ",";
//
os << filedNames.nFlowDirect << ",";
//
os << filedNames.dVelocity << ",";
//
os << filedNames.dHeadloss << ",";
//
os << filedNames.dUnitHeadloss << ",";
//
os << filedNames.dFromNodHeadloss << ",";
//
os << filedNames.dToNodHeadloss << ",";
//
os << filedNames.dLocalHeadloss << ",";
//
os << filedNames.dFrictionHeadloss << ",";
//
os << filedNames.szStatus << ",";
//
os << filedNames.dDate << ",";
//
os << filedNames.dInterval << ",";
//
os << filedNames.dModifyTime;
//
os << ") VALUES";
//
std::string preSql = os.str();
//
os.clear();
//
os.str("");
//
// 2, 参数值
//
size_t total = lineItems.size();
//
for (int i = 0; i < total; i++)
//
{
//
LinkResultItem item = lineItems[i];
//
os << "('" << item.szNo << "'" << ",";
//
os << item.dFlow << ",";
//
os << item.nFlowDirect << ",";
//
os << item.dVelocity << ",";
//
os << item.dHeadloss << ",";
//
os << item.dUnitHeadloss << ",";
//
os << item.dFromNodHeadloss << ",";
//
os << item.dToNodHeadloss << ",";
//
os << item.dLocalHeadloss << ",";
//
os << item.dFrictionHeadloss << ",";
//
os << "'" << TransUTFCoding(item.szStatus) << "'" << ",";
//
os << "'" << CurrentDate << "',";
//
os << item.dInterval << ",";
//
os << "'" << CurrentTime << "'";
//
if (i == (total - 1))
//
os << ")";
//
else
//
os << "),";
//
}
//
std::string utf8Sql = TransUTFCoding(preSql);
//
std::string sql = utf8Sql + os.str();
//
os.clear();
//
os.str("");
//
if (!execSql(sql))
//
return false;
//
}
return
true
;
}
...
...
pandaDbManager/CivDbConn.h
View file @
7a2c9a7e
...
...
@@ -3,11 +3,11 @@
#include "CivTypes.h"
#include "CivTableTemp.h"
#define DBEXPORT __declspec(dllexport)
/**
数据库连接接口
*/
class
CivDbConn
class
DBEXPORT
CivDbConn
{
public
:
CivDbConn
();
...
...
pandaDbManager/CivDbConnection.cpp
View file @
7a2c9a7e
...
...
@@ -122,6 +122,7 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
os
<<
filedNames
.
dTankVolume
<<
","
;
os
<<
filedNames
.
dDate
<<
","
;
os
<<
filedNames
.
dInterval
<<
","
;
os
<<
filedNames
.
dQuality
<<
","
;
os
<<
filedNames
.
dModifyTime
;
os
<<
") VALUES"
;
...
...
@@ -131,10 +132,9 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
os
.
str
(
""
);
// 2, 参数值
size_t
total
=
nodeItems
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
for
(
auto
iter
=
nodeItems
.
begin
();
iter
!=
nodeItems
.
end
();
iter
++
)
{
NodeResultItem
item
=
nodeItems
[
i
]
;
NodeResultItem
item
=
iter
->
second
;
os
<<
"('"
<<
item
.
szNo
<<
"',"
;
os
<<
item
.
dDemand
<<
","
;
os
<<
item
.
dHead
<<
","
;
...
...
@@ -145,8 +145,12 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
os
<<
item
.
dTankVolume
<<
","
;
os
<<
"'"
<<
CurrentDate
<<
"',"
;
os
<<
item
.
dInterval
<<
","
;
os
<<
item
.
dQuality
<<
","
;
os
<<
"'"
<<
CurrentTime
<<
"'"
;
if
(
i
==
(
total
-
1
))
auto
subiter
=
iter
;
++
subiter
;
if
(
subiter
==
nodeItems
.
end
())
{
os
<<
")"
;
}
...
...
@@ -190,6 +194,7 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
os
<<
filedNames
.
szStatus
<<
","
;
os
<<
filedNames
.
dDate
<<
","
;
os
<<
filedNames
.
dInterval
<<
","
;
os
<<
filedNames
.
dQuality
<<
","
;
os
<<
filedNames
.
dModifyTime
;
os
<<
") VALUES"
;
...
...
@@ -197,13 +202,10 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
os
.
clear
();
os
.
str
(
""
);
// 2, 参数值
size_t
total
=
lineItems
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
for
(
auto
iter
=
lineItems
.
begin
();
iter
!=
lineItems
.
end
();
iter
++
)
{
LinkResultItem
item
=
lineItems
[
i
]
;
LinkResultItem
item
=
iter
->
second
;
os
<<
"('"
<<
item
.
szNo
<<
"'"
<<
","
;
os
<<
item
.
dFlow
<<
","
;
os
<<
item
.
nFlowDirect
<<
","
;
...
...
@@ -217,8 +219,12 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
os
<<
"'"
<<
TransUTFCoding
(
item
.
szStatus
)
<<
"'"
<<
","
;
os
<<
"'"
<<
CurrentDate
<<
"',"
;
os
<<
item
.
dInterval
<<
","
;
os
<<
item
.
dQuality
<<
","
;
os
<<
"'"
<<
CurrentTime
<<
"'"
;
if
(
i
==
(
total
-
1
))
auto
subIte
=
iter
;
++
subIte
;
if
(
subIte
==
lineItems
.
end
())
os
<<
")"
;
else
os
<<
"),"
;
...
...
pandaDbManager/CivDbConnection.h
View file @
7a2c9a7e
...
...
@@ -55,6 +55,15 @@ public:
bool
updateNodeByInterval
(
StrQuote
currDate
,
StrQuote
interval
);
bool
updateLinkByInterval
(
StrQuote
currDate
,
StrQuote
interval
);
/**
*@brief 刷新模拟的水质字段值
*@quality: 水质
*@currDate: 模拟的日期
*@StrQuote: 模拟的次数
*/
bool
updateNodeQuality
(
const
NodeResultItems
&
nodeItems
);
bool
updatePipeQuality
(
const
LinkResultItems
&
lineItems
);
/**
*@brief 更新点表数据
*@nodeItems:需要更新的值
...
...
pandaDbManager/CivPgConn.h
View file @
7a2c9a7e
...
...
@@ -4,7 +4,7 @@
#include "CivDbConn.h"
#include <libpq-fe.h>
#define DBEXPORT __declspec(dllexport)
/**
postgress 数据库
*/
...
...
pandaDbManager/CivTypes.h
View file @
7a2c9a7e
...
...
@@ -171,7 +171,6 @@ struct CurvesFields {
};
// 参数选项表
struct
ParameterFileds
{
Str
name
=
"参数名"
;
Str
val
=
"参数值"
;
...
...
@@ -274,8 +273,8 @@ struct LinkResultItem
int
dInterval
;
// 时段
};
#define NodeResultItems std::
vector<
NodeResultItem>
#define LinkResultItems std::
vector<
LinkResultItem>
#define NodeResultItems std::
map<Str,
NodeResultItem>
#define LinkResultItems std::
map<Str,
LinkResultItem>
#endif // !CIVTYPES_H
...
...
建模文档/水力模型.docx
View file @
7a2c9a7e
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