From 0a351ca635398037788482d03879b5299dfcab13 Mon Sep 17 00:00:00 2001 From: "support.sampyo" Date: Thu, 23 May 2024 05:33:27 +0000 Subject: [PATCH] Commit message --- control.json | 4 ++++ framework.yaml | 2 +- main.py | 26 ++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/control.json b/control.json index 826aaf6..319a7c3 100644 --- a/control.json +++ b/control.json @@ -16,6 +16,10 @@ "duration": 10, "holding": 5 }, + "enter":{ + "action": "Off", + "duration": 10 + }, "vent": { "action": "Off", "duration": 30, diff --git a/framework.yaml b/framework.yaml index 6777616..6496a94 100644 --- a/framework.yaml +++ b/framework.yaml @@ -7,5 +7,5 @@ spec: virtualEnv: base # 사용할 가상환경 이름입니다. package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.) stackbase: - tagName: v0.0.15 # Stackbase(gitea)에 릴리즈 태그명 입니다. + tagName: v0.0.16 # Stackbase(gitea)에 릴리즈 태그명 입니다. repoName: sampyo-dio # Stackbase(gitea)에 저장될 저장소 이릅니다. diff --git a/main.py b/main.py index 4568d49..6ca2bba 100644 --- a/main.py +++ b/main.py @@ -43,12 +43,20 @@ def Valve_PureWater(chip, status, action): chip.set_values(status) -def Measure_Weight(client): - # print('In') +def Valve_EnterWater(chip, status, action): + if action == 'On': + status[4] = 1 + else: # action == 'Off' + status[4] = 0 + + chip.set_values(status) + +def measure_weight(client): + # print('in') val = 0 try: result = client.read_holding_registers(1, 1) - if result.isError(): + if result.iserror(): print(f'Error: {result}') else: val = result.registers[0] @@ -92,8 +100,12 @@ def Command_Read(): # input mixed water Valve_MixedWater(chip=output_lines, status=status, action='On') + time.sleep(0.5) + Valve_EnterWater(chip=output_lines, status=status, action='On') time.sleep(mixed_duration) Valve_MixedWater(chip=output_lines, status=status, action='Off') + time.sleep(0.5) + Valve_EnterWater(chip=output_lines, status=status, action='Off') time.sleep(measure_duration) # measure weight @@ -139,10 +151,14 @@ def Command_Read(): # 3) Input Pure Water Valve_PureWater(chip=output_lines, status=status, action='On') + time.sleep(0.5) + Valve_EnterWater(chip=output_lines, status=status, action='On') time.sleep(pure_duration + pure_holding) Valve_PureWater(chip=output_lines, status=status, action='Off') time.sleep(0.5) - + Valve_PureWater(chip=output_lines, status=status, action='Off') + time.sleep(0.5) + # 4) Wait until empty time.sleep(vent_duration) @@ -159,6 +175,8 @@ def Command_Read(): Valve_Vent(chip=output_lines, status=status, action=cmd['device']['vent']['action']) Valve_MixedWater(chip=output_lines, status=status, action=cmd['device']['mixed']['action']) Valve_PureWater(chip=output_lines, status=status, action=cmd['device']['pure']['action']) + Valve_EnterWater(chip=output_lines, status=status, action=cmd['device']['enter']['action']) + if cmd['device']['measure']['action'] == 'On': result = Measure_Weight(client=client) Calculate_Concentration(result)