Commit message
This commit is contained in:
parent
d1a2dd1027
commit
e5d745c4e1
|
@ -29,5 +29,11 @@
|
||||||
"action": "Off"
|
"action": "Off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"maintenance": {
|
||||||
|
"clean": {
|
||||||
|
"duration": 20,
|
||||||
|
"time": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
"type": "manual"
|
"type": "manual"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.27 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
tagName: v0.0.28 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||||
repoName: sampyo-dio # Stackbase(gitea)에 저장될 저장소 이릅니다.
|
repoName: sampyo-dio # Stackbase(gitea)에 저장될 저장소 이릅니다.
|
||||||
|
|
68
main.py
68
main.py
|
@ -97,8 +97,6 @@ def Command_Read():
|
||||||
vent_holding = int(cmd['device']['vent']['holding'])
|
vent_holding = int(cmd['device']['vent']['holding'])
|
||||||
measure_duration = int(cmd['device']['measure']['duration'])
|
measure_duration = int(cmd['device']['measure']['duration'])
|
||||||
enter_duration = int(cmd['device']['enter']['duration'])
|
enter_duration = int(cmd['device']['enter']['duration'])
|
||||||
|
|
||||||
time.sleep(7)
|
|
||||||
start = Measure_Weight(client=client)
|
start = Measure_Weight(client=client)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
@ -132,18 +130,22 @@ def Command_Read():
|
||||||
Valve_PureWater(chip=output_lines, status=status, action='On')
|
Valve_PureWater(chip=output_lines, status=status, action='On')
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
Valve_EnterWater(chip=output_lines, status=status, action='On')
|
Valve_EnterWater(chip=output_lines, status=status, action='On')
|
||||||
time.sleep(pure_holding)
|
time.sleep(0.5)
|
||||||
|
|
||||||
# 3) Open Vent
|
# 3) Open Vent
|
||||||
Valve_Vent(chip=output_lines, status=status, action='On')
|
Valve_Vent(chip=output_lines, status=status, action='On')
|
||||||
time.sleep(pure_duration)
|
time.sleep(pure_duration)
|
||||||
|
Valve_Vent(chip=output_lines, status=status, action='Off')
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
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_EnterWater(chip=output_lines, status=status, action='Off')
|
Valve_EnterWater(chip=output_lines, status=status, action='Off')
|
||||||
|
|
||||||
# 4) Wait until empty
|
# 4) Wait until empty
|
||||||
|
Valve_Vent(chip=output_lines, status=status, action='On')
|
||||||
time.sleep(vent_duration)
|
time.sleep(vent_duration)
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
# 5) Motor Off and Vent close
|
# 5) Motor Off and Vent close
|
||||||
Motor(chip=output_lines, status=status, action='Off')
|
Motor(chip=output_lines, status=status, action='Off')
|
||||||
|
@ -152,7 +154,10 @@ def Command_Read():
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
elif cmd['type'] == 'clean':
|
||||||
|
clean_system()
|
||||||
|
|
||||||
else: # cmd['type'] == 'manual'
|
else: # cmd['type'] == 'manual'
|
||||||
Motor(chip=output_lines, status=status, action=cmd['device']['motor']['action'])
|
Motor(chip=output_lines, status=status, action=cmd['device']['motor']['action'])
|
||||||
Valve_Vent(chip=output_lines, status=status, action=cmd['device']['vent']['action'])
|
Valve_Vent(chip=output_lines, status=status, action=cmd['device']['vent']['action'])
|
||||||
|
@ -170,6 +175,25 @@ def Command_Read():
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def clean_system():
|
||||||
|
with open('./control.json', 'r') as f:
|
||||||
|
cmd = json.load(f)
|
||||||
|
|
||||||
|
clean_duration = int(cmd['maintenace']['clean']['duration'])
|
||||||
|
|
||||||
|
if cmd['type'] == 'clean':
|
||||||
|
Valve_EnterWater(chip=output_lines, status=status, action='Off')
|
||||||
|
time.sleep(0.5)
|
||||||
|
Value_PureWater(chip=output_lines, status=status, action='On')
|
||||||
|
time.sleep(0.5)
|
||||||
|
Value_MixedWater(chip=output_lines, status=status, action='On')
|
||||||
|
time.sleep(clean_duration)
|
||||||
|
|
||||||
|
Value_PureWater(chip=output_lines, status=status, action='Off')
|
||||||
|
time.sleep(0.5)
|
||||||
|
Value_MixedWater(chip=output_lines, status=status, action='Off')
|
||||||
|
time.sleep(6)
|
||||||
|
|
||||||
def runAction():
|
def runAction():
|
||||||
# Write the app's actions in the "runAction" function.
|
# Write the app's actions in the "runAction" function.
|
||||||
|
|
||||||
|
@ -195,6 +219,7 @@ def runAction():
|
||||||
# - You may need it to create a topic.
|
# - You may need it to create a topic.
|
||||||
|
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
clean_flag = 0
|
||||||
while True:
|
while True:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
result = Command_Read()
|
result = Command_Read()
|
||||||
|
@ -207,7 +232,21 @@ def runAction():
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
|
||||||
end = time.time()
|
end = time.time()
|
||||||
|
|
||||||
|
try:
|
||||||
|
now = datetime.now(pytz.timezone('Asia/Seoul'))
|
||||||
|
time_str = now.strftime('%H')
|
||||||
|
time_int = int(time_str)
|
||||||
|
|
||||||
|
if time_int == int(cmd['maintenance']['clean']['time']):
|
||||||
|
if clean_flag < 3:
|
||||||
|
clean_flag += 1
|
||||||
|
clean_system()
|
||||||
|
else:
|
||||||
|
clean_flag = 0
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
diff = end - start
|
diff = end - start
|
||||||
if diff < 3:
|
if diff < 3:
|
||||||
time.sleep(3 - diff)
|
time.sleep(3 - diff)
|
||||||
|
@ -267,7 +306,22 @@ def handle_client(conn, ip, port):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err_msg = 'STXERRORETX'
|
err_msg = 'STXERRORETX'
|
||||||
conn.sendall(err_msg.encode("utf8"))
|
conn.sendall(err_msg.encode("utf8"))
|
||||||
|
|
||||||
|
elif message[3] == 'C': # Clean sequence
|
||||||
|
try:
|
||||||
|
with open('./control.json', 'r') as f:
|
||||||
|
cmd = json.load(f)
|
||||||
|
|
||||||
|
cmd['type'] = 'clean'
|
||||||
|
|
||||||
|
with open('./control.json', 'w') as f:
|
||||||
|
json.dunp(cmd, f, indent=4)
|
||||||
|
send_msg = 'STXOKETX'
|
||||||
|
conn.sendall(send_msg.encode("utf8"))
|
||||||
|
except Exception as e:
|
||||||
|
err_msg = 'STXERRORETX'
|
||||||
|
conn.sendall(err_msg.encode("utf8"))
|
||||||
|
|
||||||
elif message[3] == 'T': # Stop measurement
|
elif message[3] == 'T': # Stop measurement
|
||||||
try:
|
try:
|
||||||
with open('./control.json', 'r') as f:
|
with open('./control.json', 'r') as f:
|
||||||
|
|
Loading…
Reference in New Issue