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
5acd729c
Commit
5acd729c
authored
Aug 12, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,代码整理
parent
125f003e
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
948 additions
and
453 deletions
+948
-453
CivHydrTest.cpp
funcDemo/CivHydrTest.cpp
+0
-24
CivHydrTest.h
funcDemo/CivHydrTest.h
+0
-7
main.cpp
funcDemo/main.cpp
+1
-1
CivBaseInpBuilder.cpp
pandaAnalysis/CivBaseInpBuilder.cpp
+1
-1
CivHydrCompute.cpp
pandaAnalysis/CivHydrCompute.cpp
+169
-71
CivHydrCompute.h
pandaAnalysis/CivHydrCompute.h
+17
-4
CivHydrFuncInter.cpp
pandaAnalysis/CivHydrFuncInter.cpp
+26
-17
CivHydrFuncInter.h
pandaAnalysis/CivHydrFuncInter.h
+0
-13
CivHydrSimulation.cpp
pandaAnalysis/CivHydrSimulation.cpp
+34
-48
CivHydrSimulation.h
pandaAnalysis/CivHydrSimulation.h
+4
-10
CivInpBuilder.cpp
pandaAnalysis/CivInpBuilder.cpp
+4
-5
CivInpBuilder.h
pandaAnalysis/CivInpBuilder.h
+1
-1
CivInpConvertor.cpp
pandaAnalysis/CivInpConvertor.cpp
+19
-3
CivSimulResultCache.cpp
pandaAnalysis/CivSimulResultCache.cpp
+57
-22
CivSimulResultCache.h
pandaAnalysis/CivSimulResultCache.h
+20
-16
CivTrackingAnalysis.cpp
pandaAnalysis/CivTrackingAnalysis.cpp
+82
-100
CivTrackingAnalysis.h
pandaAnalysis/CivTrackingAnalysis.h
+2
-1
pandaAnalysis.vcxproj
pandaAnalysis/pandaAnalysis.vcxproj
+0
-2
pandaAnalysis.vcxproj.filters
pandaAnalysis/pandaAnalysis.vcxproj.filters
+0
-7
CivAssembly.h
pandaDbManager/CivAssembly.h
+1
-1
CivConnection.cpp
pandaDbManager/CivConnection.cpp
+57
-7
CivConnection.h
pandaDbManager/CivConnection.h
+3
-0
CivInpDbHelper.cpp
pandaDbManager/CivInpDbHelper.cpp
+18
-8
CivInpHelperAbs.cpp
pandaDbManager/CivInpHelperAbs.cpp
+1
-1
CivPgDbConnection.cpp
pandaDbManager/CivPgDbConnection.cpp
+8
-3
CivSimuResDbHelper.cpp
pandaDbManager/CivSimuResDbHelper.cpp
+0
-17
CivSimuResDbHelper.h
pandaDbManager/CivSimuResDbHelper.h
+0
-21
CivSimuResStruct.h
pandaDbManager/CivSimuResStruct.h
+24
-1
CivSimulResDbHelper.cpp
pandaDbManager/CivSimulResDbHelper.cpp
+160
-0
CivSimulResDbHelper.h
pandaDbManager/CivSimulResDbHelper.h
+26
-0
CivSimulResHelperAbs.cpp
pandaDbManager/CivSimulResHelperAbs.cpp
+37
-0
CivSimulResHelperAbs.h
pandaDbManager/CivSimulResHelperAbs.h
+28
-0
CivTableFields.h
pandaDbManager/CivTableFields.h
+6
-16
CivTypes.h
pandaDbManager/CivTypes.h
+1
-0
pandaDbManager.vcxproj
pandaDbManager/pandaDbManager.vcxproj
+9
-5
pandaDbManager.vcxproj.filters
pandaDbManager/pandaDbManager.vcxproj.filters
+13
-10
CivCommonUtils.cpp
pandaLog/CivCommonUtils.cpp
+14
-6
CivCommonUtils.h
pandaLog/CivCommonUtils.h
+5
-3
CivDate.cpp
pandaLog/CivDate.cpp
+58
-0
CivDate.h
pandaLog/CivDate.h
+22
-0
pandaLog.vcxproj
pandaLog/pandaLog.vcxproj
+7
-1
pandaLog.vcxproj.filters
pandaLog/pandaLog.vcxproj.filters
+13
-0
No files found.
funcDemo/CivHydrTest.cpp
View file @
5acd729c
...
...
@@ -10,12 +10,6 @@ void CivConHydrTest::test(char* uri)
std
::
cout
<<
"测试结果:"
<<
succ
<<
std
::
endl
;
}
// 模型维护
void
CivModelHydrTest
::
test
(
char
*
uri
)
{
int
succ
=
modelMatation
(
uri
);
std
::
cout
<<
"测试结果:"
<<
succ
<<
std
::
endl
;
}
// 水质测试
void
CivConQuaTest
::
test
(
char
*
uri
)
...
...
@@ -38,24 +32,6 @@ void CivConTrackTest::test(char* uri)
std
::
cout
<<
"测试结果:"
<<
succ
<<
std
::
endl
;
}
void
CivConGetRptTest
::
test
(
char
*
uri
)
{
std
::
string
condtion
=
"
\"
日期
\"
='2020-07-13' and
\"
时段
\"
=1"
;
std
::
string
type
=
"管段"
;
char
result
[
1024
*
128
];
char
newCondition
[
256
];
strcpy
(
newCondition
,
condtion
.
c_str
());
char
newType
[
32
];
strcpy
(
newType
,
type
.
c_str
());
bool
isSucc
=
getRptByCondition
(
uri
,
newType
,
newCondition
,
result
);
std
::
cout
<<
result
<<
std
::
endl
;
std
::
cout
<<
"测试结果:"
<<
isSucc
<<
std
::
endl
;
}
void
CivUpstreamTrackingTest
::
test
(
char
*
uri
)
{
// 追踪节点编号
...
...
funcDemo/CivHydrTest.h
View file @
5acd729c
...
...
@@ -7,13 +7,6 @@ public:
virtual
void
test
(
char
*
uri
)
=
0
;
};
// 模型监测和维护
class
CivModelHydrTest
:
public
CivHydrTest
{
public
:
virtual
void
test
(
char
*
uri
);
};
// 水力测试
class
CivConHydrTest
:
public
CivHydrTest
{
...
...
funcDemo/main.cpp
View file @
5acd729c
...
...
@@ -14,7 +14,7 @@ using namespace std;
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
uri
=
"host=192.168.1
2.7 port=5432 dbname=tese1111
user=postgres password=admin"
;
const
char
*
uri
=
"host=192.168.1
9.100 port=5432 dbname=JinXian
user=postgres password=admin"
;
char
*
findUri
=
const_cast
<
char
*>
(
uri
);
// 测试水力
...
...
pandaAnalysis/CivBaseInpBuilder.cpp
View file @
5acd729c
...
...
@@ -158,7 +158,7 @@ void CivBaseInpBuilder::buildQuality()
}
CivQuality
quality
;
if
(
!
mHelper
->
getQuality
(
quality
))
;
if
(
!
mHelper
->
getQuality
(
quality
))
return
;
mNewInp
->
setQuality
(
quality
);
...
...
pandaAnalysis/CivHydrCompute.cpp
View file @
5acd729c
#include "CivHydrCompute.h"
#include "CivSimuResStruct.h"
#include "CivCommonUtils.h"
#include "CivDate.h"
CivHydrCompute
::
CivHydrCompute
(
char
*
inp
,
char
*
rptFile
,
char
*
binFile
)
:
mInpFile
(
inp
),
mRptFile
(
rptFile
),
mBinFile
(
binFile
)
CivHydrCompute
::
CivHydrCompute
()
{
mInFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.inp"
;
mRptFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.rpt"
;
mBinFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.bin"
;
}
bool
CivHydrCompute
::
qualityCompute
()
...
...
@@ -14,7 +17,18 @@ bool CivHydrCompute::qualityCompute()
int
iTime
(
0
);
int
errcode
=
0
;
errcode
=
ENopen
(
mInpFile
,
mRptFile
,
mBinFile
);
char
inpFile
[
128
];
strcpy_s
(
inpFile
,
mInFile
.
c_str
());
char
rptFile
[
128
];
strcpy_s
(
rptFile
,
mRptFile
.
c_str
());
char
binFile
[
128
];
strcpy_s
(
binFile
,
mBinFile
.
c_str
());
errcode
=
ENopen
(
inpFile
,
rptFile
,
binFile
);
if
(
errcode
>
0
)
{
ENclose
();
...
...
@@ -105,8 +119,18 @@ bool CivHydrCompute::hdyrCompute()
int
iTime
(
0
);
int
errcode
=
0
;
char
inpFile
[
128
];
strcpy_s
(
inpFile
,
mInFile
.
c_str
());
char
rptFile
[
128
];
strcpy_s
(
rptFile
,
mRptFile
.
c_str
());
char
binFile
[
128
];
strcpy_s
(
binFile
,
mBinFile
.
c_str
());
errcode
=
ENopen
(
inpFile
,
rptFile
,
binFile
);
errcode
=
ENopen
(
mInpFile
,
mRptFile
,
mBinFile
);
if
(
errcode
>
0
)
{
ENclose
();
...
...
@@ -158,83 +182,97 @@ bool CivHydrCompute::hdyrCompute()
return
true
;
}
void
CivHydrCompute
::
dateAndTime
(
int
time
,
std
::
string
&
nowDate
,
std
::
string
&
nowTime
)
{
CivDate
civDate
;
nowDate
=
civDate
.
getDate
();
int
baseTime
=
CivCommonUtils
::
currentHour
();
int
a
=
baseTime
+
time
;
int
modulus
=
a
%
24
;
int
yu
=
a
/
24
;
if
(
yu
>
0
)
{
civDate
.
addDate
();
nowDate
=
civDate
.
getDate
();
a
=
modulus
;
}
if
(
modulus
<
10
)
nowTime
=
(
"0"
+
std
::
to_string
(
a
)
+
":00"
);
else
nowTime
=
(
std
::
to_string
(
a
)
+
":00"
);
}
void
CivHydrCompute
::
getNodeResult
(
short
time
)
{
// 计算节点
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
//
int* typeCode = (int*)malloc(sizeof(int));
std
::
string
nowDate
;
std
::
string
nowTime
;
dateAndTime
(
time
,
nowDate
,
nowTime
);
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
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
)
;
continu
e
;
}
else
{
//
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); // 液位高度
// tankItem.dDate = nowDate;
// tankItem.dTime = nowTime
;
// tankItem.dModifyTime = CurrentTim
e;
//
}
//
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
);
}
// nodeItem.dInterval = time;
// 放到缓存类中
//mResultCache.addNodeItems(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
);
// 实际需水量
nodeItem
.
dDate
=
nowDate
;
nodeItem
.
dTime
=
nowTime
;
nodeItem
.
dModifyTime
=
CurrentTime
;
mResultCache
.
addNodeItems
(
time
,
nodeItem
);
// }
}
free
(
typeCode
);
// 计算的水池
int
tankCount
;
// free(typeCode);
}
void
CivHydrCompute
::
getLinkResult
(
short
time
)
{
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
std
::
string
nowDate
;
std
::
string
nowTime
;
dateAndTime
(
time
,
nowDate
,
nowTime
);
for
(
int
i
=
1
;
i
<=
nLinkCount
;
i
++
)
{
LinkResultItem
linkItem
;
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
ENgetlinktype
(
i
,
typeCode
);
if
(
*
typeCode
!=
EN_PIPE
)
{
free
(
typeCode
);
continue
;
}
free
(
typeCode
);
// 编号
ENgetlinkid
(
i
,
linkItem
.
szNo
);
// 流量
ENgetlinkvalue
(
i
,
EN_FLOW
,
&
linkItem
.
dFlow
);
// 流速
ENgetlinkvalue
(
i
,
EN_
VELOCITY
,
&
linkItem
.
dVelocity
);
// 水头损失
ENgetlinkvalue
(
i
,
EN_HEADLOSS
,
&
linkItem
.
dHeadloss
);
ENgetlinkid
(
i
,
linkItem
.
szNo
);
// 编号
ENgetlinkvalue
(
i
,
EN_
FLOW
,
&
linkItem
.
dFlow
);
// 流量
ENgetlinkvalue
(
i
,
EN_VELOCITY
,
&
linkItem
.
dVelocity
);
// 流速
ENgetlinkvalue
(
i
,
EN_HEADLOSS
,
&
linkItem
.
dHeadloss
);
// 水头损失
// 状态
float
fState
=
0
;
...
...
@@ -244,10 +282,14 @@ void CivHydrCompute::getLinkResult(short time)
else
strcpy_s
(
linkItem
.
szStatus
,
"开启"
);
//linkItem.dInterval = time;
linkItem
.
dDate
=
nowDate
;
linkItem
.
dTime
=
nowTime
;
linkItem
.
dModifyTime
=
CurrentTime
;
// 放到缓存类中
// mResultCache.addLinkItems(
linkItem);
mResultCache
.
addLinkItems
(
time
,
linkItem
);
}
free
(
typeCode
);
}
void
CivHydrCompute
::
getNodeQuality
(
short
time
)
...
...
@@ -259,12 +301,11 @@ void CivHydrCompute::getNodeQuality(short time)
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
char
No
[
35
];
// 编号
ENgetnodeid
(
i
,
No
);
// 水质
ENgetnodevalue
(
i
,
EN_QUALITY
,
quality
);
ENgetnodeid
(
i
,
No
);
// 编号
ENgetnodevalue
(
i
,
EN_QUALITY
,
quality
);
// 水质
//
mResultCache.addNodeQuality(*quality, time, No);
mResultCache
.
addNodeQuality
(
*
quality
,
time
,
No
);
}
free
(
quality
);
}
...
...
@@ -281,13 +322,69 @@ void CivHydrCompute::getLinkQuality(short time)
ENgetlinktype
(
i
,
typeCode
);
char
lnkNo
[
35
];
// 编号
ENgetlinkid
(
i
,
lnkNo
);
char
lnkNo
[
35
];
ENgetlinkid
(
i
,
lnkNo
);
// 编号
float
quality
;
ENgetlinkvalue
(
i
,
EN_LINKQUAL
,
&
quality
);
// 水质
float
quality
;
// 水质
ENgetlinkvalue
(
i
,
EN_LINKQUAL
,
&
quality
);
mResultCache
.
addLinkQuality
(
quality
,
time
,
lnkNo
);
}
free
(
typeCode
);
}
void
CivHydrCompute
::
saveResult
(
const
std
::
string
&
uri
)
{
mResultCache
.
save
(
uri
);
}
void
CivHydrCompute
::
getTrackingResult
(
const
std
::
string
&
uri
,
std
::
string
&
jsonResult
)
{
PipeCoords
pipeCoords
;
mResultCache
.
getAllPipeCoords
(
uri
,
pipeCoords
);
// 查找
std
::
vector
<
std
::
vector
<
std
::
string
>>
pipeSns
;
mResultCache
.
getPipesSnsByQuality
(
pipeSns
);
jsonResult
.
append
(
"["
);
int
hours
=
pipeSns
.
size
();
for
(
int
i
=
0
;
i
<
hours
;
i
++
)
{
std
::
vector
<
std
::
string
>
pipeS
=
pipeSns
[
i
];
size_t
total
=
pipeS
.
size
();
if
(
total
<=
0
)
continue
;
jsonResult
.
append
(
"["
);
for
(
int
j
=
0
;
j
<
total
;
j
++
)
{
std
::
string
sn
=
pipeS
[
j
];
PipeCoord
pipe
=
pipeCoords
.
find
(
sn
)
->
second
;
jsonResult
.
append
(
"[["
);
jsonResult
.
append
(
pipe
.
startX
);
jsonResult
.
append
(
","
);
jsonResult
.
append
(
pipe
.
startY
);
jsonResult
.
append
(
"],["
);
jsonResult
.
append
(
pipe
.
endX
);
jsonResult
.
append
(
","
);
jsonResult
.
append
(
pipe
.
endY
);
jsonResult
.
append
(
"]],"
);
}
jsonResult
=
jsonResult
.
substr
(
0
,
jsonResult
.
length
()
-
1
);
jsonResult
.
append
(
"],"
);
}
jsonResult
=
jsonResult
.
substr
(
0
,
jsonResult
.
length
()
-
1
);
jsonResult
.
append
(
"]"
);
}
void
CivHydrCompute
::
getNodeItemByInterval
(
int
time
,
NodeResultItems
&
nodeItem
)
{
mResultCache
.
getNodeItemByInterval
(
time
,
nodeItem
);
}
void
CivHydrCompute
::
getPipeItemByInterval
(
int
time
,
LinkResultItems
&
linkItem
)
{
mResultCache
.
getPipeItemByInterval
(
time
,
linkItem
);
}
\ No newline at end of file
pandaAnalysis/CivHydrCompute.h
View file @
5acd729c
#pragma once
#include "epanet2.h"
#include "CivSimulResultCache.h"
/**
水力计算类
...
...
@@ -7,7 +8,7 @@
class
CivHydrCompute
{
public
:
explicit
CivHydrCompute
(
char
*
inp
,
char
*
rptFile
,
char
*
binFile
);
explicit
CivHydrCompute
();
/**
*@brief 水质计算
...
...
@@ -19,13 +20,25 @@ public:
*/
bool
hdyrCompute
();
/**
*@brief 将计算结果保存到数据库
*@param uri 数据库连接地址
*/
void
saveResult
(
const
std
::
string
&
uri
);
void
getTrackingResult
(
const
std
::
string
&
uri
,
std
::
string
&
jsonResult
);
void
getNodeItemByInterval
(
int
time
,
NodeResultItems
&
nodeItem
);
void
getPipeItemByInterval
(
int
time
,
LinkResultItems
&
linkItem
);
private
:
void
getNodeResult
(
short
time
);
void
getLinkResult
(
short
time
);
void
getNodeQuality
(
short
time
);
void
getLinkQuality
(
short
time
);
void
dateAndTime
(
int
time
,
std
::
string
&
date
,
std
::
string
&
nowtime
);
char
*
mInpFile
;
char
*
mRptFile
;
char
*
mBinFile
;
CivSimulResultCache
mResultCache
;
std
::
string
mInFile
;
std
::
string
mRptFile
;
std
::
string
mBinFile
;
};
pandaAnalysis/CivHydrFuncInter.cpp
View file @
5acd729c
...
...
@@ -4,46 +4,55 @@
#include "CivHydrSimulation.h"
#include "CivTrackingAnalysis.h"
bool
FUNEXPORT
modelMatation
(
char
*
uri
)
{
return
true
;
}
bool
FUNEXPORT
hdyrSimulation
(
char
*
uri
)
{
return
true
;
CivHydrSimulation
simulation
(
uri
);
return
simulation
.
hdyrSimulation
();
}
bool
FUNEXPORT
qualitySimulation
(
char
*
uri
)
{
return
true
;
CivHydrSimulation
simulation
(
uri
);
return
simulation
.
qualitySimulation
()
;
}
bool
FUNEXPORT
trackingSimulation
(
char
*
uri
,
char
*
sN
,
int
hours
,
char
*
result
)
{
CivHydrSimulation
simulation
(
uri
);
std
::
string
res
;
if
(
!
simulation
.
trackingSimulation
(
sN
,
hours
,
res
))
return
false
;
strcpy
(
result
,
res
.
c_str
());
return
true
;
}
bool
FUNEXPORT
getRptByCondition
(
char
*
uri
,
char
*
type
,
char
*
conditio
n
,
char
*
result
)
bool
FUNEXPORT
upstreamTracking
(
char
*
uri
,
char
*
s
n
,
char
*
result
)
{
CivTrackingAnalysis
track
(
uri
);
track
.
createGraphFrom
();
return
true
;
}
std
::
string
jsonResult
;
if
(
!
track
.
upstreamTracking
(
sn
,
jsonResult
))
return
false
;
strcpy
(
result
,
jsonResult
.
c_str
());
bool
FUNEXPORT
upstreamTracking
(
char
*
uri
,
char
*
sn
,
char
*
result
)
{
return
true
;
}
bool
FUNEXPORT
downstreamTracking
(
char
*
uri
,
char
*
sn
,
char
*
result
)
{
CivTrackingAnalysis
track
(
uri
);
track
.
createGraphFrom
();
std
::
string
jsonResult
;
if
(
!
track
.
downstreamTracking
(
sn
,
jsonResult
))
return
false
;
strcpy
(
result
,
jsonResult
.
c_str
());
return
true
;
}
...
...
pandaAnalysis/CivHydrFuncInter.h
View file @
5acd729c
...
...
@@ -6,9 +6,6 @@
#if defined(__cplusplus)
extern
"C"
{
#endif
bool
FUNEXPORT
modelMatation
(
char
*
uri
);
/**
*@brief 上游追踪
*@param uri 数据库连接地址
...
...
@@ -33,16 +30,6 @@ extern "C" {
*/
bool
FUNEXPORT
waterSupplyScopeAnalysis
(
char
*
uri
,
char
*
sn
,
char
*
result
);
/**
*@brief 获取当前日期和时段的结果值
*@param uri:数据库连接地址
*@param type: 节点或者管段
*@param condition:时段
*@param result 获取的结果值
*@return 1: 成功,其他值失败
*/
bool
FUNEXPORT
getRptByCondition
(
char
*
uri
,
char
*
type
,
char
*
condition
,
char
*
result
);
/**
*@brief 水力计算服务
*@param uri:数据库连接地址
...
...
pandaAnalysis/CivHydrSimulation.cpp
View file @
5acd729c
#include "CivHydrSimulation.h"
#include "CivNewInp.h"
#include "CivInpDirector.h"
#include "CivSysLog.h"
#include "epanet2.h"
#include "CivTrackingResultCache.h"
#include "CivInpConvertor.h"
CivHydrSimulation
::
CivHydrSimulation
()
CivHydrSimulation
::
CivHydrSimulation
(
const
std
::
string
&
uri
)
:
mUri
(
uri
)
{
}
...
...
@@ -18,60 +13,50 @@ CivHydrSimulation::~CivHydrSimulation()
bool
CivHydrSimulation
::
hdyrSimulation
()
{
CivInpConvertor
convertor
(
mUri
);
std
::
string
inpFileS
=
convertor
.
convertBaseInp
();
if
(
inpFileS
.
empty
())
return
false
;
if
(
!
mHydrCompute
.
hdyrCompute
())
{
return
false
;
}
mHydrCompute
.
saveResult
(
mUri
);
return
true
;
}
bool
CivHydrSimulation
::
qualitySimulation
()
{
CivInpConvertor
convertor
(
mUri
);
std
::
string
inpFileS
=
convertor
.
convertBaseInp
();
if
(
inpFileS
.
empty
())
return
false
;
if
(
!
mHydrCompute
.
qualityCompute
())
{
return
false
;
}
mHydrCompute
.
saveResult
(
mUri
);
return
true
;
}
bool
CivHydrSimulation
::
trackingSimulation
(
char
*
snNode
,
int
hours
,
std
::
string
&
jsonResult
)
{
return
true
;
}
void
CivHydrSimulation
::
getTrackingResult
(
int
hours
,
std
::
string
&
jsonResult
)
{
// 缓存节点和管段空间信息
CivTrackingResultCache
trackingCache
;
// trackingCache.cacheInfoFromDb(mDbConn);
jsonResult
.
append
(
"["
);
CivInpConvertor
convertor
(
mUri
);
std
::
string
inpFileS
=
convertor
.
convertTrackInp
(
snNode
,
std
::
to_string
(
hours
));
if
(
inpFileS
.
empty
())
return
false
;
for
(
int
i
=
0
;
i
<
hours
;
i
++
)
if
(
!
mHydrCompute
.
qualityCompute
()
)
{
auto
iter
=
mTrackLinkSns
.
find
(
i
);
if
(
iter
==
mTrackLinkSns
.
end
())
{
continue
;
}
jsonResult
.
append
(
"["
);
std
::
vector
<
std
::
string
>
vecSns
=
iter
->
second
;
for
(
int
j
=
0
;
j
<
vecSns
.
size
();
j
++
)
{
Pipes
pipe
;
std
::
string
sn
=
vecSns
[
j
];
trackingCache
.
getPipeInfoBySn
(
sn
,
pipe
);
jsonResult
.
append
(
"[["
);
jsonResult
.
append
(
pipe
.
startX
);
jsonResult
.
append
(
","
);
jsonResult
.
append
(
pipe
.
startY
);
jsonResult
.
append
(
"],["
);
jsonResult
.
append
(
pipe
.
endX
);
jsonResult
.
append
(
","
);
jsonResult
.
append
(
pipe
.
endY
);
jsonResult
.
append
(
"]],"
);
}
jsonResult
=
jsonResult
.
substr
(
0
,
jsonResult
.
length
()
-
1
);
jsonResult
.
append
(
"],"
);
return
false
;
}
jsonResult
=
jsonResult
.
substr
(
0
,
jsonResult
.
length
()
-
1
);
jsonResult
.
append
(
"]"
);
}
mHydrCompute
.
getTrackingResult
(
mUri
,
jsonResult
);
return
true
;
}
\ No newline at end of file
pandaAnalysis/CivHydrSimulation.h
View file @
5acd729c
#pragma once
#include "CivSimulResultCache.h"
#include "CivNewInp.h"
class
CivDbConn
;
#include "CivHydrCompute.h"
/**
水力模拟计算类
...
...
@@ -10,7 +9,7 @@ class CivDbConn;
class
CivHydrSimulation
{
public
:
explicit
CivHydrSimulation
();
explicit
CivHydrSimulation
(
const
std
::
string
&
uri
);
~
CivHydrSimulation
();
/**
...
...
@@ -30,13 +29,8 @@ public:
*/
bool
trackingSimulation
(
char
*
snNode
,
int
hours
,
std
::
string
&
jsonResult
);
/**
*@brief 获取追踪结果值
*@param hours:追踪的小时数
*/
void
getTrackingResult
(
int
hours
,
std
::
string
&
result
);
private
:
CivSimulResultCache
mResultCache
;
// 存储模拟结果缓存类
std
::
string
mUri
;
CivHydrCompute
mHydrCompute
;
std
::
map
<
int
,
std
::
vector
<
std
::
string
>>
mTrackLinkSns
;
};
pandaAnalysis/CivInpBuilder.cpp
View file @
5acd729c
...
...
@@ -47,13 +47,12 @@ void CivInpBuilder::setReaction(const std::string& name,
mReactions
.
addItem
(
table
);
}
std
::
string
CivInpBuilder
::
getNewInp
(
)
bool
CivInpBuilder
::
getNewInp
(
std
::
string
&
infile
)
{
std
::
string
inpFile
=
"test.inp"
;
if
(
mNewInp
->
writeToFile
(
inpFile
))
return
NULL
;
if
(
!
mNewInp
->
writeToFile
(
infile
))
return
false
;
return
inpFil
e
;
return
tru
e
;
}
void
CivInpBuilder
::
buildParamter
()
...
...
pandaAnalysis/CivInpBuilder.h
View file @
5acd729c
...
...
@@ -37,7 +37,7 @@ public:
/**
*@brief 返回装成的inp文件名
*/
std
::
string
getNewInp
(
);
bool
getNewInp
(
std
::
string
&
infile
);
void
buildParamter
();
virtual
void
buildNode
()
=
0
;
...
...
pandaAnalysis/CivInpConvertor.cpp
View file @
5acd729c
...
...
@@ -2,6 +2,7 @@
#include "CivProjInpBuilder.h"
#include "CivInpDirector.h"
#include "CivBaseInpBuilder.h"
#include "CivCommonUtils.h"
CivInpConvertor
::
CivInpConvertor
(
const
std
::
string
&
uri
)
:
mUri
(
uri
)
...
...
@@ -27,7 +28,12 @@ std::string CivInpConvertor::convertPorjInp(
director
.
setBuilder
(
builder
);
director
.
create
();
std
::
string
inpFile
=
builder
->
getNewInp
();
std
::
string
inpFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.inp"
;
if
(
builder
->
getNewInp
(
inpFile
))
{
delete
builder
;
return
NULL
;
}
delete
builder
;
return
inpFile
;
...
...
@@ -40,7 +46,12 @@ std::string CivInpConvertor::convertBaseInp()
director
.
setBuilder
(
builder
);
director
.
create
();
std
::
string
inpFile
=
builder
->
getNewInp
();
std
::
string
inpFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.inp"
;
if
(
!
builder
->
getNewInp
(
inpFile
))
{
delete
builder
;
return
NULL
;
}
delete
builder
;
return
inpFile
;
...
...
@@ -59,7 +70,12 @@ std::string CivInpConvertor::convertTrackInp(const std::string& sn,
director
.
setBuilder
(
builder
);
director
.
create
();
std
::
string
inpFile
=
builder
->
getNewInp
();
std
::
string
inpFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.inp"
;
if
(
builder
->
getNewInp
(
inpFile
))
{
delete
builder
;
return
NULL
;
}
delete
builder
;
return
inpFile
;
...
...
pandaAnalysis/CivSimulResultCache.cpp
View file @
5acd729c
#include "CivSimulResultCache.h"
#include"CivSysLog.h"
#include "CivSimulResDbHelper.h"
void
CivSimulResultCache
::
addNodeQuality
(
float
quality
,
int
interval
,
const
std
::
string
&
sNo
)
{
...
...
@@ -25,37 +26,30 @@ void CivSimulResultCache::addLinkQuality(float quality, int interval,const std::
mLinkItemsMap
[
interval
][
sNo
].
dQuality
=
quality
;
}
void
CivSimulResultCache
::
addNodeItems
(
const
NodeResultItem
&
nodeItem
)
void
CivSimulResultCache
::
addNodeItems
(
int
internal
,
const
NodeResultItem
&
nodeItem
)
{
// mNodeItemsMap[nodeItem.dInterv
al][nodeItem.szNo] = nodeItem;
mNodeItemsMap
[
intern
al
][
nodeItem
.
szNo
]
=
nodeItem
;
}
void
CivSimulResultCache
::
addLinkItems
(
const
LinkResultItem
&
linkItem
)
void
CivSimulResultCache
::
addLinkItems
(
int
interval
,
const
LinkResultItem
&
linkItem
)
{
//mLinkItemsMap[linkItem.dI
nterval][linkItem.szNo] = linkItem;
mLinkItemsMap
[
i
nterval
][
linkItem
.
szNo
]
=
linkItem
;
}
void
CivSimulResultCache
::
get
ResultByTime
(
int
time
,
NodeResultItems
&
nodeItems
,
LinkResultItems
&
linkItem
s
)
void
CivSimulResultCache
::
get
PipesSnsByQuality
(
std
::
vector
<
std
::
vector
<
std
::
string
>>&
sn
s
)
{
nodeItems
.
clear
();
linkItems
.
clear
();
auto
nodeIter
=
mNodeItemsMap
.
find
(
time
);
auto
linkIter
=
mLinkItemsMap
.
find
(
time
);
if
(
nodeIter
==
mNodeItemsMap
.
end
()
||
linkIter
==
mLinkItemsMap
.
end
())
for
(
auto
iter
=
mLinkItemsMap
.
begin
();
iter
!=
mLinkItemsMap
.
end
();
iter
++
)
{
return
;
}
// ⷢ쳣
try
{
nodeItems
=
nodeIter
->
second
;
linkItems
=
link
Iter
->
second
;
}
catch
(
const
std
::
exception
&
e
)
{
CivSysLog
::
getInstance
()
->
error
(
e
.
what
(),
"CivSimulResultCache"
,
__FUNCTION__
);
std
::
vector
<
std
::
string
>
vec
;
std
::
map
<
std
::
string
,
LinkResultItem
>
subMap
=
iter
->
second
;
for
(
auto
subIter
=
subMap
.
begin
();
subIter
!=
subMap
.
end
();
subIter
++
)
{
LinkResultItem
item
=
sub
Iter
->
second
;
if
(
item
.
dQuality
>
0
)
vec
.
push_back
(
item
.
szNo
);
}
sns
.
push_back
(
vec
);
}
}
...
...
@@ -65,3 +59,44 @@ void CivSimulResultCache::clear()
mNodeItemsMap
.
clear
();
}
bool
CivSimulResultCache
::
save
(
const
std
::
string
&
uri
)
{
CivSimulResDbHelper
helper
(
uri
);
for
(
auto
iter
=
mNodeItemsMap
.
begin
();
iter
!=
mNodeItemsMap
.
end
();
iter
++
)
{
helper
.
insertNodes
(
iter
->
second
);
}
for
(
auto
iter
=
mLinkItemsMap
.
begin
();
iter
!=
mLinkItemsMap
.
end
();
iter
++
)
{
helper
.
insertLinks
(
iter
->
second
);
}
return
true
;
}
void
CivSimulResultCache
::
getAllNodeCoords
(
const
std
::
string
&
uri
,
NodeCoords
&
nodeCoords
)
{
CivSimulResDbHelper
helper
(
uri
);
helper
.
getAllNodeCoords
(
nodeCoords
);
}
void
CivSimulResultCache
::
getAllPipeCoords
(
const
std
::
string
&
uri
,
PipeCoords
&
pipeCoords
)
{
CivSimulResDbHelper
helper
(
uri
);
helper
.
getAllPipeCoords
(
pipeCoords
);
}
void
CivSimulResultCache
::
getNodeItemByInterval
(
int
time
,
NodeResultItems
&
nodeItems
)
{
auto
iter
=
mNodeItemsMap
.
find
(
time
);
if
(
iter
!=
mNodeItemsMap
.
end
())
nodeItems
=
iter
->
second
;
}
void
CivSimulResultCache
::
getPipeItemByInterval
(
int
time
,
LinkResultItems
&
linkItems
)
{
auto
iter
=
mLinkItemsMap
.
find
(
time
);
if
(
iter
!=
mLinkItemsMap
.
end
())
linkItems
=
iter
->
second
;
}
pandaAnalysis/CivSimulResultCache.h
View file @
5acd729c
...
...
@@ -2,8 +2,11 @@
#define CIVSIMULRESULTCACHE_H
#include <map>
#include <vector>
#include "CivSimuResStruct.h"
using
namespace
std
;
/**
模拟结果缓存类
*/
...
...
@@ -16,7 +19,7 @@ public:
*@param interval:模拟第几次
*@param sNo:本点号
*/
void
addNodeQuality
(
float
quality
,
int
interval
,
const
st
d
::
st
ring
&
sNo
);
void
addNodeQuality
(
float
quality
,
int
interval
,
const
string
&
sNo
);
/**
*@brief 缓存管线水质
...
...
@@ -24,35 +27,36 @@ public:
*@param interval:模拟第几次
*@param sNo:管线编号
*/
void
addLinkQuality
(
float
quality
,
int
interval
,
const
st
d
::
st
ring
&
sNo
);
void
addLinkQuality
(
float
quality
,
int
interval
,
const
string
&
sNo
);
/**
*@brief 缓存节点水力模拟情况
*@param nodeItem:节点水力结果值
*/
void
addNodeItems
(
const
NodeResultItem
&
nodeItem
);
void
addNodeItems
(
int
interval
,
const
NodeResultItem
&
nodeItem
);
/**
*@brief 缓存管线水力模拟情况
*@param linkItem:管线模拟结果
*/
void
addLinkItems
(
const
LinkResultItem
&
linkItem
);
*@brief 缓存管线水力模拟情况
*@param linkItem:管线模拟结果
*/
void
addLinkItems
(
int
interval
,
const
LinkResultItem
&
linkItem
);
/**
*@brief 释放缓存的结果值
*/
void
clear
();
/**
*@brief 根据时段获取
*@param time 时段
*@param nodeItems 节点值集合
*@param linkItems 管线值集合
*/
void
getResultByTime
(
int
time
,
NodeResultItems
&
nodeItems
,
LinkResultItems
&
linkItems
);
bool
save
(
const
string
&
uri
);
void
getPipesSnsByQuality
(
std
::
vector
<
std
::
vector
<
std
::
string
>>&
);
void
getAllNodeCoords
(
const
std
::
string
&
uri
,
NodeCoords
&
nodeCoords
);
void
getAllPipeCoords
(
const
std
::
string
&
uri
,
PipeCoords
&
pipeCoords
);
void
getNodeItemByInterval
(
int
time
,
NodeResultItems
&
nodeItem
);
void
getPipeItemByInterval
(
int
time
,
LinkResultItems
&
linkItem
);
private
:
std
::
map
<
int
,
NodeResultItems
>
mNodeItemsMap
;
// 模拟
std
::
map
<
int
,
LinkResultItems
>
mLinkItemsMap
;
// 计算的
map
<
int
,
NodeResultItems
>
mNodeItemsMap
;
// 模拟
map
<
int
,
LinkResultItems
>
mLinkItemsMap
;
// 计算的
map
<
int
,
TankResultItems
>
mTankItemsMap
;
};
#endif // !CIVSIMULRESULTCACHE_H
pandaAnalysis/CivTrackingAnalysis.cpp
View file @
5acd729c
...
...
@@ -2,6 +2,8 @@
#include "CivSimulResultCache.h"
#include "CivHydrSimulation.h"
#include "CivGraphFactory.h"
#include "CivInpConvertor.h"
#include "CivInpDbHelper.h"
CivTrackingAnalysis
::
CivTrackingAnalysis
(
const
std
::
string
&
uri
)
:
mGraph
(
new
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>
()),
mUri
(
uri
)
...
...
@@ -16,84 +18,87 @@ CivTrackingAnalysis::~CivTrackingAnalysis()
bool
CivTrackingAnalysis
::
createGraphFrom
()
{
CivInpConvertor
convertor
(
mUri
);
std
::
string
inpFile
=
convertor
.
convertTrackInp
(
""
,
"0"
);
if
(
inpFile
.
empty
())
return
false
;
CivHydrCompute
dyCompute
;
if
(
!
dyCompute
.
hdyrCompute
())
return
false
;
NodeResultItems
nodeItems
;
LinkResultItems
linkItems
;
dyCompute
.
getNodeItemByInterval
(
0
,
nodeItems
);
dyCompute
.
getPipeItemByInterval
(
0
,
linkItems
);
if
(
nodeItems
.
size
()
<=
0
)
return
false
;
// 顶点坐标
CivCoordinates
coords
;
CivInpDbHelper
helper
(
mUri
);
helper
.
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
);
}
//CivHydrSimulation simulation;
//simulation.registDb(dbConn);
//if (!simulation.hdyrInstantSimulation())
// return false;
//NodeResultItems nodeItems;
//LinkResultItems linkItems;
//simulation.getDataByTime(0, nodeItems, linkItems);
//if (nodeItems.size() <= 0)
// return false;
//// 顶点坐标
//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);
//}
//// 管段
//CivPipe civPipe;
//dbConn->getPipe(civPipe);
//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);
// }
//}
// 管段
CivPipe
civPipe
;
helper
.
getPipe
(
civPipe
);
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
;
}
...
...
@@ -102,28 +107,6 @@ bool CivTrackingAnalysis::transformJson(const std::vector<CivGraphJunction>& jun
{
jsonResult
.
append
(
"["
);
//// 节点
//size_t juncTotal = junctions.size();
//for (int i = 0; i < juncTotal; i++)
//{
// CivGraphJunction junction = junctions.at(i);
// std::string sn = junction.getSn();
// std::string xCoord = junction.getXCoord();
// std::string yCoord = junction.getYCoord();
// jsonResult.append("[");
// jsonResult.append(sn);
// jsonResult.append(",");
// jsonResult.append(xCoord);
// jsonResult.append(",");
// jsonResult.append(yCoord);
// jsonResult.append("],");
//}
//jsonResult = jsonResult.substr(0, jsonResult.length() - 1);
//jsonResult.append("],\"pipes\":[");
// 管段
size_t
pipesTotal
=
pipes
.
size
();
for
(
int
i
=
0
;
i
<
pipesTotal
;
i
++
)
...
...
@@ -183,7 +166,6 @@ bool CivTrackingAnalysis::downstreamTracking(const std::string& sN, std::string&
{
return
false
;
}
return
true
;
}
...
...
pandaAnalysis/CivTrackingAnalysis.h
View file @
5acd729c
...
...
@@ -33,12 +33,13 @@ public:
*/
bool
waterSupplyScopeAnalysis
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
);
private
:
/**
*@brief 根据数据库管网构建管网有向图
*@param uri 数据库连接地址
*/
bool
createGraphFrom
();
private
:
/**
*@brief 节点和管段集合信息转换成json字符串
...
...
pandaAnalysis/pandaAnalysis.vcxproj
View file @
5acd729c
...
...
@@ -152,7 +152,6 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"..\pandaDbManager\CivCommonUtils.cpp"
/>
<ClCompile
Include=
"CivBaseInpBuilder.cpp"
/>
<ClCompile
Include=
"CivGraphFactory.cpp"
/>
<ClCompile
Include=
"CivHydDataType.cpp"
/>
...
...
@@ -189,7 +188,6 @@
<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 @
5acd729c
...
...
@@ -18,9 +18,6 @@
<ClCompile
Include=
"CivHydrFuncInter.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"..\pandaDbManager\CivCommonUtils.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivInpDirector.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
...
...
@@ -125,8 +122,5 @@
<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 @
5acd729c
...
...
@@ -127,7 +127,7 @@ public:
Str
ID
;
Str
Node1
;
Str
Node2
;
Str
Parameters
;
Str
Parameters
=
"HEAD 1"
;
}
PumpTable
;
void
addItem
(
const
PumpTable
&
table
);
...
...
pandaDbManager/CivConnection.cpp
View file @
5acd729c
#include "CivConnection.h"
#include "CivCommonUtils.h"
#include <iostream>
CivConnection
::
CivConnection
()
{
...
...
@@ -25,7 +27,7 @@ bool CivConnection::update(const std::string& table, const std::map<std::string,
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
!
execSql
(
sql
))
return
false
;
...
...
@@ -38,13 +40,59 @@ bool CivConnection::del(const std::string& table, const std::string& where)
return
false
;
std
::
string
sql
=
"delete from "
+
table
+
"where "
+
where
;
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
if
(
!
execSql
(
sql
))
return
false
;
return
true
;
}
bool
CivConnection
::
insertBulk
(
const
std
::
string
&
table
,
const
std
::
vector
<
std
::
string
>&
fields
,
const
std
::
vector
<
std
::
vector
<
std
::
string
>>&
result
)
{
if
(
table
.
empty
()
||
result
.
size
()
<=
0
)
return
false
;
// 拼接sql语句
std
::
string
sql
=
"INSERT INTO
\"
"
+
table
+
"
\"
("
;
size_t
total
=
fields
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
std
::
string
field
=
fields
[
i
];
sql
.
append
(
field
);
sql
.
append
(
","
);
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
sql
.
append
(
") values"
);
// 拼接值
size_t
rows
=
result
.
size
();
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
sql
.
append
(
"("
);
std
::
vector
<
std
::
string
>
filedvals
=
result
[
i
];
size_t
cols
=
filedvals
.
size
();
for
(
int
j
=
0
;
j
<
cols
;
j
++
)
{
sql
.
append
(
filedvals
[
j
]);
sql
.
append
(
","
);
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
sql
.
append
(
"),"
);
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
std
::
cout
<<
sql
<<
std
::
endl
;
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
//2 执行插入操作
if
(
!
execSql
(
utf8Sql
))
return
false
;
return
true
;
}
bool
CivConnection
::
insert
(
const
std
::
string
&
table
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
result
)
{
if
(
table
.
empty
()
||
result
.
size
()
<=
0
)
...
...
@@ -70,8 +118,9 @@ bool CivConnection::insert(const std::string& table, const std::map<std::string,
sql
.
append
(
") VALUES"
);
sql
.
append
(
vals
);
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
//2 执行插入操作
if
(
!
execSql
(
s
ql
))
if
(
!
execSql
(
utf8S
ql
))
return
false
;
return
true
;
...
...
@@ -92,17 +141,18 @@ bool CivConnection::query(const std::string& table, const std::vector<std::strin
}
sql
=
sql
.
substr
(
0
,
sql
.
length
()
-
1
);
sql
.
append
(
"from "
);
sql
.
append
(
"
from "
);
sql
.
append
(
table
);
if
(
!
where
.
empty
())
{
sql
.
append
(
"where "
);
sql
.
append
(
"
where "
);
sql
.
append
(
where
);
}
std
::
cout
<<
sql
<<
std
::
endl
;
std
::
string
utf8Sql
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
// 2 执行sql语句
if
(
!
execSql
(
s
ql
))
if
(
!
execSql
(
utf8S
ql
))
{
return
false
;
}
...
...
pandaDbManager/CivConnection.h
View file @
5acd729c
...
...
@@ -57,6 +57,9 @@ public:
*/
bool
insert
(
const
std
::
string
&
table
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
result
);
bool
insertBulk
(
const
std
::
string
&
table
,
const
std
::
vector
<
std
::
string
>&
fields
,
const
std
::
vector
<
std
::
vector
<
std
::
string
>>&
result
);
/**
*@brief 执行查询操作,与具体的数据有关子类实现
*@param table 待查询的表名
...
...
pandaDbManager/CivInpDbHelper.cpp
View file @
5acd729c
...
...
@@ -22,11 +22,11 @@ bool CivInpDbHelper::getNode(CivNode& node)
{
nodeTableFields
.
sn
,
nodeTableFields
.
elev
,
nodeTableFields
.
d
emand
,
nodeTableFields
.
baseD
emand
,
nodeTableFields
.
demandPattern
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
P
UMP
,
fields
,
resultVector
);
mDbConn
->
query
(
P
IPENODE
,
fields
,
resultVector
);
// ༭װ
size_t
total
=
resultVector
.
size
();
...
...
@@ -61,7 +61,7 @@ bool CivInpDbHelper::getPipe(CivPipe& pipes)
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
P
UMP
,
fields
,
resultVector
);
mDbConn
->
query
(
P
IPELINE
,
fields
,
resultVector
);
size_t
total
=
resultVector
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
...
...
@@ -100,7 +100,7 @@ bool CivInpDbHelper::getTank(CivTank& tanks)
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
PUMP
,
fields
,
resultVector
);
mDbConn
->
query
(
TANK
,
fields
,
resultVector
);
size_t
total
=
resultVector
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
...
...
@@ -136,7 +136,7 @@ bool CivInpDbHelper::getValve(CivValve& valves)
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
PUMP
,
fields
,
resultVector
);
mDbConn
->
query
(
VALVE
,
fields
,
resultVector
);
size_t
totals
=
resultVector
.
size
();
for
(
int
i
=
0
;
i
<
totals
;
i
++
)
...
...
@@ -164,7 +164,8 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps)
pmTable
.
sn
,
pmTable
.
startPoint
,
pmTable
.
endPoint
,
pmTable
.
headCurve
pmTable
.
headCurve
,
pmTable
.
power
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
...
...
@@ -179,8 +180,17 @@ bool CivInpDbHelper::getPumps(CivPumps& pumps)
pump
.
ID
=
map
.
find
(
pmTable
.
sn
)
->
second
;
pump
.
Node1
=
map
.
find
(
pmTable
.
startPoint
)
->
second
;
pump
.
Node2
=
map
.
find
(
pmTable
.
endPoint
)
->
second
;
pump
.
Parameters
=
map
.
find
(
pmTable
.
headCurve
)
->
second
;
std
::
string
param
;
std
::
string
curve
=
map
.
find
(
pmTable
.
headCurve
)
->
second
;
if
(
curve
!=
""
)
param
.
append
(
"head "
+
curve
);
std
::
string
power
=
map
.
find
(
pmTable
.
power
)
->
second
;
if
(
power
!=
""
)
param
.
append
(
" power "
+
power
);
pump
.
Parameters
=
param
;
pumps
.
addItem
(
pump
);
}
return
true
;
...
...
@@ -197,7 +207,7 @@ bool CivInpDbHelper::getReservoirs(CivReservoirs& reservoirs)
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
PUMP
,
fields
,
resultVector
);
mDbConn
->
query
(
RESIVOIR
,
fields
,
resultVector
);
size_t
totals
=
resultVector
.
size
();
for
(
int
i
=
0
;
i
<
totals
;
i
++
)
...
...
pandaDbManager/CivInpHelperAbs.cpp
View file @
5acd729c
...
...
@@ -108,7 +108,7 @@ bool CivInpHelperAbs::getCurves(CivCurves& curves)
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
resultVector
;
mDbConn
->
query
(
PATTERN
TABLE
,
fields
,
resultVector
);
mDbConn
->
query
(
CURVE
TABLE
,
fields
,
resultVector
);
size_t
totals
=
resultVector
.
size
();
for
(
int
i
=
0
;
i
<
totals
;
i
++
)
...
...
pandaDbManager/CivPgDbConnection.cpp
View file @
5acd729c
#include "CivPgDbConnection.h"
#include "CivCommonUtils.h"
#include <iostream>
CivPgDbConnection
::
CivPgDbConnection
()
:
CivConnection
(),
mConn
(
nullptr
),
mResult
(
nullptr
)
...
...
@@ -29,6 +32,7 @@ bool CivPgDbConnection::disconnect()
if
(
mConn
!=
NULL
)
{
PQfinish
(
mConn
);
mConn
=
NULL
;
}
return
true
;
}
...
...
@@ -42,8 +46,8 @@ bool CivPgDbConnection::queryResult(std::vector<std::map<std::string,std::string
std
::
map
<
std
::
string
,
std
::
string
>
map
;
for
(
int
j
=
0
;
j
<
columns
;
j
++
)
{
std
::
string
filedName
=
PQfname
(
mResult
,
j
);
std
::
string
filedValue
=
PQgetvalue
(
mResult
,
i
,
0
);
std
::
string
filedName
=
CivCommonUtils
::
UTF8_To_string
(
PQfname
(
mResult
,
j
));
std
::
string
filedValue
=
CivCommonUtils
::
UTF8_To_string
(
PQgetvalue
(
mResult
,
i
,
j
)
);
map
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
filedName
,
filedValue
));
}
...
...
@@ -54,7 +58,7 @@ bool CivPgDbConnection::queryResult(std::vector<std::map<std::string,std::string
bool
CivPgDbConnection
::
execSql
(
const
std
::
string
&
sql
)
{
if
(
mConn
)
if
(
!
mConn
)
return
false
;
mResult
=
PQexec
(
mConn
,
sql
.
c_str
());
...
...
@@ -63,6 +67,7 @@ bool CivPgDbConnection::execSql(const std::string& sql)
if
(
!
errorStr
.
empty
())
{
mLastError
=
errorStr
;
std
::
cout
<<
mLastError
<<
std
::
endl
;
PQclear
(
mResult
);
return
false
;
}
...
...
pandaDbManager/CivSimuResDbHelper.cpp
deleted
100644 → 0
View file @
125f003e
#include "CivSimuResDbHelper.h"
CivSimuResDbHelper
::
CivSimuResDbHelper
()
{
}
bool
CivSimuResDbHelper
::
saveNode
()
{
return
true
;
}
bool
CivSimuResDbHelper
::
saveLink
()
{
return
true
;
}
\ No newline at end of file
pandaDbManager/CivSimuResDbHelper.h
deleted
100644 → 0
View file @
125f003e
#pragma once
#include<string>
class
CivConnection
;
/**
ģ洢
*/
class
CivSimuResDbHelper
{
public
:
CivSimuResDbHelper
();
CivConnection
*
getConnection
(
const
std
::
string
&
uri
);
bool
saveNode
();
bool
saveLink
();
private
:
};
panda
Analysis
/CivSimuResStruct.h
→
panda
DbManager
/CivSimuResStruct.h
View file @
5acd729c
#pragma once
#include<string>
#include<map>
typedef
struct
ResultItem
struct
ResultItem
{
char
szNo
[
64
];
std
::
string
dDate
;
std
::
string
dTime
;
float
dQuality
;
std
::
string
dModifyTime
;
};
// 节点结果模拟值
...
...
@@ -37,3 +39,24 @@ struct TankResultItem :public ResultItem
#define NodeResultItems std::map<std::string,NodeResultItem>
#define LinkResultItems std::map<std::string,LinkResultItem>
#define TankResultItems std::map<std::string,TankResultItem>
// 节点
typedef
struct
NodeCoord
{
std
::
string
xCoord
;
// x坐标
std
::
string
yCoord
;
// y坐标
}
NodeCoord
;
// 管段
typedef
struct
PipeCoord
{
std
::
string
startX
;
// 起始节点x
std
::
string
startY
;
// 起始节点Y
std
::
string
endX
;
// 终止节点X
std
::
string
endY
;
// 终止节点Y
}
PipeCoord
;
#define NodeCoords std::map<std::string,NodeCoord>
#define PipeCoords std::map<std::string,PipeCoord>
pandaDbManager/CivSimulResDbHelper.cpp
0 → 100644
View file @
5acd729c
#include "CivSimulResDbHelper.h"
#include "CivPgDbConnection.h"
#include "CivTableFields.h"
#include "CivCommonUtils.h"
CivSimulResDbHelper
::
CivSimulResDbHelper
(
const
std
::
string
&
uri
)
{
mConn
=
new
CivPgDbConnection
();
mConn
->
connect
(
uri
);
NodeResultTableField
tableFields
;
mNodeFields
=
{
tableFields
.
Number
,
tableFields
.
dDemand
,
tableFields
.
dPressure
,
tableFields
.
dQuality
,
tableFields
.
dHead
,
tableFields
.
dDate
,
tableFields
.
dInterval
,
tableFields
.
dModifyTime
};
//
PipeResultTableField
pipeFields
;
mLinkFileds
=
{
pipeFields
.
szNo
,
pipeFields
.
dFlow
,
pipeFields
.
dVelocity
,
pipeFields
.
dUnitHeadloss
,
pipeFields
.
dQuality
,
pipeFields
.
szStatus
,
pipeFields
.
dDate
,
pipeFields
.
dInterval
,
pipeFields
.
dModifyTime
};
}
CivSimulResDbHelper
::~
CivSimulResDbHelper
()
{
mConn
->
disconnect
();
delete
mConn
;
}
bool
CivSimulResDbHelper
::
insertNodes
(
const
NodeResultItems
&
nodeitems
)
{
std
::
vector
<
std
::
vector
<
std
::
string
>>
vecVec
;
for
(
auto
iter
=
nodeitems
.
begin
();
iter
!=
nodeitems
.
end
();
iter
++
)
{
NodeResultItem
nodeItem
=
iter
->
second
;
std
::
string
sn
=
nodeItem
.
szNo
;
std
::
vector
<
std
::
string
>
vecRes
=
{
"
\'
"
+
sn
+
"
\'
"
,
std
::
to_string
(
nodeItem
.
dDemand
),
std
::
to_string
(
nodeItem
.
dPressure
),
std
::
to_string
(
nodeItem
.
dQuality
),
std
::
to_string
(
nodeItem
.
dHead
),
"
\'
"
+
nodeItem
.
dDate
+
"
\'
"
,
"
\'
"
+
nodeItem
.
dTime
+
"
\'
"
,
"
\'
"
+
CurrentTime
+
"
\'
"
};
vecVec
.
push_back
(
vecRes
);
}
if
(
!
mConn
->
insertBulk
(
NODERESULTTABLE
,
mNodeFields
,
vecVec
))
return
false
;
return
true
;
}
bool
CivSimulResDbHelper
::
insertLinks
(
const
LinkResultItems
&
linkMap
)
{
std
::
vector
<
std
::
vector
<
std
::
string
>>
vecVec
;
for
(
auto
iter
=
linkMap
.
begin
();
iter
!=
linkMap
.
end
();
iter
++
)
{
LinkResultItem
linkItem
=
iter
->
second
;
std
::
string
sn
=
linkItem
.
szNo
;
std
::
string
status
=
linkItem
.
szStatus
;
std
::
vector
<
std
::
string
>
vecRes
=
{
"
\'
"
+
sn
+
"
\'
"
,
std
::
to_string
(
linkItem
.
dFlow
),
std
::
to_string
(
linkItem
.
dVelocity
),
std
::
to_string
(
linkItem
.
dHeadloss
),
std
::
to_string
(
linkItem
.
dQuality
),
"
\'
"
+
status
+
"
\'
"
,
"
\'
"
+
linkItem
.
dDate
+
"
\'
"
,
"
\'
"
+
linkItem
.
dTime
+
"
\'
"
,
"
\'
"
+
CurrentTime
+
"
\'
"
};
vecVec
.
push_back
(
vecRes
);
}
if
(
!
mConn
->
insertBulk
(
PIPERESULTTABLE
,
mLinkFileds
,
vecVec
))
return
false
;
return
true
;
}
bool
CivSimulResDbHelper
::
insertTanks
(
const
TankResultItems
&
tankMap
)
{
return
true
;
}
void
CivSimulResDbHelper
::
getAllNodeCoords
(
NodeCoords
&
nodeCoords
)
{
std
::
vector
<
std
::
string
>
fileds
=
{
"本点号"
,
"横坐标"
,
"纵坐标"
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
res
;
if
(
!
mConn
->
query
(
PIPENODE
,
fileds
,
res
))
return
;
size_t
total
=
res
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
std
::
map
<
std
::
string
,
std
::
string
>
nodeInfo
=
res
[
i
];
NodeCoord
nodeCoord
;
std
::
string
key
=
nodeInfo
.
find
(
fileds
[
0
])
->
second
;
nodeCoord
.
xCoord
=
nodeInfo
.
find
(
fileds
[
1
])
->
second
;
nodeCoord
.
yCoord
=
nodeInfo
.
find
(
fileds
[
2
])
->
second
;
nodeCoords
[
key
]
=
nodeCoord
;
}
}
void
CivSimulResDbHelper
::
getAllPipeCoords
(
PipeCoords
&
pipeCoords
)
{
std
::
vector
<
std
::
string
>
fileds
=
{
"ST_X(ST_StartPoint(ST_GeometryN(geom,1))) as startx"
,
"ST_Y(ST_StartPoint(ST_GeometryN(geom,1))) as starty"
,
"ST_X(ST_EndPoint(ST_GeometryN(geom,1))) as endX"
,
"ST_Y(ST_EndPoint(ST_GeometryN(geom,1))) as endY"
,
"编号"
};
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>>
res
;
if
(
!
mConn
->
query
(
PIPELINE
,
fileds
,
res
))
return
;
size_t
total
=
res
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
std
::
map
<
std
::
string
,
std
::
string
>
nodeInfo
=
res
[
i
];
PipeCoord
pipeCoord
;
std
::
string
key
=
nodeInfo
.
find
(
"startx"
)
->
second
;
pipeCoord
.
startX
=
nodeInfo
.
find
(
"startx"
)
->
second
;
pipeCoord
.
startY
=
nodeInfo
.
find
(
"starty"
)
->
second
;
pipeCoord
.
endX
=
nodeInfo
.
find
(
"endX"
)
->
second
;
pipeCoord
.
endY
=
nodeInfo
.
find
(
"endY"
)
->
second
;
pipeCoords
[
key
]
=
pipeCoord
;
}
}
\ No newline at end of file
pandaDbManager/CivSimulResDbHelper.h
0 → 100644
View file @
5acd729c
#pragma once
#include "CivSimulResHelperAbs.h"
#include<vector>
#include<string>
#define RESDBHELPER __declspec(dllexport)
class
RESDBHELPER
CivSimulResDbHelper
:
public
CivSimulResHelperAbs
{
public
:
explicit
CivSimulResDbHelper
(
const
std
::
string
&
uri
);
~
CivSimulResDbHelper
();
virtual
bool
insertNodes
(
const
NodeResultItems
&
nodeitems
);
virtual
bool
insertLinks
(
const
LinkResultItems
&
linkMap
);
virtual
bool
insertTanks
(
const
TankResultItems
&
tankMap
);
virtual
void
getAllNodeCoords
(
NodeCoords
&
nodeCoords
);
virtual
void
getAllPipeCoords
(
PipeCoords
&
pipeCoords
);
private
:
std
::
vector
<
std
::
string
>
mNodeFields
;
std
::
vector
<
std
::
string
>
mLinkFileds
;
std
::
vector
<
std
::
string
>
mTankFileds
;
};
pandaDbManager/CivSimulResHelperAbs.cpp
0 → 100644
View file @
5acd729c
#include "CivSimulResHelperAbs.h"
#include "CivConnection.h"
#include "CivTypes.h"
CivSimulResHelperAbs
::
CivSimulResHelperAbs
()
{
}
CivSimulResHelperAbs
::~
CivSimulResHelperAbs
()
{
}
bool
CivSimulResHelperAbs
::
insertNodes
(
const
NodeResultItems
&
nodeMap
)
{
return
true
;
}
bool
CivSimulResHelperAbs
::
insertLinks
(
const
LinkResultItems
&
linkMap
)
{
return
true
;
}
bool
CivSimulResHelperAbs
::
insertTanks
(
const
TankResultItems
&
tankMap
)
{
return
true
;
}
void
CivSimulResHelperAbs
::
getAllNodeCoords
(
NodeCoords
&
nodeCoords
)
{
}
void
CivSimulResHelperAbs
::
getAllPipeCoords
(
PipeCoords
&
pipeCoords
)
{
}
pandaDbManager/CivSimulResHelperAbs.h
0 → 100644
View file @
5acd729c
#pragma once
#include <string>
#include <map>
#include "CivSimuResStruct.h"
#define SIMULABSEXPORT __declspec(dllexport)
class
CivConnection
;
/**
ģ
*/
class
SIMULABSEXPORT
CivSimulResHelperAbs
{
public
:
explicit
CivSimulResHelperAbs
();
virtual
~
CivSimulResHelperAbs
();
virtual
bool
insertNodes
(
const
NodeResultItems
&
nodeitems
);
virtual
bool
insertLinks
(
const
LinkResultItems
&
linkMap
);
virtual
bool
insertTanks
(
const
TankResultItems
&
tankMap
);
virtual
void
getAllNodeCoords
(
NodeCoords
&
nodeCoords
);
virtual
void
getAllPipeCoords
(
PipeCoords
&
pipeCoords
);
protected
:
CivConnection
*
mConn
=
nullptr
;
};
\ No newline at end of file
pandaDbManager/CivTableFields.h
View file @
5acd729c
...
...
@@ -77,7 +77,7 @@ typedef struct PumpTableFileds
Str
sn
=
"本点号"
;
Str
desc
=
"描述"
;
Str
label
=
"标签"
;
Str
headCurve
=
"
水泵
曲线"
;
Str
headCurve
=
"
扬程
曲线"
;
Str
power
=
"功率"
;
Str
ratio
=
"转速比"
;
Str
pattern
=
"模式"
;
...
...
@@ -106,7 +106,7 @@ typedef struct TankTableFileds
Str
minLevel
=
"最低水位"
;
Str
maxLevel
=
"最高水位"
;
Str
diametor
=
"直径"
;
Str
minVolume
=
"
最小容积
"
;
Str
minVolume
=
"
容量
"
;
Str
volumeCurve
=
"容积曲线"
;
Str
mixedCore
=
"混合分数"
;
Str
mixedPattern
=
"混合模式"
;
...
...
@@ -168,16 +168,12 @@ typedef struct ValveTableFileds
typedef
struct
NodeResultTableField
{
Str
Number
=
"本点号"
;
Str
dHead
=
"水头"
;
Str
dHead
=
"
总
水头"
;
Str
dPressure
=
"压力"
;
Str
dElevation
=
"标高"
;
Str
dDemand
=
"实际需水量"
;
Str
dTankVolume
=
"水池容量"
;
Str
dTankMaxVolume
=
"水池最大容量"
;
Str
dTankLevel
=
"液位高度"
;
Str
dQuality
=
"水质"
;
Str
dDate
=
"日期"
;
Str
dInterval
=
"时
段
"
;
Str
dInterval
=
"时
间点
"
;
Str
dModifyTime
=
"修改时间"
;
}
NodeResultTable
;
...
...
@@ -189,18 +185,12 @@ typedef struct PipeResultTableField
{
Str
szNo
=
"编号"
;
Str
dFlow
=
"流量"
;
Str
nFlowDirect
=
"流向"
;
Str
dVelocity
=
"流速"
;
Str
dHeadloss
=
"水头损失"
;
Str
dUnitHeadloss
=
"单位水头损"
;
Str
dFromNodHeadloss
=
"上点水头"
;
Str
dToNodHeadloss
=
"本点水头"
;
Str
dLocalHeadloss
=
"局部水头损"
;
Str
dFrictionHeadloss
=
"摩擦水头损"
;
Str
dUnitHeadloss
=
"单位水损"
;
Str
szStatus
=
"状态"
;
Str
dQuality
=
"水质"
;
Str
dDate
=
"日期"
;
Str
dInterval
=
"时
段
"
;
Str
dInterval
=
"时
间点
"
;
Str
dModifyTime
=
"修改时间"
;
}
PipeResultTable
;
...
...
pandaDbManager/CivTypes.h
View file @
5acd729c
...
...
@@ -6,6 +6,7 @@
#include <vector>
#include <set>
#define Str std::string
// 水力模型表名
#define PIPELINE Str("管段")
#define PIPENODE Str("节点")
...
...
pandaDbManager/pandaDbManager.vcxproj
View file @
5acd729c
...
...
@@ -154,31 +154,35 @@ 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>
copy CivSimuResStruct.h $(OutDir)..\include /y
copy CivSimulResHelperAbs.h $(OutDir)..\include /y
copy CivSimulResDbHelper.h $(OutDir)..\include /y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude
Include=
"CivAssembly.h"
/>
<ClInclude
Include=
"CivCommonUtils.h"
/>
<ClInclude
Include=
"CivConnection.h"
/>
<ClInclude
Include=
"CivInpDbHelper.h"
/>
<ClInclude
Include=
"CivInpHelperAbs.h"
/>
<ClInclude
Include=
"CivPgDbConnection.h"
/>
<ClInclude
Include=
"CivProjInpDbHelper.h"
/>
<ClInclude
Include=
"CivSimuResDbHelper.h"
/>
<ClInclude
Include=
"CivSimulResDbHelper.h"
/>
<ClInclude
Include=
"CivSimulResHelperAbs.h"
/>
<ClInclude
Include=
"CivSimuResStruct.h"
/>
<ClInclude
Include=
"CivTableFields.h"
/>
<ClInclude
Include=
"CivTrackingResultCache.h"
/>
<ClInclude
Include=
"CivTypes.h"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivAssembly.cpp"
/>
<ClCompile
Include=
"CivCommonUtils.cpp"
/>
<ClCompile
Include=
"CivConnection.cpp"
/>
<ClCompile
Include=
"CivInpDbHelper.cpp"
/>
<ClCompile
Include=
"CivInpHelperAbs.cpp"
/>
<ClCompile
Include=
"CivPgDbConnection.cpp"
/>
<ClCompile
Include=
"CivProjInpDbHelper.cpp"
/>
<ClCompile
Include=
"CivSimuResDbHelper.cpp"
/>
<ClCompile
Include=
"CivSimulResDbHelper.cpp"
/>
<ClCompile
Include=
"CivSimulResHelperAbs.cpp"
/>
<ClCompile
Include=
"CivTrackingResultCache.cpp"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
...
...
pandaDbManager/pandaDbManager.vcxproj.filters
View file @
5acd729c
...
...
@@ -18,9 +18,6 @@
<ClInclude
Include=
"CivTypes.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivCommonUtils.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivAssembly.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
...
...
@@ -42,17 +39,20 @@
<ClInclude
Include=
"CivProjInpDbHelper.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivSimuResDbHelper.h"
>
<Filter>
源文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivTableFields.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivSimulResHelperAbs.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivSimulResDbHelper.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivSimuResStruct.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivCommonUtils.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivAssembly.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
...
...
@@ -74,7 +74,10 @@
<ClCompile
Include=
"CivProjInpDbHelper.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivSimuResDbHelper.cpp"
>
<ClCompile
Include=
"CivSimulResHelperAbs.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivSimulResDbHelper.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
...
...
panda
DbManager
/CivCommonUtils.cpp
→
panda
Log
/CivCommonUtils.cpp
View file @
5acd729c
...
...
@@ -77,7 +77,7 @@ std::string CivCommonUtils::currentDate()
return
s
;
}
std
::
string
CivCommonUtils
::
currentHour
()
int
CivCommonUtils
::
currentHour
()
{
time_t
rawtime
;
struct
tm
*
timeinfo
;
...
...
@@ -86,11 +86,8 @@ std::string CivCommonUtils::currentHour()
timeinfo
=
localtime
(
&
rawtime
);
time_t
tick
=
mktime
(
timeinfo
);
strftime
(
s
,
sizeof
(
s
),
"%H"
,
timeinfo
);
std
::
string
res
=
lstrip
(
s
,
'0'
);
return
res
;
return
timeinfo
->
tm_hour
;
}
std
::
string
CivCommonUtils
::
lstrip
(
char
aa
[],
char
c
)
...
...
@@ -118,4 +115,14 @@ std::string CivCommonUtils::lstrip(char aa[], char c)
}
std
::
string
res
=
bb
;
return
res
;
}
std
::
string
CivCommonUtils
::
getExePath
(
void
)
{
char
szFilePath
[
MAX_PATH
+
1
]
=
{
0
};
GetModuleFileNameA
(
NULL
,
szFilePath
,
MAX_PATH
);
(
strrchr
(
szFilePath
,
'\\'
))[
0
]
=
0
;
// 删除文件名,只获得路径字串
std
::
string
path
=
szFilePath
;
return
path
;
}
\ No newline at end of file
panda
DbManager
/CivCommonUtils.h
→
panda
Log
/CivCommonUtils.h
View file @
5acd729c
...
...
@@ -2,7 +2,7 @@
#include<string>
#include<map>
// #include<json/reader.h>
#define UTILSEXPORT __declspec(dllexport)
// 字符串转编码
#define TransUTFCoding(name) CivCommonUtils::string_To_UTF8(name)
...
...
@@ -15,7 +15,7 @@
#define CurrentHour CivCommonUtils::currentHour()
class
CivCommonUtils
class
UTILSEXPORT
CivCommonUtils
{
public
:
...
...
@@ -39,10 +39,12 @@ public:
*/
static
std
::
string
currentDate
();
static
std
::
string
currentHour
();
static
int
currentHour
();
static
std
::
string
lstrip
(
char
str
[],
char
c
);
static
std
::
string
getExePath
(
void
);
///**
//*@brief 将json字符串解析为
//*/
...
...
pandaLog/CivDate.cpp
0 → 100644
View file @
5acd729c
#include "CivDate.h"
#include <time.h>
#include <iostream>
using
namespace
std
;
CivDate
::
CivDate
()
{
time_t
rawtime
;
struct
tm
*
timeinfo
;
char
s
[
100
];
time
(
&
rawtime
);
timeinfo
=
localtime
(
&
rawtime
);
time_t
tick
=
mktime
(
timeinfo
);
year
=
1900
+
timeinfo
->
tm_year
;
month
=
1
+
timeinfo
->
tm_mon
;
day
=
timeinfo
->
tm_mday
;
}
void
CivDate
::
setDate
(
int
year
,
int
month
,
int
day
)
{
this
->
year
=
year
;
this
->
month
=
month
;
this
->
day
=
day
;
}
//add one day
void
CivDate
::
addDate
()
{
if
((
'y'
==
flagleap
)
&&
(
day
==
YearL
[
month
-
1
]))
{
day
=
1
;
month
+=
1
;
}
else
if
(
day
==
YearNL
[
month
-
1
])
{
day
=
1
;
month
+=
1
;
}
else
{
day
+=
1
;
}
}
//get the date
std
::
string
CivDate
::
getDate
()
{
std
::
string
date
;
date
.
append
(
std
::
to_string
(
year
));
date
.
append
(
"-"
);
date
.
append
(
std
::
to_string
(
month
));
date
.
append
(
"-"
);
date
.
append
(
std
::
to_string
(
day
));
return
date
;
}
pandaLog/CivDate.h
0 → 100644
View file @
5acd729c
#pragma once
#include <string>
#define CDATEEXPORT __declspec(dllexport)
class
CDATEEXPORT
CivDate
{
private
:
int
year
;
int
month
;
int
day
;
int
YearNL
[
12
]
=
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
int
YearL
[
12
]
=
{
31
,
29
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
char
flagleap
=
'n'
;
public
:
CivDate
();
void
setDate
(
int
year
,
int
month
,
int
day
);
void
addDate
();
std
::
string
getDate
();
};
pandaLog/pandaLog.vcxproj
View file @
5acd729c
...
...
@@ -142,15 +142,21 @@
</Link>
<PostBuildEvent>
<Command>
copy CivSysLog.h $(OutDir)..\include /y
copy CivCsvReader.h $(OutDir)..\include /y
</Command>
copy CivCsvReader.h $(OutDir)..\include /y
copy CivCommonUtils.h $(OutDir)..\include /y
copy CivDate.h $(OutDir)..\include /y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude
Include=
"CivCommonUtils.h"
/>
<ClInclude
Include=
"CivCsvReader.h"
/>
<ClInclude
Include=
"CivDate.h"
/>
<ClInclude
Include=
"CivSysLog.h"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivCommonUtils.cpp"
/>
<ClCompile
Include=
"CivCsvReader.cpp"
/>
<ClCompile
Include=
"CivDate.cpp"
/>
<ClCompile
Include=
"CivSysLog.cpp"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
...
...
pandaLog/pandaLog.vcxproj.filters
View file @
5acd729c
...
...
@@ -21,6 +21,12 @@
<ClInclude
Include=
"CivCsvReader.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivCommonUtils.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivDate.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivSysLog.cpp"
>
...
...
@@ -29,5 +35,11 @@
<ClCompile
Include=
"CivCsvReader.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivCommonUtils.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivDate.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
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