-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateiDB.py
38 lines (33 loc) · 1.04 KB
/
updateiDB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
@date: 23/11/2022
@author: Rohan Vangal
@brief: Back-end function to update database with data from multiple sites and machines via MQTT broker
@description:
@notes:
"""
import logging
import time
import sys
from MqttManager import MqttManager
#Initializing logger
logging.basicConfig(filename= 'updateDB.log',
filemode= 'a',
format='%(asctime)s %(levelname)s - [%(filename)s : %(lineno)d] %(message)s',
datefmt='%Y/%m/%d %H:%M:%S',
level=logging.INFO)
# To schedule update of TagList
start_time = time.time()
if __name__ == '__main__':
# Initialize manager object
mgr = MqttManager()
# Generate mqtt clients for each topics
mgr.regenClients()
while(True):
# Update database if data is found in the queue
mgr.insertData()
# Regenerate topic list if timer expires
start_time = mgr.regenClients(start_time)
if(not mgr.run_flag):
break
mgr.stopClients()
sys.exit()