1. Read_Temperature: register 주소 값 변경
2. Set_Temperature: 장비 구동 방법 변경 3. timestamp 값 milisecond 값으로 표현되도록 변경
This commit is contained in:
parent
8dbb6c0ba5
commit
eed0eacab4
|
@ -91,7 +91,7 @@ def Read_Temperature(client, ch_num):
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"assetCode": info['mqtt']['assetCode'],
|
"assetCode": info['mqtt']['assetCode'],
|
||||||
"timestamp": int(time.time()),
|
"timestamp": int(time.time() * 1000),
|
||||||
"dataType": "DATA",
|
"dataType": "DATA",
|
||||||
"data": {
|
"data": {
|
||||||
name: value
|
name: value
|
||||||
|
@ -110,18 +110,66 @@ def Set_Temperature(client, ch_num, order, val=None):
|
||||||
else: # ch_num == 3
|
else: # ch_num == 3
|
||||||
id = 3
|
id = 3
|
||||||
|
|
||||||
if order == 'start':
|
if not val == None:
|
||||||
client.write_register(address=2336, value=val, slave=id) # H.SP_L1
|
val *= 10
|
||||||
client.write_register(address=2338, value=val, slave=id) # H.TSP_L1
|
val = int(val)
|
||||||
client.write_register(address=2340, value=1440, slave=id) # H.TM
|
|
||||||
|
|
||||||
client.write_register(address=2315, value=1, slave=id) # MODE
|
try:
|
||||||
elif order == 'change':
|
if order == 'start':
|
||||||
client.write_register(address=2336, value=val, slave=id) # H.SP_L1
|
# Patten 1
|
||||||
client.write_register(address=2338, value=val, slave=id) # H.TSP_L1
|
client.write_register(address=8000, value=1, slave=id) # PTNO._C
|
||||||
client.write_register(address=2340, value=1440, slave=id) # H.TM
|
client.write_register(address=8004, value=1, slave=id) # STC
|
||||||
else: # order == 'stop'
|
|
||||||
client.write_register(address=2315, value=0, slave=id) # MODE
|
# 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):
|
def Read_Power(client, ch_num):
|
||||||
if ch_num == 1:
|
if ch_num == 1:
|
||||||
|
@ -151,7 +199,7 @@ def Read_Power(client, ch_num):
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"assetCode": info['mqtt']['assetCode'],
|
"assetCode": info['mqtt']['assetCode'],
|
||||||
"timestamp": int(time.time()),
|
"timestamp": int(time.time() * 1000),
|
||||||
"dataType": "DATA",
|
"dataType": "DATA",
|
||||||
"data": {
|
"data": {
|
||||||
name: value
|
name: value
|
||||||
|
@ -217,7 +265,7 @@ def Read_GasDetector(client, ch_num):
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"assetCode": info['mqtt']['assetCode'],
|
"assetCode": info['mqtt']['assetCode'],
|
||||||
"timestamp": int(time.time()),
|
"timestamp": int(time.time() * 1000),
|
||||||
"dataType": "DATA",
|
"dataType": "DATA",
|
||||||
"data": {
|
"data": {
|
||||||
name_1: oxygen_value,
|
name_1: oxygen_value,
|
||||||
|
|
Loading…
Reference in New Issue