Commit 12ac51d2 authored by 刘乐's avatar 刘乐

删掉荣冗余的部分

parent 2dd32d84
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(36,5): warning MSB4211: 正在首次将属性“IntermediateOutputPath”设置为某个值,但已在“C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (35,5)”处使用了该属性。
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(337,5): warning MSB4211: 正在首次将属性“CleanFile”设置为某个值,但已在“C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets (35,5)”处使用了该属性。
StdAfx.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIManager.h(45,2): warning C4091: “typedef ”: 没有声明变量时忽略“DuiLib::EVENTTYPE_UI”的左侧
UIActiveX.cpp
UIButton.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIButton.cpp(127,35): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UICheckBox.cpp
UICombo.cpp
UIDateTime.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIDateTime.cpp(297,35): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIEdit.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIEdit.cpp(288,35): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIGifAnim.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIGifAnim.cpp(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
UILabel.cpp
UIList.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIList.cpp(1781,44): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
D:\work\hydr\hydraulicModel\DuiLib\Control\UIList.cpp(2417,48): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIOption.cpp
UIProgress.cpp
UIRichEdit.cpp
UIScrollBar.cpp
UISlider.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UISlider.cpp(212,36): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIText.cpp
D:\work\hydr\hydraulicModel\DuiLib\Control\UIText.cpp(52,37): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UITreeView.cpp
UIWebBrowser.cpp
UIBase.cpp
UIContainer.cpp
UIControl.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIControl.cpp(832,40): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
正在生成代码...
正在编译...
UIDlgBuilder.cpp
UIManager.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIManager.cpp(1045,39): warning C4838: 从“DWORD”转换到“LONG”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIManager.cpp(1045,48): warning C4838: 从“DWORD”转换到“LONG”需要收缩转换
UIMarkup.cpp
UIRender.cpp
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1196,61): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1196,86): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1196,111): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1197,66): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1197,92): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
D:\work\hydr\hydraulicModel\DuiLib\Core\UIRender.cpp(1197,118): warning C4838: 从“int”转换到“COLOR16”需要收缩转换
UIChildLayout.cpp
UIHorizontalLayout.cpp
D:\work\hydr\hydraulicModel\DuiLib\Layout\UIHorizontalLayout.cpp(313,37): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UITabLayout.cpp
UITileLayout.cpp
UIVerticalLayout.cpp
D:\work\hydr\hydraulicModel\DuiLib\Layout\UIVerticalLayout.cpp(306,37): warning C4302: “类型强制转换”: 从“LPSTR”到“WORD”截断
UIlib.cpp
UIDelegate.cpp
Utils.cpp
WinImplBase.cpp
正在生成代码...
stb_image.c
XUnzip.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1316,5): warning MSB8012: TargetPath(D:\work\hydr\hydraulicModel\DuiLib\.\Build\Release\DuiLib.dll) 与 Linker 的 OutputFile 属性值(D:\work\hydr\hydraulicModel\bin\DuiLib.dll)不匹配。这可能导致项目生成不正确。若要更正此问题,请确保 $(OutDir)、$(TargetName) 和 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配。
正在创建库 ../Lib/DuiLib.lib 和对象 ../Lib/DuiLib.exp
StdAfx.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall CWndShadow::~CWndShadow(void)" (??1CWndShadow@@UAE@XZ),函数 "public: virtual void * __thiscall CWndShadow::`vector deleting destructor'(unsigned int)" (??_ECWndShadow@@UAEPAXI@Z) 中引用了该符号
..\bin\DuiLib.dll : fatal error LNK1120: 1 个无法解析的外部命令
B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP
B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP
B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP B^D:\WORK\HYDR\HYDRAULICMODEL\DUILIB\STDAFX.CPP
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0:
Release|Win32|D:\work\hydr\hydraulicModel\|
This diff is collapsed.
...@@ -2,39 +2,39 @@ ...@@ -2,39 +2,39 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="Source Files"> <Filter Include="Source Files">
<UniqueIdentifier>{7d17d310-9655-4640-9d72-abb7c0fe0bc6}</UniqueIdentifier> <UniqueIdentifier>{5b27eb95-a601-4dda-af77-f2776f1ebf19}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter> </Filter>
<Filter Include="Source Files\Utils"> <Filter Include="Source Files\Utils">
<UniqueIdentifier>{1e313975-0756-4625-a65a-297ff225ada1}</UniqueIdentifier> <UniqueIdentifier>{f89c670d-3c5c-4a83-9cd3-d9a450e04f9f}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Source Files\Core"> <Filter Include="Source Files\Core">
<UniqueIdentifier>{f7184c42-483c-41c1-a76d-59a5a9f76ee4}</UniqueIdentifier> <UniqueIdentifier>{14f59ead-5602-45a3-958e-36dfaecf4cf4}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Source Files\Layout"> <Filter Include="Source Files\Layout">
<UniqueIdentifier>{3e8f088f-a5b6-40e1-8042-40354cc25b8d}</UniqueIdentifier> <UniqueIdentifier>{8298e5f9-fb12-4bd6-9994-85fa350e9745}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Source Files\Control"> <Filter Include="Source Files\Control">
<UniqueIdentifier>{eaa8f7be-293a-46de-834f-071a9a441a28}</UniqueIdentifier> <UniqueIdentifier>{20efef9d-1462-4f6f-96a6-c40bd63d2e70}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files"> <Filter Include="Header Files">
<UniqueIdentifier>{44fffdff-1307-447a-873d-d0cc2e94a7ce}</UniqueIdentifier> <UniqueIdentifier>{f7ba34b1-ba61-405a-916a-322aff7191a3}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions> <Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter> </Filter>
<Filter Include="Header Files\Utils"> <Filter Include="Header Files\Utils">
<UniqueIdentifier>{2f0ac3de-1412-4d51-a46c-59a70d45e4b5}</UniqueIdentifier> <UniqueIdentifier>{4e21ae8a-9b4d-4b54-8ad8-a3d4eafb767e}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files\Core"> <Filter Include="Header Files\Core">
<UniqueIdentifier>{f7a96342-a157-41bb-a57d-d283f6a9b11e}</UniqueIdentifier> <UniqueIdentifier>{0c40e815-995c-4ace-8b97-27e8d5c46dd2}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files\Layout"> <Filter Include="Header Files\Layout">
<UniqueIdentifier>{7e3238a6-3b1f-4c5a-9454-15ebb7dd7290}</UniqueIdentifier> <UniqueIdentifier>{223f4dc0-41f9-4aac-8275-2ff4da55c9fe}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files\Control"> <Filter Include="Header Files\Control">
<UniqueIdentifier>{9d25d6fa-9ff9-4ebd-a5a9-20302dd1c58a}</UniqueIdentifier> <UniqueIdentifier>{5a864c61-53d3-4bc2-959f-712e055c5c14}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Resource Files"> <Filter Include="Resource Files">
<UniqueIdentifier>{c6069066-0c47-4447-90dc-5ca0e3e72cc6}</UniqueIdentifier> <UniqueIdentifier>{1a004266-89c5-4c79-a130-cdf4071e5184}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions> <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter> </Filter>
</ItemGroup> </ItemGroup>
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
<ClCompile Include="Utils\Utils.cpp"> <ClCompile Include="Utils\Utils.cpp">
<Filter>Source Files\Utils</Filter> <Filter>Source Files\Utils</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Utils\WinImplBase.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="Utils\XUnzip.cpp"> <ClCompile Include="Utils\XUnzip.cpp">
<Filter>Source Files\Utils</Filter> <Filter>Source Files\Utils</Filter>
</ClCompile> </ClCompile>
...@@ -111,6 +114,9 @@ ...@@ -111,6 +114,9 @@
<ClCompile Include="Control\UIEdit.cpp"> <ClCompile Include="Control\UIEdit.cpp">
<Filter>Source Files\Control</Filter> <Filter>Source Files\Control</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Control\UIGifAnim.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Control\UILabel.cpp"> <ClCompile Include="Control\UILabel.cpp">
<Filter>Source Files\Control</Filter> <Filter>Source Files\Control</Filter>
</ClCompile> </ClCompile>
...@@ -135,19 +141,10 @@ ...@@ -135,19 +141,10 @@
<ClCompile Include="Control\UIText.cpp"> <ClCompile Include="Control\UIText.cpp">
<Filter>Source Files\Control</Filter> <Filter>Source Files\Control</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Control\UIWebBrowser.cpp"> <ClCompile Include="Control\UITreeView.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Control\UIGifAnim.cpp">
<Filter>Source Files\Control</Filter> <Filter>Source Files\Control</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Utils\WndShadow.cpp"> <ClCompile Include="Control\UIWebBrowser.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="Utils\WinImplBase.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="Control\UITreeView.cpp">
<Filter>Source Files\Control</Filter> <Filter>Source Files\Control</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
...@@ -236,6 +233,9 @@ ...@@ -236,6 +233,9 @@
<ClInclude Include="Control\UIEdit.h"> <ClInclude Include="Control\UIEdit.h">
<Filter>Header Files\Control</Filter> <Filter>Header Files\Control</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Control\UIGifAnim.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Control\UILabel.h"> <ClInclude Include="Control\UILabel.h">
<Filter>Header Files\Control</Filter> <Filter>Header Files\Control</Filter>
</ClInclude> </ClInclude>
...@@ -260,16 +260,10 @@ ...@@ -260,16 +260,10 @@
<ClInclude Include="Control\UIText.h"> <ClInclude Include="Control\UIText.h">
<Filter>Header Files\Control</Filter> <Filter>Header Files\Control</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Control\UIWebBrowser.h"> <ClInclude Include="Control\UITreeView.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Control\UIGifAnim.h">
<Filter>Header Files\Control</Filter> <Filter>Header Files\Control</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Utils\WndShadow.h"> <ClInclude Include="Control\UIWebBrowser.h">
<Filter>Header Files\Utils</Filter>
</ClInclude>
<ClInclude Include="Control\UITreeView.h">
<Filter>Header Files\Control</Filter> <Filter>Header Files\Control</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace DuiLib namespace DuiLib
{ {
enum UILIB_RESOURCETYPE enum UILIB_RESOURCETYPE
{ {
UILIB_FILE=1, // 来自磁盘文件 UILIB_FILE=1, // 来自磁盘文件
......
...@@ -8,14 +8,37 @@ CivHydrTest::~CivHydrTest() ...@@ -8,14 +8,37 @@ CivHydrTest::~CivHydrTest()
} }
void CivNetTopoTest::test(char* uri)
{
char error[256];
bool res = netTopo(uri, error);
std::cout << "测试结果" << res << std::endl;
}
void CivResdualChrolmeTest::test(char* uri)
{
// {"startTime":'',"endTime":'',"水池":[{"code":'',"余氯量":},{"code":'',"余氯量":}]}
std::string conditionMap = "{\"TK0000001\":50,\"TK0000002\":100}";
std::string startTimeStr = "2021-01-19 00:00:00";
std::string endTimeStr = "2021-01-19 24:00:00";
char* condition = const_cast<char*>(conditionMap.c_str());
char* startTime = const_cast<char*>(startTimeStr.c_str());
char* endTime = const_cast<char*>(endTimeStr.c_str());
char error[250];
bool res = residualChlorineAnalysis(uri, startTime, endTime,condition, error);
std::cout << "测试结果" << res << std::endl;
std::cout << error << std::endl;
}
// 优化调度测试 // 优化调度测试
void CivOptSchedulingTest::test(char* uri) void CivOptSchedulingTest::test(char* uri)
{ {
std::string condtionMap = "{\"bcdd358e-1925-47be-8e20-d93999e33c1c\":{\"min\":30, \"max\" : 40}, \ std::string condtionMap = "{\"bcdd358e-1925-47be-8e20-d93999e33c1c\":{\"min\":30, \"max\" : 40}, \
\"fd605205-c10e-4f7e-81a4-89c88166e763\" : {\"min\":50, \"max\" : 60}, \"c446cc2c-4110-406a-bda1-4f9544e38cb4\" : {\"min\":70, \"max\" : 80}}"; \"fd605205-c10e-4f7e-81a4-89c88166e763\" : {\"min\":50, \"max\" : 60}, \"c446cc2c-4110-406a-bda1-4f9544e38cb4\" : {\"min\":70, \"max\" : 80}}";
// std::string condtionMap = "{\"JD0000159\":{\"min\":20,\"max\":48},\"JD0000324\":{\"min\":20,\"max\":48},\"JD0000416\":{\"min\":20,\"max\":48},\"JD0000422\":{\"min\":20,\"max\":48},\"JD0000457\":{\"min\":20,\"max\":48},\"JD0000532\":{\"min\":20,\"max\":48},\"JD0000538\":{\"min\":20,\"max\":48},\"JD0000582\":{\"min\":20,\"max\":48},\"JD0000648\":{\"min\":20,\"max\":48},\"JD0000652\":{\"min\":20,\"max\":48},\"JD0000665\":{\"min\":20,\"max\":48},\"JD0000703\":{\"min\":20,\"max\":48},\"JD0000724\":{\"min\":20,\"max\":48}}";
int time = 17; int time = 17;
char* condition = const_cast<char*>(condtionMap.c_str()); char* condition = const_cast<char*>(condtionMap.c_str());
char result[1024 * 512]; char result[1024 * 512];
...@@ -110,10 +133,10 @@ void CivProjSimulationTest::test(char* uri) ...@@ -110,10 +133,10 @@ void CivProjSimulationTest::test(char* uri)
{ {
// 追踪节点编号 // 追踪节点编号
char projCode[512]; char projCode[512];
strcpy(projCode, "aedbda8f-29fd-40ef-bb7e-961eed178f35"); strcpy(projCode, "e9443d7f-d05b-4768-94b7-084a5d0fe3ba");
char time[512]; char time[512];
strcpy(time, "2020-12-14 15:00:00"); strcpy(time, "2021-1-27 11:00:00");
bool isSucc = projSimulation(uri, projCode, time); bool isSucc = projSimulation(uri, projCode, time);
......
...@@ -8,6 +8,20 @@ public: ...@@ -8,6 +8,20 @@ public:
virtual ~CivHydrTest(); virtual ~CivHydrTest();
}; };
// 拓扑维护
class CivNetTopoTest :public CivHydrTest
{
public:
virtual void test(char* uri);
};
// 余氯分析测试
class CivResdualChrolmeTest :public CivHydrTest
{
public:
virtual void test(char* uri);
};
// 优化调度测试 // 优化调度测试
class CivOptSchedulingTest :public CivHydrTest class CivOptSchedulingTest :public CivHydrTest
{ {
......
...@@ -62,6 +62,8 @@ int main(int argc, char* argv[]) ...@@ -62,6 +62,8 @@ int main(int argc, char* argv[])
cout << "\t6.水源供水范围分析\n"; cout << "\t6.水源供水范围分析\n";
cout << "\t7.方案模拟\n"; cout << "\t7.方案模拟\n";
cout << "\t8.优化调度测试\n"; cout << "\t8.优化调度测试\n";
cout << "\t9.余氯分析测试\n";
cout << "\t10.拓扑维护测试\n";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
int test_no; int test_no;
...@@ -112,6 +114,17 @@ int main(int argc, char* argv[]) ...@@ -112,6 +114,17 @@ int main(int argc, char* argv[])
context.setHydrTest(new CivOptSchedulingTest()); context.setHydrTest(new CivOptSchedulingTest());
context.contextTest(findUri); context.contextTest(findUri);
break; break;
case 9: // 8 优化调度测试
context.setHydrTest(new CivResdualChrolmeTest());
context.contextTest(findUri);
break;
case 10: // 拓扑维护
context.setHydrTest(new CivNetTopoTest());
context.contextTest(findUri);
break;
default: default:
cout << "输入测试号错误!" << endl; cout << "输入测试号错误!" << endl;
break; break;
...@@ -119,6 +132,8 @@ int main(int argc, char* argv[]) ...@@ -119,6 +132,8 @@ int main(int argc, char* argv[])
end = clock(); end = clock();
cout << (end - start)/1000 << endl; cout << (end - start)/1000 << endl;
} }
return 0; return 0;
} }
\ No newline at end of file
...@@ -22,10 +22,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaWaterCore", "pandaWate ...@@ -22,10 +22,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaWaterCore", "pandaWate
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaInpCore", "pandaInpCore\pandaInpCore.vcxproj", "{1363870B-C5EC-4A75-B73E-3D71F6D60052}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaInpCore", "pandaInpCore\pandaInpCore.vcxproj", "{1363870B-C5EC-4A75-B73E-3D71F6D60052}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "DuiLib\DuiLib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaWater", "pandaWater\pandaWater.vcxproj", "{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -218,44 +214,6 @@ Global ...@@ -218,44 +214,6 @@ Global
{1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x64.Build.0 = Release|x64 {1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x64.Build.0 = Release|x64
{1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x86.ActiveCfg = Release|Win32 {1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x86.ActiveCfg = Release|Win32
{1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x86.Build.0 = Release|Win32 {1363870B-C5EC-4A75-B73E-3D71F6D60052}.UnicodeRelease|x86.Build.0 = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.ActiveCfg = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x86.ActiveCfg = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x86.Build.0 = Debug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Any CPU.ActiveCfg = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.ActiveCfg = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x86.ActiveCfg = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x86.Build.0 = Release|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|Any CPU.ActiveCfg = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|x64.ActiveCfg = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|x86.ActiveCfg = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|x86.Build.0 = UnicodeDebug|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Any CPU.ActiveCfg = UnicodeRelease|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x64.ActiveCfg = UnicodeRelease|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x86.ActiveCfg = UnicodeRelease|Win32
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x86.Build.0 = UnicodeRelease|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|Any CPU.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x64.ActiveCfg = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x64.Build.0 = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x86.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Debug|x86.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|Any CPU.ActiveCfg = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x64.ActiveCfg = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x64.Build.0 = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x86.ActiveCfg = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.Release|x86.Build.0 = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|Any CPU.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|Any CPU.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x64.ActiveCfg = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x64.Build.0 = Debug|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x86.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeDebug|x86.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|Any CPU.ActiveCfg = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|Any CPU.Build.0 = Debug|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x64.ActiveCfg = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x64.Build.0 = Release|x64
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x86.ActiveCfg = Release|Win32
{D160D029-4D97-4DA9-BE59-4EAB8262D3B5}.UnicodeRelease|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
#pragma once
/**
ڽӱ
*/
template<typename T>
class Bag {
public:
T operator[](int i)
{
}
};
#pragma once
#include <string>
#include "Iterator.h"
/**
无向图定义
*/
template<typename T,typename V>
class Graph {
explicit Graph(int v);
// 定点数
int V() const
{
return mV;
}
// 边数
int E() const;
{
return mE;
}
void addEdage(int v, int w)
{
}
Iterator<T> adj(V v);
std::string toString();
private:
int mV; // 顶点数目
int mE; // 边的数目
};
#pragma once
/**
*/
template<class T>
class Iterator {
public:
Iterator(T* p, int c) :data(p), len(c) {}
int valid() const
{
return len > 0;
}
T next()
{
--len;
return *data++;
}
private:
T* data;
int len;
};
...@@ -152,9 +152,12 @@ copy OptScheduling.h $(OutDir)..\include /y</Command> ...@@ -152,9 +152,12 @@ copy OptScheduling.h $(OutDir)..\include /y</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Bag.h" />
<ClInclude Include="FirstOptScheduling.h" /> <ClInclude Include="FirstOptScheduling.h" />
<ClInclude Include="GenAlg.h" /> <ClInclude Include="GenAlg.h" />
<ClInclude Include="Genome.h" /> <ClInclude Include="Genome.h" />
<ClInclude Include="Graph.h" />
<ClInclude Include="Iterator.h" />
<ClInclude Include="OptScheduling.h" /> <ClInclude Include="OptScheduling.h" />
<ClInclude Include="pandaAlgorithm.h" /> <ClInclude Include="pandaAlgorithm.h" />
<ClInclude Include="SecondOptScheduling.h" /> <ClInclude Include="SecondOptScheduling.h" />
......
...@@ -33,6 +33,15 @@ ...@@ -33,6 +33,15 @@
<ClInclude Include="SecondOptScheduling.h"> <ClInclude Include="SecondOptScheduling.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Graph.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Iterator.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Bag.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="OptScheduling.cpp"> <ClCompile Include="OptScheduling.cpp">
......
#include "CivDynamicCompute.h"
#include "epanet2.h"
#include "types.h"
#include "CivSysLog.h"
#include "StringUtils.h"
#include<map>
#include<string>
#include <regex>
CivDynamicCompute::CivDynamicCompute()
{
mRptFile = "test.rpt";
mBinFile = "test.bin";
}
bool CivDynamicCompute::openFile(ConstStringRef fileName)
{
char inpFile[256];
strcpy_s(inpFile, fileName.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;
}
// 将所有节点水质清零
resetQuality();
return true;
}
bool CivDynamicCompute::beginCompute()
{
return true;
}
void CivDynamicCompute::endCompute()
{
ENcloseH();
ENclose();
}
void CivDynamicCompute::updatePumpSpeed(ConstStringRef pcode, float speeds)
{
}
bool CivDynamicCompute::compute(int startTime, int endTime)
{
short hydCode = 1;
long t(0), tstep(0);
int iTime(0);
int errcode = 0;
if (ENinitH(EN_SAVE) > 0)
{
CivSysLog::getInstance()->error("ENinitH 失败", "CivHydrCompute", __FUNCTION__);
ENclose();
return false;
}
float dHStep;
ENGetVal(4, &dHStep);
do
{
if (ENrunH(&t) > 100) // errcode > 100 是错误
{
ENcloseH();
ENclose();
return false;
}
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;
}
if (iTime == startTime)
{
std::map<std::string, float>::iterator iter = mWaterSourcesMap.begin();
for (; iter != mWaterSourcesMap.end(); iter++)
{
addWaterResiChlorine(iter->first, iter->second);
}
}
// 满足条件保存
if (iTime>=startTime && iTime<=endTime)
{
saveResult(iTime);
}
iTime++;
ENstepQ(&tstep);
} while (tstep > 0);
ENcloseQ();
ENclose();
return true;
}
bool CivDynamicCompute::saveResult(int iTime)
{
// 计算节点
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
std::map<std::string, float> qualityMap;
for (int i = 1; i <= nNodeCount; i++)
{
char szNo[256];
ENgetnodeid(i, szNo);// 编号
float quality;
ENgetnodevalue(i, EN_QUALITY, &quality); // 获取水质
qualityMap.insert(std::pair<std::string, double>(szNo, quality));
}
std::string ontheHourStr = onTheHour(iTime);
mSimulQualityMap.insert(std::pair<std::string, std::map<std::string, float>>(ontheHourStr, qualityMap));
return true;
}
std::string CivDynamicCompute::onTheHour(int iTime)
{
if (iTime < 0 || iTime>24)
return "";
std::string repStr;
if (iTime < 10)
repStr = "0" + std::to_string(iTime) + ":00:00";
else
repStr = std::to_string(iTime) + ":00:00";
std::string dateHour = mStartTime;
std::vector<std::string> strVec;
StringUtils::split(mStartTime, strVec);
if (strVec.size() <= 0)
return mStartTime;
std::string dateStr = strVec[0];
repStr = std::to_string(iTime) + ":00:00";
return dateStr +" "+repStr;
}
void CivDynamicCompute::addWaterResiChlorine(const std::string& pid, float density)
{
int nLinkCount;
ENgetcount(EN_NODECOUNT, &nLinkCount);
for (int i = 1; i <= nLinkCount; i++)
{
// 获取节点类型
char id[128];
ENgetnodeid(i, id);
// 根据id添加余氯量
if (strcmp(id, pid.c_str()) == 0)
{
ENsetnodevalue(i, EN_INITQUAL, density);
}
}
}
void CivDynamicCompute::updateQuality(const std::map<std::string, float>& waterSources)
{
mWaterSourcesMap = waterSources;
}
void CivDynamicCompute::resetQuality()
{
int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount);
for (int i = 1; i <= nNodeCount; i++)
{
ENsetnodevalue(i, EN_INITQUAL, 0);
}
}
void CivDynamicCompute::simulResult(std::map<std::string, std::map<std::string, float>>& resultMap) const
{
resultMap = mSimulQualityMap;
}
\ No newline at end of file
#pragma once
#include <string>
#include <map>
/**
水力动态计算类
*/
class CivDynamicCompute
{
public:
typedef std::string String;
typedef String& StringRef;
typedef const StringRef ConstStringRef;
CivDynamicCompute();
/**
* @brief 加载inp文件
* @param [fileName] inp文件名
* @return 打开加载inp文件成功返回True,否则返回False
*/
bool openFile(ConstStringRef fileName);
/**
* @brief 开始执行水质计算,做一些初始化工作
*/
bool beginCompute();
/**
* @brief 结束水质计算,做一些清理工作
*/
void endCompute();
/**
* @brief 获取某个四段某个时段的
* @param [startTime] 开始时间
* @param [endTime] 结束时刻
*/
bool compute(int startTime, int endTime);
/**
* @brief 更新水泵的转速比
* @param [pcode] 水泵标识
* @param [speeds] 转速比数值
*/
void updatePumpSpeed(ConstStringRef pcode, float speeds);
/**
* @brief 需要更新的水池的水质
* @param [waterSources] 水源编号和水质
*/
void updateQuality(const std::map<std::string, float>& waterSources);
void setStartTime(const std::string& startTime) { mStartTime = startTime; }
void setEndTime(const std::string& endTime) { mEndTime = endTime; }
/**
*@brief 获取模拟结果
* @param[resultMap] 存储模拟的结果
*/
void simulResult(std::map<std::string, std::map<std::string, float>>& resultMap) const;
private:
/**
* @brief 给水源添加余氯量
* @param [sourceType] 水源类型,水池或者水库
* @param [pid] 水源的编码
* @param [density] 余氯浓度
*/
void addWaterResiChlorine(const std::string& pid, float density);
/**
*@brief 初始化水质,将所有节点水质初始化为0
*/
void resetQuality();
/**
* @brief 保存模拟结果
* @param 需要保存哪个时段的数据
*/
bool saveResult(int iTime);
/**
*@brief 获取整点时刻
*/
std::string onTheHour(int iTime);
private:
String mRptFile;
String mBinFile;
String mInpFile;
int mErrcode;
std::string mStartTime;
std::string mEndTime;
// 水质模拟结果
std::map<std::string, std::map<std::string, float>> mSimulQualityMap;
// 水池水质
std::map<std::string, float> mWaterSourcesMap; // 水质
};
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
private: private:
std::string mSN;// 编号 std::string mSN;// 编号
std::string mLength; // 管长 std::string mLength; // 管长
float mFlow;
std::string mStartX; std::string mStartX;
std::string mStartY; std::string mStartY;
......
...@@ -75,11 +75,6 @@ bool CivHydrCompute::qualityCompute() ...@@ -75,11 +75,6 @@ bool CivHydrCompute::qualityCompute()
ENnextH(&tstep); ENnextH(&tstep);
iTime++; iTime++;
// 获取当前节点和管段数据
getNodeResult(iTime);
getLinkResult(iTime);
} while (tstep > 0); } while (tstep > 0);
ENcloseH(); ENcloseH();
...@@ -379,8 +374,12 @@ void CivHydrCompute::getLinkResult(short time) ...@@ -379,8 +374,12 @@ void CivHydrCompute::getLinkResult(short time)
{ {
case EN_PIPE: case EN_PIPE:
{ {
ENgetlinkid(i, linkItem.szNo); // 编号 ENgetlinkid(i, linkItem.szNo); // 编号
ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow);// 流量
float flow;
ENgetlinkvalue(i, EN_FLOW, &flow);// 流量
linkItem.dFlow = std::abs(flow);
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速 ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失 ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失
...@@ -418,32 +417,56 @@ void CivHydrCompute::getLinkResult(short time) ...@@ -418,32 +417,56 @@ void CivHydrCompute::getLinkResult(short time)
void CivHydrCompute::getNodeQuality(short time) void CivHydrCompute::getNodeQuality(short time)
{ {
if (time <= 0) if (time <= 0)
return; return;
time -= 1; time -= 1;
// 计算节点
int nNodeCount; int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount); ENgetcount(EN_NODECOUNT, &nNodeCount);
int* typeCode = (int*)malloc(sizeof(int)); int* typeCode = (int*)malloc(sizeof(int));
std::string nowDate;
std::string nowTime;
dateAndTime(time, nowDate, nowTime);
for (int i = 1; i <= nNodeCount; i++) for (int i = 1; i <= nNodeCount; i++)
{ {
ENgetnodetype(i, typeCode); ENgetnodetype(i, typeCode);
if (*typeCode == EN_JUNCTION)
switch (*typeCode)
{
case EN_JUNCTION: // 用户节点
{
NodeResultItem nodeItem;
ENgetnodeid(i, nodeItem.szNo);// 编号
ENgetnodevalue(i, EN_HEAD, &nodeItem.dHead);// 水头
ENgetnodevalue(i, EN_PRESSURE, &nodeItem.dPressure); // 压力
ENgetnodevalue(i, EN_ELEVATION, &nodeItem.dElevation);// 标高
ENgetnodevalue(i, EN_DEMAND, &nodeItem.dDemand);// 实际需水量
ENgetnodevalue(i, EN_QUALITY, &nodeItem.dQuality); // 水质
nodeItem.dDate = nowDate;
nodeItem.dTime = nowTime;
nodeItem.dModifyTime = CurrentTime;
mResultCache.addNodeItems(time, nodeItem);
}
break;
case EN_TANK: // 水厂
{ {
char No[35];
ENgetnodeid(i, No);// 编号
float quality;
ENgetnodevalue(i, EN_QUALITY, &quality); // 水质
mResultCache.addNodeQuality(quality, time, No); }
} break;
default:
break;
}
} }
free(typeCode);
} }
void CivHydrCompute::getLinkQuality(short time) void CivHydrCompute::getLinkQuality(short time)
{ {
if (time <= 0) if (time <= 0)
return; return;
...@@ -451,18 +474,59 @@ void CivHydrCompute::getLinkQuality(short time) ...@@ -451,18 +474,59 @@ void CivHydrCompute::getLinkQuality(short time)
int nLinkCount; int nLinkCount;
ENgetcount(EN_LINKCOUNT, &nLinkCount); ENgetcount(EN_LINKCOUNT, &nLinkCount);
int* typeCode = (int*)malloc(sizeof(int)); int* typeCode = (int*)malloc(sizeof(int));
std::string nowDate;
std::string nowTime;
dateAndTime(time, nowDate, nowTime);
for (int i = 1; i <= nLinkCount; i++) for (int i = 1; i <= nLinkCount; i++)
{ {
LinkResultItem linkItem;
ENgetlinktype(i, typeCode); ENgetlinktype(i, typeCode);
if (*typeCode != EN_PIPE)
continue;
char lnkNo[35]; switch (*typeCode)
ENgetlinkid(i, lnkNo);// 编号 {
float quality; case EN_PIPE:
ENgetlinkvalue(i, EN_LINKQUAL, &quality);// 水质 {
ENgetlinkid(i, linkItem.szNo); // 编号
float flow;
ENgetlinkvalue(i, EN_FLOW, &flow);// 流量
if(flow<0)
linkItem.dFlow = std::abs(flow);
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失
ENgetlinkvalue(i, EN_LINKQUAL, &linkItem.dQuality);// 水质
// 状态
float fState = 0;
ENgetlinkvalue(i, EN_STATUS, &fState);
if ((int)fState == 0)
strcpy_s(linkItem.szStatus, "关闭");
else
strcpy_s(linkItem.szStatus, "开启");
linkItem.dDate = nowDate;
linkItem.dTime = nowTime;
linkItem.dModifyTime = CurrentTime;
// 放到缓存类中
mResultCache.addLinkItems(time, linkItem);
}
break;
case EN_PUMP:
{
ENgetlinkid(i, linkItem.szNo); // 编号
ENgetlinkvalue(i, EN_ENERGY, &linkItem.dFlow);// 水泵耗能
}
break;
default:
break;
}
mResultCache.addLinkQuality(quality, time, lnkNo);
} }
free(typeCode); free(typeCode);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
class CivHydrCompute class CivHydrCompute
{ {
public: public:
explicit CivHydrCompute(); CivHydrCompute();
/** /**
*@brief 水质计算 *@brief 水质计算
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
#include "CivProjSimulation.h" #include "CivProjSimulation.h"
#include "JsonParseObject.h" #include "JsonParseObject.h"
#include "CivOptSchedEngine.h" #include "CivOptSchedEngine.h"
#include "CivInpConvertor.h"
#include "CivDynamicCompute.h"
#include "CivPumpHelper.h"
#include "CivHydrTableHelper.h"
#include "StringUtils.h"
bool PANDANALYSIS_API hdyrSimulation(char* uri) bool PANDANALYSIS_API hdyrSimulation(char* uri)
{ {
...@@ -170,12 +175,77 @@ bool PANDANALYSIS_API optimalSchedulingSimulation(char* uri, char* condition, in ...@@ -170,12 +175,77 @@ bool PANDANALYSIS_API optimalSchedulingSimulation(char* uri, char* condition, in
return true; return true;
} }
bool PANDANALYSIS_API residualChlorineAnalysis(char* uri, char* conditionMap,char* error) bool PANDANALYSIS_API residualChlorineAnalysis(char* uri, char* startTime, char* endTime, char* conditionMap,char* error)
{ {
std::string uriStr = uri; std::string uriStr = uri;
std::string conditionMapStr = conditionMap; std::string conditionMapStr = conditionMap;
std::string startTimeStr = startTime;
std::string endTimeStr = endTime;
std::string result;
struct ConditionStruct conditionStruct;
JsonParseObject jsonParseObj;
jsonParseObj.parse(conditionMapStr);
jsonParseObj.read(conditionStruct);
if (conditionStruct.mCondMap.size() <= 0)
{
result = "输入的json字符串有错误!";
return false;
}
// 转inp文件
CivInpConvertor conventor(uriStr);
std::string inpFile = conventor.convertResidualInp();
// 调用计算接口
CivDynamicCompute dynCompute;
if (!dynCompute.openFile(inpFile))
{
result = "打开inp文件失败";
return false;
}
dynCompute.setStartTime(startTimeStr);
dynCompute.setEndTime(endTimeStr);
dynCompute.updateQuality(conditionStruct.mCondMap);
// 解析开始和结束时间
int start = StringUtils::parseInt(startTimeStr);
int end = StringUtils::parseInt(endTimeStr);
// 开始执行加u三
if (!dynCompute.compute(start, end))
{
result = "计算失败!";
return false;
}
// 计算成功后,读取计算值更新到数据库
std::map<std::string, std::map<std::string, float>> resultMap;
dynCompute.simulResult(resultMap);
if (resultMap.size() <= 0)
{
result = "出现位置错误,,没有获取到模拟值!";
return false;
}
// 链接数据库,更新数据
CivPumpHelper pumpHelper(uriStr);
if (!pumpHelper.updateDatas("节点模拟值", resultMap))
{
result = "存储数据失败!";
return false;
}
//
return true; return true;
}
bool PANDANALYSIS_API netTopo(char* uri, char* error)
{
CivHydrTableHelper hydrHelper(uri);
return hydrHelper.mainTain();
} }
\ No newline at end of file
...@@ -71,12 +71,21 @@ extern "C" { ...@@ -71,12 +71,21 @@ extern "C" {
bool PANDANALYSIS_API optimalSchedulingSimulation(char* uri, char* condition, int timeInterval, char* result); bool PANDANALYSIS_API optimalSchedulingSimulation(char* uri, char* condition, int timeInterval, char* result);
/** /**
*@brief 优化调度模拟 * @brief 余氯分析模拟
* @param [in] uri:condition * @param [in] uri:condition
* @param [in] startTime:startTime
* @param [in] endTime:condition
* @param [in] condition:约束条件, 格式: json字符串 {"startTime":'',"endTime":'',"水池":[{"code":'',"余氯量":},{"code":'',"余氯量":}]} * @param [in] condition:约束条件, 格式: json字符串 {"startTime":'',"endTime":'',"水池":[{"code":'',"余氯量":},{"code":'',"余氯量":}]}
* @param [error] 错误警告 * @param [error] 输出值,错误警告
*/ */
bool PANDANALYSIS_API residualChlorineAnalysis(char* uri, char* conditionMap,char* error); bool PANDANALYSIS_API residualChlorineAnalysis(char* uri,char* startTime,char* endTime, char* conditionMap,char* error);
/**
* @brief 管网拓扑,二次维护
* @param [in] uri:condition
* @param [error] 输出值,错误警告
*/
bool PANDANALYSIS_API netTopo(char* uri, char* error);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -66,23 +66,23 @@ bool CivHydrSimulation::qualitySimulation() ...@@ -66,23 +66,23 @@ bool CivHydrSimulation::qualitySimulation()
CivSysLog::getInstance()->info("计算成功", "CivSysLog", __FUNCTION__); CivSysLog::getInstance()->info("计算成功", "CivSysLog", __FUNCTION__);
// 余氯计算 //// 余氯计算
inpFileS = convertor.convertResidualInp(); //inpFileS = convertor.convertResidualInp();
mHydrCompute.setInpFile(inpFileS); //mHydrCompute.setInpFile(inpFileS);
mHydrCompute.setRptFile("test.rpt"); //mHydrCompute.setRptFile("test.rpt");
mHydrCompute.setBinFile("test.bin"); //mHydrCompute.setBinFile("test.bin");
if (inpFileS.empty() || inpFileS == "") //if (inpFileS.empty() || inpFileS == "")
{ //{
CivSysLog::getInstance()->error("转inp文件失败", "CivSysLog", __FUNCTION__); // CivSysLog::getInstance()->error("转inp文件失败", "CivSysLog", __FUNCTION__);
return false; // return false;
} //}
if (!mHydrCompute.chlorineCompute()) //if (!mHydrCompute.chlorineCompute())
{ //{
CivSysLog::getInstance()->error("计算失败", "CivSysLog", __FUNCTION__); // CivSysLog::getInstance()->error("计算失败", "CivSysLog", __FUNCTION__);
return false; // return false;
} //}
mHydrCompute.saveResult(mUri); mHydrCompute.saveResult(mUri);
return true; return true;
......
#include "CivInpProject.h"
CivInpProject::CivInpProject()
{
}
CivInpProject::~CivInpProject()
{
}
bool CivInpProject::writeToFile(const string& filename)
{
return true;
}
\ No newline at end of file
#pragma once
#include <string>
using namespace std;
/*
ݿinpļ
*/
class CivInpProject
{
public:
explicit CivInpProject();
~CivInpProject();
bool writeToFile(const string& filename);
private:
};
...@@ -239,7 +239,6 @@ void CivProjSimulation::getProjLinkResult() ...@@ -239,7 +239,6 @@ void CivProjSimulation::getProjLinkResult()
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失 ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadloss);// 水头损失
mProjCache.addPipeHeadLoss(linkItem.szNo, linkItem.dHeadloss); mProjCache.addPipeHeadLoss(linkItem.szNo, linkItem.dHeadloss);
} }
free(typeCode); free(typeCode);
} }
...@@ -284,8 +283,12 @@ void CivProjSimulation::getLinkResult() ...@@ -284,8 +283,12 @@ void CivProjSimulation::getLinkResult()
if (*typeCode != EN_PIPE) if (*typeCode != EN_PIPE)
continue; continue;
ENgetlinkid(i, linkItem.szNo); // 编号 ENgetlinkid(i, linkItem.szNo); // 编号
ENgetlinkvalue(i, EN_FLOW, &linkItem.dFlow);// 流量
float flow;
ENgetlinkvalue(i, EN_FLOW, &flow);// 流量
linkItem.dFlow = std::abs(flow);
ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速 ENgetlinkvalue(i, EN_VELOCITY, &linkItem.dVelocity);// 流速
ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadLoss);// 水头损失 ENgetlinkvalue(i, EN_HEADLOSS, &linkItem.dHeadLoss);// 水头损失
......
...@@ -39,7 +39,6 @@ bool CivSchedulingCompute::openFile(const string& inpFILE) ...@@ -39,7 +39,6 @@ bool CivSchedulingCompute::openFile(const string& inpFILE)
return false; return false;
} }
return true; return true;
} }
...@@ -51,8 +50,6 @@ bool CivSchedulingCompute::saveInpFile(char* inpFile) ...@@ -51,8 +50,6 @@ bool CivSchedulingCompute::saveInpFile(char* inpFile)
return true; return true;
} }
bool CivSchedulingCompute::calculate() bool CivSchedulingCompute::calculate()
{ {
short hydCode = 1; short hydCode = 1;
...@@ -98,42 +95,9 @@ bool CivSchedulingCompute::calculate() ...@@ -98,42 +95,9 @@ bool CivSchedulingCompute::calculate()
default: default:
break; break;
} }
//if (linkType != EN_PUMP || linkType != EN_PBV)
// continue;
//switch (mChdulingType)
//{
//case PumpScheduling& EN_PUMP:
//{
// if (linkType != EN_PUMP)
// continue;
// char id[128] = "";
// ENgetlinkid(i, id);
// map<string,float>::iterator iter = mPumpSpeed.find(id);
// if (iter == mPumpSpeed.end())
// continue;
// // 更新水泵的转速
// ENsetlinkvalue(i, EN_STATUS, iter->second );
//}
// break;
//case PBVScheduling& EN_PBV:
//{
// if (linkType != EN_PBV)
// continue;
//}
// break;
//default:
// break;
//}
} }
do do
{ {
if (ENrunH(&t) > 100) // errcode > 100 是错误 if (ENrunH(&t) > 100) // errcode > 100 是错误
{ {
ENclose(); ENclose();
...@@ -181,7 +145,6 @@ void CivSchedulingCompute::setMonitors(const vector<string>& monitor) ...@@ -181,7 +145,6 @@ void CivSchedulingCompute::setMonitors(const vector<string>& monitor)
void CivSchedulingCompute::saveResult(int time) void CivSchedulingCompute::saveResult(int time)
{ {
// 计算节点 // 计算节点
int nNodeCount; int nNodeCount;
ENgetcount(EN_NODECOUNT, &nNodeCount); ENgetcount(EN_NODECOUNT, &nNodeCount);
......
...@@ -98,12 +98,12 @@ bool CivTrackingAnalysis::createGraphFrom() ...@@ -98,12 +98,12 @@ bool CivTrackingAnalysis::createGraphFrom()
continue; continue;
} }
std::string endcode = endCodeiter->second; std::string endcode = endCodeiter->second;
// 获取管段终点坐标值 // 获取管段终点坐标值
CivGraphJunction graphJunction2(endcode); CivGraphJunction graphJunction2(endcode);
int index2 = mGraph->getVertexIndex(graphJunction2); int index2 = mGraph->getVertexIndex(graphJunction2);
CivGraphJunction endJunction = mGraph->getData(index2); CivGraphJunction endJunction = mGraph->getData(index2);
if (sStartjuction.getHead() > endJunction.getHead()) if (sStartjuction.getHead() > endJunction.getHead())
{ {
CivGraphEdage edAge(pipeTable.code, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() }); CivGraphEdage edAge(pipeTable.code, pipeTable.Length, { sStartjuction.getXCoord(),sStartjuction.getYCoord(),endJunction.getXCoord(),endJunction.getYCoord() });
......
...@@ -158,6 +158,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command> ...@@ -158,6 +158,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClCompile Include="CivBaseInpBuilder.cpp" /> <ClCompile Include="CivBaseInpBuilder.cpp" />
<ClCompile Include="CivBreakPipeAnalysis.cpp" /> <ClCompile Include="CivBreakPipeAnalysis.cpp" />
<ClCompile Include="CivCloseValveProj.cpp" /> <ClCompile Include="CivCloseValveProj.cpp" />
<ClCompile Include="CivDynamicCompute.cpp" />
<ClCompile Include="CivHydDataType.cpp" /> <ClCompile Include="CivHydDataType.cpp" />
<ClCompile Include="CivHydrCompute.cpp" /> <ClCompile Include="CivHydrCompute.cpp" />
<ClCompile Include="CivHydrFuncInter.cpp" /> <ClCompile Include="CivHydrFuncInter.cpp" />
...@@ -165,7 +166,6 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command> ...@@ -165,7 +166,6 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClCompile Include="CivInpBuilder.cpp" /> <ClCompile Include="CivInpBuilder.cpp" />
<ClCompile Include="CivInpConvertor.cpp" /> <ClCompile Include="CivInpConvertor.cpp" />
<ClCompile Include="CivInpDirector.cpp" /> <ClCompile Include="CivInpDirector.cpp" />
<ClCompile Include="CivInpProject.cpp" />
<ClCompile Include="CivNewInp.cpp" /> <ClCompile Include="CivNewInp.cpp" />
<ClCompile Include="CivOptSchedEngine.cpp" /> <ClCompile Include="CivOptSchedEngine.cpp" />
<ClCompile Include="CivProjInpBuilder.cpp" /> <ClCompile Include="CivProjInpBuilder.cpp" />
...@@ -182,6 +182,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command> ...@@ -182,6 +182,7 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClInclude Include="CivBaseInpBuilder.h" /> <ClInclude Include="CivBaseInpBuilder.h" />
<ClInclude Include="CivBreakPipeAnalysis.h" /> <ClInclude Include="CivBreakPipeAnalysis.h" />
<ClInclude Include="CivCloseValveProj.h" /> <ClInclude Include="CivCloseValveProj.h" />
<ClInclude Include="CivDynamicCompute.h" />
<ClInclude Include="CivGraphList.h" /> <ClInclude Include="CivGraphList.h" />
<ClInclude Include="CivHydDataType.h" /> <ClInclude Include="CivHydDataType.h" />
<ClInclude Include="CivHydrCompute.h" /> <ClInclude Include="CivHydrCompute.h" />
...@@ -190,7 +191,6 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command> ...@@ -190,7 +191,6 @@ copy pandaAnalysis.h $(OutDir)..\include /y</Command>
<ClInclude Include="CivInpBuilder.h" /> <ClInclude Include="CivInpBuilder.h" />
<ClInclude Include="CivInpConvertor.h" /> <ClInclude Include="CivInpConvertor.h" />
<ClInclude Include="CivInpDirector.h" /> <ClInclude Include="CivInpDirector.h" />
<ClInclude Include="CivInpProject.h" />
<ClInclude Include="CivNewInp.h" /> <ClInclude Include="CivNewInp.h" />
<ClInclude Include="CivOptSchedEngine.h" /> <ClInclude Include="CivOptSchedEngine.h" />
<ClInclude Include="CivProjInpBuilder.h" /> <ClInclude Include="CivProjInpBuilder.h" />
......
...@@ -63,9 +63,6 @@ ...@@ -63,9 +63,6 @@
<ClCompile Include="CivCloseValveProj.cpp"> <ClCompile Include="CivCloseValveProj.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivInpProject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivStopWaterAnalysis.cpp"> <ClCompile Include="CivStopWaterAnalysis.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
...@@ -81,6 +78,9 @@ ...@@ -81,6 +78,9 @@
<ClCompile Include="CivReportReader.cpp"> <ClCompile Include="CivReportReader.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivDynamicCompute.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CivHydrFuncInter.h"> <ClInclude Include="CivHydrFuncInter.h">
...@@ -131,9 +131,6 @@ ...@@ -131,9 +131,6 @@
<ClInclude Include="CivStopWaterAnalysis.h"> <ClInclude Include="CivStopWaterAnalysis.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivInpProject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivCloseValveProj.h"> <ClInclude Include="CivCloseValveProj.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
...@@ -158,5 +155,8 @@ ...@@ -158,5 +155,8 @@
<ClInclude Include="CivReportReader.h"> <ClInclude Include="CivReportReader.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivDynamicCompute.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -7,7 +7,11 @@ void CivNode::addItem(const NodeTable& table) ...@@ -7,7 +7,11 @@ void CivNode::addItem(const NodeTable& table)
void CivPipe::addItem(const PipesTable& table) void CivPipe::addItem(const PipesTable& table)
{ {
mTables.push_back(table); auto iter = std::find(mTables.begin(), mTables.end(), table);
if (iter == mTables.end())
{
mTables.push_back(table);
}
} }
void CivTank::addItem(const TankTable& table) void CivTank::addItem(const TankTable& table)
......
...@@ -65,6 +65,11 @@ public: ...@@ -65,6 +65,11 @@ public:
Str MinorLoss; Str MinorLoss;
Str Status; Str Status;
Str code; Str code;
bool operator==(const Table& other)
{
return ID == other.ID;
}
} PipesTable; } PipesTable;
void addItem(const PipesTable& table); void addItem(const PipesTable& table);
......
This diff is collapsed.
...@@ -38,10 +38,26 @@ private: ...@@ -38,10 +38,26 @@ private:
/** /**
*@brief 拓扑维护阀门,需要特殊处理 *@brief 拓扑维护阀门,需要特殊处理
*/ */
bool topoValve(const std::string& sn,const std::string& fromcode,const std::string& tocode ); bool topoValve(const std::string& pipeTable,
const std::string& valveTable,
const std::string& sn,
const std::string& fromcode,
const std::string& tocode,
const std::string& nodeTable="节点" );
bool topoLikelyPipe(const std::string& pipeTable, const std::string& nodeTable, bool topoLikelyPipe(const std::string& pipeTable, const std::string& nodeTable,
const std::string& filed, const std::string& tocode); const std::string& filed, const std::string& tocode);
bool topoPump(const std::string& pipeTable,
const std::string& pumpTable,
const std::string& sn,
const std::string& fromcode,
const std::string& tocode,
const std::string& nodeTable);
// 拼接维护水泵的sql语句
std::string inline splicingPumpSql(const std::string& pumpTable,const std::string& nodetable);
private: private:
std::vector<std::string> mNecessTables; std::vector<std::string> mNecessTables;
std::map<std::string, std::string> mNeedTableMap; std::map<std::string, std::string> mNeedTableMap;
......
...@@ -322,55 +322,7 @@ void CivInpDbHelper::handlePump() ...@@ -322,55 +322,7 @@ void CivInpDbHelper::handlePump()
bool CivInpDbHelper::handleValves2() bool CivInpDbHelper::handleValves2()
{ {
std::string sql = "SELECT A.*,B.* FROM\ std::string sql = splicingSql("节点");
(\
SELECT\
node.\"本点号\",\
node.\"横坐标\" AS 阀门横坐标,\
node.\"纵坐标\" AS 阀门纵坐标,\
node.\"固定状态\" AS 阀门固定状态,\
node.\"类型\" AS 阀门类型,\
node.\"设置\" AS 阀门设置,\
node.\"水损系数\" AS 阀门水损系数,\
pipe.编号 AS 上游管段编号,\
pipe.\"管长\" AS 上游管长,\
pipe.\"管径\" AS 上游管径,\
pipe.\"摩阻系数\" AS 上游管段摩阻系数,\
junc.\"本点号\" AS 上游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 上游节点高程,\
junc.\"需水量模式\" AS 上游节点蓄水量模式,\
junc.\"基本需水量\" as 上游节点基本需水量,\
junc.\"横坐标\" AS 上游节点横坐标,\
junc.\"纵坐标\" AS 上游节点纵坐标,\
junc.\"初始水质\" AS 上游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, 节点 as junc\
WHERE\
pipe.\"from_code\" = node.\"code\" AND pipe.\"to_code\" = junc.\"code\"\
) A,\
(\
SELECT\
pipe.编号 AS 下游管段编号,\
pipe.\"管长\" AS 下游管段管长,\
pipe.\"管径\" AS 下游管段管径,\
pipe.\"摩阻系数\" AS 下游管段摩阻系数,\
node.\"本点号\",\
junc.\"本点号\" AS 下游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 下游节点高程,\
junc.\"需水量模式\" AS 下游节点蓄水量模式,\
junc.\"基本需水量\" as 下游节点基本需水量,\
junc.\"横坐标\" AS 下游节点横坐标,\
junc.\"纵坐标\" AS 下游节点纵坐标,\
junc.\"初始水质\" AS 下游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, 节点 as junc\
WHERE\
pipe.\"to_code\" = node.\"code\" AND pipe.\"from_code\" = junc.\"code\"\
) B\
WHERE\
A.\"本点号\" = b.\"本点号\"";
if (!mDbConn->execSql(sql)) if (!mDbConn->execSql(sql))
{ {
...@@ -382,6 +334,16 @@ bool CivInpDbHelper::handleValves2() ...@@ -382,6 +334,16 @@ bool CivInpDbHelper::handleValves2()
std::vector<std::map<std::string, std::string>> valvesPipes; std::vector<std::map<std::string, std::string>> valvesPipes;
mDbConn->queryResult(valvesPipes); mDbConn->queryResult(valvesPipes);
// 非
std::string sql2 = splicingSql("水库","0","1");
if (!mDbConn->execSql(sql2))
{
std::string error = mDbConn->getLastError();
return false;
}
mDbConn->queryResult(valvesPipes);
// 总个数 // 总个数
size_t total = valvesPipes.size(); size_t total = valvesPipes.size();
for (int i = 0; i < total; i++) for (int i = 0; i < total; i++)
...@@ -434,8 +396,8 @@ bool CivInpDbHelper::handleValves2() ...@@ -434,8 +396,8 @@ bool CivInpDbHelper::handleValves2()
startNodeTable.Demand = "0"; startNodeTable.Demand = "0";
// 两点之间直线 // 两点之间直线
double vupperXcoord = (atof(upperNodeXcoord.c_str()) - atof(vaXcoord.c_str()))/5+atof(vaXcoord.c_str()); double vupperXcoord = (atof(upperNodeXcoord.c_str()) - atof(vaXcoord.c_str()))/10+atof(vaXcoord.c_str());
double vupperYcoord = (atof(upperNodeYcoord.c_str()) - atof(vaYcoord.c_str()))/5 + atof(vaYcoord.c_str()); double vupperYcoord = (atof(upperNodeYcoord.c_str()) - atof(vaYcoord.c_str()))/10 + atof(vaYcoord.c_str());
// 节点坐标 // 节点坐标
startNodeCoord.ID = "VUP" + vaSzNo; startNodeCoord.ID = "VUP" + vaSzNo;
...@@ -455,8 +417,8 @@ bool CivInpDbHelper::handleValves2() ...@@ -455,8 +417,8 @@ bool CivInpDbHelper::handleValves2()
mCoords.push_back(startNodeCoord); mCoords.push_back(startNodeCoord);
// 两点之间直线 // 两点之间直线
double vdownXcoord = (atof(donwNodeXcoord.c_str()) - atof(vaXcoord.c_str())) / 5 + atof(vaXcoord.c_str()); double vdownXcoord = (atof(donwNodeXcoord.c_str()) - atof(vaXcoord.c_str())) / 10 + atof(vaXcoord.c_str());
double vdownYcoord = (atof(donwNodeYcoord.c_str()) - atof(vaYcoord.c_str())) / 5 + atof(vaYcoord.c_str()); double vdownYcoord = (atof(donwNodeYcoord.c_str()) - atof(vaYcoord.c_str())) / 10 + atof(vaYcoord.c_str());
// 终止节点坐标信息 // 终止节点坐标信息
endNodeCoord.ID = "VDW" + vaSzNo; endNodeCoord.ID = "VDW" + vaSzNo;
...@@ -540,4 +502,73 @@ void CivInpDbHelper::handleValve() ...@@ -540,4 +502,73 @@ void CivInpDbHelper::handleValve()
{ {
handleValves2(); handleValves2();
return; return;
}
std::string CivInpDbHelper::splicingSql(const std::string& rightTable, const std::string& demandName , const std::string& demandPattern)
{
std::string upcondition;
std::string downcondition;
if (rightTable == "节点")
{
upcondition = "pipe.\"from_code\" = node.\"code\" AND pipe.\"to_code\" = junc.\"code\"";
downcondition = "pipe.\"to_code\" = node.\"code\" AND pipe.\"from_code\" = junc.\"code\"";
}
else
{
upcondition = "(pipe.\"to_code\" = node.\"code\"\
AND pipe.\"from_code\" = junc.\"code\") or\
(pipe.\"from_code\" = node.\"code\"\
AND pipe.\"to_code\" = junc.\"code\")";
downcondition = "(pipe.\"to_code\" = node.\"code\"\
AND pipe.\"from_code\" = junc.\"code\") or\
(pipe.\"from_code\" = node.\"code\"\
AND pipe.\"to_code\" = junc.\"code\")";
}
std::string sql2 = "SELECT A.*, B.* FROM (SELECT\
node.\"本点号\",\
node.\"横坐标\" AS 阀门横坐标,\
node.\"纵坐标\" AS 阀门纵坐标,\
node.\"固定状态\" AS 阀门固定状态,\
node.\"类型\" AS 阀门类型,\
node.\"设置\" AS 阀门设置,\
node.\"水损系数\" AS 阀门水损系数,\
pipe.编号 AS 上游管段编号,\
pipe.\"管长\" AS 上游管长,\
pipe.\"管径\" AS 上游管径,\
pipe.\"摩阻系数\" AS 上游管段摩阻系数,\
junc.\"本点号\" AS 上游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 上游节点高程,\
"+ demandPattern + " AS 上游节点蓄水量模式,\
"+demandName + " AS 上游节点基本需水量,\
junc.\"横坐标\" AS 上游节点横坐标,\
junc.\"纵坐标\" AS 上游节点纵坐标,\
junc.\"初始水质\" AS 上游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, "+rightTable+" AS junc\
WHERE "+ upcondition+") A,\
(\
SELECT\
pipe.编号 AS 下游管段编号,\
pipe.\"管长\" AS 下游管段管长,\
pipe.\"管径\" AS 下游管段管径,\
pipe.\"摩阻系数\" AS 下游管段摩阻系数,\
node.\"本点号\",\
junc.\"本点号\" AS 下游节点,\
junc.\"code\" AS 上游节点code,\
junc.\"高程\" AS 下游节点高程,\
junc.\"需水量模式\" AS 下游节点蓄水量模式,\
junc.\"基本需水量\" AS 下游节点基本需水量,\
junc.\"横坐标\" AS 下游节点横坐标,\
junc.\"纵坐标\" AS 下游节点纵坐标,\
junc.\"初始水质\" AS 下游节点初始水质\
FROM\
阀门 AS node, 管段 AS pipe, 节点 AS junc\
WHERE "+downcondition+") B\
WHERE\
A.\"本点号\" = b.\"本点号\"";
return sql2;
} }
\ No newline at end of file
...@@ -27,5 +27,7 @@ public: ...@@ -27,5 +27,7 @@ public:
private: private:
bool handleValves2(); bool handleValves2();
std::string splicingSql(const std::string& rightTable,const std::string& demandName="需水量模式",const std::string& demandPattern = "基本需水量");
}; };
This diff is collapsed.
#pragma once #pragma once
#include "CivAssembly.h" #include "CivAssembly.h"
#include "CivInpHelperAbs.h" #include "CivInpHelperAbs.h"
#include <memory>
#include "pandaDbManager.h"
/** /**
* 增加 * 增加
...@@ -30,6 +32,17 @@ private: ...@@ -30,6 +32,17 @@ private:
// 将方案详情表查出的数据按图层分类 // 将方案详情表查出的数据按图层分类
void sortProjDeatil(); void sortProjDeatil();
std::string splicingSql(const std::string& rightTable,
const std::string& demandName = "需水量模式",
const std::string& demandPattern = "基本需水量");
// 根据方案编码生成对应,联合图层的视图sql语句
std::string inline genSqlView(const std::string& table,
const std::string& projTable,
const std::vector<std::string>& fieldsVec,
const std::string& projCode);
/** /**
*@brief 根据图层动态生成需要查询详情表条件 *@brief 根据图层动态生成需要查询详情表条件
*/ */
...@@ -37,6 +50,8 @@ private: ...@@ -37,6 +50,8 @@ private:
std::string inline genSql(const std::string& table); std::string inline genSql(const std::string& table);
bool handleValves2();
std::string mPorjCode; std::string mPorjCode;
std::string mCondition; std::string mCondition;
......
#include "CivPumpHelper.h" #include "CivPumpHelper.h"
#include "CivPgDbConnection.h" #include "CivPgDbConnection.h"
#include "StringUtils.h"
#include <set> #include <set>
CivPumpHelper::CivPumpHelper(const string& uri) CivPumpHelper::CivPumpHelper(const string& uri)
...@@ -142,4 +143,202 @@ void CivPumpHelper::getMonitors(vector<string>& monitors,map<string,string>& mon ...@@ -142,4 +143,202 @@ void CivPumpHelper::getMonitors(vector<string>& monitors,map<string,string>& mon
monitorMap.insert(pair<string, string>(szNo,code)); monitorMap.insert(pair<string, string>(szNo,code));
} }
} }
}
bool CivPumpHelper::updateDatas(const std::string& tablename,
const std::map<std::string, std::map<std::string, float>>& resultMap)
{
if (tablename.empty())
return false;
if (resultMap.size() <= 0)
return false;
bool resBool = true;
std::map<std::string, std::map<std::string, float>>::const_iterator iter = resultMap.cbegin();
// 缓存节点图层本点号和code 的映射
std::map<std::string, std::string> snToCodeMap;
snToCode("节点", snToCodeMap);
for (; iter != resultMap.cend(); iter++)
{
std::string key = iter->first;
std::map<std::string, float> resmap = iter->second;
std::vector<std::string> dateStrVec;
StringUtils::split(key, dateStrVec);
std::string dateStr;
if (dateStrVec.size() > 1)
dateStr = dateStrVec[0];
// 判断该条件下是否存在数据
std::string sesql = "select \"id\" from "+tablename +" where \"时间点\"='"+key+"'";
if (!mConn->execSql(sesql))
continue;
std::vector<std::map<std::string, std::string>> vecMap;
mConn->queryResult(vecMap);
if (vecMap.size() <= 0 || vecMap[0].size() < 0)
{
// 数据库没数据需要直接插入操作
std::string sql = "INSERT INTO " + tablename + "(日期,时间点,code,余氯) VALUES";
std::map<std::string, float>::const_iterator const_iter = resmap.cbegin();
for (; const_iter != resmap.cend(); const_iter++)
{
std::string keyStr = const_iter->first;
float valStr = const_iter->second;
std::map<std::string, std::string>::iterator keyIter = snToCodeMap.find(keyStr);
if (keyIter != snToCodeMap.end())
{
keyStr = keyIter->second;
}
else
{
continue;
}
sql.append("(");
sql.append("'" + dateStr + "'");
sql.append("'" + key + "'");
sql.append("'" + keyStr + "'");
sql.append(std::to_string(valStr));
sql.append("),");
}
sql = sql.substr(0, sql.size() - 1);
if (!mConn->execSql(sql))
{
resBool = false;
break;
}
}
else // 数据库存在数据则需要更新
{
std::string sql = "update " + tablename +" set \"余氯\" = data_table.vals ";
std::map<std::string, float>::const_iterator const_iter = resmap.cbegin();
std::string codeArr = "array[";
std::string valArr = "array[";
std::string timeArr = "array[";
for (; const_iter != resmap.cend(); const_iter++)
{
std::string keyStr = const_iter->first;
float valStr = const_iter->second;
std::map<std::string, std::string>::iterator keyIter = snToCodeMap.find(keyStr);
if (keyIter != snToCodeMap.end())
{
keyStr = keyIter->second;
}
else
{
continue;
}
// 编码
codeArr.append("'" + keyStr + "',");
// 值
valArr.append(std::to_string(valStr) + ",");
}
std::string codeArrStr = codeArr.substr(0, codeArr.length() - 1);
std::string valArrStr = valArr.substr(0, valArr.length() - 1);
codeArrStr.append("]");
valArrStr.append("]");
sql.append("from (select unnest(");
sql.append(codeArrStr);
sql.append(") as codes,");
// 拼接余氯值
sql.append("unnest(");
sql.append(valArrStr);
sql.append(") as vals) as data_table");
sql.append(" where "+tablename+".\"时间点\" = ' "+key+"'");
sql.append(" and "+ tablename+".\"code\" = data_table.codes");
if (!mConn->execSql(sql))
{
resBool = false;
break;
}
}
}
return resBool;
}
void CivPumpHelper::codeToSn(const std::string& tablename,
std::map<std::string, std::string>& resmap)
{
baseCommonCache(tablename, resmap, CodeToSn);
}
void CivPumpHelper::snToCode(const std::string& tablename,
std::map<std::string, std::string>& resmap)
{
baseCommonCache(tablename, resmap, SnToCode);
}
void CivPumpHelper::baseCommonCache(const std::string& tablename, std::map<std::string, std::string>& resmap, CacheType cacheType)
{
std::string sql;
if (tablename == "管段")
{
sql = "select \"编号\",\"code\" from " + tablename;
}
else
{
sql = "select \"本点号\",\"code\" from " + tablename;
}
if (mConn && !mConn->execSql(sql))
{
return;
}
std::vector<std::map<std::string, std::string>> res;
mConn->queryResult(res);
if (res.size() <= 0)
{
return;
}
//
int total = res.size();
for (int i = 0; i < total; i++)
{
std::map<std::string, std::string> resultMap = res[i];
std::map<std::string, std::string>::const_iterator const_iter = resultMap.cbegin();
std::string key;
std::string val;
for (; const_iter != resultMap.cend(); const_iter++)
{
if(const_iter->first == "code")
key = const_iter->second;
else
val = const_iter->second;
}
switch (cacheType)
{
case CodeToSn:
resmap.insert(std::pair<std::string, std::string>(key, val));
break;
case SnToCode:
resmap.insert(std::pair<std::string, std::string>(val, key));
break;
default:
break;
}
}
return;
} }
\ No newline at end of file
...@@ -15,6 +15,11 @@ class CivConnection; ...@@ -15,6 +15,11 @@ class CivConnection;
class PANDADBMANAGER_API CivPumpHelper class PANDADBMANAGER_API CivPumpHelper
{ {
public: public:
enum CacheType
{
SnToCode,
CodeToSn
};
explicit CivPumpHelper(const string& uri); explicit CivPumpHelper(const string& uri);
~CivPumpHelper(); ~CivPumpHelper();
...@@ -31,6 +36,12 @@ public: ...@@ -31,6 +36,12 @@ public:
void getPumpStations(vector<PumpStation>& stations); void getPumpStations(vector<PumpStation>& stations);
void getMonitors(vector<string>& monitors, map<string, string>& monitorMap); void getMonitors(vector<string>& monitors, map<string, string>& monitorMap);
bool updateDatas(const std::string& tablename, const std::map<std::string, std::map<std::string, float>>& resultMap);
void codeToSn(const std::string& tablename, std::map<std::string, std::string>& resmap);
void snToCode(const std::string& tablename, std::map<std::string, std::string>& resmap);
private:
void baseCommonCache(const std::string& tablename, std::map<std::string, std::string>& resmap, CacheType cacheType);
private: private:
CivConnection* mConn = nullptr; CivConnection* mConn = nullptr;
......
...@@ -15,8 +15,8 @@ struct ResultItem ...@@ -15,8 +15,8 @@ struct ResultItem
char szNo[64]; char szNo[64];
std::string dDate; std::string dDate;
std::string dTime; std::string dTime;
float dQuality; float dQuality = 0;
float dChlorine; float dChlorine = 0;
std::string dModifyTime; std::string dModifyTime;
}; };
...@@ -34,6 +34,7 @@ struct LinkResultItem:public ResultItem ...@@ -34,6 +34,7 @@ struct LinkResultItem:public ResultItem
{ {
char szStatus[32]; char szStatus[32];
float dFlow; float dFlow;
float dDrection = 1;
float dVelocity; float dVelocity;
float dHeadloss;// 单位水损 float dHeadloss;// 单位水损
}; };
......
...@@ -10,4 +10,7 @@ public: ...@@ -10,4 +10,7 @@ public:
CivInpExporter(); CivInpExporter();
~CivInpExporter(); ~CivInpExporter();
private:
}; };
...@@ -30,3 +30,6 @@ ...@@ -30,3 +30,6 @@
#define s_BACKDROP "[BACK" #define s_BACKDROP "[BACK"
#define s_TAGS "[TAGS" #define s_TAGS "[TAGS"
#define s_END "[END" #define s_END "[END"
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
class CivInpVector class CivInpVector
{ {
public: public:
enum VectorType
{
Point,
Line,
Other
};
CivInpVector(); CivInpVector();
~CivInpVector(); ~CivInpVector();
......
#include <iostream>
#include "CivInpImpoter.h"
int main(char* argc, char** argv)
{
CivInpImpoter importer;
if (!importer.load("D:\\work\\hydr\\hModelProgram\\Program\\test.inp"))
{
}
getchar();
return 0;
}
\ No newline at end of file
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
<ClInclude Include="CivInpObserver.h" /> <ClInclude Include="CivInpObserver.h" />
<ClInclude Include="CivInpSubject.h" /> <ClInclude Include="CivInpSubject.h" />
<ClInclude Include="CivInpVector.h" /> <ClInclude Include="CivInpVector.h" />
<ClInclude Include="CivTypes.h" /> <ClInclude Include="CivInpTypes.h" />
<ClInclude Include="pandaInpCore.h" /> <ClInclude Include="pandaInpCore.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
...@@ -159,7 +159,6 @@ ...@@ -159,7 +159,6 @@
<ClCompile Include="CivInpObserver.cpp" /> <ClCompile Include="CivInpObserver.cpp" />
<ClCompile Include="CivInpSubject.cpp" /> <ClCompile Include="CivInpSubject.cpp" />
<ClCompile Include="CivInpVector.cpp" /> <ClCompile Include="CivInpVector.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
......
...@@ -30,9 +30,6 @@ ...@@ -30,9 +30,6 @@
<ClCompile Include="CivInpExporter.cpp"> <ClCompile Include="CivInpExporter.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="main.cpp">
<Filter>头文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CivInpExporter.h"> <ClInclude Include="CivInpExporter.h">
...@@ -53,7 +50,7 @@ ...@@ -53,7 +50,7 @@
<ClInclude Include="pandaInpCore.h"> <ClInclude Include="pandaInpCore.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivTypes.h"> <ClInclude Include="CivInpTypes.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
......
...@@ -39,7 +39,7 @@ void JsonParseObject::read(map<string, vector<double>>& resMap) ...@@ -39,7 +39,7 @@ void JsonParseObject::read(map<string, vector<double>>& resMap)
while (parent) while (parent)
{ {
string key = parent->string; string key = parent->string;
cJSON* child = parent->child; cJSON* child = parent->child;
if (child && child->next) if (child && child->next)
{ {
...@@ -58,6 +58,24 @@ void JsonParseObject::read(map<string, vector<double>>& resMap) ...@@ -58,6 +58,24 @@ void JsonParseObject::read(map<string, vector<double>>& resMap)
} }
} }
void JsonParseObject::read(Condition& resMap)
{
if (!mResultJson)
return;
cJSON* parent = mResultJson->child;
if (!parent)
return;
while (parent)
{
string key = parent->string;
double Val = parent->valuedouble;
resMap.mCondMap.insert(std::pair<std::string, double>(key, Val));
parent = parent->next;
}
}
void JsonParseObject::clear() void JsonParseObject::clear()
{ {
cJSON_Delete(mResultJson); cJSON_Delete(mResultJson);
......
...@@ -8,6 +8,11 @@ using namespace std; ...@@ -8,6 +8,11 @@ using namespace std;
class cJSON; class cJSON;
typedef struct ConditionStruct
{
std::map<std::string, float> mCondMap;
}Condition;
/** /**
json解析对象 json解析对象
*/ */
...@@ -22,6 +27,7 @@ public: ...@@ -22,6 +27,7 @@ public:
void parse(string& jsonStr); void parse(string& jsonStr);
void read(map<string, string>& resMap); void read(map<string, string>& resMap);
void read(Condition& resMap);
void read(map<string, vector<double>>& resMap); void read(map<string, vector<double>>& resMap);
......
...@@ -27,3 +27,26 @@ void StringUtils::trim(std::string & s) ...@@ -27,3 +27,26 @@ void StringUtils::trim(std::string & s)
s.erase(s.find_last_not_of(" ") + 1); s.erase(s.find_last_not_of(" ") + 1);
} }
} }
int StringUtils::parseInt(std::string& s)
{
std::vector<std::string> sVec;
split(s, sVec);
int res = -1;
if (sVec.size() <1)
return -1;
std::string ss = sVec[1];
std::vector<std::string> ssVec;
split(ss, ssVec,":");
if (ssVec.size() >0)
{
std::string temp = ssVec[0];
res = std::atoi(temp.c_str());
}
return res;
}
...@@ -23,4 +23,10 @@ public: ...@@ -23,4 +23,10 @@ public:
*@param [in] s 源字符串 *@param [in] s 源字符串
*/ */
static void trim(std::string& s); static void trim(std::string& s);
/**
*@brief 解析字符串里的整数值
*@param [in] s 源字符串
*/
static int parseInt(std::string& s);
}; };
#include <windows.h> #include <windows.h>
#include <objbase.h> #include <objbase.h>
#include <zmouse.h> #include <zmouse.h>
#include "MainFrameWnd.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
...@@ -12,7 +13,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*l ...@@ -12,7 +13,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*l
HRESULT Hr = ::CoInitialize(NULL); HRESULT Hr = ::CoInitialize(NULL);
if (FAILED(Hr)) return 0; if (FAILED(Hr)) return 0;
C360SafeFrameWnd* pFrame = new C360SafeFrameWnd(); MainFrameWnd* pFrame = new MainFrameWnd();
if (pFrame == NULL) return 0; if (pFrame == NULL) return 0;
pFrame->Create(NULL, _T("360ȫʿ"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572); pFrame->Create(NULL, _T("360ȫʿ"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572);
pFrame->CenterWindow(); pFrame->CenterWindow();
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;UILIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;UILIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(OUTDIR)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(OUTDIR)..\include;$(OUTDIR)..\include\Control;$(OUTDIR)..\include\Utils;$(OUTDIR)..\include\Layout;$(OUTDIR)..\include\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
......
...@@ -28,5 +28,5 @@ void CivFeature::addAttributes(const CivAttributes& attributes) ...@@ -28,5 +28,5 @@ void CivFeature::addAttributes(const CivAttributes& attributes)
std::string CivFeature::params() const std::string CivFeature::params() const
{ {
return "";
} }
...@@ -14,6 +14,7 @@ public: ...@@ -14,6 +14,7 @@ public:
explicit CivFeature(const CivGeometry& geom ); explicit CivFeature(const CivGeometry& geom );
CivFeature() = default; CivFeature() = default;
~CivFeature(); ~CivFeature();
/** /**
* @brief 要素的几何体 * @brief 要素的几何体
* @param [geo] 几何体 * @param [geo] 几何体
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment