Commit 02686d8d authored by 刘乐's avatar 刘乐

first commit

parent 397a563e
#pragma once
#include "CivTypes.h"
#include <vector>
#include <libpq-fe.h>
#define DLLEXPORT __declspec(dllexport)
class CivDbConnection;
/**
数据库连接类,获取数据,写入数据接口
*/
class DLLEXPORT CivDbConnection
{
public:
CivDbConnection(char* uri);
~CivDbConnection();
/**
*@brief 获取管网的所有表
*@netName: 管网名
*/
Tables getTables(StrQuote netName);
/**
*@brief 获取管网组件数据:管线,节点,水源等(必须组件) 水泵,阀门(可选组件)
*@tableName: 组件表
*/
Componets getComponets(StrQuote tableName);
/**
*@brief 创建表格
*/
bool createTable(StrQuote tableName);
bool open();
void close();
bool isValid();
private:
PGconn* mConn;
bool mIsOpen = false;
char* mUri;
};
\ No newline at end of file
#pragma once
#include <string>
#define DBNAME std::string("dbname")
#define HOSTADDR std::string("host")
#define USER std::string("user");
#define PASSWORD std::string("password")
#define PORT std::string("port")
class CivDbSourceUri
{
public:
CivDbSourceUri();
CivDbSourceUri(std::string uri);
std::string uri();
void setDbName(const std::string& dbname);
std::string dbName() const;
void setHostAddr(const std::string hostAddr);
std::string hostAddr() const;
void setPort(const std::string& port);
std::string port() const;
void setUserName(const std::string& user);
std::string userName() const;
void setPassword(const std::string& password);
std::string password() const;
private:
private:
std::string mDbName;
std::string mHostAddr;
std::string mUser;
std::string mPassWord;
std::string mPort;
};
\ No newline at end of file
#pragma once
#include <map>
#include<string>
typedef std::string Str;
typedef const std::string& StrQuote;
#define Tables std::vector<Str>
#define PIPELINE Str("管段")
#define PIPENODE Str("节点")
#define RESIVOIR Str("水源")
#define TANK Str("水池")
#define PUMP Str("水泵")
// 管点
#define Node std::map<Str,Str>
#define Nodes std::vector<Node>
// 管线集合
#define Componet std::map<Str,Str>
#define Componets std::vector<Componet>
// 组件类型
enum SectType {
_TITLE, _JUNCTIONS, _RESERVOIRS, _TANKS, _PIPES, _PUMPS,
_VALVES, _CONTROLS, _RULES, _DEMANDS, _SOURCES, _EMITTERS,
_PATTERNS, _CURVES, _QUALITY, _STATUS, _ROUGHNESS, _ENERGY,
_REACTIONS, _MIXING, _REPORT, _TIMES, _OPTIONS,
_COORDS, _VERTICES, _LABELS, _BACKDROP, _TAGS, _END
};
// 数据库与inp文件所需字段的映射
// REACTIONS
// 定义对应于管网中与化学成分反应的参数。
struct Reactions {
};
// [REPORT]
// 描述模拟生成的输出报表内容。
struct Report {
};
/*
*/
// pump
struct PumpFields {
};
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
struct PipeFields {
Str ID = "编号";
Str Node1 = Str("上点号");
Str Node2 = Str("本点号");
Str Length = Str("管长");
Str Diameter = Str("管径") ; // 管径
Str Roughness = Str("摩阻系数") ; //
Str MinorLoss = Str("局部水头损");
Str Status = Str("状态");
};
// 节点
struct JunctionsFields {
Str ID = "本点号";
Str Elev = "高程";
Str Demand = "需水量";
Str Pattern = "需水量模式";
Str X_Coord = "横坐标";
Str Y_Coord = "纵坐标";
Str InitQual = "初始水质";
} ;
// 水池
//[TANKS] ;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
struct TanksFields {
Str ID = "本点号";
Str Elev = "高程";
Str InitLevel = "初始水位";
Str MinLevel = "最低水位";
Str MaxLevel = "最高水位";
Str Diameter = "直径";
Str MinVol = "容量";
Str VolCurve = "容积取线ID";
Str X_Coord = "横坐标";
Str Y_Coord = "纵坐标";
};
#ifndef _EPANETOUT_H
#define _EPANETOUT_H
/* These are codes used by the DLL functions */
// --- Define the EPANET toolkit constants
/// Node property codes
typedef enum {
EN_ELEVATION = 0, /**< Node Elevation */
EN_BASEDEMAND = 1, /**< Node Base Demand, from last demand category */
EN_PATTERN = 2, /**< Node Demand Pattern */
EN_EMITTER = 3, /**< Node Emitter Coefficient */
EN_INITQUAL = 4, /**< Node initial quality */
EN_SOURCEQUAL = 5, /**< Node source quality */
EN_SOURCEPAT = 6, /**< Node source pattern index */
EN_SOURCETYPE = 7, /**< Node source type */
EN_TANKLEVEL = 8, /**< Tank Level */
EN_DEMAND = 9, /**< Node current simulated demand */
EN_HEAD = 10, /**< Node Head value */
EN_PRESSURE = 11, /**< Node pressure value */
EN_QUALITY = 12, /**< Node quality value */
EN_SOURCEMASS = 13, /**< Node source mass value */
EN_INITVOLUME = 14, /**< Tank or Reservoir initial volume */
EN_MIXMODEL = 15, /**< Tank mixing model */
EN_MIXZONEVOL = 16, /**< Tank mixing zone volume */
EN_TANKDIAM = 17, /**< Tank diameter */
EN_MINVOLUME = 18, /**< Tank minimum volume */
EN_VOLCURVE = 19, /**< Tank volume curve index */
EN_MINLEVEL = 20, /**< Tank minimum level */
EN_MAXLEVEL = 21, /**< Tank maximum level */
EN_MIXFRACTION = 22, /**< Tank mixing fraction */
EN_TANK_KBULK = 23, /**< Tank bulk decay coefficient */
EN_TANKVOLUME = 24, /**< Tank current volume */
EN_MAXVOLUME = 25 /**< Tank maximum volume */
} EN_NodeProperty;
/// Link property codes
typedef enum {
EN_DIAMETER = 0,
EN_LENGTH = 1,
EN_ROUGHNESS = 2,
EN_MINORLOSS = 3,
EN_INITSTATUS = 4,
EN_INITSETTING = 5,
EN_KBULK = 6,
EN_KWALL = 7,
EN_FLOW = 8,
EN_VELOCITY = 9,
EN_HEADLOSS = 10,
EN_STATUS = 11,
EN_SETTING = 12,
EN_ENERGY = 13,
EN_LINKQUAL = 14,
EN_LINKPATTERN = 15
} EN_LinkProperty;
/// Time parameter codes
typedef enum {
EN_DURATION = 0,
EN_HYDSTEP = 1,
EN_QUALSTEP = 2,
EN_PATTERNSTEP = 3,
EN_PATTERNSTART = 4,
EN_REPORTSTEP = 5,
EN_REPORTSTART = 6,
EN_RULESTEP = 7,
EN_STATISTIC = 8,
EN_PERIODS = 9,
EN_STARTTIME = 10,
EN_HTIME = 11,
EN_QTIME = 12,
EN_HALTFLAG = 13,
EN_NEXTEVENT = 14
} EN_TimeProperty;
typedef enum {
EN_ITERATIONS = 0,
EN_RELATIVEERROR = 1
} EN_AnalysisStatistic;
typedef enum {
EN_NODECOUNT = 0, /**< Number of Nodes (Juntions + Tanks + Reservoirs) */
EN_TANKCOUNT = 1, /**< Number of Tanks */
EN_LINKCOUNT = 2, /**< Number of Links (Pipes + Pumps + Valves) */
EN_PATCOUNT = 3, /**< Number of Time Patterns */
EN_CURVECOUNT = 4, /**< Number of Curves */
EN_CONTROLCOUNT = 5 /**< Number of Control Statements */
} EN_CountType;
typedef enum {
EN_JUNCTION = 0,
EN_RESERVOIR = 1,
EN_TANK = 2
} EN_NodeType;
typedef enum {
EN_CVPIPE = 0, /* Link types. */
EN_PIPE = 1, /* See LinkType in TYPES.H */
EN_PUMP = 2,
EN_PRV = 3,
EN_PSV = 4,
EN_PBV = 5,
EN_FCV = 6,
EN_TCV = 7,
EN_GPV = 8
} EN_LinkType;
typedef enum {
EN_NONE = 0, /* Quality analysis types. */
EN_CHEM = 1, /* See QualType in TYPES.H */
EN_AGE = 2,
EN_TRACE = 3
} EN_QualityType;
typedef enum {
EN_CONCEN = 0, /* Source quality types. */
EN_MASS = 1, /* See SourceType in TYPES.H. */
EN_SETPOINT = 2,
EN_FLOWPACED = 3
} EN_SourceType;
typedef enum {
EN_CFS = 0, /* Flow units types. */
EN_GPM = 1, /* See FlowUnitsType */
EN_MGD = 2, /* in TYPES.H. */
EN_IMGD = 3,
EN_AFD = 4,
EN_LPS = 5,
EN_LPM = 6,
EN_MLD = 7,
EN_CMH = 8,
EN_CMD = 9
} EN_FlowUnits;
/// Simulation Option codes
typedef enum {
EN_TRIALS = 0,
EN_ACCURACY = 1,
EN_TOLERANCE = 2,
EN_EMITEXPON = 3,
EN_DEMANDMULT = 4
} EN_Option;
typedef enum {
EN_LOWLEVEL = 0, /* Control types. */
EN_HILEVEL = 1, /* See ControlType */
EN_TIMER = 2, /* in TYPES.H. */
EN_TIMEOFDAY = 3
} EN_ControlType;
typedef enum {
EN_AVERAGE = 1, /* Time statistic types. */
EN_MINIMUM = 2, /* See TstatType in TYPES.H */
EN_MAXIMUM = 3,
EN_RANGE = 4
} EN_StatisticType;
typedef enum {
EN_MIX1 = 0, /* Tank mixing models */
EN_MIX2 = 1,
EN_FIFO = 2,
EN_LIFO = 3
} EN_MixingModel;
typedef enum {
EN_NOSAVE = 0,
EN_SAVE = 1,
EN_INITFLOW = 10,
EN_SAVE_AND_INIT = 11
} EN_SaveOption;
typedef enum {
EN_CONST_HP = 0, /* constant horsepower */
EN_POWER_FUNC = 1, /* power function */
EN_CUSTOM = 2 /* user-defined custom curve */
} EN_CurveType;
#ifdef _EPANETDLL_
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport) _stdcall
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
int API ENepanet(char *, char *, char *, void (*) (char *));
int API ENGetVal(int n, float* fRtn);
int API ENopen(char *, char *, char *);
int API ENsaveinpfile(char *);
int API ENclose(void);
int API ENsolveH(void);
int API ENsaveH(void);
int API ENopenH(void);
int API ENinitH(int);
int API ENrunH(long *);
int API ENnextH(long *);
int API ENcloseH(void);
int API ENsavehydfile(char *);
int API ENusehydfile(char *);
int API ENsolveQ(void);
int API ENopenQ(void);
int API ENinitQ(int);
int API ENrunQ(long *);
int API ENnextQ(long *);
int API ENstepQ(long *);
int API ENcloseQ(void);
int API ENwriteline(char *);
int API ENreport(void);
int API ENresetreport(void);
int API ENsetreport(char *);
int API ENgetcontrol(int, int *, int *, float *,int *, float *);
int API ENgetcount(int, int *);
int API ENgetoption(int, float *);
int API ENgettimeparam(int, long *);
int API ENgetflowunits(int *);
int API ENgetpatternindex(char *, int *);
int API ENgetpatternid(int, char *);
int API ENgetpatternlen(int, int *);
int API ENgetpatternvalue(int, int, float *);
int API ENgetqualtype(int *, int *);
int API ENgeterror(int, char *, int);
int API ENgetnodeindex(char *, int *);
int API ENgetnodeid(int, char *);
int API ENgetnodetype(int, int *);
int API ENgetnodevalue(int, int, float *);
int API ENgetlinkindex(char *, int *);
int API ENgetlinkid(int, char *);
int API ENgetlinktype(int, int *);
int API ENgetlinknodes(int, int *, int *);
int API ENgetlinkvalue(int, int, float *);
/*** Updated 10/25/00 ***/
int API ENgetversion(int *);
int API ENsetcontrol(int, int, int, float, int, float);
int API ENsetnodevalue(int, int, float);
int API ENsetlinkvalue(int, int, float);
int API ENsetpattern(int, float *, int);
int API ENsetpatternvalue(int, int, float);
int API ENsettimeparam(int, long);
int API ENsetoption(int, float);
int API ENsetstatusreport(int);
int API ENsetqualtype(int, char *, char *, char *);
//设置水力指数
void API ENsetHexp(double exp);
//设置管网类型
void API ENsetnettype(short type);
//设置管段的管材与压力状态内存
void API ENsetpipestatekindmem(long* pipesk);
//设置资源中心内存
void API ENsetresourcemem(double* pData);
//获得输入错误文件路径
int API ENgetMyErrFile(char* filePath);
int API ENnetSize(int);
int API ENgetpumpvalue(int, float *);
#if defined(__cplusplus)
}
#endif
#ifndef _EPANETDLL_
#ifdef _DEBUG
#pragma comment(lib, "Epanet2D.lib")
#else
#pragma comment(lib, "Epanet2.lib")
#endif
#endif
#endif
This diff is collapsed.
This diff is collapsed.
/*
* src/include/pg_config_ext.h.win32. This is generated manually, not by
* autoheader, since we want to limit which symbols get defined here.
*/
/* Define to the name of a signed 64-bit integer type. */
#define PG_INT64_TYPE long long int
/*-------------------------------------------------------------------------
*
* postgres_ext.h
*
* This file contains declarations of things that are visible everywhere
* in PostgreSQL *and* are visible to clients of frontend interface libraries.
* For example, the Oid type is part of the API of libpq and other libraries.
*
* Declarations which are specific to a particular interface should
* go in the header file for that interface (such as libpq-fe.h). This
* file is only for fundamental Postgres declarations.
*
* User-written C functions don't count as "external to Postgres."
* Those function much as local modifications to the backend itself, and
* use header files that are otherwise internal to Postgres to interface
* with the backend.
*
* src/include/postgres_ext.h
*
*-------------------------------------------------------------------------
*/
#ifndef POSTGRES_EXT_H
#define POSTGRES_EXT_H
#include "pg_config_ext.h"
/*
* Object ID is a fundamental type in Postgres.
*/
typedef unsigned int Oid;
#ifdef __cplusplus
#define InvalidOid (Oid(0))
#else
#define InvalidOid ((Oid) 0)
#endif
#define OID_MAX UINT_MAX
/* you will need to include <limits.h> to use the above #define */
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
/* the above needs <stdlib.h> */
/* Define a signed 64-bit integer type for use in client API declarations. */
typedef PG_INT64_TYPE pg_int64;
/*
* Identifiers of error message fields. Kept here to keep common
* between frontend and backend, and also to export them to libpq
* applications.
*/
#define PG_DIAG_SEVERITY 'S'
#define PG_DIAG_SEVERITY_NONLOCALIZED 'V'
#define PG_DIAG_SQLSTATE 'C'
#define PG_DIAG_MESSAGE_PRIMARY 'M'
#define PG_DIAG_MESSAGE_DETAIL 'D'
#define PG_DIAG_MESSAGE_HINT 'H'
#define PG_DIAG_STATEMENT_POSITION 'P'
#define PG_DIAG_INTERNAL_POSITION 'p'
#define PG_DIAG_INTERNAL_QUERY 'q'
#define PG_DIAG_CONTEXT 'W'
#define PG_DIAG_SCHEMA_NAME 's'
#define PG_DIAG_TABLE_NAME 't'
#define PG_DIAG_COLUMN_NAME 'c'
#define PG_DIAG_DATATYPE_NAME 'd'
#define PG_DIAG_CONSTRAINT_NAME 'n'
#define PG_DIAG_SOURCE_FILE 'F'
#define PG_DIAG_SOURCE_LINE 'L'
#define PG_DIAG_SOURCE_FUNCTION 'R'
#endif /* POSTGRES_EXT_H */
File added
File added
File added
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