Commit 47d69698 authored by 刘乐's avatar 刘乐

1, 模型修正

parent bebd398c
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
const char* uri = "host=192.168.12.7 port=5432 dbname=liulele 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 net[128]; char net[128];
......
...@@ -91,8 +91,9 @@ bool CivHydrCalc::exportInp(char* fileName) ...@@ -91,8 +91,9 @@ bool CivHydrCalc::exportInp(char* fileName)
if (!mDbConn->open()) if (!mDbConn->open())
return false; return false;
bool patren = mDbConn->createTable(PATTERNTABLE, "public", CivDbConnection::PATTERN_TABLE); bool pattern = mDbConn->createTable(PATTERNTABLE, "public", CivDbConnection::PATTERN_TABLE);
bool curve = mDbConn->createTable(CURVETABLE, "public", CivDbConnection::CURVE_TABLE); bool cii = mDbConn->createTable(OPTIONTTABLE, "public", CivDbConnection::PARAMETER_TABLE);
// 获取表格 // 获取表格
Tables tables = mDbConn->getTables(mNetname); Tables tables = mDbConn->getTables(mNetname);
...@@ -111,14 +112,7 @@ bool CivHydrCalc::exportInp(char* fileName) ...@@ -111,14 +112,7 @@ bool CivHydrCalc::exportInp(char* fileName)
} }
assemble(PIPELINE, civInp); assemble(PIPELINE, civInp);
// 设置模式
Componets patterns = mDbConn->getComponets(PATTERNTABLE);
size_t patternSize = patterns.size();
for (int i = 0; i < patternSize; i++)
{
}
// 设置曲线 // 设置曲线
Componets curves = mDbConn->getComponets(CURVETABLE); Componets curves = mDbConn->getComponets(CURVETABLE);
...@@ -245,9 +239,38 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp) ...@@ -245,9 +239,38 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
nodeCoordItem.push_back(y_coord); nodeCoordItem.push_back(y_coord);
nodeCoordItems.push_back(nodeCoordItem); nodeCoordItems.push_back(nodeCoordItem);
if (pattern == "")
continue;
// 蓄水模式
PatternFields fileds;
char where[128] = " where ";
strcat_s(where, fileds.NetName.c_str());
strcat_s(where, "=");
strcat_s(where, mNetname.c_str());
strcat_s(where, " and ");
strcat_s(where, fileds.Name.c_str());
strcat_s(where, "= ");
strcat_s(where, pattern.c_str());
Componets patterns = mDbConn->getComponetsByWhere(PATTERNTABLE, where);
size_t patternSize = patterns.size();
for (int i = 0; i < patternSize; i++)
{
Componet pattern = patterns[i];
Str paternName = pattern.find(fileds.Name)->second;
Str paternValue = pattern.find(fileds.Value)->second;
CivItem item;
item.push_back(paternName);
item.push_back(paternValue);
patternItems.push_back(item);
}
} }
inp.writeComponet(jounItems,_JUNCTIONS); inp.writeComponet(jounItems,_JUNCTIONS);
inp.writeComponet(nodeCoordItems, _COORDS); inp.writeComponet(nodeCoordItems, _COORDS);
inp.writeComponet(patternItems, _PATTERNS);
} }
else if (RESIVOIR == table) // 水源 else if (RESIVOIR == table) // 水源
{ {
...@@ -421,7 +444,6 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp) ...@@ -421,7 +444,6 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
} }
inp.writeComponet(vavleItems, _VALVES); inp.writeComponet(vavleItems, _VALVES);
} }
} }
void CivHydrCalc::getNodeResult(short time) void CivHydrCalc::getNodeResult(short time)
......
...@@ -624,7 +624,7 @@ bool CivDbConnection::createTable(StrQuote tableName, StrQuote schema,TableType ...@@ -624,7 +624,7 @@ bool CivDbConnection::createTable(StrQuote tableName, StrQuote schema,TableType
{ {
PatternFields fileds; PatternFields fileds;
tableTemp.addProperty(fileds.Name, CivTableTemp::FILED_VARCHAR); tableTemp.addProperty(fileds.Name, CivTableTemp::FILED_VARCHAR);
tableTemp.addProperty(fileds.Value, CivTableTemp::FILED_JSON); tableTemp.addProperty(fileds.Value, CivTableTemp::FILED_VARCHAR64);
tableTemp.addProperty(fileds.NetName, CivTableTemp::FILED_VARCHAR); tableTemp.addProperty(fileds.NetName, CivTableTemp::FILED_VARCHAR);
} }
break; break;
...@@ -637,6 +637,15 @@ bool CivDbConnection::createTable(StrQuote tableName, StrQuote schema,TableType ...@@ -637,6 +637,15 @@ bool CivDbConnection::createTable(StrQuote tableName, StrQuote schema,TableType
tableTemp.addProperty(fileds.YCoord, CivTableTemp::FILED_DOUBLE); tableTemp.addProperty(fileds.YCoord, CivTableTemp::FILED_DOUBLE);
} }
break; break;
case PARAMETER_TABLE:
{
ParameterFileds fileds;
tableTemp.addProperty(fileds.name, CivTableTemp::FILED_VARCHAR);
tableTemp.addProperty(fileds.val, CivTableTemp::FILED_VARCHAR);
tableTemp.addProperty(fileds.type, CivTableTemp::FILED_VARCHAR);
tableTemp.addProperty(fileds.netName, CivTableTemp::FILED_VARCHAR64);
}
break;
default: default:
break; break;
} }
......
...@@ -22,7 +22,8 @@ public: ...@@ -22,7 +22,8 @@ public:
NODE_TABLE, // 计算结果点表 NODE_TABLE, // 计算结果点表
PIPE_TABLE, // 计算结果线表 PIPE_TABLE, // 计算结果线表
PATTERN_TABLE, // 模式表 PATTERN_TABLE, // 模式表
CURVE_TABLE CURVE_TABLE,
PARAMETER_TABLE // 参数表
}; };
CivDbConnection(char* uri); CivDbConnection(char* uri);
......
...@@ -8,6 +8,8 @@ CivTableTemp::CivTableTemp(std::string tableName) ...@@ -8,6 +8,8 @@ CivTableTemp::CivTableTemp(std::string tableName)
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_INTEGER,"integer")); 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_DOUBLE, "double precision"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR, "varchar(20)")); mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR, "varchar(20)"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_VARCHAR64, "varchar(64)"));
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_DATETIME, "timestamp"));
mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_JSON, "json")); mFieldTyepMap.insert(std::pair<FieldType, std::string>(CivTableTemp::FILED_JSON, "json"));
} }
......
...@@ -25,6 +25,8 @@ public: ...@@ -25,6 +25,8 @@ public:
FILED_INTEGER, FILED_INTEGER,
FILED_DOUBLE, FILED_DOUBLE,
FILED_VARCHAR, FILED_VARCHAR,
FILED_VARCHAR64,
FILED_VARCHAR128,
FILED_DATETIME, FILED_DATETIME,
FILED_JSON FILED_JSON
}; };
......
...@@ -14,6 +14,7 @@ typedef const std::string& StrQuote; ...@@ -14,6 +14,7 @@ typedef const std::string& StrQuote;
#define PUMP Str("水泵") #define PUMP Str("水泵")
#define PATTERNTABLE Str("__pattern__") #define PATTERNTABLE Str("__pattern__")
#define CURVETABLE Str("__curve__") #define CURVETABLE Str("__curve__")
#define OPTIONTTABLE Str("__parameter__")
#define PRV_TYPE Str("稳压阀") #define PRV_TYPE Str("稳压阀")
#define PSV_TYPE Str("减压阀") #define PSV_TYPE Str("减压阀")
...@@ -63,7 +64,7 @@ enum PumpParameter ...@@ -63,7 +64,7 @@ enum PumpParameter
// REACTIONS // REACTIONS
// 定义对应于管网中与化学成分反应的参数。 // 定义对应于管网中与化学成分反应的参数。
struct Reactions { struct Reactions {
Str name;
}; };
// [REPORT] // [REPORT]
...@@ -159,6 +160,22 @@ struct CurvesFields { ...@@ -159,6 +160,22 @@ struct CurvesFields {
Str Type = "类型"; Str Type = "类型";
}; };
// 参数选项表
struct ParameterFileds {
Str name = "参数名";
Str val = "参数值";
Str type = "参数类型";/*
[REACTIONS]
[SOURCES]
[MIXING]
[OPTIONS]
[TIMES]
[REPORT]
*/
Str netName = "管网名";
};
// 水池 // 水池
//[TANKS] ;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve //[TANKS] ;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
struct TanksFields { struct TanksFields {
......
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