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
bb7193b7
Commit
bb7193b7
authored
Jul 24, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,上下游追踪
parent
81b040f6
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
867 additions
and
2170 deletions
+867
-2170
CivHydrTest.cpp
funcDemo/CivHydrTest.cpp
+50
-0
CivHydrTest.h
funcDemo/CivHydrTest.h
+27
-0
main.cpp
funcDemo/main.cpp
+17
-2
hydraulicModel.sln
hydraulicModel.sln
+0
-12
CivGraphList.h
pandaAlgorithm/CivGraphList.h
+0
-125
CivTrackingAnalysis.cpp
pandaAlgorithm/CivTrackingAnalysis.cpp
+0
-75
pandaAlgorithm.vcxproj
pandaAlgorithm/pandaAlgorithm.vcxproj
+0
-164
pandaAlgorithm.vcxproj.filters
pandaAlgorithm/pandaAlgorithm.vcxproj.filters
+0
-46
pandaAlgorithm.vcxproj.user
pandaAlgorithm/pandaAlgorithm.vcxproj.user
+0
-5
CivBuilder.cpp
pandaAnalysis/CivBuilder.cpp
+5
-0
CivBuilder.h
pandaAnalysis/CivBuilder.h
+2
-0
CivGraphFactory.cpp
pandaAnalysis/CivGraphFactory.cpp
+18
-4
CivGraphFactory.h
pandaAnalysis/CivGraphFactory.h
+4
-2
CivGraphList.h
pandaAnalysis/CivGraphList.h
+241
-54
CivHydDataType.cpp
pandaAnalysis/CivHydDataType.cpp
+17
-2
CivHydDataType.h
pandaAnalysis/CivHydDataType.h
+31
-8
CivHydrCalc.cpp
pandaAnalysis/CivHydrCalc.cpp
+0
-762
CivHydrCalc.h
pandaAnalysis/CivHydrCalc.h
+0
-83
CivHydrFuncInter.cpp
pandaAnalysis/CivHydrFuncInter.cpp
+71
-32
CivHydrFuncInter.h
pandaAnalysis/CivHydrFuncInter.h
+24
-8
CivHydrSimulation.cpp
pandaAnalysis/CivHydrSimulation.cpp
+74
-9
CivHydrSimulation.h
pandaAnalysis/CivHydrSimulation.h
+8
-0
CivInp.cpp
pandaAnalysis/CivInp.cpp
+0
-572
CivInp.h
pandaAnalysis/CivInp.h
+0
-188
CivNewInp.cpp
pandaAnalysis/CivNewInp.cpp
+13
-0
CivNewInp.h
pandaAnalysis/CivNewInp.h
+3
-0
CivTrackingAnalysis.cpp
pandaAnalysis/CivTrackingAnalysis.cpp
+222
-0
CivTrackingAnalysis.h
pandaAnalysis/CivTrackingAnalysis.h
+11
-1
pandaAnalysis.vcxproj
pandaAnalysis/pandaAnalysis.vcxproj
+7
-4
pandaAnalysis.vcxproj.filters
pandaAnalysis/pandaAnalysis.vcxproj.filters
+22
-12
No files found.
funcDemo/CivHydrTest.cpp
View file @
bb7193b7
...
...
@@ -63,3 +63,53 @@ void CivConGetRptTest::test(char* uri)
std
::
cout
<<
result
<<
std
::
endl
;
std
::
cout
<<
"测试结果:"
<<
isSucc
<<
std
::
endl
;
}
void
CivUpstreamTrackingTest
::
test
(
char
*
uri
)
{
// 追踪节点编号
char
sn
[
32
];
strcpy
(
sn
,
"JD00000016"
);
char
result
[
1024
*
32
];
bool
isSucc
=
upstreamTracking
(
uri
,
sn
,
result
);
std
::
cout
<<
result
<<
std
::
endl
;
std
::
cout
<<
"测试结果:"
<<
isSucc
<<
std
::
endl
;
}
/**
下游追踪
*/
void
CivDownStreamTrackingTest
::
test
(
char
*
uri
)
{
// 追踪节点编号
char
sn
[
32
];
strcpy
(
sn
,
"JD00000047"
);
char
result
[
1024
*
128
];
bool
isSucc
=
downstreamTracking
(
uri
,
sn
,
result
);
std
::
cout
<<
result
<<
std
::
endl
;
std
::
cout
<<
"测试结果:"
<<
isSucc
<<
std
::
endl
;
}
/**
水源供水范围分析
*/
void
CivWaterSupplyScopeTest
::
test
(
char
*
uri
)
{
// 追踪节点编号
char
sn
[
32
];
strcpy
(
sn
,
"JD00000016"
);
char
result
[
1024
*
32
];
bool
isSucc
=
waterSupplyScopeAnalysis
(
uri
,
sn
,
result
);
std
::
cout
<<
result
<<
std
::
endl
;
std
::
cout
<<
"测试结果:"
<<
isSucc
<<
std
::
endl
;
}
funcDemo/CivHydrTest.h
View file @
bb7193b7
...
...
@@ -45,3 +45,30 @@ class CivConGetRptTest :public CivHydrTest
public
:
virtual
void
test
(
char
*
uri
);
};
/**
上游追踪
*/
class
CivUpstreamTrackingTest
:
public
CivHydrTest
{
public
:
virtual
void
test
(
char
*
uri
);
};
/**
下游追踪
*/
class
CivDownStreamTrackingTest
:
public
CivHydrTest
{
public
:
virtual
void
test
(
char
*
uri
);
};
/**
水源供水范围分析
*/
class
CivWaterSupplyScopeTest
:
public
CivHydrTest
{
public
:
virtual
void
test
(
char
*
uri
);
};
funcDemo/main.cpp
View file @
bb7193b7
...
...
@@ -24,8 +24,8 @@ int main(int argc, char* argv[])
context.contextTest(findUri);*/
// 测试追踪分析
CivTestContext
context
(
new
CivConTrackTest
());
context
.
contextTest
(
findUri
);
/*
CivTestContext context(new CivConTrackTest());
context.contextTest(findUri);
*/
// 测试根据时段获取值
/* CivTestContext context(new CivConGetDataTest());
...
...
@@ -34,6 +34,20 @@ int main(int argc, char* argv[])
// 测试根据
/* CivTestContext context(new CivConGetRptTest());
context.contextTest(findUri);*/
// 上游追踪
/* CivTestContext context(new CivUpstreamTrackingTest());
context.contextTest(findUri);*/
// 下游追踪
CivTestContext
context
(
new
CivDownStreamTrackingTest
());
context
.
contextTest
(
findUri
);
// 水源供水范围分析
/* CivTestContext context(new CivWaterSupplyScopeTest());
context.contextTest(findUri);*/
getchar
();
return
0
;
}
\ No newline at end of file
hydraulicModel.sln
View file @
bb7193b7
...
...
@@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "funcDemo", "funcDemo\funcDe
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaLog", "pandaLog\pandaLog.vcxproj", "{4C38D294-830F-441E-B892-60117ABA8BFE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaAlgorithm", "pandaAlgorithm\pandaAlgorithm.vcxproj", "{B004F96E-D760-410C-B298-B6E0510E831E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
@@ -79,16 +77,6 @@ Global
{4C38D294-830F-441E-B892-60117ABA8BFE}.Release|x64.Build.0 = Release|x64
{4C38D294-830F-441E-B892-60117ABA8BFE}.Release|x86.ActiveCfg = Release|Win32
{4C38D294-830F-441E-B892-60117ABA8BFE}.Release|x86.Build.0 = Release|Win32
{B004F96E-D760-410C-B298-B6E0510E831E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{B004F96E-D760-410C-B298-B6E0510E831E}.Debug|x64.ActiveCfg = Debug|x64
{B004F96E-D760-410C-B298-B6E0510E831E}.Debug|x64.Build.0 = Debug|x64
{B004F96E-D760-410C-B298-B6E0510E831E}.Debug|x86.ActiveCfg = Debug|Win32
{B004F96E-D760-410C-B298-B6E0510E831E}.Debug|x86.Build.0 = Debug|Win32
{B004F96E-D760-410C-B298-B6E0510E831E}.Release|Any CPU.ActiveCfg = Release|Win32
{B004F96E-D760-410C-B298-B6E0510E831E}.Release|x64.ActiveCfg = Release|x64
{B004F96E-D760-410C-B298-B6E0510E831E}.Release|x64.Build.0 = Release|x64
{B004F96E-D760-410C-B298-B6E0510E831E}.Release|x86.ActiveCfg = Release|Win32
{B004F96E-D760-410C-B298-B6E0510E831E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
pandaAlgorithm/CivGraphList.h
deleted
100644 → 0
View file @
81b040f6
#pragma once
#include <iostream>
#include <cstdio>
#include <vector>
#define IN
#define OUT
#define INOUT
using
namespace
std
;
class
CivDbConn
;
/**
*@brief 边表结点
*@param weight 权重类型
*/
template
<
class
EdgeType
>
struct
Edge
{
int
nDestVertex
;
// 该边所指向的顶点位置
EdgeType
edgeObj
;
// 边的属性值对象
Edge
<
EdgeType
>*
pNextEdge
;
// 连接下一条弧的指针
Edge
(
int
d
,
EdgeType
c
,
Edge
<
EdgeType
>*
p
=
NULL
)
:
nDestVertex
(
d
),
edgeObj
(
c
),
pNextEdge
(
p
)
{}
};
/**
*@brief 邻接表中表的顶点
*@param VertexType 节点信息
*@param EdgeType 弧信息
*/
template
<
class
VertexType
,
class
EdgeType
>
struct
Vertex
{
VertexType
mVertex
;
// 顶点信息
Edge
<
EdgeType
>*
pAdjEdges
;
// 指向第一条依附该顶点的弧
Vertex
(
VertexType
x
,
Edge
<
EdgeType
>*
p
=
NULL
)
:
mVertex
(
x
),
pAdjEdges
(
p
)
{}
};
/**
基于邻接表的图
*/
template
<
class
VertexType
,
class
EdgeType
>
class
ALGraph
{
public
:
explicit
ALGraph
();
~
ALGraph
();
void
BFS
(
VertexType
vetexType
,
std
::
vector
<
int
>&
visited
);
/**
*@brief 图反向
*/
void
graphReverse
();
Edge
<
EdgeType
>*
reverseList
(
Edge
<
EdgeType
>*
edge
);
/**
*@brief 往图中插入一个节点
*@param vertexName 节点值
*/
bool
insertAVertex
(
IN
const
VertexType
&
vertexName
);
/**
*@brief 两个节点之间插入一条边
*@param vertexName1 节点对象1
*@param vertexName2 节点对象2
*@param edge 边
*/
bool
insertAEdge
(
IN
const
VertexType
&
vertexName1
,
IN
const
VertexType
&
vertexName2
,
IN
const
EdgeType
&
edge
);
/**
*@brief 移除两个节点的边
*@param vertexName1 节点对象1
*@param vertexName2 节点对象2
*@param edge 边
*/
bool
removeAEdge
(
IN
const
VertexType
&
vertexName1
,
IN
const
VertexType
&
vertexName2
,
IN
const
EdgeType
&
edgeWeight
);
/**
*@brief 获取两个节点之间连接的最小权重值
*@param vertexName1 节点1
*@param vertexName2 节点2
*/
EdgeType
getMinWeight
(
IN
const
VertexType
&
vertexName1
,
IN
const
VertexType
&
vertexName2
);
/**
*@brief 获取两个节点之间连接的最小权重值
*@param vertexName1 节点1
*@param vertexName2 节点2
*/
int
getVertexIndex
(
IN
const
VertexType
&
vertexName
);
/**
*@brief 获取顶点数据
*/
int
getVertexNumber
();
/**
*@brief 根据索引获取顶点数据
*@param index 索引值
*/
VertexType
getData
(
IN
int
index
);
private
:
bool
isReverse
=
false
;
EdgeType
getEdgeWeight
(
IN
const
Edge
<
EdgeType
>*
pEdge
);
void
getVertexEdgeWeight
(
IN
const
int
v1
,
OUT
vector
<
EdgeType
>&
DistanceArray
);
vector
<
Vertex
<
VertexType
,
EdgeType
>>
mVertexArray
;
// 节点数组
};
pandaAlgorithm/CivTrackingAnalysis.cpp
deleted
100644 → 0
View file @
81b040f6
#include "CivTrackingAnalysis.h"
#include "CivGraphFactory.h"
CivTrackingAnalysis
::
CivTrackingAnalysis
()
:
mGraph
(
nullptr
)
{
}
CivTrackingAnalysis
::~
CivTrackingAnalysis
()
{
delete
mGraph
;
}
bool
CivTrackingAnalysis
::
createGraphFrom
(
CivDbConn
*
dbConn
)
{
if
(
dbConn
==
nullptr
)
return
false
;
CivGraphFactory
factory
;
mGraph
=
factory
.
createGraph
(
dbConn
);
if
(
mGraph
==
nullptr
)
return
false
;
return
true
;
}
bool
CivTrackingAnalysis
::
upstreamTracking
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
)
{
return
true
;
}
bool
CivTrackingAnalysis
::
downstreamTracking
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
)
{
return
true
;
}
bool
CivTrackingAnalysis
::
waterSupplyScopeAnalysis
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
)
{
return
true
;
}
bool
CivTrackingAnalysis
::
upstreamTracking
(
const
std
::
string
&
sN
,
std
::
vector
<
CivGraphJunction
>&
junctions
,
std
::
vector
<
CivGraphEdage
>&
pipes
)
{
return
true
;
}
bool
CivTrackingAnalysis
::
downstreamTracking
(
const
std
::
string
&
sN
,
std
::
vector
<
CivGraphJunction
>&
junctions
,
std
::
vector
<
CivGraphEdage
>&
pipes
)
{
if
(
mGraph
==
nullptr
)
return
false
;
CivGraphJunction
junction
(
sN
);
std
::
vector
<
int
>
visited
;
mGraph
->
BFS
(
junction
,
visited
);
return
true
;
}
bool
CivTrackingAnalysis
::
waterSupplyScopeAnalysis
(
const
std
::
string
&
sN
,
std
::
vector
<
CivGraphJunction
>&
junctions
,
std
::
vector
<
CivGraphEdage
>&
pipes
)
{
return
true
;
}
\ No newline at end of file
pandaAlgorithm/pandaAlgorithm.vcxproj
deleted
100644 → 0
View file @
81b040f6
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Debug|x64"
>
<Configuration>
Debug
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|x64"
>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<VCProjectVersion>
16.0
</VCProjectVersion>
<Keyword>
Win32Proj
</Keyword>
<ProjectGuid>
{b004f96e-d760-410c-b298-b6e0510e831e}
</ProjectGuid>
<RootNamespace>
pandaAlgorithm
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"Shared"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<LinkIncremental>
true
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<LinkIncremental>
false
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<LinkIncremental>
true
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<LinkIncremental>
false
</LinkIncremental>
<OutDir>
..\..\hModelProgram\Program\
</OutDir>
<IncludePath>
$(OUTDIR)..\include;$(IncludePath)
</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<Optimization>
Disabled
</Optimization>
<AdditionalIncludeDirectories>
$(OUTDIR)..\include;$(SolutionDir)pandaDbManager;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<AdditionalDependencies>
pandaDbManager.lib;%(AdditionalDependencies)
</AdditionalDependencies>
<AdditionalLibraryDirectories>
$(OUTDIR)..\lib
</AdditionalLibraryDirectories>
<ImportLibrary>
$(OutDir)..\lib\$(TargetName).lib
</ImportLibrary>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude
Include=
"CivGraphFactory.h"
/>
<ClInclude
Include=
"CivGraphList.h"
/>
<ClInclude
Include=
"CivHydDataType.h"
/>
<ClInclude
Include=
"CivTrackingAnalysis.h"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivGraphFactory.cpp"
/>
<ClCompile
Include=
"CivGraphList.cpp"
/>
<ClCompile
Include=
"CivHydDataType.cpp"
/>
<ClCompile
Include=
"CivTrackingAnalysis.cpp"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
pandaAlgorithm/pandaAlgorithm.vcxproj.filters
deleted
100644 → 0
View file @
81b040f6
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"源文件"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"头文件"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
</Extensions>
</Filter>
<Filter
Include=
"资源文件"
>
<UniqueIdentifier>
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
</UniqueIdentifier>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivGraphList.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivHydDataType.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivGraphFactory.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivTrackingAnalysis.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivGraphList.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivHydDataType.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivGraphFactory.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivTrackingAnalysis.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
pandaAlgorithm/pandaAlgorithm.vcxproj.user
deleted
100644 → 0
View file @
81b040f6
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup
/>
</Project>
\ No newline at end of file
pandaAnalysis/CivBuilder.cpp
View file @
bb7193b7
...
...
@@ -43,6 +43,11 @@ void CivInpBuilder::setQualityType(const QualityAnalyType analyType, const std::
mNewInp
->
setQualityType
(
analyType
,
qulityName
);
}
void
CivInpBuilder
::
setDuration
(
int
duration
)
{
mNewInp
->
setDuration
(
duration
);
}
void
CivInpBuilder
::
registDb
(
CivDbConn
*
dbConn
)
{
mDbConn
=
dbConn
;
...
...
pandaAnalysis/CivBuilder.h
View file @
bb7193b7
...
...
@@ -14,6 +14,7 @@ public:
virtual
~
CivBuilder
();
virtual
void
setQualityType
(
const
QualityAnalyType
analyType
,
const
std
::
string
&
qulityName
)
=
0
;
virtual
void
setDuration
(
int
duration
)
=
0
;
virtual
void
registDb
(
CivDbConn
*
dbConn
)
=
0
;
virtual
void
buildNode
()
=
0
;
virtual
void
buildPipe
()
=
0
;
...
...
@@ -55,6 +56,7 @@ public:
~
CivInpBuilder
();
virtual
void
setQualityType
(
const
QualityAnalyType
analyType
,
const
std
::
string
&
qulityName
);
virtual
void
setDuration
(
int
duration
);
// 注册数据库连接
virtual
void
registDb
(
CivDbConn
*
dbConn
);
virtual
void
buildNode
();
...
...
pandaA
lgorithm
/CivGraphFactory.cpp
→
pandaA
nalysis
/CivGraphFactory.cpp
View file @
bb7193b7
...
...
@@ -2,18 +2,21 @@
#include "CivGraphList.h"
#include "CivDbConn.h"
#include "CivPgConn.h"
#include "CivTrackingResultCache.h"
CivGraphFactory
::
CivGraphFactory
()
{
}
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
CivGraphFactory
::
createGraph
(
CivDbConn
*
dbConn
)
bool
CivGraphFactory
::
initGraph
(
CivDbConn
*
dbConn
,
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
)
{
if
(
graph
==
nullptr
)
return
false
;
if
(
dbConn
==
nullptr
)
return
false
;
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
=
new
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>
();
// 顶点坐标
CivCoordinates
coords
;
...
...
@@ -51,9 +54,19 @@ ALGraph<CivGraphJunction, CivGraphEdage>* CivGraphFactory::createGraph(CivDbCon
CivGraphJunction
endJunction
=
graph
->
getData
(
index2
);
CivGraphEdage
edAge
(
pipeTable
.
ID
,
pipeTable
.
Length
,
{
sStartjuction
.
getXCoord
(),
sStartjuction
.
getYCoord
(),
endJunction
.
getXCoord
(),
endJunction
.
getYCoord
()});
if
(
sStartjuction
.
getHead
()
>
endJunction
.
getHead
())
{
CivGraphEdage
edAge
(
pipeTable
.
ID
,
pipeTable
.
Length
,
{
sStartjuction
.
getXCoord
(),
sStartjuction
.
getYCoord
(),
endJunction
.
getXCoord
(),
endJunction
.
getYCoord
()
});
graph
->
insertAEdge
(
sStartjuction
,
endJunction
,
edAge
);
}
return
graph
;
else
{
CivGraphEdage
edAge
(
pipeTable
.
ID
,
pipeTable
.
Length
,
{
endJunction
.
getXCoord
(),
endJunction
.
getYCoord
(),
sStartjuction
.
getXCoord
(),
sStartjuction
.
getYCoord
()
});
graph
->
insertAEdge
(
endJunction
,
sStartjuction
,
edAge
);
}
}
return
true
;
}
\ No newline at end of file
pandaA
lgorithm
/CivGraphFactory.h
→
pandaA
nalysis
/CivGraphFactory.h
View file @
bb7193b7
#pragma once
#include "CivHydDataType.h"
#include "CivGraphList.h"
// 声明模板图类型
template
<
class
VertexType
,
class
EdgeType
>
class
ALGraph
;
class
CivDbConn
;
class
CivGraphJunction
;
class
CivGraphEdage
;
class
CivGraphFactory
{
...
...
@@ -16,5 +18,5 @@ public:
*@param dbConn 数据库连接
*@param graph 有向图
*/
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
createGraph
(
CivDbConn
*
dbConn
);
bool
initGraph
(
CivDbConn
*
dbConn
,
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
);
};
pandaA
lgorithm/CivGraphList.cpp
→
pandaA
nalysis/CivGraphList.h
View file @
bb7193b7
#include "CivGraphList.h"
#include "CivPgConn.h"
#include "CivDbConn.h"
#include "CivHydDataType.h"
#pragma once
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define IN
#define OUT
#define INOUT
#define ALGRAPHEXPORT __declspec(dllexport)
class
CivDbConn
;
/**
*@brief 边表结点
*@param weight 权重类型
*/
template
<
class
EdgeType
>
struct
Edge
{
int
nDestVertex
;
// 该边所指向的顶点位置
EdgeType
edgeObj
;
// 边的属性值对象
Edge
<
EdgeType
>*
pNextEdge
;
// 连接下一条弧的指针
Edge
()
{
}
Edge
(
int
d
,
EdgeType
c
,
Edge
<
EdgeType
>*
p
=
NULL
)
:
nDestVertex
(
d
),
edgeObj
(
c
),
pNextEdge
(
p
)
{}
};
/**
*@brief 邻接表中表的顶点
*@param VertexType 节点信息
*@param EdgeType 弧信息
*/
template
<
class
VertexType
,
class
EdgeType
>
struct
Vertex
{
VertexType
mVertex
;
// 顶点信息
Edge
<
EdgeType
>*
pAdjEdges
;
// 指向第一条依附该顶点的弧
Vertex
(
VertexType
x
,
Edge
<
EdgeType
>*
p
=
NULL
)
:
mVertex
(
x
),
pAdjEdges
(
p
)
{}
};
/**
基于邻接表的图
*/
template
<
class
VertexType
,
class
EdgeType
>
class
ALGraph
{
public
:
explicit
ALGraph
();
~
ALGraph
();
void
getVisitedResult
(
IN
const
VertexType
&
vetexType
,
OUT
std
::
vector
<
VertexType
>&
vertex
,
OUT
std
::
vector
<
EdgeType
>&
edges
);
void
BFS
(
IN
VertexType
vetexType
,
OUT
std
::
vector
<
int
>&
visited
);
/**
*@brief 构建逆邻接表
*/
ALGraph
<
VertexType
,
EdgeType
>*
reverseGraph
();
/**
*@brief 往图中插入一个节点
*@param vertexName 节点值
*/
bool
insertAVertex
(
IN
const
VertexType
&
vertexName
);
/**
*@brief 两个节点之间插入一条边
*@param vertexName1 节点对象1
*@param vertexName2 节点对象2
*@param edge 边
*/
bool
insertAEdge
(
IN
const
VertexType
&
vertexName1
,
IN
const
VertexType
&
vertexName2
,
IN
const
EdgeType
&
edge
);
/**
*@brief 添加头节点
*@param index 顶点索引
*@param arcNode 头节点
*/
bool
addHeadEdage
(
IN
const
int
index
,
IN
Edge
<
EdgeType
>*
arcNode
);
bool
insertBeforeEdage
(
IN
const
int
index
,
IN
Edge
<
EdgeType
>*
arcNode
);
/**
*@brief 移除两个节点的边
*@param vertexName1 节点对象1
*@param vertexName2 节点对象2
*@param edge 边
*/
bool
removeAEdge
(
IN
const
VertexType
&
vertexName1
,
IN
const
VertexType
&
vertexName2
,
IN
const
EdgeType
&
edgeWeight
);
/**
*@brief 获取两个节点之间连接的最小权重值
*@param vertexName1 节点1
*@param vertexName2 节点2
*/
EdgeType
getMinWeight
(
IN
const
VertexType
&
vertexName1
,
IN
const
VertexType
&
vertexName2
);
/**
*@brief 获取顶点索引
*@param vertexName 顶点名,唯一标识
*/
int
getVertexIndex
(
IN
const
VertexType
&
vertexName
);
/**
*@brief 获取顶点数据
*/
int
getVertexNumber
();
/**
*@brief 根据索引获取顶点数据
*@param index 索引值
*/
VertexType
getData
(
IN
int
index
);
private
:
EdgeType
getEdgeWeight
(
IN
const
Edge
<
EdgeType
>*
pEdge
);
void
getVertexEdgeWeight
(
IN
const
int
v1
,
OUT
std
::
vector
<
EdgeType
>&
DistanceArray
);
std
::
vector
<
Vertex
<
VertexType
,
EdgeType
>>
mVertexArray
;
// 节点数组
};
template
<
class
VertexType
,
class
EdgeType
>
ALGraph
<
VertexType
,
EdgeType
>::
ALGraph
()
...
...
@@ -10,21 +142,52 @@ ALGraph<VertexType, EdgeType>::ALGraph()
}
template
<
class
VertexType
,
class
EdgeType
>
void
ALGraph
<
VertexType
,
EdgeType
>::
BFS
(
VertexType
vertexName
,
std
::
vector
<
int
>&
visited
)
void
ALGraph
<
VertexType
,
EdgeType
>::
getVisitedResult
(
IN
const
VertexType
&
vetexType
,
OUT
std
::
vector
<
VertexType
>&
vertex
,
OUT
std
::
vector
<
EdgeType
>&
edges
)
{
std
::
vector
<
int
>
visited
;
BFS
(
vetexType
,
visited
);
size_t
total
=
visited
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
int
index
=
visited
[
i
];
Vertex
<
VertexType
,
EdgeType
>
vertexTemp
=
mVertexArray
.
at
(
index
);
VertexType
vertexType
=
vertexTemp
.
mVertex
;
Edge
<
EdgeType
>*
pArcNext
=
vertexTemp
.
pAdjEdges
;
// 顶点数据
vertex
.
push_back
(
vertexType
);
// 边数据,注意去重
while
(
pArcNext
!=
nullptr
)
{
EdgeType
edgeType
=
pArcNext
->
edgeObj
;
pArcNext
=
pArcNext
->
pNextEdge
;
edges
.
push_back
(
edgeType
);
}
}
}
template
<
class
VertexType
,
class
EdgeType
>
void
ALGraph
<
VertexType
,
EdgeType
>::
BFS
(
IN
VertexType
vetexType
,
OUT
std
::
vector
<
int
>&
visited
)
{
// 获取输入顶点索引
int
vi
=
getVertexIndex
(
ve
rtexNam
e
);
if
(
-
1
==
v
1
)
int
vi
=
getVertexIndex
(
ve
texTyp
e
);
if
(
-
1
==
v
i
)
{
cerr
<<
"There is no vertex "
<<
endl
;
return
false
;
return
;
}
Edge
<
EdgeType
>*
edageNext
;
// 初始化队列
std
::
queue
<
int
>
Q
;
Q
.
push
(
node
);
Q
.
push
(
vi
);
visited
.
push_back
(
vi
);
while
(
!
Q
.
empty
())
{
...
...
@@ -39,7 +202,7 @@ void ALGraph<VertexType, EdgeType>::BFS(VertexType vertexName, std::vector<int>&
int
pVal
=
edageNext
->
nDestVertex
;
auto
iter
=
std
::
find
(
visited
.
begin
(),
visited
.
end
(),
pVal
);
if
(
iter
==
visited
.
end
())
if
(
pVal
>-
1
&&
iter
==
visited
.
end
())
{
visited
.
push_back
(
pVal
);
Q
.
push
(
pVal
);
...
...
@@ -51,52 +214,47 @@ void ALGraph<VertexType, EdgeType>::BFS(VertexType vertexName, std::vector<int>&
}
}
template
<
class
VertexType
,
class
EdgeType
>
Edge
<
EdgeType
>*
ALGraph
<
VertexType
,
EdgeType
>::
reverseList
(
Edge
<
EdgeType
>*
edge
)
ALGraph
<
VertexType
,
EdgeType
>*
ALGraph
<
VertexType
,
EdgeType
>::
reverseGraph
()
{
Edge
<
EdgeType
>*
resultList
=
new
Edge
<
EdgeType
>
(
0
,
EdgeType
());
result
->
pNextEdge
=
edge
;
Edge
<
EdgeType
>*
p
=
edge
;
Edge
<
EdgeType
>*
pNext
=
p
->
pNextEdge
;
// 构造一个你临界表图对象
ALGraph
<
VertexType
,
EdgeType
>*
graph
=
new
ALGraph
<
VertexType
,
EdgeType
>
();
while
(
pNext
!=
nullptr
)
size_t
vertexSize
=
mVertexArray
.
size
();
//初始化表头顶点表
for
(
int
i
=
0
;
i
<
vertexSize
;
i
++
)
{
p
->
pNextEdge
=
pNext
->
pNextEdge
;
pNext
->
pNextEdge
=
resultList
->
pNextEdge
;
resultList
->
pNextEdge
=
pNext
;
pNext
=
p
->
pNextEdge
;
}
Vertex
<
VertexType
,
EdgeType
>
vetex
=
mVertexArray
.
at
(
i
);
graph
->
insertAVertex
(
vetex
.
mVertex
);
Edge
<
EdgeType
>*
node
=
resultList
->
pNextEdge
;
delete
resultList
;
// 定义头节点
Edge
<
EdgeType
>*
arcNode
=
new
Edge
<
EdgeType
>
(
-
1
,
EdgeType
());
int
index
=
graph
->
getVertexIndex
(
vetex
.
mVertex
);
return
node
;
}
// 添加头节点
graph
->
addHeadEdage
(
index
,
arcNode
);
}
template
<
class
VertexType
,
class
EdgeType
>
void
ALGraph
<
VertexType
,
EdgeType
>::
graphReverse
()
{
for
(
int
i
=
0
;
i
<
mVertexArray
.
size
();
i
++
)
//遍历所有弧,构建逆邻接表
for
(
int
i
=
0
;
i
<
vertexSize
;
i
++
)
{
Vertex
<
VertexType
,
EdgeType
>
vetex
=
mVertexArray
.
at
(
i
);
Edge
<
EdgeType
>*
edge
=
vetex
.
pAdjEdges
;
// 顶点i的第一个出度
Edge
<
EdgeType
>*
p
=
vetex
.
pAdjEdges
;
Edge
<
EdgeType
>*
pNext
=
p
->
pNextEdge
;
while
(
pNext
!=
nullptr
)
while
(
edge
!=
nullptr
)
{
p
->
pNextEdge
=
pNext
->
pNextEdge
;
pNext
->
pNextEdge
=
vetex
.
pAdjEdges
;
int
k
=
edge
->
nDestVertex
;
// 记录节点索引位置
vetex
.
pAdjEdges
=
pNext
;
pNext
=
p
->
pNextEdge
;
// 构造
Edge
<
EdgeType
>*
arcNode
=
new
Edge
<
EdgeType
>
(
i
,
edge
->
edgeObj
);
graph
->
insertBeforeEdage
(
k
,
arcNode
);
edge
=
edge
->
pNextEdge
;
}
}
return
;
return
graph
;
}
template
<
class
VertexType
,
class
EdgeType
>
...
...
@@ -127,6 +285,32 @@ bool ALGraph<VertexType, EdgeType>::insertAVertex(IN const VertexType& vertexNam
return
true
;
}
template
<
class
VertexType
,
class
EdgeType
>
bool
ALGraph
<
VertexType
,
EdgeType
>::
addHeadEdage
(
IN
const
int
index
,
IN
Edge
<
EdgeType
>*
arcNode
)
{
if
(
index
<
0
||
index
>=
mVertexArray
.
size
())
{
return
false
;
}
mVertexArray
.
at
(
index
).
pAdjEdges
=
arcNode
;
return
true
;
}
template
<
class
VertexType
,
class
EdgeType
>
bool
ALGraph
<
VertexType
,
EdgeType
>::
insertBeforeEdage
(
IN
const
int
index
,
IN
Edge
<
EdgeType
>*
arcNode
)
{
if
(
index
<
0
&&
index
>=
mVertexArray
.
size
())
{
return
false
;
}
arcNode
->
pNextEdge
=
mVertexArray
.
at
(
index
).
pAdjEdges
->
pNextEdge
;
mVertexArray
.
at
(
index
).
pAdjEdges
->
pNextEdge
=
arcNode
;
return
true
;
}
template
<
class
VertexType
,
class
EdgeType
>
bool
ALGraph
<
VertexType
,
EdgeType
>::
insertAEdge
(
IN
const
VertexType
&
vertexName1
,
IN
const
VertexType
&
vertexName2
,
IN
const
EdgeType
&
edgeWeight
)
...
...
@@ -134,14 +318,14 @@ bool ALGraph<VertexType, EdgeType>::insertAEdge(IN const VertexType& vertexName1
int
v1
=
getVertexIndex
(
vertexName1
);
if
(
-
1
==
v1
)
{
cerr
<<
"There is no vertex 1"
<<
endl
;
return
false
;
}
int
v2
=
getVertexIndex
(
vertexName2
);
if
(
-
1
==
v2
)
{
cerr
<<
"There is no vertex 2"
<<
endl
;
return
false
;
}
...
...
@@ -176,14 +360,14 @@ bool ALGraph<VertexType, EdgeType>::removeAEdge(IN const VertexType& vertexName1
int
v1
=
getVertexIndex
(
vertexName1
);
if
(
-
1
==
v1
)
{
cerr
<<
"There is no vertex 1"
<<
endl
;
return
false
;
}
int
v2
=
getVertexIndex
(
vertexName2
);
if
(
-
1
==
v2
)
{
cerr
<<
"There is no vertex 2"
<<
endl
;
return
false
;
}
...
...
@@ -197,11 +381,10 @@ bool ALGraph<VertexType, EdgeType>::removeAEdge(IN const VertexType& vertexName1
if
(
NULL
==
p
)
{
cerr
<<
"Edge is not found"
<<
endl
;
return
false
;
}
while
(
edgeWeight
!=
p
->
edge
Weight
&&
p
->
nDestVertex
==
v2
)
while
(
edgeWeight
!=
p
->
edge
Obj
&&
p
->
nDestVertex
==
v2
)
{
q
=
p
;
p
=
p
->
pNextEdge
;
...
...
@@ -209,7 +392,6 @@ bool ALGraph<VertexType, EdgeType>::removeAEdge(IN const VertexType& vertexName1
if
(
v2
!=
p
->
nDestVertex
)
{
cerr
<<
"Edge is not found"
<<
endl
;
return
false
;
}
...
...
@@ -226,9 +408,11 @@ EdgeType ALGraph<VertexType, EdgeType>::getEdgeWeight(IN const Edge<EdgeType>* p
}
template
<
class
VertexType
,
class
EdgeType
>
void
ALGraph
<
VertexType
,
EdgeType
>::
getVertexEdgeWeight
(
IN
const
int
v1
,
OUT
vector
<
EdgeType
>&
DistanceArray
)
void
ALGraph
<
VertexType
,
EdgeType
>::
getVertexEdgeWeight
(
IN
const
int
v1
,
OUT
std
::
vector
<
EdgeType
>&
DistanceArray
)
{
Edge
<
EdgeType
>*
p
=
mVertexArray
.
at
(
v1
).
pAdjEdges
;
Vertex
<
VertexType
,
EdgeType
>
tex
=
mVertexArray
.
at
(
v1
);
Edge
<
EdgeType
>*
p
=
tex
.
pAdjEdges
;
int
prevIndex
=
-
1
;
EdgeType
tmp
;
...
...
@@ -261,14 +445,12 @@ EdgeType ALGraph<VertexType, EdgeType>::getMinWeight(IN const VertexType& vertex
int
v1
=
getVertexIndex
(
vertexName1
);
if
(
-
1
==
v1
)
{
cerr
<<
"There is no vertex 1"
<<
endl
;
return
false
;
}
int
v2
=
getVertexIndex
(
vertexName2
);
if
(
-
1
==
v2
)
{
cerr
<<
"There is no vertex 2"
<<
endl
;
return
false
;
}
...
...
@@ -318,5 +500,10 @@ int ALGraph<VertexType, EdgeType>::getVertexNumber()
template
<
class
VertexType
,
class
EdgeType
>
VertexType
ALGraph
<
VertexType
,
EdgeType
>::
getData
(
IN
int
index
)
{
return
mVertexArray
.
at
(
index
).
mVertex
;
Vertex
<
VertexType
,
EdgeType
>
tex
=
mVertexArray
.
at
(
index
);
VertexType
vertex
=
tex
.
mVertex
;
return
vertex
;
}
pandaA
lgorithm
/CivHydDataType.cpp
→
pandaA
nalysis
/CivHydDataType.cpp
View file @
bb7193b7
#include "CivHydDataType.h"
bool
operator
==
(
const
CivGraphEdage
&
left
,
const
CivGraphEdage
&
right
)
{
return
left
.
mSN
==
right
.
mSN
;
}
bool
operator
==
(
const
CivGraphJunction
&
left
,
const
CivGraphJunction
&
right
)
{
return
left
.
mSN
==
right
.
mSN
;
}
CivGraphJunction
::
CivGraphJunction
()
{
}
CivGraphJunction
::
CivGraphJunction
(
std
::
string
sN
)
:
mSN
(
sN
)
{
...
...
@@ -17,6 +31,7 @@ bool CivGraphJunction::operator== (const CivGraphJunction& edage)
return
mSN
==
edage
.
mSN
;
}
CivGraphEdage
::
CivGraphEdage
()
{
}
...
...
@@ -25,7 +40,7 @@ CivGraphEdage::CivGraphEdage()
{
mSN
=
sn
;
mLength
=
length
;
if
(
position
.
size
()
!=
5
)
if
(
position
.
size
()
!=
4
)
return
;
...
...
@@ -37,7 +52,7 @@ CivGraphEdage::CivGraphEdage()
bool
CivGraphEdage
::
operator
==
(
const
CivGraphEdage
&
edage
)
{
return
m
Length
==
edage
.
mLength
;
return
m
SN
==
edage
.
mSN
;
}
bool
CivGraphEdage
::
operator
>
(
const
CivGraphEdage
&
edage
)
...
...
pandaA
lgorithm
/CivHydDataType.h
→
pandaA
nalysis
/CivHydDataType.h
View file @
bb7193b7
...
...
@@ -9,22 +9,30 @@
class
CivGraphJunction
{
public
:
explicit
CivGraphJunction
(
std
::
string
sN
);
explicit
CivGraphJunction
(
std
::
string
sN
,
std
::
string
xCoord
,
std
::
string
yCoord
);
CivGraphJunction
();
bool
operator
==
(
const
CivGraphJunction
&
edage
);
CivGraphJunction
(
std
::
string
sN
);
CivGraphJunction
(
std
::
string
sN
,
std
::
string
xCoord
,
std
::
string
yCoord
);
bool
operator
==
(
const
CivGraphJunction
&
j1
);
friend
bool
operator
==
(
const
CivGraphJunction
&
left
,
const
CivGraphJunction
&
right
);
void
setSn
(
const
std
::
string
&
sn
)
{
mSN
=
sn
;
}
std
::
string
getSn
()
{
return
mSN
;
}
void
setXCoord
(
std
::
string
xCoord
)
{
mXCoord
=
xCoord
;
}
void
setXCoord
(
const
std
::
string
&
xCoord
)
{
mXCoord
=
xCoord
;
}
std
::
string
getXCoord
()
{
return
mXCoord
;
}
void
setYCoord
(
std
::
string
yCoord
)
{
mXCoord
=
yCoord
;
}
void
setYCoord
(
const
std
::
string
&
yCoord
)
{
mXCoord
=
yCoord
;
}
std
::
string
getYCoord
()
{
return
mYCoord
;
}
void
setHead
(
float
head
)
{
mHead
=
head
;
}
float
getHead
()
{
return
mHead
;
}
private
:
std
::
string
mSN
;
// 本点号,
float
mHead
;
// 高程
std
::
string
mXCoord
;
// 横坐标
std
::
string
mYCoord
;
// 纵坐标
};
...
...
@@ -41,13 +49,28 @@ public:
*@param length 管长
*@param position 注意顺序,[length, startx, starty, endx, endy]
*/
explicit
CivGraphEdage
();
explicit
CivGraphEdage
(
std
::
string
sn
,
std
::
string
length
,
std
::
vector
<
std
::
string
>
position
);
CivGraphEdage
();
CivGraphEdage
(
std
::
string
sn
,
std
::
string
length
,
std
::
vector
<
std
::
string
>
position
);
friend
bool
operator
==
(
const
CivGraphEdage
&
left
,
const
CivGraphEdage
&
right
);
bool
operator
==
(
const
CivGraphEdage
&
edage
);
bool
operator
>
(
const
CivGraphEdage
&
edage
);
bool
operator
<
(
const
CivGraphEdage
&
edage
);
bool
operator
!=
(
const
CivGraphEdage
&
edage
);
bool
operator
!=
(
const
CivGraphEdage
&
edage
);
std
::
string
getLength
()
{
return
mLength
;
}
std
::
string
getSN
()
{
return
mSN
;
}
std
::
string
getStartX
()
{
return
mStartX
;
}
std
::
string
getStartY
()
{
return
mStartY
;
}
std
::
string
getEndX
()
{
return
mEndX
;
}
std
::
string
getEndY
()
{
return
mEndY
;
}
void
setLength
(
const
std
::
string
&
length
)
{
mLength
=
length
;
}
void
setSN
(
const
std
::
string
&
sn
)
{
mSN
=
sn
;
}
void
setStartX
(
const
std
::
string
&
startX
)
{
mStartX
=
startX
;
}
void
setStartY
(
const
std
::
string
&
startY
)
{
mStartY
=
startY
;
}
void
setEndX
(
const
std
::
string
&
endX
)
{
mEndX
=
endX
;
}
void
setEndY
(
const
std
::
string
&
endY
)
{
mEndY
=
endY
;
}
private
:
std
::
string
mSN
;
// 编号
...
...
pandaAnalysis/CivHydrCalc.cpp
deleted
100644 → 0
View file @
81b040f6
#include "CivHydrCalc.h"
#include "CivDbConnection.h"
#include "CivTypes.h"
#include "Epanet2.h"
#include "../pandaDbManager/CivCommonUtils.h"
#include <time.h>
#include "CivBuilder.h"
#include "CivInpDirector.h"
#include "CivDbConn.h"
#include "CivPgConn.h"
#include <iostream>
CivHydrCalc
::
CivHydrCalc
(
char
*
uri
,
std
::
string
netName
)
:
mNetname
(
netName
)
{
mDbConn
=
new
CivDbConnection
(
uri
);
mPgConn
=
new
CivPgConn
(
uri
);
}
CivHydrCalc
::~
CivHydrCalc
()
{
delete
mDbConn
;
}
bool
CivHydrCalc
::
hydrSimulation
(
char
*
fileName
,
char
*
rptFile
,
char
*
binOutFile
)
{
if
(
!
exportInp
(
fileName
))
{
CivSysLog
::
getInstance
()
->
error
(
"写入inp文件失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"写入inp成功"
,
"CivHydrCalc"
,
__FUNCTION__
);
short
hydCode
=
1
;
long
t
(
0
),
tstep
(
0
);
int
iTime
(
0
);
int
errcode
=
0
;
errcode
=
ENopen
(
fileName
,
rptFile
,
binOutFile
);
if
(
errcode
>
0
)
{
ENclose
();
CivSysLog
::
getInstance
()
->
error
(
"ENopen inp 失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"ENopen inp 成功"
,
"CivHydrCalc"
,
__FUNCTION__
);
if
(
ENopenH
()
>
0
)
{
ENclose
();
CivSysLog
::
getInstance
()
->
error
(
"ENopenH inp 失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
if
(
ENinitH
(
0
)
>
0
)
{
ENclose
();
CivSysLog
::
getInstance
()
->
error
(
"ENinitH inp 失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"ENinitH inp 成功"
,
"CivHydrCalc"
,
__FUNCTION__
);
float
dHStep
;
ENGetVal
(
4
,
&
dHStep
);
// hydrCompute(errcode);
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 是错误
{
ENclose
();
return
false
;
}
ENnextH
(
&
tstep
);
if
(
isFirst
)
{
mDbConn
->
deleteByDate
(
NODERESULTTABLE
,
"日期"
,
CurrentDate
);
mDbConn
->
deleteByDate
(
PIPERESULTTABLE
,
"日期"
,
CurrentDate
);
isFirst
=
false
;
}
// 获取当前节点和管段数据
getNodeResult
(
iTime
);
getLinkResult
(
iTime
);
iTime
++
;
}
while
(
tstep
>
0
);
// 更新数据
if
(
!
mResultCache
.
updateToDb
(
mDbConn
))
{
CivSysLog
::
getInstance
()
->
error
(
"水力分析结果存储失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
// 更新管网数据库数据
(
void
)
mDbConn
->
updateNodeByInterval
(
CurrentDate
,
"0"
);
(
void
)
mDbConn
->
updateLinkByInterval
(
CurrentDate
,
"0"
);
ENcloseH
();
ENclose
();
return
true
;
}
bool
CivHydrCalc
::
qualitySimulation
(
char
*
inpFile
,
char
*
rptFile
,
char
*
binOutFile
)
{
CivSysLog
::
getInstance
()
->
error
(
"开始水质分析计算"
,
"CivHydrCalc"
,
__FUNCTION__
);
if
(
!
exportInp
(
inpFile
))
{
CivSysLog
::
getInstance
()
->
error
(
"写入inp文件失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"写入inp成功"
,
"CivHydrCalc"
,
__FUNCTION__
);
// 运行水质运算需要先进行水力运算,没有直接采用ENSolveH 是为了考虑减压阀的压力曲线设置
long
t
(
0
),
tstep
(
0
);
int
iTime
(
0
);
int
errcode
=
0
;
errcode
=
ENopen
(
inpFile
,
rptFile
,
binOutFile
);
if
(
errcode
>
0
)
{
ENclose
();
CivSysLog
::
getInstance
()
->
error
(
"ENopen inp 失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"ENopen inp 成功"
,
"CivHydrCalc"
,
__FUNCTION__
);
if
(
ENopenH
()
>
0
)
{
ENclose
();
CivSysLog
::
getInstance
()
->
error
(
"ENopenH inp 失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
if
(
ENinitH
(
EN_SAVE
)
>
0
)
{
ENclose
();
CivSysLog
::
getInstance
()
->
error
(
"ENinitH inp 失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"ENinitH inp 成功"
,
"CivHydrCalc"
,
__FUNCTION__
);
bool
isFirst
=
true
;
do
{
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
errcode
=
ENrunH
(
&
t
);
// errcode > 100 是错误
if
(
errcode
>
100
)
{
ENopenQ
();
ENclose
();
return
false
;
}
if
(
isFirst
)
{
mDbConn
->
deleteByDate
(
NODERESULTTABLE
,
"日期"
,
CurrentDate
);
mDbConn
->
deleteByDate
(
PIPERESULTTABLE
,
"日期"
,
CurrentDate
);
isFirst
=
false
;
}
// 获取当前节点和管段数据
getNodeResult
(
iTime
);
getLinkResult
(
iTime
);
ENnextH
(
&
tstep
);
iTime
++
;
}
while
(
tstep
>
0
);
ENcloseH
();
// 进行水质分析
ENopenQ
();
ENinitQ
(
1
);
t
=
0
;
tstep
=
0
;
iTime
=
0
;
do
{
errcode
=
ENrunQ
(
&
t
);
// errcode > 100 是错误
if
(
errcode
>
100
)
{
ENcloseQ
();
ENclose
();
return
false
;
}
// 获取水质模拟结果
getNodeQuality
(
iTime
);
getLinkQuality
(
iTime
);
ENstepQ
(
&
tstep
);
iTime
++
;
}
while
(
tstep
>
0
);
ENcloseQ
();
ENclose
();
// 更新数据
if
(
!
mResultCache
.
updateToDb
(
mDbConn
))
{
CivSysLog
::
getInstance
()
->
error
(
"水质分析结果存储失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"水质分析结果存储成功"
,
"CivHydrCalc"
,
__FUNCTION__
);
// 更新管网数据库数据
(
void
)
mDbConn
->
updateNodeByInterval
(
CurrentDate
,
"0"
);
(
void
)
mDbConn
->
updateLinkByInterval
(
CurrentDate
,
"0"
);
CivSysLog
::
getInstance
()
->
info
(
"结束水质分析计算"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
true
;
}
bool
CivHydrCalc
::
exportInp
(
char
*
fileName
)
{
//1 ,获取管网组件
if
(
!
mDbConn
)
return
false
;
if
(
!
mDbConn
->
open
())
return
false
;
///*bool pattern = mDbConn->createTable(*CivPatternTableTemp());
//bool cii = mDbConn->createTable(OPTIONTTABLE, "public", CivTableTemp::PARAMETER_TABLE);
//bool curve = mDbConn->createTable(CURVETABLE, "public", CivTableTemp::CURVE_TABLE);
//bool node = mDbConn->createTable(NODERESULTTABLE, "public", CivTableTemp::NODE_TABLE);
//bool link = mDbConn->createTable(PIPERESULTTABLE, "public", CivTableTemp::PIPE_TABLE);*/
// 获取表格
Tables
tables
=
mDbConn
->
getTables
(
mNetname
);
if
(
tables
.
size
()
<=
0
)
CivSysLog
::
getInstance
()
->
error
(
mNetname
+
"查询不到表"
,
"CivHydrCalc"
,
__FUNCDNAME__
);
//2,解析管网组件
// 解析管网组件顺序: 管线放最后
CivInp
civInp
(
CivInp
::
HOURS
);
int
total
=
tables
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
std
::
string
table
=
tables
[
i
];
std
::
cout
<<
table
<<
std
::
endl
;
if
(
PIPELINE
==
table
)
continue
;
assemble
(
table
,
civInp
);
}
assemble
(
PIPELINE
,
civInp
);
// 设置曲线
// Componets curves = mDbConn->getComponets(CURVETABLE);
// 初始化参数
Options
options
;
options
.
units
=
Options
::
UNITS
::
LPS
;
options
.
TRIALS
=
"40"
;
options
.
ACCURACY
=
"0.001 "
;
options
.
EMITTEREXPONENT
=
"0.5"
;
options
.
SpecificGravity
=
"0.998"
;
options
.
headLoss
=
Options
::
HEADLOSS
::
HW
;
options
.
TOLERANCE
=
"0.0166666666666667 "
;
options
.
quality
=
Options
::
QUALITY
::
AGE
;
std
::
map
<
std
::
string
,
std
::
string
>
optMap
;
optMap
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"DAMPLIMIT"
,
"0"
));
optMap
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"CHECKFREQ"
,
"2"
));
optMap
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
"MAXCHECK"
,
"10"
));
civInp
.
setOption
(
options
,
optMap
);
// 设置
civInp
.
setDuration
(
24
);
civInp
.
setTimestep
(
"PATTERN"
,
1
);
civInp
.
setTimestep
(
"HYDRAULIC"
,
1
);
civInp
.
setTimestep
(
"QUALITY"
,
1
);
civInp
.
setTimeStart
(
"REPORT"
,
1
);
civInp
.
writeToFile
(
fileName
);
return
false
;
}
void
CivHydrCalc
::
assemble
(
const
std
::
string
&
table
,
CivInp
&
inp
)
{
// 根据组建类型解析字段
if
(
PIPELINE
==
table
)
{
// 管线
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
// 必备参数
Componets
comps
=
mDbConn
->
getComponets
(
table
);
PipeFields
pipes
;
Civitems
items
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
// 过滤掉与阀门和水泵连接的管线
Str
number
=
comp
.
find
(
"id"
)
->
second
;
FiledFilter
filter
=
mDbConn
->
getFilter
();
auto
iter
=
filter
.
find
(
PIPELINE
);
if
(
iter
!=
filter
.
end
())
{
auto
lineFilter
=
iter
->
second
;
if
(
lineFilter
.
count
(
number
)
>
0
)
continue
;
}
Str
id
=
comp
.
find
(
pipes
.
ID
)
->
second
;
Str
startNode
=
comp
.
find
(
pipes
.
Node1
)
->
second
;
Str
endNode
=
comp
.
find
(
pipes
.
Node2
)
->
second
;
Str
length
=
comp
.
find
(
pipes
.
Length
)
->
second
;
Str
diameter
=
comp
.
find
(
pipes
.
Diameter
)
->
second
;
Str
roughness
=
comp
.
find
(
pipes
.
Roughness
)
->
second
;
Str
minorLoss
=
comp
.
find
(
pipes
.
MinorLoss
)
->
second
;
Str
status
=
comp
.
find
(
pipes
.
Status
)
->
second
;
// 注意顺序
CivItem
civItem
;
if
(
id
==
""
||
id
.
empty
())
id
=
"GD"
+
comp
.
find
(
"id"
)
->
second
;
civItem
.
push_back
(
id
);
civItem
.
push_back
(
startNode
);
civItem
.
push_back
(
endNode
);
civItem
.
push_back
(
length
);
civItem
.
push_back
(
diameter
);
civItem
.
push_back
(
roughness
);
civItem
.
push_back
(
minorLoss
);
civItem
.
push_back
(
status
);
items
.
push_back
(
civItem
);
}
inp
.
writeComponet
(
items
,
_PIPES
);
}
else
if
(
PIPENODE
==
table
)
{
Componets
comps
=
mDbConn
->
getComponets
(
table
);
// 节点参数
// ;ID Elev Demand Pattern
// 坐标
//;Node X-Coord Y-Coord
JunctionsFields
jontionFields
;
Civitems
jounItems
;
Civitems
nodeCoordItems
;
Civitems
patternItems
;
Civitems
initQaulityItems
;
int
total
=
comps
.
size
();
std
::
set
<
Str
>
patterNams
;
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
Str
id
=
comp
.
find
(
jontionFields
.
ID
)
->
second
;
Str
elevation
=
comp
.
find
(
jontionFields
.
Elev
)
->
second
;
Str
demand
=
comp
.
find
(
jontionFields
.
Demand
)
->
second
;
Str
pattern
=
comp
.
find
(
jontionFields
.
Pattern
)
->
second
;
Str
x_coord
=
comp
.
find
(
jontionFields
.
X_Coord
)
->
second
;
Str
y_coord
=
comp
.
find
(
jontionFields
.
Y_Coord
)
->
second
;
// 注意顺序
//1, 节点
CivItem
civItem
;
civItem
.
push_back
(
id
);
civItem
.
push_back
(
elevation
);
civItem
.
push_back
(
demand
);
civItem
.
push_back
(
pattern
);
jounItems
.
push_back
(
civItem
);
// 2, 节点坐标
CivItem
nodeCoordItem
;
nodeCoordItem
.
push_back
(
id
);
nodeCoordItem
.
push_back
(
x_coord
);
nodeCoordItem
.
push_back
(
y_coord
);
nodeCoordItems
.
push_back
(
nodeCoordItem
);
if
(
!
pattern
.
empty
())
{
patterNams
.
insert
(
pattern
);
}
// 初始水质
Str
initQual
=
comp
.
find
(
jontionFields
.
InitQual
)
->
second
;
CivItem
initQualItem
;
initQualItem
.
push_back
(
id
);
initQualItem
.
push_back
(
initQual
);
initQaulityItems
.
push_back
(
initQualItem
);
}
Componets
patterns
=
mDbConn
->
getComponets
(
PATTERNTABLE
);
PatternFields
fileds
;
size_t
patternSize
=
patterns
.
size
();
for
(
int
i
=
0
;
i
<
patternSize
;
i
++
)
{
Componet
pattern
=
patterns
[
i
];
Str
paternName
=
pattern
.
find
(
fileds
.
Name
)
->
second
;
Str
paternValue
=
pattern
.
find
(
fileds
.
Value
)
->
second
;
CivItem
item
;
item
.
push_back
(
paternName
);
item
.
push_back
(
paternValue
);
patternItems
.
push_back
(
item
);
}
inp
.
writeComponet
(
jounItems
,
_JUNCTIONS
);
inp
.
writeComponet
(
nodeCoordItems
,
_COORDS
);
inp
.
writeComponet
(
patternItems
,
_PATTERNS
);
inp
.
writeComponet
(
initQaulityItems
,
_QUALITY
);
}
else
if
(
RESIVOIR
==
table
)
// 水源
{
Componets
comps
=
mDbConn
->
getComponets
(
table
);
//;ID Head Pattern
Civitems
coordItems
;
Civitems
resirvoirItems
;
ResivoirFields
fields
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
Str
id
=
comp
.
find
(
fields
.
ID
)
->
second
;
Str
elevation
=
comp
.
find
(
fields
.
Elev
)
->
second
;
Str
flow
=
comp
.
find
(
fields
.
Flow
)
->
second
;
Str
head
=
comp
.
find
(
fields
.
Head
)
->
second
;
Str
pattern
=
comp
.
find
(
fields
.
Pattern
)
->
second
;
Str
x_coord
=
comp
.
find
(
fields
.
X_Coord
)
->
second
;
Str
y_coord
=
comp
.
find
(
fields
.
Y_Coord
)
->
second
;
// 注意顺序
//1, coord
CivItem
civItem
;
civItem
.
push_back
(
id
);
civItem
.
push_back
(
head
);
civItem
.
push_back
(
pattern
);
resirvoirItems
.
push_back
(
civItem
);
// 2, 节点坐标
CivItem
nodeCoordItem
;
nodeCoordItem
.
push_back
(
id
);
nodeCoordItem
.
push_back
(
x_coord
);
nodeCoordItem
.
push_back
(
y_coord
);
coordItems
.
push_back
(
nodeCoordItem
);
}
inp
.
writeComponet
(
coordItems
,
_COORDS
);
inp
.
writeComponet
(
resirvoirItems
,
_RESERVOIRS
);
}
else
if
(
PUMP
==
table
)
// 水泵
{
//;ID Node1 Node2 Parameters
Componets
comps
=
mDbConn
->
getLikelyPipes
(
table
);
PumpFields
fields
;
Civitems
pumpItems
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
Str
id
=
comp
.
find
(
fields
.
ID
)
->
second
;
Str
node1
=
comp
.
find
(
fields
.
node1
)
->
second
;
Str
node2
=
comp
.
find
(
fields
.
node2
)
->
second
;
std
::
vector
<
Str
>
vec
;
Str
head
=
comp
.
find
(
fields
.
head
)
->
second
;
if
(
!
head
.
empty
())
vec
.
push_back
(
"HEAD "
+
head
);
Str
power
=
comp
.
find
(
fields
.
power
)
->
second
;
if
(
!
power
.
empty
())
vec
.
push_back
(
"POWER "
+
power
);
Str
pattern
=
comp
.
find
(
fields
.
pattern
)
->
second
;
if
(
!
pattern
.
empty
())
vec
.
push_back
(
"PATTERN "
+
pattern
);
Str
speed
=
comp
.
find
(
fields
.
speed
)
->
second
;
if
(
!
speed
.
empty
())
vec
.
push_back
(
"SPEED "
+
speed
);
// 水池数据
CivItem
tankNode
;
tankNode
.
push_back
(
id
);
tankNode
.
push_back
(
node1
);
tankNode
.
push_back
(
node2
);
// 构建参数
char
param
[
128
]
=
" "
;
int
total
=
vec
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
strcat_s
(
param
,
vec
[
i
].
c_str
());
}
tankNode
.
push_back
(
param
);
pumpItems
.
push_back
(
tankNode
);
}
inp
.
writeComponet
(
pumpItems
,
_PUMPS
);
}
else
if
(
TANK
==
table
)
// 水池
{
Componets
comps
=
mDbConn
->
getComponets
(
table
);
// ; ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
TanksFields
tkfFileds
;
Civitems
nodeCoordItems
;
Civitems
tankItems
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
Str
id
=
comp
.
find
(
tkfFileds
.
ID
)
->
second
;
Str
elevation
=
comp
.
find
(
tkfFileds
.
Elev
)
->
second
;
Str
initLevel
=
comp
.
find
(
tkfFileds
.
InitLevel
)
->
second
;
Str
minLevel
=
comp
.
find
(
tkfFileds
.
MinLevel
)
->
second
;
Str
maxLevel
=
comp
.
find
(
tkfFileds
.
MaxLevel
)
->
second
;
Str
diametor
=
comp
.
find
(
tkfFileds
.
Diameter
)
->
second
;
Str
minVol
=
comp
.
find
(
tkfFileds
.
MinVol
)
->
second
;
Str
x_coord
=
comp
.
find
(
tkfFileds
.
X_Coord
)
->
second
;
Str
y_coord
=
comp
.
find
(
tkfFileds
.
Y_Coord
)
->
second
;
// 水池数据
CivItem
tankNode
;
tankNode
.
push_back
(
id
);
tankNode
.
push_back
(
elevation
);
tankNode
.
push_back
(
initLevel
);
tankNode
.
push_back
(
minLevel
);
tankNode
.
push_back
(
maxLevel
);
tankNode
.
push_back
(
diametor
);
tankNode
.
push_back
(
minVol
);
tankItems
.
push_back
(
tankNode
);
// 2, 节点坐标
CivItem
nodeCoordItem
;
nodeCoordItem
.
push_back
(
id
);
nodeCoordItem
.
push_back
(
x_coord
);
nodeCoordItem
.
push_back
(
y_coord
);
nodeCoordItems
.
push_back
(
nodeCoordItem
);
}
inp
.
writeComponet
(
nodeCoordItems
,
_COORDS
);
inp
.
writeComponet
(
tankItems
,
_TANKS
);
}
else
{
// 阀门
//;ID Node1 Node2 Diameter Type Setting MinorLoss
Componets
comps
=
mDbConn
->
getLikelyPipes
(
table
);
ValvesFields
fields
;
Civitems
vavleItems
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
Str
id
=
comp
.
find
(
fields
.
ID
)
->
second
;
Str
node1
=
comp
.
find
(
fields
.
node1
)
->
second
;
Str
node2
=
comp
.
find
(
fields
.
node2
)
->
second
;
Str
diametor
=
comp
.
find
(
fields
.
Diameter
)
->
second
;
Str
label
=
comp
.
find
(
fields
.
type
)
->
second
;
Str
typeSeting
=
comp
.
find
(
fields
.
setting
)
->
second
;
Str
minorLoss
=
comp
.
find
(
fields
.
minorLoss
)
->
second
;
// 阀门数据
CivItem
vavleNode
;
vavleNode
.
push_back
(
id
);
vavleNode
.
push_back
(
node1
);
vavleNode
.
push_back
(
node2
);
vavleNode
.
push_back
(
diametor
);
vavleNode
.
push_back
(
label
);
vavleNode
.
push_back
(
typeSeting
);
vavleNode
.
push_back
(
minorLoss
);
vavleItems
.
push_back
(
vavleNode
);
}
inp
.
writeComponet
(
vavleItems
,
_VALVES
);
}
}
bool
CivHydrCalc
::
getDataByInterval
(
char
*
date
,
char
*
interval
)
{
if
(
!
mDbConn
->
open
())
return
false
;
if
(
!
mDbConn
->
updateNodeByInterval
(
date
,
interval
))
return
false
;
if
(
!
mDbConn
->
updateLinkByInterval
(
date
,
interval
))
return
false
;
return
true
;
}
void
CivHydrCalc
::
getNodeResult
(
short
time
)
{
int
nNodeCount
;
ENgetcount
(
EN_NODECOUNT
,
&
nNodeCount
);
for
(
int
i
=
1
;
i
<=
nNodeCount
;
i
++
)
{
NodeResultItem
nodeItem
;
// 编号
ENgetnodeid
(
i
,
nodeItem
.
szNo
);
// 流量
ENgetnodevalue
(
i
,
EN_DEMAND
,
&
nodeItem
.
dFlow
);
// 水头
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
;
// 放到缓存类中
mResultCache
.
addNodeItems
(
nodeItem
);
}
}
void
CivHydrCalc
::
getLinkResult
(
short
time
)
{
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
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
);
// 流向
linkItem
.
nFlowDirect
=
(
linkItem
.
dFlow
>=
0
)
?
0
:
1
;
// 流速
ENgetlinkvalue
(
i
,
EN_VELOCITY
,
&
linkItem
.
dVelocity
);
// 水头损失
ENgetlinkvalue
(
i
,
EN_HEADLOSS
,
&
linkItem
.
dHeadloss
);
// 单位水头损失
float
dPipeLen
=
0.0
f
;;
ENgetlinkvalue
(
i
,
EN_LENGTH
,
&
dPipeLen
);
linkItem
.
dUnitHeadloss
=
(
linkItem
.
dHeadloss
/
dPipeLen
)
*
1000
;
// 获取上点和本点
int
node1
=
0
;
int
node2
=
0
;
ENgetlinknodes
(
i
,
&
node1
,
&
node2
);
// 上点水头
ENgetnodevalue
(
node1
,
EN_HEAD
,
&
linkItem
.
dFromNodHeadloss
);
// 本点水头
ENgetnodevalue
(
node2
,
EN_HEAD
,
&
linkItem
.
dToNodHeadloss
);
// 局部水头损失
float
fCoeff
;
ENgetlinkvalue
(
i
,
EN_MINORLOSS
,
&
fCoeff
);
double
dMinorloss
=
fCoeff
*
linkItem
.
dHeadloss
;
linkItem
.
dLocalHeadloss
=
dMinorloss
;
// 局部水头损失
// 摩擦水头损失
linkItem
.
dFrictionHeadloss
=
linkItem
.
dHeadloss
-
linkItem
.
dLocalHeadloss
;
// 局部水头损失
// 状态
float
fState
=
0
;
ENgetlinkvalue
(
i
,
EN_STATUS
,
&
fState
);
if
((
int
)
fState
==
0
)
strcpy_s
(
linkItem
.
szStatus
,
"关闭"
);
else
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
);
int
*
typeCode
=
(
int
*
)
malloc
(
sizeof
(
int
));
float
*
quality
=
(
float
*
)
malloc
(
sizeof
(
float
));
for
(
int
i
=
1
;
i
<=
nLinkCount
;
i
++
)
{
ENgetlinktype
(
i
,
typeCode
);
if
(
*
typeCode
!=
EN_PIPE
)
{
continue
;
}
char
lnkNo
[
35
];
// 编号
ENgetlinkid
(
i
,
lnkNo
);
// 水质
ENgetlinkvalue
(
i
,
EN_LINKQUAL
,
quality
);
mResultCache
.
addLinkQuality
(
*
quality
,
time
,
lnkNo
);
}
free
(
typeCode
);
free
(
quality
);
}
\ No newline at end of file
pandaAnalysis/CivHydrCalc.h
deleted
100644 → 0
View file @
81b040f6
#pragma once
#include<string>
#include<set>
#include "CivInp.h"
#include "CivSysLog.h"
#include "CivSimulResultCache.h"
class
CivDbConnection
;
class
CivDbConn
;
/**
* 水力计算类
*/
class
CivHydrCalc
{
public
:
CivHydrCalc
(
char
*
uri
,
std
::
string
netName
);
~
CivHydrCalc
();
/**
*@brief 水力模拟计算
*@param inpFile:inp文件
*@param rptFile: 输出文件
*@param binOutFile: 二进制输出文件
*/
bool
hydrSimulation
(
char
*
inpFile
,
char
*
rptFile
,
char
*
binOutFile
);
/**
*@brief 水质模拟计算
*@param inpFile:inp文件
*@param rptFile: 输出文件
*@param binOutFile: 二进制输出文件
*/
bool
qualitySimulation
(
char
*
inpFile
,
char
*
rptFile
,
char
*
binOutFile
);
bool
getDataByInterval
(
char
*
date
,
char
*
interval
);
/**
*@brief 导出inp文件
*/
bool
exportInp
(
char
*
fileName
);
private
:
/**
*@brief 解析表字段名,按顺序写入
*@param table:表
*@param inp: inp文件对象
*/
void
assemble
(
const
std
::
string
&
table
,
CivInp
&
inp
);
/*
*@brief 获取节点计算结果
*@param time: 时间
*/
void
getNodeResult
(
short
time
);
/*
*@brief 获取管线计算结果
*@param time: 时间
*/
void
getLinkResult
(
short
time
);
/*
*@brief 获取节点的水质计算结果
*@param time: 时间
*/
void
getNodeQuality
(
short
time
);
/*
*@brief 获取管线水值计算结果
*@param time: 时间
*/
void
getLinkQuality
(
short
time
);
private
:
CivDbConnection
*
mDbConn
;
CivDbConn
*
mPgConn
;
std
::
string
mNetname
;
CivSimulResultCache
mResultCache
;
// 存储模拟结果缓存类
};
pandaAnalysis/CivHydrFuncInter.cpp
View file @
bb7193b7
#include "CivHydrFuncInter.h"
#include "CivHydrCalc.h"
#include "CivSysLog.h"
#include "CivTableTemp.h"
#include "CivPgConn.h"
#include "CivHydrSimulation.h"
bool
DLLEXPORT
simulation
(
char
*
uri
,
char
*
netName
,
char
*
flag
)
{
char
fileName
[
256
];
char
rptR
[
256
];
char
outBinFile
[
256
];
strcpy_s
(
fileName
,
"test.inp"
);
strcpy_s
(
rptR
,
"test.rpt"
);
strcpy_s
(
outBinFile
,
"test.bin"
);
CivHydrCalc
*
calc
=
new
CivHydrCalc
(
uri
,
netName
);
CivSysLog
::
getInstance
()
->
info
(
"开始"
,
"interface"
,
__FUNCTION__
);
bool
msg
=
false
;
if
(
strcmp
(
flag
,
"HDY"
)
==
0
)
msg
=
calc
->
hydrSimulation
(
fileName
,
rptR
,
outBinFile
);
else
if
(
strcmp
(
flag
,
"QUALITY"
)
==
0
)
msg
=
calc
->
qualitySimulation
(
fileName
,
rptR
,
outBinFile
);
if
(
msg
)
{
CivSysLog
::
getInstance
()
->
info
(
"成功"
,
"interface"
,
__FUNCTION__
);
}
else
{
CivSysLog
::
getInstance
()
->
info
(
"失败"
,
"interface"
,
__FUNCTION__
);
}
delete
calc
;
return
msg
;
}
#include "CivTrackingAnalysis.h"
bool
DLLEXPORT
getDataByInterval
(
char
*
uri
,
char
*
date
,
char
*
interval
)
{
...
...
@@ -206,3 +175,72 @@ bool DLLEXPORT getRptByCondition(char* uri, char* type, char* condition, char* r
}
return
true
;
}
bool
DLLEXPORT
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
DLLEXPORT
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
DLLEXPORT
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/CivHydrFuncInter.h
View file @
bb7193b7
...
...
@@ -6,6 +6,30 @@
extern
"C"
{
#endif
/**
*@brief 上游追踪
*@param uri 数据库连接地址
*@param sn 追踪节点本点号
*@param result 追踪结果
*/
bool
DLLEXPORT
upstreamTracking
(
char
*
uri
,
char
*
sn
,
char
*
result
);
/**
*@brief 下游追踪
*@param uri 数据库连接地址
*@param sn 追踪节点本点号
*@param result 追踪结果
*/
bool
DLLEXPORT
downstreamTracking
(
char
*
uri
,
char
*
sn
,
char
*
result
);
/**
*@brief 供水范围追踪
*@param uri 数据库连接地址
*@param sn 追踪节点本点号
*@param result 追踪结果
*/
bool
DLLEXPORT
waterSupplyScopeAnalysis
(
char
*
uri
,
char
*
sn
,
char
*
result
);
/**
*@brief 获取当前日期和时段的结果值
*@param uri:数据库连接地址
...
...
@@ -40,14 +64,6 @@ extern "C" {
*/
bool
DLLEXPORT
trackingSimulation
(
char
*
uri
,
char
*
sN
,
int
hours
,
char
*
result
);
/**
*@brief 模拟计算
*@param uri: 管网数据库连接
*@param netName: 管网名
*@param flag: 标记
*/
bool
DLLEXPORT
simulation
(
char
*
uri
,
char
*
netName
,
char
*
flag
);
/**
*@brief 获取管网计算特定时段的结果
*@param uri: 管网数据库连接uri
...
...
pandaAnalysis/CivHydrSimulation.cpp
View file @
bb7193b7
...
...
@@ -115,16 +115,8 @@ bool CivHydrSimulation::convertInp(const QualityAnalyType analyType, const std::
return
true
;
}
bool
CivHydrSimulation
::
hdyr
Simulation
()
bool
CivHydrSimulation
::
hdyr
Compute
()
{
CivSysLog
::
getInstance
()
->
error
(
"开始水力分析计算"
,
"CivHydrSimulation"
,
__FUNCTION__
);
if
(
!
convertInp
(
ANALYSIS_RESERVE
,
""
))
{
CivSysLog
::
getInstance
()
->
error
(
"写入inp文件失败"
,
"CivHydrSimulation"
,
__FUNCTION__
);
return
false
;
}
CivSysLog
::
getInstance
()
->
info
(
"写入inp成功"
,
"CivHydrSimulation"
,
__FUNCTION__
);
short
hydCode
=
1
;
long
t
(
0
),
tstep
(
0
);
int
iTime
(
0
);
...
...
@@ -190,6 +182,79 @@ bool CivHydrSimulation::hdyrSimulation()
ENcloseH
();
ENclose
();
return
true
;
}
void
CivHydrSimulation
::
getDataByTime
(
int
time
,
NodeResultItems
&
nodeItems
,
LinkResultItems
&
linkItems
)
{
mResultCache
.
getResultByTime
(
time
,
nodeItems
,
linkItems
);
}
bool
CivHydrSimulation
::
hdyrInstantSimulation
()
{
CivBuilder
*
builder
=
new
CivInpBuilder
();
builder
->
setDuration
(
0
);
builder
->
setQualityType
(
ANALYSIS_RESERVE
,
""
);
builder
->
registDb
(
mDbConn
);
CivInpDirector
director
;
director
.
setBuilder
(
builder
);
director
.
create
();
CivNewInp
*
newInp
=
builder
->
getNewInp
();
char
*
inpFileName
=
getInpFile
();
if
(
inpFileName
&&
(
*
inpFileName
!=
'\0'
)
&&
!
newInp
->
writeToFile
(
inpFileName
))
{
delete
builder
;
return
false
;
}
delete
builder
;
// 水力计算
if
(
!
hdyrCompute
())
{
CivSysLog
::
getInstance
()
->
error
(
"水力分析结果存储失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
return
true
;
}
bool
CivHydrSimulation
::
hdyrSimulation
()
{
CivBuilder
*
builder
=
new
CivInpBuilder
();
builder
->
setQualityType
(
ANALYSIS_RESERVE
,
""
);
builder
->
registDb
(
mDbConn
);
CivInpDirector
director
;
director
.
setBuilder
(
builder
);
director
.
create
();
CivNewInp
*
newInp
=
builder
->
getNewInp
();
char
*
inpFileName
=
getInpFile
();
if
(
inpFileName
&&
(
*
inpFileName
!=
'\0'
)
&&
!
newInp
->
writeToFile
(
inpFileName
))
{
delete
builder
;
return
false
;
}
delete
builder
;
// 水力计算
if
(
!
hdyrCompute
())
{
CivSysLog
::
getInstance
()
->
error
(
"水力分析结果存储失败"
,
"CivHydrCalc"
,
__FUNCTION__
);
return
false
;
}
//模拟数据刷新
if
(
!
brushingResult
())
{
...
...
pandaAnalysis/CivHydrSimulation.h
View file @
bb7193b7
...
...
@@ -24,6 +24,13 @@ public:
*/
bool
hdyrSimulation
();
/**
*@brief 瞬时计算
*/
bool
hdyrInstantSimulation
();
bool
hdyrCompute
();
/**
*@brief 水质模拟,水龄,化学物质
*/
...
...
@@ -41,6 +48,7 @@ public:
*@param hours: 小时数
*/
bool
trackingSimulation
(
char
*
snNode
,
int
hours
);
void
getDataByTime
(
int
time
,
NodeResultItems
&
nodeItems
,
LinkResultItems
&
linkItems
);
/**
*@brief 导出inp文件
...
...
pandaAnalysis/CivInp.cpp
deleted
100644 → 0
View file @
81b040f6
#include "CivInp.h"
#include<time.h>
CivInp
::
CivInp
(
TimeUnit
timetype
)
:
mTimeUnit
(
timetype
)
{
writeTitles
();
}
bool
CivInp
::
writeToFile
(
const
char
*
fileName
)
{
writeTextStream
();
FILE
*
file
;
std
::
string
ss
;
if
(
file
=
fopen
(
fileName
,
"wb"
))
{
fprintf
(
file
,
mTextStream
.
str
().
c_str
());
mTextStream
.
clear
();
fclose
(
file
);
return
true
;
}
mTextStream
.
clear
();
return
false
;
}
void
CivInp
::
writeComponet
(
const
Civitems
&
items
,
SectType
type
)
{
switch
(
type
)
{
case
_TITLE
:
break
;
case
_JUNCTIONS
:
mJunctionsItems
.
insert
(
mJunctionsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_RESERVOIRS
:
mReservoirsItems
.
insert
(
mReservoirsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_TANKS
:
mTanksItems
.
insert
(
mTanksItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_PIPES
:
mPipesItems
.
insert
(
mPipesItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_PUMPS
:
mPumpsItems
.
insert
(
mPumpsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_VALVES
:
mValvesItems
.
insert
(
mValvesItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_CONTROLS
:
mControlsItems
.
insert
(
mControlsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_RULES
:
mRulesItems
.
insert
(
mRulesItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_DEMANDS
:
mDemandsItems
.
insert
(
mDemandsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_SOURCES
:
mSourceItems
.
insert
(
mSourceItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_EMITTERS
:
mEmittersItems
.
insert
(
mEmittersItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_PATTERNS
:
mPatternsItems
.
insert
(
mPatternsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_CURVES
:
mCurvesItems
.
insert
(
mCurvesItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_QUALITY
:
mQualityItems
.
insert
(
mQualityItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_STATUS
:
mStatusItems
.
insert
(
mStatusItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_ROUGHNESS
:
break
;
case
_ENERGY
:
mEnergyItems
.
insert
(
mEnergyItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_REACTIONS
:
mReactionItems
.
insert
(
mReactionItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_MIXING
:
mMixingItems
.
insert
(
mMixingItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_REPORT
:
mReportItems
.
insert
(
mReportItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_TIMES
:
mTImesItems
.
insert
(
mTImesItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_OPTIONS
:
mOptionsItems
.
insert
(
mOptionsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_COORDS
:
mCoordinatesItems
.
insert
(
mCoordinatesItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_VERTICES
:
mVerticesItems
.
insert
(
mVerticesItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_LABELS
:
mLabelsItems
.
insert
(
mLabelsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_BACKDROP
:
mBackdropItems
.
insert
(
mBackdropItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_TAGS
:
mTagsItems
.
insert
(
mTagsItems
.
end
(),
items
.
begin
(),
items
.
end
());
break
;
case
_END
:
break
;
default
:
break
;
}
}
void
CivInp
::
writeTextStream
()
{
writeJunctions
(
mJunctionsItems
);
writeReservoirs
(
mReservoirsItems
);
writeTanks
(
mTanksItems
);
writePipes
(
mPipesItems
);
writePumps
(
mPumpsItems
);
writeValves
(
mValvesItems
);
writeTags
(
mTagsItems
);
writeDemand
(
mDemandsItems
);
writeStatus
(
mStatusItems
);
writePatterns
(
mPatternsItems
);
writeCurves
(
mCurvesItems
);
writeControls
(
mControlsItems
);
writeRules
(
mRulesItems
);
writeEnergy
(
mEnergyItems
);
writeEmitters
(
mEmittersItems
);
writeQuality
(
mQualityItems
);
writeSources
(
mSourceItems
);
writeReactions
(
mReactionItems
);
writeMixing
(
mMixingItems
);
writeTimes
(
mTImesItems
);
writeOptions
(
mOptionsItems
);
writeCoordinates
(
mCoordinatesItems
);
writeVertices
(
mVerticesItems
);
writeBackdrop
(
mBackdropItems
);
writeEnd
();
}
void
CivInp
::
writeSources
(
Civitems
items
)
{
writeString
(
"[SOURCES]"
);
// дǩ
writeString
(
";Node Type Quality Pattern"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeTimes
(
Civitems
items
)
{
writeString
(
"[TIMES]"
);
// дǩ
writeString
(
";Tank Model"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeMixing
(
Civitems
items
)
{
writeString
(
"[MIXING]"
);
// дǩ
writeString
(
";Tank Model"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeEmitters
(
Civitems
items
)
{
writeString
(
"[EMITTERS]"
);
// дǩ
writeString
(
";Junction Coefficient"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeQuality
(
Civitems
items
)
{
writeString
(
"[QUALITY]"
);
// дǩ
writeString
(
";Node InitQual"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeEnergy
(
Civitems
items
)
{
writeString
(
"[ENERGY]"
);
// дǩ
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeReactions
(
Civitems
items
)
{
writeString
(
"[REACTIONS]"
);
// дǩ
writeString
(
";Type Pipe/Tank Coefficient"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeRules
(
Civitems
items
)
{
writeString
(
"[RULES]"
);
// дǩ
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeCurves
(
Civitems
items
)
{
writeString
(
"[CURVES]"
);
// дǩ
writeString
(
";ID X-Value Y-Value"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeControls
(
Civitems
items
)
{
writeString
(
"[CONTROLS]"
);
// дǩ
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeStatus
(
Civitems
items
)
{
writeString
(
"[STATUS]"
);
// дǩ
writeString
(
";ID Status/Setting"
);
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeTags
(
Civitems
items
)
{
writeString
(
"[TAGS]"
);
// дǩ
writeItems
(
items
);
writeString
(
""
);
}
void
CivInp
::
writeTitles
()
{
writeString
(
"[TITLE]"
);
// дǩ
writeString
(
"Scenario: Base"
);
writeString
(
"Date:"
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeJunctions
(
Civitems
items
)
{
writeString
(
"[JUNCTIONS]"
);
writeString
(
";ID Elev Demand Pattern "
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeItems
(
const
Civitems
&
items
)
{
size_t
rows
=
items
.
size
();
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
CivItem
item
=
items
[
i
];
size_t
itemSize
=
item
.
size
();
int
index
=
0
;
std
::
string
itemStr
=
item
[
0
]
+
" "
;
while
((
++
index
)
<
itemSize
)
itemStr
+=
(
item
[
index
]
+
" "
);
writeString
(
itemStr
);
}
}
void
CivInp
::
writePipes
(
Civitems
items
)
{
writeString
(
"[PIPES]"
);
writeString
(
";ID Node1 Node2 Length Diameter Roughness MinorLoss Status"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeTanks
(
Civitems
items
)
{
writeString
(
"[TANKS]"
);
writeString
(
"; ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeReservoirs
(
Civitems
items
)
{
writeString
(
"[RESERVOIRS]"
);
writeString
(
";ID Head Pattern "
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writePumps
(
Civitems
items
)
{
writeString
(
"[PUMPS]"
);
writeString
(
";ID Node1 Node2 Parameters"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeValves
(
Civitems
items
)
{
writeString
(
"[VALVES]"
);
writeString
(
";ID Node1 Node2 Diameter Type Setting MinorLoss "
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeCoordinates
(
Civitems
items
)
{
writeString
(
"[COORDINATES]"
);
writeString
(
";Node X-Coord Y-Coord"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeLabels
(
Civitems
items
)
{
writeString
(
"[LABELS]"
);
writeString
(
";X-Coord Y-Coord Label & Anchor Node"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeVertices
(
Civitems
items
)
{
writeString
(
"[VERTICES]"
);
writeString
(
";Link X-Coord Y-Coord"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeDemand
(
Civitems
items
)
{
writeString
(
"[DEMANDS]"
);
writeString
(
";Junction Demand Pattern Category"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeOptions
(
const
Civitems
&
items
)
{
writeString
(
"[OPTIONS]"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writePatterns
(
Civitems
items
)
{
writeString
(
"[PATTERNS]"
);
writeString
(
";ID Multipliers"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeBackdrop
(
Civitems
items
)
{
writeString
(
"[BACKDROP]"
);
writeItems
(
items
);
writeString
(
""
);
writeString
(
""
);
}
void
CivInp
::
writeEnd
()
{
writeString
(
"[END]"
);
}
void
CivInp
::
writeString
(
const
std
::
string
&
s
)
{
mTextStream
<<
s
<<
"
\n
"
;
}
void
CivInp
::
setPattern
(
StrQuote
pId
,
std
::
vector
<
Str
>
pValue
)
{
}
void
CivInp
::
setOption
(
Options
options
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
others
)
{
// ĵλ
CivItem
unitItem
;
unitItem
.
push_back
(
"UNITS"
);
Str
unit
=
"LPS"
;
switch
(
options
.
units
)
{
case
Options
:
:
UNITS
::
AFD
:
unit
=
"AFD"
;
break
;
case
Options
:
:
UNITS
::
CFS
:
unit
=
"CFS"
;
break
;
case
Options
:
:
UNITS
::
CMG
:
unit
=
"CMG"
;
break
;
case
Options
:
:
UNITS
::
CMH
:
unit
=
"CMH"
;
break
;
case
Options
:
:
UNITS
::
GPM
:
unit
=
"GPM"
;
break
;
case
Options
:
:
UNITS
::
IMGD
:
unit
=
"IMGD"
;
break
;
case
Options
:
:
UNITS
::
LPM
:
unit
=
"LPM"
;
break
;
case
Options
:
:
UNITS
::
LPS
:
unit
=
"LPS"
;
break
;
case
Options
:
:
UNITS
::
MGD
:
unit
=
"MGD"
;
break
;
case
Options
:
:
UNITS
::
MLD
:
unit
=
"MLD"
;
break
;
default
:
break
;
}
unitItem
.
push_back
(
unit
);
mOptionsItems
.
push_back
(
unitItem
);
CivItem
headLossItem
;
headLossItem
.
push_back
(
"HEADLOSS"
);
Str
lossValue
=
"H-W"
;
switch
(
options
.
headLoss
)
{
case
Options
:
:
HEADLOSS
::
HW
:
lossValue
=
"H-W"
;
break
;
case
Options
:
:
HEADLOSS
::
CM
:
lossValue
=
"C-M"
;
break
;
case
Options
:
:
HEADLOSS
::
DW
:
lossValue
=
"D-W"
;
break
;
default
:
break
;
}
headLossItem
.
push_back
(
lossValue
);
mOptionsItems
.
push_back
(
headLossItem
);
// ˮ
CivItem
qualityItem
;
qualityItem
.
push_back
(
"QUALITY"
);
Str
qualityValue
=
"NONE"
;
switch
(
options
.
quality
)
{
case
Options
:
:
QUALITY
::
NONE
:
qualityValue
=
"NONE"
;
break
;
case
Options
:
:
QUALITY
::
AGE
:
qualityValue
=
"AGE"
;
break
;
case
Options
:
:
QUALITY
::
CHEMICAL
:
qualityValue
=
"CHEMICAL mg/L"
;
break
;
case
Options
:
:
QUALITY
::
TRACE
:
qualityValue
=
"TRACE"
;
break
;
default
:
break
;
}
qualityItem
.
push_back
(
qualityValue
);
mOptionsItems
.
push_back
(
qualityItem
);
mOptionsItems
.
push_back
({
"ACCURACY"
,
options
.
ACCURACY
});
mOptionsItems
.
push_back
({
"Pattern"
,
options
.
Pattern
});
mOptionsItems
.
push_back
({
"Unbalanced"
,
options
.
UNBALANCED
});
mOptionsItems
.
push_back
({
"Demand Multiplier"
,
options
.
DEMANDMULTIPLIER
});
mOptionsItems
.
push_back
({
"Emitter Exponent"
,
options
.
EMITTEREXPONENT
});
mOptionsItems
.
push_back
({
"Diffusivity"
,
options
.
DIFFUSIVITY
});
mOptionsItems
.
push_back
({
"Trials"
,
options
.
TRIALS
});
mOptionsItems
.
push_back
({
"Viscosity"
,
options
.
VISCOSITY
});
mOptionsItems
.
push_back
({
"SPECIFIC GRAVITY"
,
options
.
SpecificGravity
});
// ѡ
for
(
auto
iter
=
others
.
cbegin
();
iter
!=
others
.
cend
();
iter
++
)
{
mOptionsItems
.
push_back
({
iter
->
first
,
iter
->
second
});
}
}
void
CivInp
::
setDuration
(
int
duration
)
{
Str
timeUnit
=
getTimeUnit
(
mTimeUnit
);
mTImesItems
.
push_back
({
"DURATION"
,
std
::
to_string
(
duration
),
timeUnit
});
}
void
CivInp
::
setTimestep
(
Str
type
,
int
step
)
{
Str
timeUnit
=
getTimeUnit
(
mTimeUnit
);
mTImesItems
.
push_back
({
type
+
" TIMESTEP"
,
std
::
to_string
(
step
),
timeUnit
});
}
void
CivInp
::
setTimeStart
(
Str
type
,
int
step
)
{
Str
timeUnit
=
getTimeUnit
(
mTimeUnit
);
mTImesItems
.
push_back
({
type
+
" START"
,
std
::
to_string
(
step
),
timeUnit
});
}
void
CivInp
::
setTimeOthers
(
Str
type
,
Str
val
)
{
mTImesItems
.
push_back
({
type
,
val
});
}
Str
CivInp
::
getTimeUnit
(
TimeUnit
timetype
)
{
Str
timeUnit
=
""
;
switch
(
timetype
)
{
case
TimeUnit
:
:
SECONDS
:
timeUnit
=
"SEC"
;
break
;
case
TimeUnit
:
:
HOURS
:
timeUnit
=
""
;
break
;
case
TimeUnit
:
:
MINUTES
:
timeUnit
=
"MIN"
;
break
;
case
TimeUnit
:
:
DAYS
:
timeUnit
=
"DAYS"
;
break
;
default
:
break
;
}
return
timeUnit
;
}
\ No newline at end of file
pandaAnalysis/CivInp.h
deleted
100644 → 0
View file @
81b040f6
#pragma once
#include <string>
#include <sstream>
#include <vector>
#include "CivTypes.h"
#define CivItem std::vector<std::string>
#define Civitems std::vector<CivItem>
// 模拟选项
struct
Options
{
// 流量被表达的单位
enum
class
UNITS
{
LPS
,
//——升 / 秒
LPM
,
//——升 / 分
MLD
,
//——百万升 / 日
CMH
,
//——立方米 / 小时
CMG
,
//——立方米 / 日
CFS
,
//——立方英尺 / 秒
GPM
,
//——加仑 / 分
MGD
,
//——百万加仑 / 日
IMGD
,
//——英制MGD
AFD
,
//——英亩 - 英尺 / 日
};
// 水头损失公式
enum
class
HEADLOSS
{
HW
,
// Hazen - Williams(H - W)
DW
,
//Darcy - Weisbach(D - W)
CM
//Chezy - Manning(C - M)
};
// 水质分析的类型
enum
class
QUALITY
{
NONE
,
//NONE(无)
CHEMICAL
,
//CHEMICAL(化学药剂)
AGE
,
// AGE(水龄)
TRACE
// TRACE(跟踪)
};
UNITS
units
;
HEADLOSS
headLoss
;
QUALITY
quality
;
Str
VISCOSITY
=
"0.1"
;
// 模拟流体的运动粘度
Str
DIFFUSIVITY
=
"1.0"
;
// 是化合物的分析扩散系数
Str
SpecificGravity
=
"1.0"
;
// 被模拟流体密度与4摄氏度水的密度之比(无量纲)。
Str
TRIALS
=
"40"
;
// ,求解管网水力特性使用的最大试算次数
Str
ACCURACY
=
"0.001"
;
//指定了确定何时达到水力结果的收敛准则
Str
UNBALANCED
=
"STOP"
;
//“STOP”将在该点终止整个分析。“CONTINUE”将在公布警告消息的情况
Str
Pattern
=
"1"
;
Str
DEMANDMULTIPLIER
=
"1.0"
;
// 用于调整所有连接节点的基本需水量数值,以及所有需水量的类型。
Str
EMITTEREXPONENT
=
"0.5"
;
// 指定了当计算扩散器的流量时,节点压力上升的幂指数
Str
TOLERANCE
=
"0.01"
;
//水质水平精度
Str
MAP
;
};
/**
inp文件对象模型
*/
class
CivInp
{
public
:
// 时间单位
enum
TimeUnit
{
SECONDS
,
MINUTES
,
HOURS
,
DAYS
};
CivInp
(
TimeUnit
timetype
);
/**
*@brief 保存inp文件
*@paramfileName: 文件名
*/
bool
writeToFile
(
const
char
*
fileName
);
/**
*@brief 根据组件类型添加
*@param items: 数据
*@param type: 枚举类型
*/
void
writeComponet
(
const
Civitems
&
items
,
SectType
type
);
/**
*@brief 写入IO流
*/
void
writeTextStream
();
/**
*@brief 定义时间模式
*@param pId: 模式id
*@param pValue: 模式值
*/
void
setPattern
(
StrQuote
pId
,
std
::
vector
<
Str
>
pValue
);
/**
*@brief 定义不同的模拟选项。
*@param options: 必选项
*@param others: 选填字段
*/
void
setOption
(
Options
options
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
others
=
std
::
map
<
std
::
string
,
std
::
string
>
());
/**
*@brief 设置模拟的历时
*@param duration: 总时间
*/
void
setDuration
(
int
duration
);
/**
*@brief 设置时间间隔
*@param type:需要设置的时间步长计算模型:PATTERN,REPORT,QUALITY
*@param step :间隔时长
*/
void
setTimestep
(
Str
type
,
int
step
);
void
setTimeStart
(
Str
type
,
int
step
);
void
setTimeOthers
(
Str
type
,
Str
val
);
/**
*@brief 设置时间单位
*/
void
setTimeUnit
(
TimeUnit
timeUnit
)
{
mTimeUnit
=
timeUnit
;
}
private
:
Str
getTimeUnit
(
TimeUnit
timetype
);
void
writeTitles
();
void
writeJunctions
(
Civitems
items
);
void
writePipes
(
Civitems
items
);
void
writeTanks
(
Civitems
items
);
void
writeReservoirs
(
Civitems
items
);
void
writePumps
(
Civitems
items
);
void
writeValves
(
Civitems
items
);
void
writeTags
(
Civitems
items
);
void
writeCoordinates
(
Civitems
items
);
void
writeLabels
(
Civitems
items
);
void
writeVertices
(
Civitems
items
);
void
writeSources
(
Civitems
items
);
void
writeBackdrop
(
Civitems
items
);
void
writeEnd
();
void
writeString
(
const
std
::
string
&
s
);
void
writeStatus
(
Civitems
items
);
void
writeCurves
(
Civitems
items
);
void
writeTimes
(
Civitems
items
);
void
writeControls
(
Civitems
items
);
void
writeReactions
(
Civitems
items
);
void
writeMixing
(
Civitems
items
);
void
writeRules
(
Civitems
items
);
void
writeEnergy
(
Civitems
items
);
void
writeEmitters
(
Civitems
items
);
void
writeQuality
(
Civitems
items
);
void
writeItems
(
const
Civitems
&
items
);
void
writeOptions
(
const
Civitems
&
items
);
void
writePatterns
(
Civitems
items
);
void
writeDemand
(
Civitems
items
);
private
:
std
::
ostringstream
mTextStream
;
TimeUnit
mTimeUnit
;
// 计算时间单位
Civitems
mJunctionsItems
;
// 节点
Civitems
mPipesItems
;
// 管线
Civitems
mReservoirsItems
;
// 水源
Civitems
mTanksItems
;
// 水池
Civitems
mPumpsItems
;
// 水泵
Civitems
mValvesItems
;
// 阀门
Civitems
mTagsItems
;
//
Civitems
mStatusItems
;
// 定义模拟开始时被选管段的初始状态
Civitems
mPatternsItems
;
// 定义时间模式
Civitems
mCurvesItems
;
// 曲线
Civitems
mControlsItems
;
// 控制参数
Civitems
mRulesItems
;
// 定义基于规则控制,根据状况的组合来修改管段。
Civitems
mEnergyItems
;
// 定义计算水泵提升能量和成本的参数
Civitems
mEmittersItems
;
// 将模拟节点定义为扩散器(喷嘴或者孔口)。
Civitems
mQualityItems
;
// 定义节点的初始水质。
Civitems
mDemandsItems
;
//定义连接节点的多模式需水,是对[JUNCTIONS]的补充。
Civitems
mSourceItems
;
//定义水质源头的位置。
Civitems
mReactionItems
;
//定义对应于管网中与化学成分反应的参数。
Civitems
mMixingItems
;
// 确定控制蓄水池混合的模型。
Civitems
mReportItems
;
//描述模拟生成的输出报表内容。
Civitems
mOptionsItems
;
// 定义不同的模拟选项。
Civitems
mCoordinatesItems
;
//
Civitems
mVerticesItems
;
//将内部顶点赋值给管网管段。
Civitems
mLabelsItems
;
// 给地图标签赋以坐标值。
Civitems
mBackdropItems
;
// 标识管网地图的背景图像及其尺寸。
Civitems
mTImesItems
;
//定义模拟中的各种事件时间步长参数。
};
pandaAnalysis/CivNewInp.cpp
View file @
bb7193b7
...
...
@@ -23,6 +23,11 @@ void CivNewInp::setQualityType(QualityAnalyType type, const std::string& quality
mQualityName
=
qualityName
;
}
void
CivNewInp
::
setDuration
(
int
duration
)
{
mDuration
=
duration
;
}
bool
CivNewInp
::
writeToFile
(
char
*
fileName
)
{
// 检查是否存在值
...
...
@@ -456,8 +461,16 @@ 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
(
""
);
}
...
...
pandaAnalysis/CivNewInp.h
View file @
bb7193b7
...
...
@@ -37,6 +37,7 @@ public:
管网组件
*/
void
setQualityType
(
QualityAnalyType
type
,
const
std
::
string
&
qualityName
);
void
setDuration
(
int
duration
);
void
setTtitle
(
const
std
::
string
&
title
);
void
setNode
(
const
CivNode
&
node
);
void
setPipes
(
const
CivPipe
&
pipes
);
...
...
@@ -87,6 +88,8 @@ private:
std
::
ostringstream
mTextStream
;
QualityAnalyType
mQualityType
=
ANALYSIS_AGE
;
//水质分析类型, 默认水龄
std
::
string
mQualityName
;
// 追踪的节点名 或者化合物名
int
mDuration
=
-
1
;
std
::
map
<
std
::
string
,
void
(
CivNewInp
::*
)(
const
CivParameter
&
)
>
mParamMap
;
// 参数类型映射
};
#endif // !CIVNEWINP_H
...
...
pandaAnalysis/CivTrackingAnalysis.cpp
0 → 100644
View file @
bb7193b7
#include "CivTrackingAnalysis.h"
#include "CivSimulResultCache.h"
#include "CivHydrSimulation.h"
#include "CivGraphFactory.h"
CivTrackingAnalysis
::
CivTrackingAnalysis
()
:
mGraph
(
new
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>
())
{
}
CivTrackingAnalysis
::~
CivTrackingAnalysis
()
{
delete
mGraph
;
}
bool
CivTrackingAnalysis
::
createGraphFrom
(
CivDbConn
*
dbConn
)
{
if
(
dbConn
==
nullptr
)
return
false
;
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
{
CivGraphEdage
edAge
(
pipeTable
.
ID
,
pipeTable
.
Length
,
{
endJunction
.
getXCoord
(),
endJunction
.
getYCoord
(),
sStartjuction
.
getXCoord
(),
sStartjuction
.
getYCoord
()
});
mGraph
->
insertAEdge
(
endJunction
,
sStartjuction
,
edAge
);
}
}
return
true
;
}
bool
CivTrackingAnalysis
::
transformJson
(
const
std
::
vector
<
CivGraphJunction
>&
junctions
,
const
std
::
vector
<
CivGraphEdage
>&
pipes
,
std
::
string
&
jsonResult
)
{
jsonResult
.
append
(
"{
\"
node
\"
:["
);
// 节点
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
++
)
{
CivGraphEdage
edge
=
pipes
[
i
];
if
(
edge
.
getSN
().
empty
())
continue
;
jsonResult
.
append
(
"["
);
jsonResult
.
append
(
edge
.
getSN
());
jsonResult
.
append
(
","
);
jsonResult
.
append
(
edge
.
getLength
());
jsonResult
.
append
(
","
);
jsonResult
.
append
(
edge
.
getStartX
());
jsonResult
.
append
(
","
);
jsonResult
.
append
(
edge
.
getStartY
());
jsonResult
.
append
(
","
);
jsonResult
.
append
(
edge
.
getEndX
());
jsonResult
.
append
(
","
);
jsonResult
.
append
(
edge
.
getEndY
());
jsonResult
.
append
(
"],"
);
}
jsonResult
=
jsonResult
.
substr
(
0
,
jsonResult
.
length
()
-
1
);
jsonResult
.
append
(
"]}"
);
return
true
;
}
bool
CivTrackingAnalysis
::
upstreamTracking
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
)
{
std
::
vector
<
CivGraphJunction
>
junctions
;
std
::
vector
<
CivGraphEdage
>
edges
;
if
(
!
upstreamTracking
(
sN
,
junctions
,
edges
))
{
return
false
;
}
// 将查询到的信息拼接成字符串
if
(
!
transformJson
(
junctions
,
edges
,
jsonResult
))
{
return
false
;
}
return
true
;
}
bool
CivTrackingAnalysis
::
downstreamTracking
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
)
{
std
::
vector
<
CivGraphJunction
>
junctions
;
std
::
vector
<
CivGraphEdage
>
edges
;
if
(
!
downstreamTracking
(
sN
,
junctions
,
edges
))
{
return
false
;
}
// 将查询到的信息拼接成字符串
if
(
!
transformJson
(
junctions
,
edges
,
jsonResult
))
{
return
false
;
}
return
true
;
}
bool
CivTrackingAnalysis
::
waterSupplyScopeAnalysis
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
)
{
return
true
;
}
bool
CivTrackingAnalysis
::
upstreamTracking
(
const
std
::
string
&
sN
,
std
::
vector
<
CivGraphJunction
>&
junctions
,
std
::
vector
<
CivGraphEdage
>&
pipes
)
{
// 上溯,图反向
ALGraph
<
CivGraphJunction
,
CivGraphEdage
>*
graph
=
mGraph
->
reverseGraph
();
CivGraphJunction
junction
(
sN
);
graph
->
getVisitedResult
(
junction
,
junctions
,
pipes
);
delete
graph
;
return
true
;
}
bool
CivTrackingAnalysis
::
downstreamTracking
(
const
std
::
string
&
sN
,
std
::
vector
<
CivGraphJunction
>&
junctions
,
std
::
vector
<
CivGraphEdage
>&
pipes
)
{
CivGraphJunction
junction
(
sN
);
mGraph
->
getVisitedResult
(
junction
,
junctions
,
pipes
);
return
true
;
}
bool
CivTrackingAnalysis
::
waterSupplyScopeAnalysis
(
const
std
::
string
&
sN
,
std
::
vector
<
CivGraphJunction
>&
junctions
,
std
::
vector
<
CivGraphEdage
>&
pipes
)
{
return
true
;
}
\ No newline at end of file
pandaA
lgorithm
/CivTrackingAnalysis.h
→
pandaA
nalysis
/CivTrackingAnalysis.h
View file @
bb7193b7
...
...
@@ -2,6 +2,7 @@
#include "CivHydDataType.h"
#include "CivGraphList.h"
#include "CivTrackingResultCache.h"
#include <vector>
#define ALGORITHMEXPORT __declspec(dllexport)
...
...
@@ -37,11 +38,20 @@ public:
/**
*@brief 计算管网中某个水源所能供水的范围
*@param sN 水源的编号
*@param j
unctions j
sonResult 结果字符串
*@param jsonResult 结果字符串
*/
bool
waterSupplyScopeAnalysis
(
const
std
::
string
&
sN
,
std
::
string
&
jsonResult
);
private
:
/**
*@brief 节点和管段集合信息转换成json字符串
*@param junctions 节点信息集合
*@param pipes 管段信息集合
*@param jsonResult 输出的结果字符串
*/
bool
transformJson
(
const
std
::
vector
<
CivGraphJunction
>&
junctions
,
const
std
::
vector
<
CivGraphEdage
>&
pipes
,
std
::
string
&
jsonResult
);
/**
*@brief 追踪节点上游路径
*@param sN 节点本点号
...
...
pandaAnalysis/pandaAnalysis.vcxproj
View file @
bb7193b7
...
...
@@ -153,25 +153,28 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"..\pandaDbManager\CivCommonUtils.cpp"
/>
<ClCompile
Include=
"CivHydrCalc.cpp"
/>
<ClCompile
Include=
"CivGraphFactory.cpp"
/>
<ClCompile
Include=
"CivHydDataType.cpp"
/>
<ClCompile
Include=
"CivHydrFuncInter.cpp"
/>
<ClCompile
Include=
"CivHydrSimulation.cpp"
/>
<ClCompile
Include=
"CivInp.cpp"
/>
<ClCompile
Include=
"CivBuilder.cpp"
/>
<ClCompile
Include=
"CivInpDirector.cpp"
/>
<ClCompile
Include=
"CivNewInp.cpp"
/>
<ClCompile
Include=
"CivSimulResultCache.cpp"
/>
<ClCompile
Include=
"CivTrackingAnalysis.cpp"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivHydrCalc.h"
/>
<ClInclude
Include=
"CivGraphFactory.h"
/>
<ClInclude
Include=
"CivGraphList.h"
/>
<ClInclude
Include=
"CivHydDataType.h"
/>
<ClInclude
Include=
"CivHydrFuncInter.h"
/>
<ClInclude
Include=
"CivHydrSimulation.h"
/>
<ClInclude
Include=
"CivInp.h"
/>
<ClInclude
Include=
"CivBuilder.h"
/>
<ClInclude
Include=
"CivInpDirector.h"
/>
<ClInclude
Include=
"CivMiddlewareQuery.h"
/>
<ClInclude
Include=
"CivNewInp.h"
/>
<ClInclude
Include=
"CivSimulResultCache.h"
/>
<ClInclude
Include=
"CivTrackingAnalysis.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
...
...
pandaAnalysis/pandaAnalysis.vcxproj.filters
View file @
bb7193b7
...
...
@@ -15,12 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"CivHydrCalc.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivInp.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivHydrFuncInter.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
...
...
@@ -42,14 +36,17 @@
<ClCompile
Include=
"CivHydrSimulation.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivTrackingAnalysis.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivHydDataType.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivGraphFactory.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivHydrCalc.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivInp.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivHydrFuncInter.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
...
...
@@ -71,5 +68,17 @@
<ClInclude
Include=
"CivHydrSimulation.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivTrackingAnalysis.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivGraphList.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivHydDataType.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivGraphFactory.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</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