Commit message

This commit is contained in:
support.sampyo 2024-05-23 05:33:27 +00:00
parent 0a996b5b66
commit 0a351ca635
3 changed files with 27 additions and 5 deletions

View File

@ -16,6 +16,10 @@
"duration": 10, "duration": 10,
"holding": 5 "holding": 5
}, },
"enter":{
"action": "Off",
"duration": 10
},
"vent": { "vent": {
"action": "Off", "action": "Off",
"duration": 30, "duration": 30,

View File

@ -7,5 +7,5 @@ spec:
virtualEnv: base # 사용할 가상환경 이름입니다. virtualEnv: base # 사용할 가상환경 이름입니다.
package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.) package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.)
stackbase: stackbase:
tagName: v0.0.15 # Stackbase(gitea)에 릴리즈 태그명 입니다. tagName: v0.0.16 # Stackbase(gitea)에 릴리즈 태그명 입니다.
repoName: sampyo-dio # Stackbase(gitea)에 저장될 저장소 이릅니다. repoName: sampyo-dio # Stackbase(gitea)에 저장될 저장소 이릅니다.

26
main.py
View File

@ -43,12 +43,20 @@ def Valve_PureWater(chip, status, action):
chip.set_values(status) chip.set_values(status)
def Measure_Weight(client): def Valve_EnterWater(chip, status, action):
# print('In') if action == 'On':
status[4] = 1
else: # action == 'Off'
status[4] = 0
chip.set_values(status)
def measure_weight(client):
# print('in')
val = 0 val = 0
try: try:
result = client.read_holding_registers(1, 1) result = client.read_holding_registers(1, 1)
if result.isError(): if result.iserror():
print(f'Error: {result}') print(f'Error: {result}')
else: else:
val = result.registers[0] val = result.registers[0]
@ -92,8 +100,12 @@ def Command_Read():
# input mixed water # input mixed water
Valve_MixedWater(chip=output_lines, status=status, action='On') 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) time.sleep(mixed_duration)
Valve_MixedWater(chip=output_lines, status=status, action='Off') 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) time.sleep(measure_duration)
# measure weight # measure weight
@ -139,10 +151,14 @@ def Command_Read():
# 3) Input Pure Water # 3) Input Pure Water
Valve_PureWater(chip=output_lines, status=status, action='On') 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) time.sleep(pure_duration + pure_holding)
Valve_PureWater(chip=output_lines, status=status, action='Off') Valve_PureWater(chip=output_lines, status=status, action='Off')
time.sleep(0.5) time.sleep(0.5)
Valve_PureWater(chip=output_lines, status=status, action='Off')
time.sleep(0.5)
# 4) Wait until empty # 4) Wait until empty
time.sleep(vent_duration) time.sleep(vent_duration)
@ -159,6 +175,8 @@ def Command_Read():
Valve_Vent(chip=output_lines, status=status, action=cmd['device']['vent']['action']) 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_MixedWater(chip=output_lines, status=status, action=cmd['device']['mixed']['action'])
Valve_PureWater(chip=output_lines, status=status, action=cmd['device']['pure']['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': if cmd['device']['measure']['action'] == 'On':
result = Measure_Weight(client=client) result = Measure_Weight(client=client)
Calculate_Concentration(result) Calculate_Concentration(result)