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
4828200d
Commit
4828200d
authored
Oct 27, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1, 优化调度框架搭建
parent
fcd5a414
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
312 additions
and
21 deletions
+312
-21
EPNAET2.vcxproj
EPNAET2/EPNAET2.vcxproj
+2
-1
main.cpp
funcDemo/main.cpp
+4
-10
GenAlg.h
pandaAlgorithm/GenAlg.h
+2
-0
CivHydrFuncInter.cpp
pandaAnalysis/CivHydrFuncInter.cpp
+26
-0
CivHydrFuncInter.h
pandaAnalysis/CivHydrFuncInter.h
+8
-1
CivOptSchedEngine.cpp
pandaAnalysis/CivOptSchedEngine.cpp
+27
-2
CivOptSchedEngine.h
pandaAnalysis/CivOptSchedEngine.h
+23
-4
CivOptSchedPumpEngine.h
pandaAnalysis/CivOptSchedPumpEngine.h
+13
-0
CivSchedulingCompute.cpp
pandaAnalysis/CivSchedulingCompute.cpp
+115
-0
CivSchedulingCompute.h
pandaAnalysis/CivSchedulingCompute.h
+37
-0
pandaAnalysis.vcxproj
pandaAnalysis/pandaAnalysis.vcxproj
+2
-0
pandaAnalysis.vcxproj.filters
pandaAnalysis/pandaAnalysis.vcxproj.filters
+7
-0
CivInpHelperAbs.cpp
pandaDbManager/CivInpHelperAbs.cpp
+0
-1
JsonParseObject.cpp
pandaLog/JsonParseObject.cpp
+25
-0
JsonParseObject.h
pandaLog/JsonParseObject.h
+19
-1
pandaLog.vcxproj
pandaLog/pandaLog.vcxproj
+2
-1
No files found.
EPNAET2/EPNAET2.vcxproj
View file @
4828200d
...
...
@@ -161,7 +161,8 @@ copy epanet2.h $(OutDir)..\include /y</Command>
</ProjectReference>
<PostBuildEvent>
<Command>
copy Epanet2Out.h $(OutDir)..\include /y
copy epanet2.h $(OutDir)..\include /y
</Command>
copy epanet2.h $(OutDir)..\include /y
copy types.h $(OutDir)..\include /y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
...
...
funcDemo/main.cpp
View file @
4828200d
...
...
@@ -16,19 +16,9 @@
using
namespace
std
;
float
random
()
{
return
rand
()
/
(
RAND_MAX
+
1.0
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
srand
((
unsigned
)
time
(
NULL
));
/*这一句dao很重要,zhi如果没有的话,每dao次产生内的数据都是不变的。*/
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
printf
(
"%d"
,
rand
()
%
2
);
/*产生10个0到容1的随机数*/
}
while
(
true
)
{
const
char
*
uri
=
"host=192.168.19.100 port=5432 dbname=JinXian user=postgres password=admin"
;
...
...
@@ -43,6 +33,7 @@ int main(int argc, char* argv[])
cout
<<
"
\t
5.下游追踪
\n
"
;
cout
<<
"
\t
6.水源供水范围分析
\n
"
;
cout
<<
"
\t
7.方案模拟
\n
"
;
cout
<<
"
\t
8.优化调度测试
\n
"
;
SetConsoleTextAttribute
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
FOREGROUND_INTENSITY
|
FOREGROUND_RED
);
int
test_no
;
...
...
@@ -88,6 +79,9 @@ int main(int argc, char* argv[])
context
.
setHydrTest
(
new
CivProjSimulationTest
());
context
.
contextTest
(
findUri
);
break
;
case
8
:
// 8 优化调度测试
break
;
default:
cout
<<
"输入测试号错误!"
<<
endl
;
break
;
...
...
pandaAlgorithm/GenAlg.h
View file @
4828200d
...
...
@@ -3,7 +3,9 @@
#include "genome.h"
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <time.h>
#include<stdlib.h>
...
...
pandaAnalysis/CivHydrFuncInter.cpp
View file @
4828200d
...
...
@@ -4,6 +4,7 @@
#include "CivHydrSimulation.h"
#include "CivTrackingAnalysis.h"
#include "CivProjSimulation.h"
#include "JsonParseObject.h"
bool
PANDANALYSIS_API
hdyrSimulation
(
char
*
uri
)
{
...
...
@@ -70,5 +71,29 @@ bool PANDANALYSIS_API projSimulation(char* uri, char* projCode, char* time)
if
(
!
projSimulation
.
simulationProj
(
projCode
,
time
))
return
false
;
return
true
;
}
bool
PANDANALYSIS_API
optimalSchedulingSimulation
(
char
*
uri
,
char
*
condition
,
char
*
timeInterval
,
char
*
result
)
{
// 类型装换
string
uriStr
=
uri
;
string
conditionStr
=
condition
;
string
timeStr
=
timeInterval
;
// 解析输入的字符串转换位对应容器数据
JsonParseObject
jsonObj
;
jsonObj
.
parse
(
conditionStr
);
map
<
string
,
string
>
condiTionMap
;
jsonObj
.
read
(
condiTionMap
);
// 清楚
jsonObj
.
clear
();
jsonObj
.
parse
(
timeStr
);
return
true
;
}
\ No newline at end of file
pandaAnalysis/CivHydrFuncInter.h
View file @
4828200d
...
...
@@ -61,7 +61,14 @@ extern "C" {
*/
bool
PANDANALYSIS_API
projSimulation
(
char
*
uri
,
char
*
projCode
,
char
*
time
);
/**
*@brief 优化调度模拟
*@param [in] uri:condition
*@param [in] condition:约束条件, 格式: json字符串 {"测压点1":[32,46],"测压点2":[28,33]}
*@param [in] timeInterval:时段,格式:{"start":'2020-10-27 00:00:00',"end":'2020-10-27 08:00:00' }
*@param [out] result: 模拟的调度结果
*/
bool
PANDANALYSIS_API
optimalSchedulingSimulation
(
char
*
uri
,
char
*
condition
,
char
*
timeInterval
,
char
*
result
);
#if defined(__cplusplus)
}
#endif
...
...
pandaAnalysis/CivOptSchedEngine.cpp
View file @
4828200d
#include "CivOptSchedEngine.h"
#include "CivInpConvertor.h"
CivOptSchedEngine
::
CivOptSchedEngine
(
const
string
&
uri
)
:
mUri
(
uri
)
{
}
bool
CivOptSchedEngine
::
optimal
()
bool
CivOptSchedEngine
::
optimal
Scheduling
()
{
// תinpļ
CivInpConvertor
convertor
(
mUri
);
string
inpFile
=
convertor
.
convertBaseInp
();
//
// ¿ªÊ¼¼ÆËã
}
void
CivOptSchedEngine
::
schedulingResultToJson
(
string
&
json
)
{
}
void
CivOptSchedEngine
::
setMonitor
(
const
map
<
string
,
vector
<
double
>>&
monitorMap
)
{
mMonitoring
=
monitorMap
;
}
void
CivOptSchedEngine
::
setDecisionVariableStatusBit
(
const
map
<
int
,
string
>&
statusMap
)
{
mStatusBit
=
statusMap
;
}
void
CivOptSchedEngine
::
setStartTime
(
const
string
&
time
)
{
mStartTime
=
time
;
}
void
CivOptSchedEngine
::
setEndTime
(
const
string
&
time
)
{
mEndTime
=
time
;
}
\ No newline at end of file
pandaAnalysis/CivOptSchedEngine.h
View file @
4828200d
...
...
@@ -3,7 +3,6 @@
#include <vector>
#include <map>
using
namespace
std
;
/**
...
...
@@ -14,7 +13,19 @@ class CivOptSchedEngine
public
:
explicit
CivOptSchedEngine
(
const
string
&
uri
);
bool
optimal
();
bool
optimalScheduling
();
// 设置监测点
void
setMonitor
(
const
map
<
string
,
vector
<
double
>>&
monitorMap
);
// 设置决策变量状态位
void
setDecisionVariableStatusBit
(
const
map
<
int
,
string
>&
statusMap
);
// 设置调度开始时段
void
setStartTime
(
const
string
&
time
);
// 设置调度结束时段
void
setEndTime
(
const
string
&
time
);
protected
:
/**
...
...
@@ -24,13 +35,21 @@ protected:
void
schedulingResultToJson
(
string
&
json
);
private
:
// 编码与状态的映射
map
<
string
,
int
>
mStatus
;
map
<
int
,
string
>
mStatusBit
;
// 调度结果
vector
<
map
<
string
,
int
>>
mSchedulingResults
;
// 监测点
map
<
string
,
vector
<
double
>>
mMonitoring
;
// 数据连接地址
string
mUri
;
// 调度开始时段
string
mStartTime
;
// 调度结束时段
string
mEndTime
;
};
pandaAnalysis/CivOptSchedPumpEngine.h
View file @
4828200d
#pragma once
#include "CivOptSchedEngine.h"
#include <string>
#include <map>
#include <vector>
using
namespace
std
;
/**
վŻ
*/
...
...
@@ -9,6 +14,14 @@ class CivOptSchedPumpEngine: public CivOptSchedEngine
public
:
explicit
CivOptSchedPumpEngine
(
const
std
::
string
&
uri
);
private
:
// ֮ǰ
vector
<
map
<
string
,
double
>>
mBeforeScheduling
;
// ֮
vector
<
map
<
string
,
double
>>
mSchduling
;
// ˮӳ
map
<
string
,
string
>
mPumpMap
;
};
pandaAnalysis/CivSchedulingCompute.cpp
0 → 100644
View file @
4828200d
#include "CivSchedulingCompute.h"
#include "CivCommonUtils.h"
#include "epanet2.h"
#include "types.h"
#include "CivSysLog.h"
CivSchedulingCompute
::
CivSchedulingCompute
()
{
mRptFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.rpt"
;
mBinFile
=
CivCommonUtils
::
getExePath
()
+
"
\\
test.bin"
;
}
bool
CivSchedulingCompute
::
openFile
(
string
&
inpFILE
)
{
char
inpFile
[
256
];
strcpy_s
(
inpFile
,
inpFILE
.
c_str
());
char
rptFile
[
128
];
strcpy_s
(
rptFile
,
mRptFile
.
c_str
());
char
binFile
[
128
];
strcpy_s
(
binFile
,
mBinFile
.
c_str
());
CivSysLog
::
getInstance
()
->
info
(
"打开inp文件"
,
"CivHydrCompute"
,
__FUNCTION__
);
mErrcode
=
ENopen
(
inpFile
,
rptFile
,
binFile
);
if
(
mErrcode
>
0
)
{
CivSysLog
::
getInstance
()
->
error
(
"ENopen 失败"
,
"CivHydrCompute"
,
__FUNCTION__
);
ENclose
();
return
false
;
}
if
(
ENopenH
()
>
0
)
{
CivSysLog
::
getInstance
()
->
error
(
"ENopenH 失败"
,
"CivHydrCompute"
,
__FUNCTION__
);
ENclose
();
return
false
;
}
if
(
ENinitH
(
EN_SAVE
)
>
0
)
{
CivSysLog
::
getInstance
()
->
error
(
"ENinitH 失败"
,
"CivHydrCompute"
,
__FUNCTION__
);
ENclose
();
return
false
;
}
return
true
;
}
bool
CivSchedulingCompute
::
calculate
()
{
short
hydCode
=
1
;
long
t
(
0
),
tstep
(
0
);
int
iTime
(
0
);
float
dHStep
;
ENGetVal
(
4
,
&
dHStep
);
do
{
int
nLinkCount
;
ENgetcount
(
EN_LINKCOUNT
,
&
nLinkCount
);
for
(
int
i
=
1
;
i
<=
nLinkCount
;
i
++
)
{
// 获取管段类型
int
linkType
;
ENgetlinktype
(
i
,
&
linkType
);
if
(
linkType
!=
EN_PUMP
)
continue
;
char
id
[
128
]
=
""
;
ENgetlinkid
(
i
,
id
);
auto
iter
=
mPumpStatus
.
find
(
id
);
if
(
iter
==
mPumpStatus
.
end
())
continue
;
iter
->
second
;
ENsetlinkvalue
(
i
,
EN_STATUS
,
iter
->
second
==
'1'
?
OPEN
:
CLOSED
);
}
if
(
ENrunH
(
&
t
)
>
100
)
// errcode > 100 是错误
{
ENclose
();
return
false
;
}
ENnextH
(
&
tstep
);
iTime
++
;
}
while
(
tstep
>
0
);
return
true
;
}
void
CivSchedulingCompute
::
close
()
{
ENcloseH
();
ENclose
();
}
void
CivSchedulingCompute
::
updatePumpStatus
(
const
map
<
string
,
char
>&
pumpStatus
)
{
mPumpStatus
.
clear
();
mPumpStatus
=
pumpStatus
;
}
void
CivSchedulingCompute
::
getMonitorsValue
(
vector
<
map
<
string
,
double
>>&
monitorMap
)
{
monitorMap
=
mMonitors
;
}
\ No newline at end of file
pandaAnalysis/CivSchedulingCompute.h
0 → 100644
View file @
4828200d
#pragma once
#include <map>
#include <string>
using
namespace
std
;
/**
优化调度计算类
*/
class
CivSchedulingCompute
{
public
:
CivSchedulingCompute
();
bool
openFile
(
string
&
inpFILE
);
bool
calculate
();
void
close
();
void
updatePumpStatus
(
const
map
<
string
,
char
>&
pumpStatus
);
void
getMonitorsValue
(
vector
<
map
<
string
,
double
>>&
monitorMap
);
private
:
std
::
string
mRptFile
;
std
::
string
mBinFile
;
// 错误吗
int
mErrcode
=
0
;
// 更新水泵的状态
map
<
string
,
char
>
mPumpStatus
;
// 存储测点的计算值
vector
<
map
<
string
,
double
>>
mMonitors
;
};
pandaAnalysis/pandaAnalysis.vcxproj
View file @
4828200d
...
...
@@ -173,6 +173,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClCompile
Include=
"CivProjManager.cpp"
/>
<ClCompile
Include=
"CivProjSimulation.cpp"
/>
<ClCompile
Include=
"CivProjSmulResultCache.cpp"
/>
<ClCompile
Include=
"CivSchedulingCompute.cpp"
/>
<ClCompile
Include=
"CivSimulResultCache.cpp"
/>
<ClCompile
Include=
"CivStopWaterAnalysis.cpp"
/>
<ClCompile
Include=
"CivTrackingAnalysis.cpp"
/>
...
...
@@ -197,6 +198,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClInclude
Include=
"CivProjManager.h"
/>
<ClInclude
Include=
"CivProjSimulation.h"
/>
<ClInclude
Include=
"CivProjSmulResultCache.h"
/>
<ClInclude
Include=
"CivSchedulingCompute.h"
/>
<ClInclude
Include=
"CivSimulResultCache.h"
/>
<ClInclude
Include=
"CivStopWaterAnalysis.h"
/>
<ClInclude
Include=
"CivTrackingAnalysis.h"
/>
...
...
pandaAnalysis/pandaAnalysis.vcxproj.filters
View file @
4828200d
...
...
@@ -78,6 +78,9 @@
<ClCompile
Include=
"CivOptSchedPumpEngine.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
<ClCompile
Include=
"CivSchedulingCompute.cpp"
>
<Filter>
源文件
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"CivHydrFuncInter.h"
>
...
...
@@ -149,5 +152,8 @@
<ClInclude
Include=
"CivOptSchedPumpEngine.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"CivSchedulingCompute.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
pandaDbManager/CivInpHelperAbs.cpp
View file @
4828200d
...
...
@@ -80,7 +80,6 @@ bool CivInpHelperAbs::getPatterns(CivPatterns& patterns)
return
true
;
}
PatternTable
patternTable
;
std
::
vector
<
std
::
string
>
fields
=
{
...
...
pandaLog/JsonParseObject.cpp
View file @
4828200d
#include "JsonParseObject.h"
#include "cJSON.h"
JsonParseObject
::
JsonParseObject
()
{
...
...
@@ -7,5 +9,27 @@ JsonParseObject::JsonParseObject()
JsonParseObject
::~
JsonParseObject
()
{
cJSON_Delete
(
mResultJson
);
}
bool
JsonParseObject
::
getKeys
(
vector
<
string
>&
keys
)
{
return
true
;
}
void
JsonParseObject
::
parse
(
string
&
jsonStr
)
{
// jsonַתλjsonṹ
const
char
*
json
=
jsonStr
.
c_str
();
mResultJson
=
cJSON_Parse
(
json
);
}
void
JsonParseObject
::
read
(
map
<
string
,
string
>&
resMap
)
{
}
void
JsonParseObject
::
clear
()
{
cJSON_Delete
(
mResultJson
);
}
\ No newline at end of file
pandaLog/JsonParseObject.h
View file @
4828200d
#pragma once
#include <string>
#include <vector>
#include <map>
#include "pandaLog.h"
using
namespace
std
;
class
cJSON
;
/**
json解析对象
*/
class
JsonParseObject
class
PANDALOG_API
JsonParseObject
{
public
:
JsonParseObject
();
~
JsonParseObject
();
bool
getKeys
(
vector
<
string
>&
keys
);
void
parse
(
string
&
jsonStr
);
void
read
(
map
<
string
,
string
>&
resMap
);
// 主动销毁已读取的数据
void
clear
();
private
:
struct
cJSON
*
mResultJson
;
// json字符串对象
};
\ No newline at end of file
pandaLog/pandaLog.vcxproj
View file @
4828200d
...
...
@@ -149,7 +149,8 @@ copy CivCsvReader.h $(OutDir)..\include /y
copy CivCommonUtils.h $(OutDir)..\include /y
copy CivDate.h $(OutDir)..\include /y
copy StringUtils.h $(OutDir)..\include /y
copy pandaLog.h $(OutDir)..\include /y
</Command>
copy pandaLog.h $(OutDir)..\include /y
copy JsonParseObject.h $(OutDir)..\include /y
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
...
...
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