From c12f901454cb72de0ade48d6db603f0acb07ea26 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Sun, 13 Sep 2015 09:53:21 +0300 Subject: [PATCH] added ENsetcoord function also minor fix to include files --- build/WinSDK/epanet2.def | 1 + include/epanet2.bas | 3 ++- include/epanet2.h | 1 + include/epanet2.vb | 4 +++- src/epanet.c | 24 +++++++++++++++++++++++- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/build/WinSDK/epanet2.def b/build/WinSDK/epanet2.def index fc84da2..ec3bee9 100644 --- a/build/WinSDK/epanet2.def +++ b/build/WinSDK/epanet2.def @@ -62,6 +62,7 @@ EXPORTS ENgetcurve = _ENgetcurve@20 ENgetstatistic = _ENgetstatistic@8 ENgetcoord = _ENgetcoord@12 + ENsetcoord = _ENsetcoord@12 ENgetqualinfo = _ENgetqualinfo@16 ENsetbasedemand = _ENsetbasedemand@12 ENgetaveragepatternvalue = _ENgetaveragepatternvalue@8 diff --git a/include/epanet2.bas b/include/epanet2.bas index 2c3295c..4260cfb 100644 --- a/include/epanet2.bas +++ b/include/epanet2.bas @@ -51,7 +51,7 @@ Global Const EN_STATUS = 11 Global Const EN_SETTING = 12 Global Const EN_ENERGY = 13 Global Const EN_LINKQUAL = 14 'ES -Global Const EN_LINKPATTERN 15 +Global Const EN_LINKPATTERN = 15 Global Const EN_DURATION = 0 ' Time parameters Global Const EN_HYDSTEP = 1 @@ -189,6 +189,7 @@ Global Const EN_INITFLOW = 10 ' Re-initialize flow flag Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal Index As Long, Code As Long) As Long Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Code As Long, Value As Single) As Long Declare Function ENgetcoord Lib "epanet2.dll" (ByVal Index As Long, X As Single, Y As Single) As Long + Declare Function ENsetcoord Lib "epanet2.dll" (ByVal Index As Long, ByVal X As Single, ByVal Y As Single) As Long Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal Index As Long, numDemands As Long) As Long Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal Index As Long, ByVal DemandIndex As Long, Value As Single) As Long diff --git a/include/epanet2.h b/include/epanet2.h index 153fef4..b2d730c 100755 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -239,6 +239,7 @@ extern "C" { int DLLEXPORT ENgetnodetype(int index, int *code); int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value); int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y); + int DLLEXPORT ENsetcoord(int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y); int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands); int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx, EN_API_FLOAT_TYPE *baseDemand); diff --git a/include/epanet2.vb b/include/epanet2.vb index e74e1a5..62da5fc 100644 --- a/include/epanet2.vb +++ b/include/epanet2.vb @@ -186,7 +186,9 @@ Public Const EN_CUSTOM = 2 ' user-defined custom curve Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal Index As Int32, ByVal ID As StringBuilder) As Int32 Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal Index As Int32, ByRef Code As Int32) As Int32 Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32 - + Declare Function ENgetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByRef X As Single, ByRef Y As Single) As Int32 + Declare Function ENsetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByVal X As Single, ByVal Y As Single) As Int32 + Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal Index As Int32, ByRef numDemands As Int32) As Int32 'ES Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByRef Value As Single) As Int32 'ES Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal Index As Int32, ByVal DemandIndex As Int32, ByRef PatIndex As Int32) As Int32 'ES diff --git a/src/epanet.c b/src/epanet.c index 76b9070..dbd9aca 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -1283,7 +1283,7 @@ int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y) /*---------------------------------------------------------------- ** Input: index = node index ** Output: *x = value of node's coordinate - ** *x = value of node's coordinate + ** *y = value of node's coordinate ** Returns: error code ** Purpose: retrieves coordinate x, y for a node **---------------------------------------------------------------- @@ -1299,6 +1299,28 @@ int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y) return 0; } + +int DLLEXPORT ENsetcoord(int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y) +/*---------------------------------------------------------------- + ** Input: index = node index + ** *x = value of node's coordinate + ** *y = value of node's coordinate + ** Output: None + ** Returns: error code + ** Purpose: sets coordinate x, y for a node + **---------------------------------------------------------------- + */ +{ + if (!Openflag) return(102); + if (index < 1 || index > Nnodes) return(203); + + Coord[index].X = x; + Coord[index].Y = y; + Coord[index].HaveCoords = 1; + return 0; +} + + int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value) /*---------------------------------------------------------------- ** Input: index = node index