Merge branch 'main' of gitlab.fdmci.hva.nl:propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/qaajeeqiinii59
This commit is contained in:
@@ -1,25 +1,12 @@
|
||||
# Talk with building management
|
||||
|
||||
## Questions for BM
|
||||
## Questions for building management
|
||||
|
||||
1. Design of page? (current page, new design or own idea)
|
||||
2. What do they expect of a page made for BM?
|
||||
2. What do they expect of a page made for building management?
|
||||
3. Do they think they can work with the incomming feedback from the enquete?
|
||||
4. Design of the node? (plastic or wood)
|
||||
|
||||
## Feedback:
|
||||
|
||||
BM had some good feedback points about the page it self, about the idea and some good pointers for the execution. They would also look into making the data they are already messuring acceseble for us. The things they had to say about the website is: they found the first design a bit unorgenised and said that they had
|
||||
Sietse design
|
||||
te klein scherm eigenlijk (1)
|
||||
naamgeving
|
||||
zoekfunctie?
|
||||
opvragen en filteren (idiot proof)
|
||||
wit zodat niet opvallen
|
||||
opschreiven wat het doet
|
||||
hoogtes?
|
||||
|
||||
|
||||
|
||||
|
||||
2x in database
|
||||
building management had some good feedback points about the page itself, about the idea, and some good pointers for the execution. They would also look into making the data they are already measuring accessible for us. The things they had to say about the website are: they found the first design a bit unorganized and said that they would rather see the second design where you can select the node you want to see, maybe also a search function to specify the node that is displayed. What also was said was to try to make it idiot-proof because not all of the building management people are technically active, to put it that way. They had some things to say about the node design, like maybe make the color white to make it better with blending into the white walls of the total area. They also asked the question of does it matter at what height the node is placed. One other thing they said was to write something onto the node to make it clear to the people in the area what it was doing, something like ReaderNode™. And the last thing they said was if we thought about how to make it vandalizing students proof.
|
31
server/bullshitSenderENQUETE.py
Normal file
31
server/bullshitSenderENQUETE.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import asyncio
|
||||
import websockets
|
||||
import json
|
||||
import random
|
||||
import time
|
||||
|
||||
async def send_data(uri):
|
||||
async with websockets.connect(uri) as websocket:
|
||||
print("Connected to WebSocket server")
|
||||
|
||||
while True:
|
||||
data = {
|
||||
"node": "69:42:08:F5:00:00",
|
||||
"Response": str(round(random.uniform(0, 2))),
|
||||
"QuestionID": str(round(random.uniform(0, 90))),
|
||||
}
|
||||
await websocket.send(json.dumps(data))
|
||||
print("Data sent")
|
||||
|
||||
response = await websocket.recv()
|
||||
print("Received message:", response)
|
||||
|
||||
await asyncio.sleep(2) # Wait a bit before sending the next message
|
||||
|
||||
# Start the WebSocket connection
|
||||
while True:
|
||||
try:
|
||||
asyncio.get_event_loop().run_until_complete(send_data("ws://145.92.8.114/ws"))
|
||||
except Exception as e:
|
||||
print("Exception:", e)
|
||||
time.sleep(1) # Wait a bit before trying to reconnect
|
@@ -6,15 +6,11 @@ import json
|
||||
sensorNodeArray = []
|
||||
enqueteNodeArray = []
|
||||
|
||||
async def processSensorNodeData(data):
|
||||
async def processSensorNodeData(data, nodeID):
|
||||
try:
|
||||
mydb = dbLogin()
|
||||
cursor = mydb.cursor()
|
||||
|
||||
# MACDataReading = mydb.cursor()
|
||||
# MACDataReading.execute("SELECT MAC FROM Node")
|
||||
|
||||
print('some_response')
|
||||
query = "INSERT INTO `Measurement` (NodeID, Type, Value) VALUES (%s, %s, %s)"
|
||||
processedData = json.loads(data)
|
||||
|
||||
@@ -23,18 +19,8 @@ async def processSensorNodeData(data):
|
||||
processedeCO2 = (processedData['eCO2'])
|
||||
processedTVOC = (processedData['TVOC'])
|
||||
processedMAC = (processedData['node'])
|
||||
MACTuple = (processedMAC,)
|
||||
|
||||
# MACDataFetching = MACDataReading.fetchall()
|
||||
# MACArray = list(MACDataFetching)
|
||||
|
||||
|
||||
# if MACTuple not in MACArray:
|
||||
# addingNode = "INSERT INTO `Node` (MAC) VALUES (%s)"
|
||||
# cursor.execute(addingNode, MACTuple)
|
||||
# mydb.commit()
|
||||
|
||||
pushingDataArray = [(1, "Temp", processedTemp), (1, "Humi", processedHumi), (1, "eCO2", processedeCO2), (1, "TVOC", processedTVOC)]
|
||||
pushingDataArray = [(nodeID, "Temp", processedTemp), (nodeID, "Humi", processedHumi), (nodeID, "eCO2", processedeCO2), (nodeID, "TVOC", processedTVOC)]
|
||||
for i in pushingDataArray:
|
||||
print(query ,i)
|
||||
cursor.execute(query, i)
|
||||
@@ -46,9 +32,30 @@ async def processSensorNodeData(data):
|
||||
cursor.close()
|
||||
mydb.close()
|
||||
|
||||
async def processEnqueteNodeData(data, nodeID):
|
||||
try:
|
||||
mydb = dbLogin()
|
||||
cursor = mydb.cursor()
|
||||
|
||||
query = "INSERT INTO `Reply` (Result, Node_NodeID, Question_QuestionID) VALUES (%s, %s, %s)"
|
||||
processedData = json.loads(data)
|
||||
|
||||
processedQuestionID = (processedData['QuestionID'])
|
||||
processedResponse = (processedData['Response'])
|
||||
|
||||
pushingDataArray = [(processedResponse, nodeID, processedQuestionID)]
|
||||
|
||||
for i in pushingDataArray:
|
||||
cursor.execute(query, i)
|
||||
mydb.commit()
|
||||
except mysql.connector.Error as err:
|
||||
print("MySQL Error:", err)
|
||||
finally:
|
||||
cursor.close()
|
||||
mydb.close()
|
||||
|
||||
async def receive_data():
|
||||
uri = "ws://145.92.8.114/ws"
|
||||
|
||||
try:
|
||||
async with websockets.connect(uri) as websocket:
|
||||
while True:
|
||||
@@ -58,7 +65,7 @@ async def receive_data():
|
||||
processedData = json.loads(data)
|
||||
macAdress = processedData['node']
|
||||
|
||||
if processedData["Temp"]:
|
||||
if "Temp" in processedData:
|
||||
type = 'sensor'
|
||||
else:
|
||||
type = 'enquete'
|
||||
@@ -66,26 +73,19 @@ async def receive_data():
|
||||
await getNodeInfo('sensor')
|
||||
await getNodeInfo('enquete')
|
||||
|
||||
print(str(sensorNodeArray))
|
||||
print(sensorNodeArray)
|
||||
|
||||
if str(macAdress) in sensorNodeArray:
|
||||
await processSensorNodeData(data)
|
||||
elif str(macAdress) in enqueteNodeArray:
|
||||
await processEnqueteNodeData(data)
|
||||
if macAdress in sensorNodeArray:
|
||||
nodeID = await getNodeID(macAdress)
|
||||
await processSensorNodeData(data, nodeID)
|
||||
elif macAdress in enqueteNodeArray:
|
||||
nodeID = await getNodeID(macAdress)
|
||||
await processEnqueteNodeData(data, nodeID)
|
||||
else:
|
||||
await newNode(macAdress, type)
|
||||
except websockets.ConnectionClosedError as e:
|
||||
print("WebSocket connection closed:", e)
|
||||
|
||||
async def processEnqueteNodeData(data):
|
||||
mydb = dbLogin()
|
||||
cursor = mydb.cursor()
|
||||
|
||||
query = "INSERT INTO `Response` (NodeID, QuestionID, Response) VALUES (%s, %s, %s)"
|
||||
processedData = json.loads(data)
|
||||
|
||||
|
||||
|
||||
async def main():
|
||||
await receive_data()
|
||||
|
||||
@@ -100,6 +100,9 @@ def dbLogin():
|
||||
return mydb
|
||||
|
||||
async def getNodeInfo(type):
|
||||
global sensorNodeArray
|
||||
global enqueteNodeArray
|
||||
|
||||
nodeInfoArray = []
|
||||
|
||||
id = (type,)
|
||||
@@ -113,6 +116,9 @@ async def getNodeInfo(type):
|
||||
nodeInfoArray.append(item)
|
||||
print(nodeInfoArray)
|
||||
|
||||
cursor.close()
|
||||
mydb.close()
|
||||
|
||||
if type == 'sensor':
|
||||
sensorNodeArray = nodeInfoArray
|
||||
print(sensorNodeArray)
|
||||
@@ -123,8 +129,18 @@ async def getNodeInfo(type):
|
||||
return enqueteNodeArray
|
||||
|
||||
|
||||
async def getNodeID(macAdress):
|
||||
id = (macAdress,)
|
||||
mydb = dbLogin()
|
||||
cursor = mydb.cursor()
|
||||
cursor.execute("""SELECT nodeID FROM Node WHERE MAC = %s""", id)
|
||||
data = cursor.fetchall()
|
||||
|
||||
for tuples in data:
|
||||
for item in tuples:
|
||||
nodeID = item
|
||||
|
||||
return nodeID
|
||||
|
||||
async def newNode(mac, type):
|
||||
id = (mac, type,)
|
||||
@@ -136,4 +152,3 @@ async def newNode(mac, type):
|
||||
mydb.commit()
|
||||
|
||||
asyncio.run(main())
|
||||
|
||||
|
Reference in New Issue
Block a user