This commit is contained in:
YujinChu 2023-09-08 08:12:39 +00:00
parent c927f89c5d
commit 10d67c039b
2 changed files with 11 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import minimalmodbus
import serial.rs485 import serial.rs485
import subprocess import subprocess
import json import json
import yaml
import queue import queue
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
import numpy as np import numpy as np
@ -38,6 +39,7 @@ parser.add_argument('-config',help='')
args = parser.parse_args() args = parser.parse_args()
ROOT_PATH = f"/usr/local/sdt/app/{args.config}" ROOT_PATH = f"/usr/local/sdt/app/{args.config}"
DEVICE_PATH = f"/etc/sdt/device-control"
############################################################################### ###############################################################################
# JSON FILE READ # # JSON FILE READ #
@ -47,6 +49,10 @@ with open(f"{ROOT_PATH}/connect_info.json","r") as f:
#with open(f"{args.config}/connect_info.json","r") as f: #with open(f"{args.config}/connect_info.json","r") as f:
info = json.load(f) info = json.load(f)
with open(f"{DEVICE_PATH}/config.yaml","r") as f:
#with open(f"{args.config}/connect_info.json","r") as f:
dev_info = yaml.load(f, Loader=yaml.FullLoader)
############################################################################### ###############################################################################
# Shared memory setting # # Shared memory setting #
@ -65,8 +71,6 @@ a = [ data[str(n+1)] for n in range(64)]
a = np.array(a) a = np.array(a)
############################################################################### ###############################################################################
# Get Data from Shared Memory # # Get Data from Shared Memory #
############################################################################### ###############################################################################
@ -80,7 +84,8 @@ b[:] = a[:]
# MQTT Broker Setting # # MQTT Broker Setting #
############################################################################### ###############################################################################
MQTT_TOPIC = info['mqtt']['topic'] #MQTT_TOPIC = info['mqtt']['topic']
MQTT_TOPIC = dev_info['assetcode']
MQTT_ID = info['mqtt']['id'] MQTT_ID = info['mqtt']['id']
MQTT_PW = info['mqtt']['pw'] MQTT_PW = info['mqtt']['pw']
MQTT_HOST_IP = info['mqtt']['host_ip'] MQTT_HOST_IP = info['mqtt']['host_ip']

View File

@ -7,3 +7,6 @@ sudo cp /usr/local/sdt/app/$1/AWX_collector.service /etc/systemd/system/$1.servi
sudo cp /usr/local/sdt/app/$1/AWX_shm_updater.service /etc/systemd/system/AWX_shm_updater.service sudo cp /usr/local/sdt/app/$1/AWX_shm_updater.service /etc/systemd/system/AWX_shm_updater.service
sudo systemctl start $1 sudo systemctl start $1
sudo systemctl enable $1 sudo systemctl enable $1
sudo systemctl start AWX_shm_updater
sudo systemctl enable AWX_shm_updater