Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions epanet-module/epamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

added function ENsimtime"""


import sys
import os
import ctypes
import platform
import datetime

this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(this_dir)

_plat= platform.system()
if _plat=='Linux':
_lib = ctypes.CDLL("libepanet2.so.2")
elif _plat=='Windows':
try:
# if epanet2.dll compiled with __cdecl (as in OpenWaterAnalytics)
_lib = ctypes.CDLL("epamodule\epanet2.dll")
_lib = ctypes.CDLL(os.path.join(this_dir, "epamodule", "epanet2.dll"))
_lib.ENgetversion(ctypes.byref(ctypes.c_int()))
except ValueError:
# if epanet2.dll compiled with __stdcall (as in EPA original DLL)
Expand All @@ -22,7 +26,8 @@
_lib.ENgetversion(ctypes.byref(ctypes.c_int()))
except ValueError:
raise Exception("epanet2.dll not suitable")

elif _plat=='Darwin':
_lib = ctypes.CDLL(os.path.join(this_dir, "epamodule", "libepanet2.dylib"))
else:
Exception('Platform '+ _plat +' unsupported (not yet)')

Expand Down