working mqtt connection
This commit is contained in:
39
main.py
Normal file
39
main.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import datetime
|
||||
from time import sleep, time
|
||||
|
||||
from multiprocessing import Process, Queue
|
||||
import source.vqe as vqe
|
||||
import source.mqtt as mqtt
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
broker_address = "mqtt.deowl.ru" # Example public broker
|
||||
broker_port = 1883
|
||||
mqttBroker = mqtt.vqeMqttBroker(broker_address, broker_port, max_connection_attempts=5)
|
||||
print(mqttBroker.get_status())
|
||||
mqttBroker.connect_to_server()
|
||||
|
||||
while True:
|
||||
print(mqttBroker.get_status())
|
||||
sleep(1)
|
||||
|
||||
# GLOBAL SYSTEM PARAMETERS
|
||||
active_electrons=2
|
||||
active_orbitals=2
|
||||
max_iterations = 500
|
||||
conv_tol = 1e-04
|
||||
step_size = 0.05
|
||||
|
||||
q = Queue()
|
||||
p = Process(target=vqe.run_vqe, args=(q, symbols, coordinates, active_electrons, active_orbitals, max_iterations, conv_tol, step_size))
|
||||
p.start()
|
||||
while p.is_alive():
|
||||
try:
|
||||
print(q.get_nowait(), datetime.datetime.now())
|
||||
except Exception as e:
|
||||
print("no_data_to_get", e)
|
||||
sleep(0.1)
|
||||
|
||||
client.loop_stop() # Stop the background loop thread if used
|
||||
client.disconnect()
|
||||
Reference in New Issue
Block a user