Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
5eff7bb7d3 | |
|
9722b2b8d0 |
|
@ -8,5 +8,5 @@ spec:
|
|||
package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.)
|
||||
runtime: python3.9
|
||||
stackbase:
|
||||
tagName: v2.0.1 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
tagName: v2.0.3 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
repoName: aquarack-sensor-collector # Satackbase(gitea)에 저장될 저장소 이릅니다.
|
||||
|
|
9
main.py
9
main.py
|
@ -7,7 +7,7 @@ import threading
|
|||
sdtcloud = sdtcloudpubsub.sdtcloudpubsub()
|
||||
sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
|
||||
|
||||
def get_modbus(evt, serial_obj, file_path):
|
||||
def get_modbus(evt, serial_obj):
|
||||
global isThread, g_zero_point, pub_dict, a_col, d_col, t_col, p_col, S_col
|
||||
|
||||
ctl_mode = 'None'
|
||||
|
@ -360,7 +360,7 @@ def timer_s1(evt):
|
|||
time.sleep(5)
|
||||
|
||||
def runAction():
|
||||
global ctl_data, pub_data
|
||||
global ctl_data, pub_dict
|
||||
sum_data = {key: 0.0 for key in pub_dict.keys()}
|
||||
|
||||
cnt, cnt_limit = 0, 0
|
||||
|
@ -378,7 +378,7 @@ def runAction():
|
|||
while True:
|
||||
start = int(time.time() * 1000)
|
||||
|
||||
for key, value in pub_data.items():
|
||||
for key, value in pub_dict.items():
|
||||
try:
|
||||
sum_data[key] += value
|
||||
except:
|
||||
|
@ -390,6 +390,7 @@ def runAction():
|
|||
cnt += 1
|
||||
if cnt == cnt_limit:
|
||||
snd_data = {key: value / cnt_limit for key, value in sum_data.items()}
|
||||
# print(snd_data)
|
||||
sdtcloud.pubMessage(snd_data)
|
||||
cnt = 0
|
||||
sum_data = {key: 0.0 for key in pub_dict.keys()}
|
||||
|
@ -474,7 +475,7 @@ if __name__ == "__main__":
|
|||
timer_evt_s0.set()
|
||||
timer_evt_s1.set()
|
||||
|
||||
thr_modbus_rtu = threading.Thread(target=get_modbus, args=(timer_evt_s0, client1, path,))
|
||||
thr_modbus_rtu = threading.Thread(target=get_modbus, args=(timer_evt_s0, client1, ))
|
||||
thr_modbus_rtu.start()
|
||||
|
||||
thr_get_sensor = threading.Thread(target=get_sensor, args=(timer_evt_s1, client2,))
|
||||
|
|
Loading…
Reference in New Issue