Commit message
This commit is contained in:
parent
0a996b5b66
commit
0a351ca635
|
@ -16,6 +16,10 @@
|
|||
"duration": 10,
|
||||
"holding": 5
|
||||
},
|
||||
"enter":{
|
||||
"action": "Off",
|
||||
"duration": 10
|
||||
},
|
||||
"vent": {
|
||||
"action": "Off",
|
||||
"duration": 30,
|
||||
|
|
|
@ -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)에 저장될 저장소 이릅니다.
|
||||
|
|
24
main.py
24
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,9 +151,13 @@ 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)
|
||||
|
|
Loading…
Reference in New Issue