Compare commits

..

No commits in common. "main" and "test2" have entirely different histories.
main ... test2

4 changed files with 20 additions and 28 deletions

View File

@ -2,7 +2,7 @@
Description=awx-perfermance-arm32
[Service]
ExecStart=/usr/bin/python3 /usr/local/sdt/app/appName/main.py -config appName
ExecStart=/usr/bin/python3 /usr/local/sdt/app/awx-perfermance-arm32/main.py
Restart=always
RestartSec=10

10
awx-perfermance.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=awx-perfermance
[Service]
ExecStart=/home/sdt/miniconda3/bin/python3 /usr/local/sdt/app/awx-perfermance/main.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

View File

@ -1,7 +1,5 @@
#!/bin/bash
sudo sed -i "s/appName/$1/g" /usr/local/sdt/app/$1/awx-perfermance-arm32.service
sudo cp /usr/local/sdt/app/$1/awx-perfermance.service /etc/systemd/system/$1.service
sudo systemctl start $1
sudo systemctl enable $1
sudo cp /usr/local/sdt/app/awx-perfermance-arm32/awx-perfermance-arm32.service /etc/systemd/system/
sudo systemctl start awx-perfermance-arm32
sudo systemctl enable awx-perfermance-arm32

28
main.py
View File

@ -1,16 +1,11 @@
import paho.mqtt.client as mqtt
import json
import argparse
from datetime import datetime
import time
import yaml
parser = argparse.ArgumentParser()
parser.add_argument('-config',help='')
args = parser.parse_args()
with open(f'/usr/local/sdt/app/{args.config}/config.yaml', encoding='UTF-8') as f:
with open('/usr/local/sdt/app/awx-perfermance-arm32/config.yaml', encoding='UTF-8') as f:
yamlData = yaml.load(f, Loader=yaml.FullLoader)
@ -23,27 +18,16 @@ while True:
for n in range(10):
data = {
"timestamp": datetime.now().timestamp(),
"current": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"voltage": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"do": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"er1": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"er2": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"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)
dataBody = {
"slot": 1,
"chamber": 1,
"channel": 1,
"list": dataList,
}
datas = json.dumps({
"modeCode": "test1",
"assetCode": "perfermance",
"dataType":"DATA",
"data": dataBody
"assetCode":"",
"timestamp":0,
"dataType":"",
"data": dataList
})
mqttc.publish(f"/device-data/{yamlData['topic']}", datas) # topic, message
# mqttc.publish(f"/device-data/perfermance", datas) # topic, message