Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F123981975
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 30, 17:02
Size
11 KB
Mime Type
text/x-python
Expires
Fri, Aug 1, 17:02 (2 d)
Engine
blob
Format
Raw Data
Handle
27786271
Attached To
R3852 EMS for Smart-Building
View Options
diff --git a/auxiliary/requests/packages/__init__.pyc b/auxiliary/requests/packages/__init__.pyc
deleted file mode 100644
index b44210b..0000000
Binary files a/auxiliary/requests/packages/__init__.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/chardet/__init__.pyc b/auxiliary/requests/packages/chardet/__init__.pyc
deleted file mode 100644
index 954295d..0000000
Binary files a/auxiliary/requests/packages/chardet/__init__.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/__init__.pyc b/auxiliary/requests/packages/urllib3/__init__.pyc
deleted file mode 100644
index 68d2e22..0000000
Binary files a/auxiliary/requests/packages/urllib3/__init__.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/_collections.pyc b/auxiliary/requests/packages/urllib3/_collections.pyc
deleted file mode 100644
index 6cd9129..0000000
Binary files a/auxiliary/requests/packages/urllib3/_collections.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/connection.pyc b/auxiliary/requests/packages/urllib3/connection.pyc
deleted file mode 100644
index 0261ba7..0000000
Binary files a/auxiliary/requests/packages/urllib3/connection.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/connectionpool.pyc b/auxiliary/requests/packages/urllib3/connectionpool.pyc
deleted file mode 100644
index 6cc2d6d..0000000
Binary files a/auxiliary/requests/packages/urllib3/connectionpool.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/contrib/__init__.pyc b/auxiliary/requests/packages/urllib3/contrib/__init__.pyc
deleted file mode 100644
index 3e2a1e4..0000000
Binary files a/auxiliary/requests/packages/urllib3/contrib/__init__.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/contrib/pyopenssl.pyc b/auxiliary/requests/packages/urllib3/contrib/pyopenssl.pyc
deleted file mode 100644
index 8f659ba..0000000
Binary files a/auxiliary/requests/packages/urllib3/contrib/pyopenssl.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/exceptions.pyc b/auxiliary/requests/packages/urllib3/exceptions.pyc
deleted file mode 100644
index ff7ded5..0000000
Binary files a/auxiliary/requests/packages/urllib3/exceptions.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/fields.pyc b/auxiliary/requests/packages/urllib3/fields.pyc
deleted file mode 100644
index 06f8db6..0000000
Binary files a/auxiliary/requests/packages/urllib3/fields.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/filepost.pyc b/auxiliary/requests/packages/urllib3/filepost.pyc
deleted file mode 100644
index 52a295a..0000000
Binary files a/auxiliary/requests/packages/urllib3/filepost.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/packages/__init__.pyc b/auxiliary/requests/packages/urllib3/packages/__init__.pyc
deleted file mode 100644
index 85b78ba..0000000
Binary files a/auxiliary/requests/packages/urllib3/packages/__init__.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/packages/ordered_dict.pyc b/auxiliary/requests/packages/urllib3/packages/ordered_dict.pyc
deleted file mode 100644
index 6fdce79..0000000
Binary files a/auxiliary/requests/packages/urllib3/packages/ordered_dict.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/packages/six.pyc b/auxiliary/requests/packages/urllib3/packages/six.pyc
deleted file mode 100644
index 5764337..0000000
Binary files a/auxiliary/requests/packages/urllib3/packages/six.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc b/auxiliary/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc
deleted file mode 100644
index e0a83f4..0000000
Binary files a/auxiliary/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/poolmanager.pyc b/auxiliary/requests/packages/urllib3/poolmanager.pyc
deleted file mode 100644
index 57d17d3..0000000
Binary files a/auxiliary/requests/packages/urllib3/poolmanager.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/request.pyc b/auxiliary/requests/packages/urllib3/request.pyc
deleted file mode 100644
index 39dda95..0000000
Binary files a/auxiliary/requests/packages/urllib3/request.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/response.pyc b/auxiliary/requests/packages/urllib3/response.pyc
deleted file mode 100644
index 105ed5e..0000000
Binary files a/auxiliary/requests/packages/urllib3/response.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/__init__.pyc b/auxiliary/requests/packages/urllib3/util/__init__.pyc
deleted file mode 100644
index bab394e..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/__init__.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/connection.pyc b/auxiliary/requests/packages/urllib3/util/connection.pyc
deleted file mode 100644
index 48e831d..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/connection.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/request.pyc b/auxiliary/requests/packages/urllib3/util/request.pyc
deleted file mode 100644
index ae73b59..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/request.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/response.pyc b/auxiliary/requests/packages/urllib3/util/response.pyc
deleted file mode 100644
index ee892a5..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/response.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/retry.pyc b/auxiliary/requests/packages/urllib3/util/retry.pyc
deleted file mode 100644
index c51cc86..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/retry.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/ssl_.pyc b/auxiliary/requests/packages/urllib3/util/ssl_.pyc
deleted file mode 100644
index 68ec450..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/ssl_.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/timeout.pyc b/auxiliary/requests/packages/urllib3/util/timeout.pyc
deleted file mode 100644
index f5c35ad..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/timeout.pyc and /dev/null differ
diff --git a/auxiliary/requests/packages/urllib3/util/url.pyc b/auxiliary/requests/packages/urllib3/util/url.pyc
deleted file mode 100644
index c18da68..0000000
Binary files a/auxiliary/requests/packages/urllib3/util/url.pyc and /dev/null differ
diff --git a/bmsinterface/bms_interf.py b/bmsinterface/bms_interf.py
index a2dd594..a51be49 100644
--- a/bmsinterface/bms_interf.py
+++ b/bmsinterface/bms_interf.py
@@ -1,92 +1,126 @@
from queue import Queue
from threading import Thread
-from conf_ems import *
+from bmsinterface.conf_ems import *
import bmsinterface.auxiliary.websocket as websocket
import bmsinterface.auxiliary.requests.api as requests
import json
class BMSInterface(Thread):
"""
Description and how to use it
"""
def __init__(self, out_q):
"""
Initialize BMSInterface object.
Launch a thread to listen to BMS bubble messages through a websocket
Initialize the dictionary to link sensors and loads
Filter the incoming messages
"""
Thread.__init__(self)
self.sensors_to_loads_list = {}
self.out_stream = out_q
def run(self):
"""
To be executed during thread process
"""
websocket.enableTrace(False) # True if you need debug info
print("Attempt to connect ...")
ws = websocket.create_connection("ws://{0}:{1}/websocket".format(RT_SERVER_IP,RT_SERVER_PORT))
ws.send("Hello World") # not recognized
ws.send("ECHO testing reply") # ECHO + space + command verifies the loop
print("Sent")
print("Received: {0}".format(ws.recv()))
# Register interest to all room (-1) otherwise give room ID list to register to events
regmsg = {"PUB_ID":-1, "MSG_TYPE":"WEB_MSG", "PAYLOAD": {"MSG_CLASS":"REG_PUBLISHER"}}
ws.send(json.dumps(regmsg))
while True:
result = ws.recv()
print("Received: {0}".format(result))
self.decode_bms_msg(result)
def decode_bms_msg(self, in_msg):
"""Interpret the bubble message coming from the BMS and update the appropriate structures"""
if in_msg[0] != '{':
return
json_obj = json.loads(in_msg)
if 'PAYLOAD' in json_obj:
json_payload_obj = json_obj['PAYLOAD']
if 'MSG_CLASS' in json_payload_obj and 'QUANTITY' in json_payload_obj and json_payload_obj['QUANTITY'] == 'P':
print('New value of P: {0} from sensor {1}'.format(json_payload_obj['VALUE'], json_obj['ID']))
self.bubble_messages(json_payload_obj['VALUE'], json_obj['ID'])
def bubble_messages(self, val, sensor_id):
if sensor_id not in self.sensors_to_loads_list:
- self.sensors_to_loads_list[sensor_id] = get_bms_load_id(sensor_id)
+ load_id = get_bms_load_id(sensor_id)
- self.out_stream.put({'load_id': self.sensors_to_loads_list[sensor_id], 'p_val': val})
+ if load_id >= 0:
+ load_info = get_bms_load_info(load_id)
+ if load_info != "":
+ self.out_stream.put({'init_info_load_id': load_id, 'data': load_info})
+ else:
+ return
+ else:
+ return
+
+ self.sensors_to_loads_list[sensor_id] = load_id
+
+ self.out_stream.put({'new_p_val': val, 'load_id': self.sensors_to_loads_list[sensor_id]})
def get_bms_load_id(sensor_id):
"""RestFul request"""
sensor_info = get_bms_info('sensor', sensor_id)
+ print(sensor_info[0])
+
+ if 'fields' not in sensor_info[0]:
+ return -1
+
+ sensor_info = sensor_info[0]['fields']
# Retrieve the load_id from the info
- print(type(sensor_info))
- print(sensor_info)
+
+ print(sensor_info['load'])
if 'load' in sensor_info:
return sensor_info['load']
else:
return -1
+def get_bms_load_info(load_id):
+ """RestFul request"""
+ load_info = get_bms_info('load', load_id)
+ # Retrieve the load_id from the info
+
+ if 'fields' not in load_info[0]:
+ return -1
+
+ load_info = load_info[0]['fields']
+
+ # TO DO: format the message to send up
+ if 'additional_parameters' in load_info:
+ return load_info['additional_parameters'] + '{"test": 4}'
+ else:
+ return ""
+
+
def get_bms_info(resource_type='room', resource_id=1):
"""Returns the info for the given ID according to the docs in openBMS"""
geturl = 'http://{0}:{1}/API/{2}/{3}'.format(OPENBMS_IP, OPENBMS_PORT, resource_type, resource_id)
r = requests.get(geturl)
# always check the return status code!
if r.status_code == 200: # Otherwise it means openBMS doesnt work
request_result = r.json()
return request_result
elif r.status_code == 404 and r.content: # Server replied but not found the midid
print('Failed to find in openBMS the {0}: {1}'.format(resource_type, resource_id))
else:
print('Failed to connect to {0}:{1}, is openBMS running?'.format(OPENBMS_IP,OPENBMS_PORT))
diff --git a/bmsinterface/conf_ems.py b/bmsinterface/conf_ems.py
index 7c9e536..42e2c44 100644
--- a/bmsinterface/conf_ems.py
+++ b/bmsinterface/conf_ems.py
@@ -1,10 +1,10 @@
__author__ = 'Georgios Lilis'
-OPENBMS_IP = '128.178.19.163' #128.178.19.240
+OPENBMS_IP = '128.178.19.240' #128.178.19.240
OPENBMS_PORT = '80'
RT_SERVER_IP = OPENBMS_IP
RT_SERVER_PORT = '8000'
WEBSOCKET_ZMQ_MSG_TYPE = "ZMQ_MSG" #for messages arriving through the zmq loop
WEBSOCKET_WEB_MSG_TYPE = "WEB_MSG" #for messages arriving through the websockets loop
\ No newline at end of file
Event Timeline
Log In to Comment