Skip to content

Commit

Permalink
Update bacnet create_ttl.py to work with service architecture [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
EttoreZ committed Nov 5, 2024
1 parent 72420f4 commit cca7aae
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions bacnet/create_ttl.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# -*- coding: utf-8 -*-
"""
Creates ttl file for creation of Brick objects.
Deploy a test case and then use this file to read the available input
and measurement points and create the ttl file accordingly.
To run this script:
1. Build BOPTEST worker docker image
2. Set 'test_case_name' parameter to test case that needs bacnet .ttl
(i.e. bestest_air)
3. Run script
4. ''<test_case_name>.ttl'' file will be generated with inputs and measurement
bacnet points
"""

import requests

# Set url for BOPTEST test case
baseurl = 'http://localhost:5000'
baseurl = 'http://127.0.0.1:80'

# Get the test case name
test_case_name = requests.get('{0}/name'.format(baseurl)).json()['payload']['name']
# Instatiate test case
test_case_name = 'bestest_air'
testid = requests.post("{0}/testcases/{1}/select".format(baseurl, test_case_name)).json()["testid"]

# Write the file prefix
prefix = '@prefix bldg: <urn:example#> .\n\
Expand All @@ -31,10 +38,13 @@
f.write(prefix)

# Get all the points and their metadata from BOPTEST test case
measurement_points = requests.get('{0}/measurements'.format(baseurl)).json()['payload']
input_points = requests.get('{0}/inputs'.format(baseurl)).json()['payload']
measurement_points = requests.get('{0}/measurements/{1}'.format(baseurl,testid)).json()['payload']
input_points = requests.get('{0}/inputs/{1}'.format(baseurl,testid)).json()['payload']
points = measurement_points | input_points

# Stop test case
requests.put('{0}/stop/{1}'.format(baseurl, testid))

# Write the bacnet objects for each point in the file
with open(test_case_name+'.ttl', 'a') as f:
obj_id = 1
Expand Down

0 comments on commit cca7aae

Please sign in to comment.