FIX: fix test code

This commit is contained in:
이수준 2023-09-25 10:20:46 +09:00
parent 624df0db8e
commit 5738b911d3
1 changed files with 19 additions and 18 deletions

37
main.py
View File

@ -14,25 +14,26 @@ with open(f'/usr/local/sdt/app/{args.config}/config.yaml', encoding='UTF-8') as
yamlData = yaml.load(f, Loader=yaml.FullLoader) yamlData = yaml.load(f, Loader=yaml.FullLoader)
mqttc = mqtt.Client() # puclisher 이름 # mqttc = mqtt.Client() # puclisher 이름
mqttc.username_pw_set("sdt", "251327") # mqttc.username_pw_set("sdt", "251327")
mqttc.connect("13.209.39.139", 32259) # mqttc.connect("13.209.39.139", 32259)
while True: while True:
dataList = [] print(f"Config value: {yamlData['topic']}")
for n in range(10): # dataList = []
data = { # for n in range(10):
"timestamp": datetime.now().timestamp(), # data = {
"data": [1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 4, 5, 6, 1], # "timestamp": datetime.now().timestamp(),
} # "data": [1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 1 ,2 ,3 ,4 ,5 ,6 ,1, 1, 2, 3, 4, 5, 6, 1],
dataList.append(data) # }
time.sleep(0.1) # dataList.append(data)
time.sleep(2)
datas = json.dumps({ # datas = json.dumps({
"assetCode":"", # "assetCode":"",
"timestamp":0, # "timestamp":0,
"dataType":"", # "dataType":"",
"data": dataList # "data": dataList
}) # })
mqttc.publish(f"/device-test/{yamlData['topic']}", datas) # topic, message # mqttc.publish(f"/device-test/{yamlData['topic']}", datas) # topic, message