Commit 7807280c authored by 刘乐's avatar 刘乐

1, 增加水质模拟

parent 7a2c9a7e
......@@ -2892,18 +2892,18 @@ char* getTmpName(char* fname)
// --- if user supplied the name of a temporary directory,
// then make it be the prefix of the full file name
n = (int)strlen(TmpDir);
if ( n > 0 )
{
strcpy(fname, TmpDir);
if ( fname[n-1] != '\\' ) strcat(fname, "\\");
}
// --- otherwise, use the relative path notation as the file name
// prefix so that the file will be placed in the current directory
else
{
strcpy(fname, ".\\");
}
//if ( n > 0 )
//{
// strcpy(fname, TmpDir);
// if ( fname[n-1] != '\\' ) strcat(fname, "\\");
//}
//// --- otherwise, use the relative path notation as the file name
//// prefix so that the file will be placed in the current directory
//else
//{
// strcpy(fname, ".\\");
//}
// --- now add the prefix to the file name
strcat(fname, name);
......
......@@ -120,7 +120,6 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
ENclose();
return false;
}
// 根据类型 更改值
errcode = ENinitH(EN_SAVE);
......@@ -192,7 +191,7 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
ENclose();
// 更新数据
if (mResultCache.updateToDb(mDbConn))
if (!mResultCache.updateToDb(mDbConn))
return false;
......@@ -214,6 +213,9 @@ bool CivHydrCalc::exportInp(char* fileName)
bool pattern = mDbConn->createTable(PATTERNTABLE, "public", CivTableTemp::PATTERN_TABLE);
bool cii = mDbConn->createTable(OPTIONTTABLE, "public", CivTableTemp::PARAMETER_TABLE);
bool curve = mDbConn->createTable(CURVETABLE, "public", CivTableTemp::CURVE_TABLE);
bool node = mDbConn->createTable(NODERESULTTABLE, "public", CivTableTemp::NODE_TABLE);
bool link = mDbConn->createTable(PIPERESULTTABLE, "public", CivTableTemp::PIPE_TABLE);
// 获取表格
Tables tables = mDbConn->getTables(mNetname);
......
......@@ -8,9 +8,9 @@ bool DLLEXPORT simulation(char* uri, char* netName, char* flag)
char rptR[256];
char outBinFile[256];
strcpy_s(fileName, "E:\\work\\workspace\\hydraulicModelCode\\hydraulicModel\\funcDemo\\test.inp");
strcpy_s(rptR, "E:\\work\\workspace\\hydraulicModelCode\\hydraulicModel\\funcDemo\\test.rpt");
strcpy_s(outBinFile, "E:\\work\\workspace\\hydraulicModelCode\\hydraulicModel\\funcDemo\\test.bin");
strcpy_s(fileName, "test.inp");
strcpy_s(rptR, "test.rpt");
strcpy_s(outBinFile, "test.bin");
CivHydrCalc* calc = new CivHydrCalc(uri, netName);
......
......@@ -10,4 +10,19 @@ void CivInpDirector::create(CivBuilder* builder)
builder->buildPump();
builder->buildVavle();
builder->buildEmitter();
builder->buildPatterns();
builder->buildParamter();
builder->buildCoordnates();
builder->buildVertices();
builder->buildLabels();
builder->buildTags();
builder->buildBackDrop();
builder->buildQuality();
builder->buildSources();
builder->buildMixing();
builder->buildCurves();
builder->buildStatus();
builder->buildControls();
builder->buildRules();
builder->buildDemands();
}
\ No newline at end of file
......@@ -109,62 +109,61 @@ bool CivDbConnection::updateNode(const NodeResultItems& nodeItems)
std::stringstream os;
NodeFieldName filedNames;
if (createTable(NODERESULTTABLE, "public", CivTableTemp::NODE_TABLE))
{
os << "INSERT INTO public."<< NODERESULTTABLE<<" ( ";
os << filedNames.Number<<",";
os<< filedNames.dDemand << ",";
os<< filedNames.dHead<<",";
os<< filedNames.dElevation<< ",";
os<< filedNames.dPressure<< ",";
os<< filedNames.dTankLevel<< ",";
os<< filedNames.dTankMaxVolume<< ",";
os<< filedNames.dTankVolume<<",";
os << filedNames.dDate << ",";
os << filedNames.dInterval<<",";
os << filedNames.dQuality<< ",";
os << filedNames.dModifyTime;
os<< ") VALUES";
std::string preSql = os.str();
os.flush();
os.clear();
os.str("");
// 2, 参数值
for(auto iter= nodeItems.begin();iter!=nodeItems.end();iter++)
{
NodeResultItem item = iter->second;
os << "('" << item.szNo << "',";
os << item.dDemand << ",";
os << item.dHead << ",";
os << item.dElevation << ",";
os << item.dPressure << ",";
os << item.dTankLevel << ",";
os << item.dTankMaxVolume << ",";
os << item.dTankVolume << ",";
os <<"'"<< CurrentDate <<"',";
os << item.dInterval<<",";
os << item.dQuality<< ",";
os << "'"<< CurrentTime <<"'";
auto subiter = iter;
++subiter;
if (subiter == nodeItems.end())
{
os << ")";
}
else
{
os << "),";
}
os << "INSERT INTO public."<< NODERESULTTABLE<<" ( ";
os << filedNames.Number<<",";
os<< filedNames.dDemand << ",";
os<< filedNames.dHead<<",";
os<< filedNames.dElevation<< ",";
os<< filedNames.dPressure<< ",";
os<< filedNames.dTankLevel<< ",";
os<< filedNames.dTankMaxVolume<< ",";
os<< filedNames.dTankVolume<<",";
os << filedNames.dDate << ",";
os << filedNames.dInterval<<",";
os << filedNames.dQuality<< ",";
os << filedNames.dModifyTime;
os<< ") VALUES";
std::string preSql = os.str();
os.flush();
os.clear();
os.str("");
// 2, 参数值
for(auto iter= nodeItems.begin();iter!=nodeItems.end();iter++)
{
NodeResultItem item = iter->second;
os << "('" << item.szNo << "',";
os << item.dDemand << ",";
os << item.dHead << ",";
os << item.dElevation << ",";
os << item.dPressure << ",";
os << item.dTankLevel << ",";
os << item.dTankMaxVolume << ",";
os << item.dTankVolume << ",";
os <<"'"<< CurrentDate <<"',";
os << item.dInterval<<",";
os << item.dQuality<< ",";
os << "'"<< CurrentTime <<"'";
auto subiter = iter;
++subiter;
if (subiter == nodeItems.end())
{
os << ")";
}
else
{
os << "),";
}
std::string sql = TransUTFCoding(preSql) + os.str();
os.clear();
os.str("");
if (!execSql(sql))
return false;
}
}
std::string sql = TransUTFCoding(preSql) + os.str();
os.clear();
os.str("");
if (!execSql(sql))
return false;
return true;
}
......@@ -177,69 +176,65 @@ bool CivDbConnection::updateLink(const LinkResultItems& lineItems)
std::stringstream os;
LinkFiledName filedNames;
std::string currData = CurrentDate;
if (createTable(PIPERESULTTABLE, "public", CivTableTemp::PIPE_TABLE))
os<< "INSERT INTO public."<< PIPERESULTTABLE <<"( ";
os<< filedNames.szNo<< ",";
os<< filedNames.dFlow<< ",";
os<< filedNames.nFlowDirect<< ",";
os<< filedNames.dVelocity<< ",";
os<< filedNames.dHeadloss<< ",";
os<< filedNames.dUnitHeadloss<< ",";
os<< filedNames.dFromNodHeadloss<< ",";
os<< filedNames.dToNodHeadloss<< ",";
os<< filedNames.dLocalHeadloss<< ",";
os<< filedNames.dFrictionHeadloss<<",";
os << filedNames.szStatus << ",";
os << filedNames.dDate << ",";
os << filedNames.dInterval<<",";
os << filedNames.dQuality << ",";
os << filedNames.dModifyTime;
os<< ") VALUES";
std::string preSql = os.str();
os.clear();
os.str("");
// 2, 参数值
for(auto iter = lineItems.begin();iter!=lineItems.end();iter++)
{
os<< "INSERT INTO public."<< PIPERESULTTABLE <<"( ";
os<< filedNames.szNo<< ",";
os<< filedNames.dFlow<< ",";
os<< filedNames.nFlowDirect<< ",";
os<< filedNames.dVelocity<< ",";
os<< filedNames.dHeadloss<< ",";
os<< filedNames.dUnitHeadloss<< ",";
os<< filedNames.dFromNodHeadloss<< ",";
os<< filedNames.dToNodHeadloss<< ",";
os<< filedNames.dLocalHeadloss<< ",";
os<< filedNames.dFrictionHeadloss<<",";
os << filedNames.szStatus << ",";
os << filedNames.dDate << ",";
os << filedNames.dInterval<<",";
os << filedNames.dQuality << ",";
os << filedNames.dModifyTime;
os<< ") VALUES";
std::string preSql = os.str();
os.clear();
os.str("");
// 2, 参数值
for(auto iter = lineItems.begin();iter!=lineItems.end();iter++)
{
LinkResultItem item =iter->second;
os<<"('" <<item.szNo<<"'"<< ",";
os<< item.dFlow<< ",";
os<< item.nFlowDirect<<",";
os<< item.dVelocity<< ",";
os<< item.dHeadloss<< ",";
os<< item.dUnitHeadloss<< ",";
os<< item.dFromNodHeadloss<< ",";
os<< item.dToNodHeadloss<< ",";
os<< item.dLocalHeadloss<< ",";
os<< item.dFrictionHeadloss<< ",";
os<< "'"<<TransUTFCoding(item.szStatus)<<"'"<<",";
os <<"'"<< CurrentDate << "',";
os<< item.dInterval<<",";
os << item.dQuality << ",";
os <<"'" << CurrentTime <<"'";
auto subIte = iter;
++subIte;
if (subIte == lineItems.end())
os << ")";
else
os << "),";
}
std::string utf8Sql = TransUTFCoding(preSql);
std::string sql = utf8Sql + os.str();
LinkResultItem item =iter->second;
os<<"('" <<item.szNo<<"'"<< ",";
os<< item.dFlow<< ",";
os<< item.nFlowDirect<<",";
os<< item.dVelocity<< ",";
os<< item.dHeadloss<< ",";
os<< item.dUnitHeadloss<< ",";
os<< item.dFromNodHeadloss<< ",";
os<< item.dToNodHeadloss<< ",";
os<< item.dLocalHeadloss<< ",";
os<< item.dFrictionHeadloss<< ",";
os<< "'"<<TransUTFCoding(item.szStatus)<<"'"<<",";
os <<"'"<< CurrentDate << "',";
os<< item.dInterval<<",";
os << item.dQuality << ",";
os <<"'" << CurrentTime <<"'";
auto subIte = iter;
++subIte;
if (subIte == lineItems.end())
os << ")";
else
os << "),";
}
std::string utf8Sql = TransUTFCoding(preSql);
std::string sql = utf8Sql + os.str();
os.clear();
os.str("");
os.clear();
os.str("");
if (!execSql(sql))
return false;
if (!execSql(sql))
return false;
}
return true;
}
......
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