Commit 52f38d22 authored by 刘乐's avatar 刘乐

1, 水力计算结果存储优化

parent 49cdef7f
@echo **************************************************
@echo * *
@echo * System Driver *
@echo * *
@echo **************************************************
@rem 设置工程目录
@set Current_path = %cd%
@Set BtMon_Path = %cd%/Toshiba_System_Driver/BtMon_SystemDriver_0725
@Set RMService_path =
@Set TabSysSvc_path =
@Set tosrfec_path =
@Set TosSysHID_path =
@Set TVALZ_path =
@Set TosQnt_path =
@rem 设置工程目录
@Set VS2019_BuildTool_path = "D:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe"
@echo === Starting to Build System Driver for WinXP Win8 Win10 ===
@echo 1,开始编译 hydraulicModel工程
@%VS2019_BuildTool_path% hydraulicModel.sln /rebuild "release|x64" /out "compile.log"
@pause
\ No newline at end of file
......@@ -129,7 +129,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(OUTDIR)..\include</AdditionalIncludeDirectories>
</ClCompile>
......
......@@ -2,6 +2,11 @@
#include <libpq-fe.h>
#include "CivHydrFuncInter.h"
#include "iostream"
#include "time.h"
#include "string.h"
using namespace std;
int main(int argc, char* argv[])
{
......@@ -18,7 +23,7 @@ int main(int argc, char* argv[])
bool msg = simulation(findUri, net, flag);
std::cout << msg << std::endl;
getchar();
return msg;
return 0;
}
\ No newline at end of file
......@@ -6,6 +6,10 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaDbManager", "pandaDbManager\pandaDbManager.vcxproj", "{2B673FBC-3F91-4952-BDD3-4B802A761162}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaAnalysis", "pandaAnalysis\pandaAnalysis.vcxproj", "{47F29C6C-9170-4188-A7AF-6BBCF38BFF6F}"
ProjectSection(ProjectDependencies) = postProject
{BE73E098-3D8C-4F80-88DD-B36A2BB68B64} = {BE73E098-3D8C-4F80-88DD-B36A2BB68B64}
{2B673FBC-3F91-4952-BDD3-4B802A761162} = {2B673FBC-3F91-4952-BDD3-4B802A761162}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EPNAET2", "EPNAET2\EPNAET2.vcxproj", "{BE73E098-3D8C-4F80-88DD-B36A2BB68B64}"
EndProject
......
......@@ -3,6 +3,7 @@
#include "CivTypes.h"
#include "Epanet2.h"
#include "CivInp.h"
#include <time.h>
#include <iostream>
......@@ -48,6 +49,8 @@ bool CivHydrCalc::hydrSimulation(char* fileName, char* rptFile, char* binOutFile
float dHStep;
ENGetVal(4, &dHStep);
bool isFirst = true;
// 计算
do
{
......@@ -67,7 +70,11 @@ bool CivHydrCalc::hydrSimulation(char* fileName, char* rptFile, char* binOutFile
return false;
}
ENnextH(&tstep);
if (isFirst)
{
mDbConn->deleteByDate(NODERESULTTABLE, "日期", currentDate());
isFirst = false;
}
// 获取当前节点和管段数据
getNodeResult(iTime);
getLinkResult(iTime);
......@@ -446,6 +453,21 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
}
}
std::string CivHydrCalc::currentDate()
{
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%Y-%m-%d", timeinfo);
return s;
}
void CivHydrCalc::getNodeResult(short time)
{
int nNodeCount;
......@@ -473,6 +495,7 @@ void CivHydrCalc::getNodeResult(short time)
ENgetnodevalue(i, EN_MAXVOLUME, &nodeItem.dTankMaxVolume);
// 液位高度
ENgetnodevalue(i, EN_TANKLEVEL, &nodeItem.dTankLevel);
nodeItem.dInterval = time;
nodeItems.push_back(nodeItem);
}
......@@ -488,6 +511,17 @@ void CivHydrCalc::getLinkResult(short time)
for (int i = 1; i <= nLinkCount; i++)
{
LinkResultItem linkItem;
int *typeCode = (int*)malloc(sizeof(int));
ENgetlinktype(i,typeCode );
if (*typeCode != EN_PIPE)
{
free(typeCode);
continue;
}
free(typeCode);
// 编号
ENgetlinkid(i, linkItem.szNo);
// 流量
......@@ -527,6 +561,8 @@ void CivHydrCalc::getLinkResult(short time)
else
strcpy_s(linkItem.szStatus, "开启");
linkItem.dInterval = time;
linkItems.push_back(linkItem);
}
mDbConn->updateLink(linkItems);
......
......@@ -41,7 +41,7 @@ private:
*@inp: inp文件对象
*/
void assemble(const std::string& table, CivInp& inp);
std::string currentDate();
/*
*@brief 获取节点计算结果
*@time: 时间
......
......@@ -49,7 +49,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
......@@ -136,13 +136,13 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)pandaDbManager;$(OUTDIR)..\include</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpq.lib;pandaDbManager.lib;EPNAET2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OUTDIR)..\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
......
#include "CivCommonUtils.h"
#include <Windows.h>
#include <wchar.h>
#include <time.h>
std::string CivCommonUtils::string_To_UTF8(const std::string& str)
{
......@@ -56,5 +58,42 @@ std::string CivCommonUtils::UTF8_To_string(const std::string& str)
std::string CivCommonUtils::currentTime()
{
return std::string();
}
\ No newline at end of file
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", timeinfo);
return s;
}
std::string CivCommonUtils::currentDate()
{
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%Y-%m-%d", timeinfo);
return s;
}
std::string CivCommonUtils::currentHour()
{
time_t rawtime;
struct tm* timeinfo;
char s[100];
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t tick = mktime(timeinfo);
strftime(s, sizeof(s), "%H", timeinfo);
return s;
}
......@@ -4,6 +4,16 @@
// #include<json/reader.h>
// 字符串转编码
#define TransUTFCoding(name) CivCommonUtils::string_To_UTF8(name)
// 当前系统日期
#define CurrentDate CivCommonUtils::currentDate()
// 获取当前系统时间
#define CurrentTime CivCommonUtils::currentTime()
#define CurrentHour CivCommonUtils::currentHour()
class CivCommonUtils
{
......@@ -24,6 +34,13 @@ public:
*/
static std::string currentTime();
/**
*@brief 获取系统当前日期
*/
static std::string currentDate();
static std::string currentHour();
///**
//*@brief 将json字符串解析为
//*/
......
This diff is collapsed.
......@@ -8,6 +8,7 @@
// 字段过滤
#define FiledFilter std::map<Str,std::set<Str>>
class CivDbConnection;
/**
......@@ -59,6 +60,8 @@ public:
*/
bool createTable(StrQuote tableName, StrQuote schema, TableType tableType);
bool deleteByDate(StrQuote table, StrQuote filedName, StrQuote fieldValue);
/**
*@brief 更新点表数据
*@nodeItems:需要更新的值
......
......@@ -12,6 +12,7 @@ CivTableTemp::CivTableTemp(std::string tableName)
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR128, "varchar(20)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_DATETIME, "timestamp"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_JSON, "json"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_DATE, "date"));
}
CivTableTemp::~CivTableTemp()
......
......@@ -28,7 +28,8 @@ public:
FILED_VARCHAR64,
FILED_VARCHAR128,
FILED_DATETIME,
FILED_JSON
FILED_JSON,
FILED_DATE
};
explicit CivTableTemp(std::string tableName);
......
......@@ -206,8 +206,10 @@ struct NodeFieldName
Str dTankVolume=" 水池容量";
Str dTankMaxVolume=" 水池最大容量";
Str dTankLevel=" 液位高度";
Str lTime = "时间";
Str dQuality = "水质";
Str dDate = "日期";
Str dInterval = "时段";
Str dModifyTime = "修改时间";
};
struct LinkFiledName
......@@ -223,8 +225,10 @@ struct LinkFiledName
Str dLocalHeadloss="局部水头损";
Str dFrictionHeadloss="摩擦水头损";
Str szStatus="状态";
Str lTime = "时间";
Str dQuality = "水质";
Str dDate = "日期";
Str dInterval = "时段";
Str dModifyTime = "修改时间";
};
// 水力计算管点结果缓存
......@@ -239,7 +243,8 @@ struct NodeResultItem
float dTankVolume; // 水池容量
float dTankMaxVolume; // 水池最大容量
float dTankLevel; // 液位高度
long lTime;
char dDate[32];// 日期
int dInterval; // 时段
};
// 水力计算管线结果缓存
......@@ -256,7 +261,8 @@ struct LinkResultItem
float dLocalHeadloss; // 局部水头损失
float dFrictionHeadloss; // 摩擦水头损失
char szStatus[20]; // 状态
long lTime;
char dDate[32];// 日期
int dInterval; // 时段
};
#define NodeResultItems std::vector<NodeResultItem>
......
......@@ -49,7 +49,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
......@@ -137,13 +137,13 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WINDOWS</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(OUTDIR)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
<Optimization>MaxSpeed</Optimization>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpq.lib;json_vc71_libmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OUTDIR)..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
......
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