Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "EVI-EnSitePy"]
path = EVI-EnSitePy
url = https://github.nrel.gov/AVCI/EVI-EnSitePy.git
branch = dev_enlitepy_api_barebone
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ COPY . /opt/reopt
WORKDIR /opt/reopt
RUN ["pip", "install", "-r", "requirements.txt"]

RUN if [ -d "EVI-EnSitePy" ] && [ "$(ls -A EVI-EnSitePy)" ]; then \
cd EVI-EnSitePy && pip install -e .; \
fi

EXPOSE 8000
ENTRYPOINT ["/bin/bash", "-c"]
1 change: 1 addition & 0 deletions EVI-EnSitePy
Submodule EVI-EnSitePy added at 5a582d
1 change: 1 addition & 0 deletions load_builder/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

urlpatterns = [
re_path(r'^load_builder/?$', views.load_builder),
re_path(r'^ensite/?$', views.ensite_view),
]
27 changes: 27 additions & 0 deletions load_builder/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@
from django.http import JsonResponse
from reo.exceptions import UnexpectedError

def get_ensitepy_simulator():
"""
Attempts to import ensitepy and return the SystemSimulator class.
If the package is not available, returns None.
"""
try:
import ensitepy
from ensitepy import SystemSimulator
return SystemSimulator
except ImportError:
print("Cannot import ensitepy or failure to call ensitepy function")
return None


def ensite_view(request):
"""
View to use the ensitepy SystemSimulator if available.
"""
SystemSimulator = get_ensitepy_simulator()
if SystemSimulator is None:
return JsonResponse({"Error": "ensitepy package is not available."}, status=500)

# Use the private package functionality
sim = SystemSimulator(t_start=0 * 3600, dt=30, t_end=2 * 24 * 3600)
# ...existing code...

return JsonResponse({"message": "Ensite view and SystemSimulator function called successfully."})

def check_load_builder_inputs(loads_table):
required_inputs = ["Power (W)", "Quantity", "% Run Time", "Start Mo.", "Stop Mo.", "Start Hr.", "Stop Hr."]
Expand Down