1. Read_Temperature: register 주소 값 변경

2. Set_Temperature: 장비 구동 방법 변경
3. timestamp 값 milisecond 값으로 표현되도록 변경
This commit is contained in:
KwanghoKim 2023-12-21 13:53:09 +09:00
parent 8dbb6c0ba5
commit eed0eacab4
1 changed files with 63 additions and 15 deletions

View File

@ -91,7 +91,7 @@ def Read_Temperature(client, ch_num):
data = {
"assetCode": info['mqtt']['assetCode'],
"timestamp": int(time.time()),
"timestamp": int(time.time() * 1000),
"dataType": "DATA",
"data": {
name: value
@ -110,18 +110,66 @@ def Set_Temperature(client, ch_num, order, val=None):
else: # ch_num == 3
id = 3
if order == 'start':
client.write_register(address=2336, value=val, slave=id) # H.SP_L1
client.write_register(address=2338, value=val, slave=id) # H.TSP_L1
client.write_register(address=2340, value=1440, slave=id) # H.TM
if not val == None:
val *= 10
val = int(val)
client.write_register(address=2315, value=1, slave=id) # MODE
elif order == 'change':
client.write_register(address=2336, value=val, slave=id) # H.SP_L1
client.write_register(address=2338, value=val, slave=id) # H.TSP_L1
client.write_register(address=2340, value=1440, slave=id) # H.TM
else: # order == 'stop'
client.write_register(address=2315, value=0, slave=id) # MODE
try:
if order == 'start':
# Patten 1
client.write_register(address=8000, value=1, slave=id) # PTNO._C
client.write_register(address=8004, value=1, slave=id) # STC
# SEG 0
client.write_register(address=8001, value=0, slave=id) # SEGNO._C
client.write_register(address=8002, value=0, slave=id) # SSP_L1
# SEG 1
client.write_register(address=8001, value=1, slave=id) # SEGNO._C
client.write_register(address=8102, value=val, slave=id) # TSP_L1
client.write_register(address=8104, value=180, slave=id) # TIME
# SEG 2
client.write_register(address=8001, value=2, slave=id) # SEGNO._C
client.write_register(address=8102, value=val, slave=id) # TSP_L1
client.write_register(address=8104, value=1440, slave=id) # TIME
# Power On
client.write_register(address=2321, value=1, slave=id) # PTNO.
client.write_register(address=2315, value=1, slave=id) # MODE
elif order == 'change':
# Power Off
client.write_register(address=2315, value=0, slave=id) # MODE
# Patten 1
client.write_register(address=8000, value=1, slave=id) # PTNO._C
client.write_register(address=8004, value=1, slave=id) # STC
# SEG 0
client.write_register(address=8001, value=0, slave=id) # SEGNO._C
client.write_register(address=8002, value=0, slave=id) # SSP_L1
# SEG 1
client.write_register(address=8001, value=1, slave=id) # SEGNO._C
client.write_register(address=8102, value=val, slave=id) # TSP_L1
client.write_register(address=8104, value=180, slave=id) # TIME
# SEG 2
client.write_register(address=8001, value=2, slave=id) # SEGNO._C
client.write_register(address=8102, value=val, slave=id) # TSP_L1
client.write_register(address=8104, value=1440, slave=id) # TIME
client.write_register(address=2321, value=1, slave=id) # PTNO.
client.write_register(address=2315, value=1, slave=id) # MODE
else: # order == 'stop'
# Power Off
client.write_register(address=2315, value=0, slave=id) # MODE
except Exception as e:
print(e)
def Read_Power(client, ch_num):
if ch_num == 1:
@ -151,7 +199,7 @@ def Read_Power(client, ch_num):
data = {
"assetCode": info['mqtt']['assetCode'],
"timestamp": int(time.time()),
"timestamp": int(time.time() * 1000),
"dataType": "DATA",
"data": {
name: value
@ -217,7 +265,7 @@ def Read_GasDetector(client, ch_num):
data = {
"assetCode": info['mqtt']['assetCode'],
"timestamp": int(time.time()),
"timestamp": int(time.time() * 1000),
"dataType": "DATA",
"data": {
name_1: oxygen_value,