From b2049635828600788bd0946de4471c26fdadb39d Mon Sep 17 00:00:00 2001 From: "support.sampyo" Date: Tue, 26 Mar 2024 09:27:51 +0000 Subject: [PATCH] Commit message --- framework.yaml | 2 +- main.py | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/framework.yaml b/framework.yaml index dc96540..5718127 100644 --- a/framework.yaml +++ b/framework.yaml @@ -7,5 +7,5 @@ spec: virtualEnv: base # 사용할 가상환경 이름입니다. package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.) stackbase: - tagName: v0.0.7 # Stackbase(gitea)에 릴리즈 태그명 입니다. + tagName: v0.0.8 # Stackbase(gitea)에 릴리즈 태그명 입니다. repoName: sampyo-dio # Stackbase(gitea)에 저장될 저장소 이릅니다. diff --git a/main.py b/main.py index 53daa11..2893478 100644 --- a/main.py +++ b/main.py @@ -124,6 +124,8 @@ def Command_Read(): time.sleep(0.5) Valve_Vent(chip=output_lines, status=status, action='Off') time.sleep(1) + + return 1 else: # cmd['type'] == 'manual' Motor(chip=output_lines, status=status, action=cmd['device']['motor']['action']) @@ -133,8 +135,12 @@ def Command_Read(): if cmd['device']['measure']['action'] == 'On': result = Measure_Weight(client=client) Calculate_Concentration(result) + return 1 + if cmd['device']['setzero']['action'] == 'On': Set_Zero(client=client) + + return 0 def runAction(): # Write the app's actions in the "runAction" function. @@ -163,16 +169,16 @@ def runAction(): cnt = 0 while True: start = time.time() - Command_Read() - data['timestamp'] = int(time.time() * 1000) - sdtcloud.pubMessage(mqttlist[cnt], data) + result = Command_Read() + + if result: + data['timestamp'] = int(time.time() * 1000) + cnt += 1 + if cnt == 5: + cnt = 0 + end = time.time() - cnt += 1 - - if cnt == 5: - cnt = 0 - diff = end - start if diff < 3: time.sleep(3 - diff)