Compare commits

..

No commits in common. "a47ea039ded273a1d56c79934d49ac3ff1bacaad" and "c927f89c5d79941d21e897828722b3a7b33001a1" have entirely different histories.

9 changed files with 3 additions and 165 deletions

View File

@ -7,7 +7,6 @@ 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
@ -39,7 +38,6 @@ 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 #
@ -49,10 +47,6 @@ 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 #
@ -71,6 +65,8 @@ 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 #
############################################################################### ###############################################################################
@ -84,8 +80,7 @@ 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

@ -1,23 +0,0 @@
import numpy as np
from multiprocessing import shared_memory
import time
import json
import argparse
existing_shm = shared_memory.SharedMemory(name="DO-shm")
c = np.ndarray((64,), dtype=np.int32, buffer=existing_shm.buf)
parser = argparse.ArgumentParser()
parser.add_argument('-config',help='')
args = parser.parse_args()
ROOT_PATH = f"/usr/local/sdt/app/{args.config}"
while True:
with open(f"{ROOT_PATH}/config.json", 'r') as file:
jsonData = json.load(file)
for n in range(64):
c[n]=jsonData[str(n+1)]
time.sleep(2)

View File

@ -1,18 +0,0 @@
import numpy as np
from multiprocessing import shared_memory
import time
import json
existing_shm = shared_memory.SharedMemory(name="DO-shm")
c = np.ndarray((64,), dtype=np.int32, buffer=existing_shm.buf)
file_path = "./config.json"
while True:
with open(file_path, 'r') as file:
jsonData = json.load(file)
for n in range(64):
c[n]=jsonData[str(n+1)]
time.sleep(2)

View File

@ -1,10 +0,0 @@
[Unit]
Description=awx_shm_updater
[Service]
ExecStart=/usr/bin/python3 /usr/local/sdt/app/appName/AWX_shm_updater.py -config appName
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

View File

@ -1,10 +0,0 @@
[Unit]
Description=awx_collector
[Service]
ExecStart=/usr/bin/python3 /usr/local/sdt/app/appName/AWX_collector.py -config appName
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

View File

@ -1,66 +0,0 @@
{
"1": 1,
"2": 1,
"3": 1,
"4": 1,
"5": 1,
"6": 1,
"7": 1,
"8": 1,
"9": 1,
"10": 0,
"11": 0,
"12": 0,
"13": 0,
"14": 0,
"15": 0,
"16": 1,
"17": 0,
"18": 0,
"19": 0,
"20": 0,
"21": 0,
"22": 0,
"23": 0,
"24": 0,
"25": 0,
"26": 0,
"27": 0,
"28": 0,
"29": 0,
"30": 0,
"31": 0,
"32": 0,
"33": 0,
"34": 0,
"35": 0,
"36": 1,
"37": 0,
"38": 0,
"39": 0,
"40": 0,
"41": 0,
"42": 0,
"43": 0,
"44": 0,
"45": 0,
"46": 1,
"47": 0,
"48": 0,
"49": 0,
"50": 0,
"51": 0,
"52": 0,
"53": 0,
"54": 0,
"55": 0,
"56": 1,
"57": 0,
"58": 0,
"59": 0,
"60": 0,
"61": 0,
"62": 0,
"63": 0,
"64": 0
}

View File

@ -7,6 +7,3 @@ 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

View File

@ -1,9 +0,0 @@
#!/bin/bash
pip install -r requirements.txt
sudo sed -i "s/appName/$1/g" /usr/local/sdt/app/$1/AWX_collector.service
sudo cp /usr/local/sdt/app/$1/AWX_collector.service /etc/systemd/system/$1.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 enable $1

View File

@ -1,18 +0,0 @@
import numpy as np
from multiprocessing import shared_memory
import time
import json
existing_shm = shared_memory.SharedMemory(name="do_shm2")
c = np.ndarray((32,), dtype=np.int32, buffer=existing_shm.buf)
file_path = "./config.json"
while True:
with open(file_path, 'r') as file:
jsonData = json.load(file)
for n in range(32):
c[n]=jsonData[str(n+1)]
time.sleep(2)