Commit 49d41dc4 authored by 刘乐's avatar 刘乐

1, 接口修改

parent b63cb844
#include <iostream> #include <iostream>
#include <libpq-fe.h> #include <libpq-fe.h>
#include "CivHydrFuncInterface.h" #include "CivHydrFuncInter.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
const char* uri = "host=192.168.12.7 port=5432 dbname=2222 user=postgres password=admin"; const char* uri = "host=192.168.12.7 port=5432 dbname=2222 user=postgres password=admin";
char* findUri = const_cast<char*>(uri); char* findUri = const_cast<char*>(uri);
char fileName[20];
char rptR[20]; char net[128];
char outBinFile[20]; char flag[128];
const char* file = "test.inp"; const char* file = "test.inp";
strcpy_s(fileName, "test.inp"); const char netName[128] = "쏵鳩彊제친謹";
strcpy_s(rptR, "test.rpt");
strcpy_s(outBinFile, "test.bin"); strcpy_s(net, "쏵鳩彊제친謹");
strcpy_s(flag, "HDY");
bool msg = hydrSimulation(findUri, std::string("ˮģ"), fileName, rptR, outBinFile); bool msg = simulation(findUri, net, flag);
std::cout << msg << std::endl; std::cout << msg << std::endl;
getchar(); getchar();
return 0; return msg;
} }
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Page 1 Fri Jun 12 11:05:01 2020
******************************************************************
* E P A N E T *
* Hydraulic and Water Quality *
* Analysis for Pipe Networks *
* Version 2.1 *
******************************************************************
Scenario: Base
Date:
Input Data File ................... test.inp
Number of Junctions................ 730
Number of Reservoirs............... 1
Number of Tanks ................... 0
Number of Pipes ................... 753
Number of Pumps ................... 2
Number of Valves .................. 1
Headloss Formula .................. Hazen-Williams
Hydraulic Timestep ................ 1.00 hrs
Hydraulic Accuracy ................ 0.001000
Status Check Frequency ............ 2
Maximum Trials Checked ............ 10
Damping Limit Threshold ........... 0.000000
Maximum Trials .................... 40
Quality Analysis .................. Age
Water Quality Time Step ........... 6.00 min
Water Quality Tolerance ........... 0.01 hrs
Specific Gravity .................. 1.00
Relative Kinematic Viscosity ...... 0.10
Relative Chemical Diffusivity ..... 1.00
Demand Multiplier ................. 1.00
Total Duration .................... 24.00 hrs
Reporting Criteria:
No Nodes
No Links
Analysis begun Fri Jun 12 11:05:01 2020
...@@ -9,10 +9,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaAnalysis", "pandaAnaly ...@@ -9,10 +9,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaAnalysis", "pandaAnaly
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EPNAET2", "EPNAET2\EPNAET2.vcxproj", "{BE73E098-3D8C-4F80-88DD-B36A2BB68B64}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EPNAET2", "EPNAET2\EPNAET2.vcxproj", "{BE73E098-3D8C-4F80-88DD-B36A2BB68B64}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaHydrCalcMiddle", "pandaHydrCalcMiddle\pandaHydrCalcMiddle.vcxproj", "{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pandaHydrDemo", "pandaHydrDemo\pandaHydrDemo.csproj", "{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "funcDemo", "funcDemo\funcDemo.vcxproj", "{6A4F723D-C24B-4B16-A230-9C39A379F082}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "funcDemo", "funcDemo\funcDemo.vcxproj", "{6A4F723D-C24B-4B16-A230-9C39A379F082}"
EndProject EndProject
Global Global
...@@ -55,28 +51,6 @@ Global ...@@ -55,28 +51,6 @@ Global
{BE73E098-3D8C-4F80-88DD-B36A2BB68B64}.Release|x64.Build.0 = Release|x64 {BE73E098-3D8C-4F80-88DD-B36A2BB68B64}.Release|x64.Build.0 = Release|x64
{BE73E098-3D8C-4F80-88DD-B36A2BB68B64}.Release|x86.ActiveCfg = Release|Win32 {BE73E098-3D8C-4F80-88DD-B36A2BB68B64}.Release|x86.ActiveCfg = Release|Win32
{BE73E098-3D8C-4F80-88DD-B36A2BB68B64}.Release|x86.Build.0 = Release|Win32 {BE73E098-3D8C-4F80-88DD-B36A2BB68B64}.Release|x86.Build.0 = Release|Win32
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Debug|x64.ActiveCfg = Debug|x64
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Debug|x64.Build.0 = Debug|x64
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Debug|x86.ActiveCfg = Debug|Win32
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Debug|x86.Build.0 = Debug|Win32
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Release|Any CPU.ActiveCfg = Release|Win32
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Release|x64.ActiveCfg = Release|x64
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Release|x64.Build.0 = Release|x64
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Release|x86.ActiveCfg = Release|Win32
{26FC1DC0-4EEE-44DA-B409-8F392D37B67E}.Release|x86.Build.0 = Release|Win32
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Debug|x64.ActiveCfg = Debug|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Debug|x64.Build.0 = Debug|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Debug|x86.ActiveCfg = Debug|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Debug|x86.Build.0 = Debug|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Release|Any CPU.Build.0 = Release|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Release|x64.ActiveCfg = Release|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Release|x64.Build.0 = Release|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Release|x86.ActiveCfg = Release|Any CPU
{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}.Release|x86.Build.0 = Release|Any CPU
{6A4F723D-C24B-4B16-A230-9C39A379F082}.Debug|Any CPU.ActiveCfg = Debug|Win32 {6A4F723D-C24B-4B16-A230-9C39A379F082}.Debug|Any CPU.ActiveCfg = Debug|Win32
{6A4F723D-C24B-4B16-A230-9C39A379F082}.Debug|x64.ActiveCfg = Debug|x64 {6A4F723D-C24B-4B16-A230-9C39A379F082}.Debug|x64.ActiveCfg = Debug|x64
{6A4F723D-C24B-4B16-A230-9C39A379F082}.Debug|x64.Build.0 = Debug|x64 {6A4F723D-C24B-4B16-A230-9C39A379F082}.Debug|x64.Build.0 = Debug|x64
......
#include "CivHydrFuncInterface.h" #include "CivHydrFuncInter.h"
#include "CivHydrCalc.h" #include "CivHydrCalc.h"
bool DLLEXPORT hydrSimulation(char* uri, std::string netName, char* inpFile, char* rptFile, char* binOutFile)
{
CivHydrCalc* calc = new CivHydrCalc(uri, netName);
bool success = calc->hydrSimulation(inpFile, rptFile, binOutFile);
delete calc;
return success;
}
bool DLLEXPORT qualitySimulation(char* uri, std::string netName, char* inpFile, char* rptFile, char* binOutFile)
{
CivHydrCalc* calc = new CivHydrCalc(uri, netName);
bool success = calc->qualitySimulation(inpFile, rptFile, binOutFile);
delete calc;
return success;
}
bool DLLEXPORT simulation(char* uri, char* netName, char* flag) bool DLLEXPORT simulation(char* uri, char* netName, char* flag)
{ {
...@@ -24,15 +8,19 @@ bool DLLEXPORT simulation(char* uri, char* netName, char* flag) ...@@ -24,15 +8,19 @@ bool DLLEXPORT simulation(char* uri, char* netName, char* flag)
char fileName[20]; char fileName[20];
char rptR[20]; char rptR[20];
char outBinFile[20]; char outBinFile[20];
const char* file = "test.inp";
strcpy_s(fileName, "test.inp"); strcpy_s(fileName, "test.inp");
strcpy_s(rptR, "test.rpt"); strcpy_s(rptR, "test.rpt");
strcpy_s(outBinFile, "test.bin"); strcpy_s(outBinFile, "test.bin");
if (flag == "HDY") CivHydrCalc* calc = new CivHydrCalc(uri, netName);
return hydrSimulation(uri, netName, fileName, rptR, outBinFile);
else if(flag == "QUALITY") bool msg = false;;
return qualitySimulation(uri, netName, fileName, rptR, outBinFile); if (strcmp(flag,"HDY")==0)
msg = calc->hydrSimulation( fileName, rptR, outBinFile);
else if(strcmp(flag, "QUALITY")==0)
msg = calc->qualitySimulation(fileName, rptR, outBinFile);
return false; delete calc;
return msg;
} }
\ No newline at end of file
...@@ -5,24 +5,13 @@ ...@@ -5,24 +5,13 @@
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
bool DLLEXPORT simulation(char* uri, char* netName,char* flag);
/**
*@brief 水力模拟计算
*@inpFile:inp文件
*@rptFile: 输出文件
*@binOutFile: 二进制输出文件
*/
bool DLLEXPORT hydrSimulation(char* uri, std::string netName, char* inpFile, char* rptFile, char* binOutFile);
/** /**
*@brief 水质模拟计算 *@brief 模拟计算
*@inpFile:inp文件 *@uri: 管网数据库连接
*@rptFile: 输出文件 *@netName: 管网名
*@binOutFile: 二进制输出文件 *@flag: 标记
*/ */
bool DLLEXPORT qualitySimulation(char* uri, std::string netName, char* inpFile, char* rptFile, char* binOutFile); bool DLLEXPORT simulation(char* uri, char* netName,char* flag);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
......
...@@ -148,20 +148,20 @@ ...@@ -148,20 +148,20 @@
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary> <ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>copy CivHydrFuncInterface.h $(OutDir)..\include /y</Command> <Command>copy CivHydrFuncInter.h $(OutDir)..\include /y</Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp" /> <ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp" />
<ClCompile Include="CivComponent.cpp" /> <ClCompile Include="CivComponent.cpp" />
<ClCompile Include="CivHydrCalc.cpp" /> <ClCompile Include="CivHydrCalc.cpp" />
<ClCompile Include="CivHydrFuncInterface.cpp" /> <ClCompile Include="CivHydrFuncInter.cpp" />
<ClCompile Include="CivInp.cpp" /> <ClCompile Include="CivInp.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CivComponent.h" /> <ClInclude Include="CivComponent.h" />
<ClInclude Include="CivHydrCalc.h" /> <ClInclude Include="CivHydrCalc.h" />
<ClInclude Include="CivHydrFuncInterface.h" /> <ClInclude Include="CivHydrFuncInter.h" />
<ClInclude Include="CivInp.h" /> <ClInclude Include="CivInp.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<ClCompile Include="CivComponent.cpp"> <ClCompile Include="CivComponent.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivHydrFuncInterface.cpp"> <ClCompile Include="CivHydrFuncInter.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<ClInclude Include="CivComponent.h"> <ClInclude Include="CivComponent.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivHydrFuncInterface.h"> <ClInclude Include="CivHydrFuncInter.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
......
...@@ -47,7 +47,6 @@ std::string CivCommonUtils::UTF8_To_string(const std::string& str) ...@@ -47,7 +47,6 @@ std::string CivCommonUtils::UTF8_To_string(const std::string& str)
return strRet; return strRet;
} }
std::string CivCommonUtils::currentTime() std::string CivCommonUtils::currentTime()
{ {
return std::string(); return std::string();
......
This diff is collapsed.
...@@ -16,6 +16,13 @@ class CivDbConnection; ...@@ -16,6 +16,13 @@ class CivDbConnection;
class DLLEXPORT CivDbConnection class DLLEXPORT CivDbConnection
{ {
public: public:
// 表类型
enum TableType
{
NODE_TABLE, // 计算结果点表
PIPE_TABLE // 计算结果线表
};
CivDbConnection(char* uri); CivDbConnection(char* uri);
~CivDbConnection(); ~CivDbConnection();
...@@ -36,12 +43,16 @@ public: ...@@ -36,12 +43,16 @@ public:
*@tableName: 组件表 *@tableName: 组件表
*/ */
Componets getLikelyPipes(StrQuote tableName); Componets getLikelyPipes(StrQuote tableName);
bool tableExist(StrQuote tableName);
/** /**
*@brief 创建表格 *@brief 创建表格
*@tableName: 表名
*@schema:
*@tableType:表类型,点结果,线结果
*/ */
bool createTable(StrQuote tableName,StrQuote schema); bool createTable(StrQuote tableName,StrQuote schema, TableType tableType);
/** /**
*@brief 更新点表数据 *@brief 更新点表数据
......
#include "CivTableTemp.h"
CivTableTemp::CivTableTemp(std::string tableName)
:mTableName(tableName)
{
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_INT, "int"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_INTEGER,"integer"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_DOUBLE, "double precision"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR, "varchar(20)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_DATETIME, "timestamp"));
}
CivTableTemp::~CivTableTemp()
{
}
void CivTableTemp::addProperty(std::string fileName, FieldType filedType)
{
FieldProperty prop = { fileName ,mFieldTyepMap.find(filedType)->second};
mPropertys.push_back(prop);
}
void CivTableTemp::addPropertys(FiledPropertys props)
{
mPropertys.insert(mPropertys.end(), props.begin(), props.end());
}
std::string CivTableTemp::createSql()
{
if (mPropertys.size() <= 0)
return "";
char sql[512] = "create table ";
strcat_s(sql, mTableName.c_str());
strcat_s(sql, "(id serial primary key");
int total = mPropertys.size();
for (int i = 0; i < total; i++)
{
FieldProperty property = mPropertys[i];
strcat_s(sql, ",");
strcat_s(sql, property.mFiledName.c_str());
strcat_s(sql, " ");
strcat_s(sql, property.mFieldType.c_str());
}
strcat_s(sql, ")");
return sql;
}
\ No newline at end of file
#pragma once
#include<string>
#include<vector>
#include<map>
typedef struct FieldProperty
{
std::string mFiledName; //字段名
std::string mFieldType; // 字段类型
};
#define FiledPropertys std::vector<FieldProperty>
/**
* 数据库表模板
*/
class CivTableTemp
{
public:
// 字段类型
enum FieldType {
FILED_INT,
FILED_INTEGER,
FILED_DOUBLE,
FILED_VARCHAR,
FILED_DATETIME
};
explicit CivTableTemp(std::string tableName);
~CivTableTemp();
/**
*@brief 添加字段属性
*@fileName:字段名
*@filedType:字段类型
*/
void addProperty(std::string fileName, FieldType filedType);
// 添加批量属性字段
void addPropertys(FiledPropertys props);
// 返回创建表的sql语句
std::string createSql();
private:
std::string mTableName; // 表明
FiledPropertys mPropertys; // 字段和字段属性
std::map< FieldType, std::string> mFieldTyepMap;
};
...@@ -158,6 +158,35 @@ struct TanksFields { ...@@ -158,6 +158,35 @@ struct TanksFields {
}; };
/********************************end **************************************************/ /********************************end **************************************************/
struct NodeFieldName
{
Str Number = "本点号";
Str dFlow = "流量";
Str dHead = " 水头";
Str dPressure=" 压力";
Str dElevation=" 标高";
Str dDemand=" 实际需水量";
Str dTankVolume=" 水池容量";
Str dTankMaxVolume=" 水池最大容量";
Str dTankLevel=" 液位高度";
Str lTime = "时间";
};
struct LinkFiledName
{
Str szNo = "编号";
Str dFlow = " 流量";
Str nFlowDirect = "流向";
Str dVelocity="流速";
Str dHeadloss="水头损失";
Str dUnitHeadloss="单位水头损失";
Str dFromNodHeadloss="上点水头";
Str dToNodHeadloss="本点水头";
Str dLocalHeadloss="局部水头损失";
Str dFrictionHeadloss="摩擦水头损失";
Str szStatus="状态";
Str lTime = "时间";
};
// 水力计算管点结果缓存 // 水力计算管点结果缓存
struct NodeResultItem struct NodeResultItem
...@@ -171,6 +200,7 @@ struct NodeResultItem ...@@ -171,6 +200,7 @@ struct NodeResultItem
float dTankVolume; // 水池容量 float dTankVolume; // 水池容量
float dTankMaxVolume; // 水池最大容量 float dTankMaxVolume; // 水池最大容量
float dTankLevel; // 液位高度 float dTankLevel; // 液位高度
long lTime;
}; };
// 水力计算管线结果缓存 // 水力计算管线结果缓存
...@@ -187,6 +217,7 @@ struct LinkResultItem ...@@ -187,6 +217,7 @@ struct LinkResultItem
float dLocalHeadloss; // 局部水头损失 float dLocalHeadloss; // 局部水头损失
float dFrictionHeadloss; // 摩擦水头损失 float dFrictionHeadloss; // 摩擦水头损失
char szStatus[20]; // 状态 char szStatus[20]; // 状态
long lTime;
}; };
#define NodeResultItems std::vector<NodeResultItem> #define NodeResultItems std::vector<NodeResultItem>
......
...@@ -156,11 +156,13 @@ copy CivTypes.h $(OutDir)..\include /y ...@@ -156,11 +156,13 @@ copy CivTypes.h $(OutDir)..\include /y
<ItemGroup> <ItemGroup>
<ClInclude Include="CivCommonUtils.h" /> <ClInclude Include="CivCommonUtils.h" />
<ClInclude Include="CivDbConnection.h" /> <ClInclude Include="CivDbConnection.h" />
<ClInclude Include="CivTableTemp.h" />
<ClInclude Include="CivTypes.h" /> <ClInclude Include="CivTypes.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CivCommonUtils.cpp" /> <ClCompile Include="CivCommonUtils.cpp" />
<ClCompile Include="CivDbConnection.cpp" /> <ClCompile Include="CivDbConnection.cpp" />
<ClCompile Include="CivTableTemp.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
<ClInclude Include="CivCommonUtils.h"> <ClInclude Include="CivCommonUtils.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CivTableTemp.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="CivDbConnection.cpp"> <ClCompile Include="CivDbConnection.cpp">
...@@ -32,5 +35,8 @@ ...@@ -32,5 +35,8 @@
<ClCompile Include="CivCommonUtils.cpp"> <ClCompile Include="CivCommonUtils.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CivTableTemp.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
#include "CivHydrCalcMiddle.h"
namespace CivHydr {
CivHydrCalcMiddle::CivHydrCalcMiddle(String^ uri, String^ netName)
{
char* curi = StringToCharStar(uri);
std::string cNetName = StringToCharStar(netName);
mHydrCalc = new CivHydrCalc(curi, cNetName);
}
CivHydrCalcMiddle::~CivHydrCalcMiddle()
{
delete mHydrCalc;
}
Boolean CivHydrCalcMiddle::simulation(String^ flag)
{
if (flag == "HDY")
return hyDrCompute();
else if (flag == "QUALITY")
return qualityCompute();
return false;
}
Boolean CivHydrCalcMiddle::getInpFile(String^ inpFile)
{
return mHydrCalc->exportInp(StringToCharStar(inpFile));
}
Boolean CivHydrCalcMiddle::hyDrCompute()
{
return mHydrCalc->hydrSimulation(mInpFile, mRptFile, mBinOutFile);
}
Boolean CivHydrCalcMiddle::qualityCompute()
{
return mHydrCalc->qualitySimulation(mInpFile, mRptFile, mBinOutFile);
}
void CivHydrCalcMiddle::setInpFile(String^ inpFileName)
{
mInpFile = StringToCharStar(inpFileName);
}
void CivHydrCalcMiddle::setReportFile(String^ rptFile)
{
mRptFile = StringToCharStar(rptFile);
}
void CivHydrCalcMiddle::setOutBinFile(String^ outBinFile)
{
mBinOutFile = StringToCharStar(outBinFile);
}
String^ CivHydrCalcMiddle::getLastError()
{
return mLastError;
}
}
\ No newline at end of file
#pragma once
#include "CivHydrCalc.h"
using namespace System;
using namespace System::Runtime::InteropServices;
namespace CivHydr {
/**
*@brief c#和c++类型转换函数
*/
static char* StringToCharStar(String^ str)
{
char* ch2 = (char*)(void*)Marshal::StringToHGlobalAnsi(str);
return ch2;
}
public ref class CivHydrCalcMiddle {
public:
/**
*@brief 带参对象构造函数
*@uri: 管网数据库连接地址,格式:"host=192.168.12.7 port=5432 dbname=2222 user=postgres password=admin";
*@netName: 管网名
*/
CivHydrCalcMiddle(String^ uri, String^ netName);
~CivHydrCalcMiddle();
/**
*@brief 水力计算
*@flag: 计算标志, HDY:水力计算 QUALITY:水质计算
*/
Boolean simulation(String^ flag);
Boolean getInpFile(String^ inpFile);
/**
*@brief 设置相关文件名
*/
void setInpFile(String^ inpFileName);
void setReportFile(String^ rptFile);
void setOutBinFile(String^ outBinFile);
private:
/**
*@brief 动态水力计算
*/
Boolean hyDrCompute();
/**
*@brief 水质计算
*/
Boolean qualityCompute();
String^ getLastError();
private:
CivHydrCalc* mHydrCalc;
// 默认值
char* mInpFile = "test.inp"; // inp文件路径
char* mRptFile = "test.rpt"; // 报告文件
char* mBinOutFile = "test.bin";
String^ mLastError;
};
}
<?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>{26fc1dc0-4eee-44da-b409-8f392d37b67e}</ProjectGuid>
<RootNamespace>pandaHydrCalcMiddle</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<TargetFrameworkVersion>
</TargetFrameworkVersion>
</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>
<CLRSupport>true</CLRSupport>
</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>false</ConformanceMode>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OUTDIR)..\lib</AdditionalLibraryDirectories>
<AdditionalDependencies>pandaAnalysis.lib</AdditionalDependencies>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CivHydrCalcMiddle.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivHydrCalcMiddle.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?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>
<ClCompile Include="CivHydrCalcMiddle.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CivHydrCalcMiddle.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
<?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
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CivHydr;
namespace pandaHydrDemo
{
class Program
{
static void Main(string[] args)
{
String uri = "host=192.168.12.7 port=5432 dbname=2222 user=postgres password=admin";
String netName = "进贤水力模型";
CivHydrCalcMiddle calc = new CivHydrCalcMiddle(uri, netName);
calc.setInpFile("test.inp");
calc.setReportFile("test.rpt");
calc.setOutBinFile("test.bin");
String flag = "HDY";
// calc.getInpFile("test.inp");
Boolean sucess = calc.simulation(flag);
Console.WriteLine(sucess);
Console.ReadKey();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("pandaHydrDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("pandaHydrDemo")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("5bdf427e-7acb-4ce9-95b2-ccd9ea5879cd")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5BDF427E-7ACB-4CE9-95B2-CCD9EA5879CD}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>pandaHydrDemo</RootNamespace>
<AssemblyName>pandaHydrDemo</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\hModelProgram\Program\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\pandaHydrCalcMiddle\pandaHydrCalcMiddle.vcxproj">
<Project>{26fc1dc0-4eee-44da-b409-8f392d37b67e}</Project>
<Name>pandaHydrCalcMiddle</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup>
</Project>
\ No newline at end of file
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