Commit message
This commit is contained in:
parent
1a6344fccf
commit
a47d7c2bd9
|
@ -27,7 +27,11 @@
|
|||
},
|
||||
"motor": {
|
||||
"action": "Off"
|
||||
}
|
||||
},
|
||||
"main": {
|
||||
"action": "Off",
|
||||
"duration": 1.5
|
||||
}
|
||||
},
|
||||
"maintenance": {
|
||||
"clean": {
|
||||
|
|
|
@ -7,5 +7,5 @@ spec:
|
|||
virtualEnv: base # 사용할 가상환경 이름입니다.
|
||||
package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.)
|
||||
stackbase:
|
||||
tagName: v0.0.38 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
tagName: v0.0.39 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
repoName: sampyo-dio # Stackbase(gitea)에 저장될 저장소 이릅니다.
|
||||
|
|
66
main.py
66
main.py
|
@ -51,6 +51,37 @@ def Valve_EnterWater(chip, status, action):
|
|||
|
||||
chip.set_values(status)
|
||||
|
||||
def Valve_MainWater(chip, status, action, duration=7):
|
||||
global main_valve_status
|
||||
|
||||
status[5] = 0
|
||||
status[6] = 0
|
||||
chip.set_values(status)
|
||||
time.sleep(0.05)
|
||||
|
||||
if action == 'On':
|
||||
status[5] = 1
|
||||
status[6] = 0
|
||||
chip.set_values(status)
|
||||
time.sleep(duration)
|
||||
else:
|
||||
status[5] = 0
|
||||
status[6] = 1
|
||||
chip.set_values(status)
|
||||
time.sleep(7)
|
||||
|
||||
status[5] = 0
|
||||
status[6] = 0
|
||||
chip.set_values(status)
|
||||
time.sleep(0.05)
|
||||
|
||||
if action == 'On' and duration == 7:
|
||||
main_valve_status = 2
|
||||
elif action = 'On' and duration != 7:
|
||||
main_valve_status = 1
|
||||
else:
|
||||
main_valve_status = 0
|
||||
|
||||
def Measure_Weight(client):
|
||||
# print('in')
|
||||
val = 0
|
||||
|
@ -80,16 +111,12 @@ def Set_Zero(client):
|
|||
client.write_coil(1, 1)
|
||||
|
||||
def Command_Read():
|
||||
global client
|
||||
global client, main_valve_status
|
||||
|
||||
with open('./control.json', 'r') as f:
|
||||
cmd = json.load(f)
|
||||
|
||||
if cmd['type'] == 'auto':
|
||||
|
||||
Valve_Vent(chip=output_lines, status=status, action='Off')
|
||||
Motor(chip=output_lines, status=status, action='Off')
|
||||
|
||||
mixed_duration = int(cmd['device']['mixed']['duration'])
|
||||
pure_duration = int(cmd['device']['pure']['duration'])
|
||||
pure_holding = int(cmd['device']['pure']['holding'])
|
||||
|
@ -97,6 +124,16 @@ def Command_Read():
|
|||
vent_holding = int(cmd['device']['vent']['holding'])
|
||||
measure_duration = int(cmd['device']['measure']['duration'])
|
||||
enter_duration = int(cmd['device']['enter']['duration'])
|
||||
main_duration = float(cmd['device']['main']['duration'])
|
||||
|
||||
if main_valve_status == 0:
|
||||
Valve_MainWater(chip=output_lines, status=status, action='On', duration=main_duration)
|
||||
else:
|
||||
Valve_MainWater(chip=output_lines, status=status, action='Off')
|
||||
Valve_MainWater(chip=output_lines, status=status, action='On', duration=main_duration)
|
||||
|
||||
Valve_Vent(chip=output_lines, status=status, action='Off')
|
||||
Motor(chip=output_lines, status=status, action='Off')
|
||||
|
||||
time.sleep(5)
|
||||
start = Measure_Weight(client=client)
|
||||
|
@ -168,6 +205,7 @@ def Command_Read():
|
|||
|
||||
elif cmd['type'] == 'clean':
|
||||
clean_system()
|
||||
time.sleep(3)
|
||||
|
||||
else: # cmd['type'] == 'manual'
|
||||
Motor(chip=output_lines, status=status, action=cmd['device']['motor']['action'])
|
||||
|
@ -176,6 +214,12 @@ def Command_Read():
|
|||
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']['main']['duration'] == 0:
|
||||
Valve_MainWater(chip=output_lines, status=status, action=cmd['device']['main']['action'])
|
||||
else:
|
||||
Valve_MainWater(chip=output_lines, status=status, action=cmd['device']['main']['action'], duration=cmd['device']['main']['duration'])
|
||||
|
||||
|
||||
if cmd['device']['measure']['action'] == 'On':
|
||||
result = Measure_Weight(client=client)
|
||||
Calculate_Concentration(result)
|
||||
|
@ -187,6 +231,7 @@ def Command_Read():
|
|||
return 0
|
||||
|
||||
def clean_system():
|
||||
global main_valve_status
|
||||
with open('./control.json', 'r') as f:
|
||||
cmd = json.load(f)
|
||||
|
||||
|
@ -195,11 +240,16 @@ def clean_system():
|
|||
if cmd['type'] == 'clean':
|
||||
Valve_EnterWater(chip=output_lines, status=status, action='Off')
|
||||
time.sleep(0.5)
|
||||
|
||||
Valve_MainWater(chip=output_lines, status=status, action='On')
|
||||
time.sleep(0.5)
|
||||
Valve_PureWater(chip=output_lines, status=status, action='On')
|
||||
time.sleep(0.5)
|
||||
Valve_MixedWater(chip=output_lines, status=status, action='On')
|
||||
time.sleep(clean_duration)
|
||||
|
||||
Valve_MainWater(chip=output_lines, status=status, action='Off')
|
||||
time.sleep(0.5)
|
||||
Valve_PureWater(chip=output_lines, status=status, action='Off')
|
||||
time.sleep(0.5)
|
||||
Valve_MixedWater(chip=output_lines, status=status, action='Off')
|
||||
|
@ -393,6 +443,7 @@ def exit_handler(signum, frame):
|
|||
Valve_MixedWater(chip=output_lines, status=status, action='Off')
|
||||
Valve_PureWater(chip=output_lines, status=status, action='Off')
|
||||
Valve_EnterWater(chip=output_lines, status=status, action='Off')
|
||||
Valve_MainWater(chip=output_lines, status=status, action='Off')
|
||||
|
||||
client.close()
|
||||
|
||||
|
@ -410,7 +461,10 @@ if __name__ == "__main__":
|
|||
status = [0, 0, 0, 0, 0, 0, 0, 0]
|
||||
|
||||
signal.signal(signal.SIGINT, exit_handler)
|
||||
|
||||
|
||||
main_valve_status = 0
|
||||
Valve_MainWater(chip=output_lines, status=status, action='Off')
|
||||
|
||||
with open('./config.json', encoding='UTF-8') as f:
|
||||
jsonData = json.load(f)
|
||||
|
||||
|
|
Loading…
Reference in New Issue