SenHuang19 / BuildingControlTest

"A Docker setup for building control testing"
3 stars 1 forks source link

eplus shutting itself down #5

Open ajaugust opened 2 years ago

ajaugust commented 2 years ago

Here is the docker-compose file:

version: '3.1'

services:
  eplus1:
    build: './eplus'
    working_dir: /home/developer/fmu
    command: python web.py config jmodelica1
    ports:
      - "127.0.0.1:5501:5500"
  jmodelica1:
    build: '.'
    working_dir: /home/developer
    command: python web.py config
    ports:
      - "127.0.0.1:5001:5000

Commands to launch emulator:

docker-compose -p instance1 build
docker-compose -p instance1 up --detach

Python code to run simulation:

import requests
import json

start_day = 33
run_period = 86400

url_eplus    = f'http://127.0.0.1:5501'
url_modelica = f'http://127.0.0.1:5001'

# Set the step
requests.put(f'{url_eplus}/step', data={'step': 60})

# Set the simulation start and end times in units of seconds
start_sec = start_day*86400
end_sec_run = start_sec + run_period  # end time of the run
end_day = (end_sec_run // 86400) + 1  # need the end time to be an integer day for eplus to be happy
end_sec = end_day*86400
requests.put(f'{url_eplus}/reset', data={'start_time':start_sec, 'end_time':end_sec})

After calling reset the eplus container shuts itself down despite returning a 200 response.

SenHuang19 commented 2 years ago

You need to call advance at least once before calling reset. so the code should be

import requests
import json

start_day = 33
run_period = 86400

url_eplus    = f'http://127.0.0.1:5501'
url_modelica = f'http://127.0.0.1:5001'

# Set the step
requests.put(f'{url_eplus}/step', data={'step': 60})

# Set the simulation start and end times in units of seconds
start_sec = start_day*86400
end_sec_run = start_sec + run_period  # end time of the run
end_day = (end_sec_run // 86400) + 1  # need the end time to be an integer day for eplus to be happy
end_sec = end_day*86400
y = requests.post('{0}/advance'.format(url_eplus), data=json.dumps({})).json()
requests.put(f'{url_eplus}/reset', data={'start_time':start_sec, 'end_time':end_sec})