Commit message
This commit is contained in:
parent
86c56cd51c
commit
90fd872969
|
@ -8,5 +8,5 @@ spec:
|
|||
package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.)
|
||||
runtime: python3.9
|
||||
stackbase:
|
||||
tagName: v1.0.0 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
tagName: v1.0.1 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
repoName: mat-plus-app # Stackbase(gitea)에 저장될 저장소 이릅니다.
|
||||
|
|
108
main.py
108
main.py
|
@ -1,29 +1,109 @@
|
|||
import sdtcloudpubsub
|
||||
#import sdtcloudpubsub
|
||||
import time
|
||||
import uuid
|
||||
import string
|
||||
import random
|
||||
|
||||
sdtcloud = sdtcloudpubsub.sdtcloudpubsub()
|
||||
sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
|
||||
#sdtcloud = sdtcloudpubsub.sdtcloudpubsub()
|
||||
#sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
|
||||
|
||||
def runAction():
|
||||
input_pressure = random.randint(1,3)
|
||||
input_flow = random.randint(1,3)
|
||||
output_pressure = random.randint(1,2)
|
||||
output_flow = random.randint(1,3)
|
||||
cpu_temperature = random.randint(50,60)
|
||||
fan1_rpm = random.randint(500,1000)
|
||||
fan2_rpm = random.randint(500,1000)
|
||||
input_pressure_state = 1
|
||||
input_flow_state = 1
|
||||
output_pressure_state = 1
|
||||
output_flow_state = 1
|
||||
cpu_temperature_state = 1
|
||||
fan1_rpm_state = 1
|
||||
fan2_rpm_state = 1
|
||||
|
||||
|
||||
characters1 = string.ascii_letters + string.digits
|
||||
random_string1 = ''.join(random.choices(characters1, k=10))
|
||||
characters2 = string.ascii_letters + string.digits
|
||||
random_string2 = ''.join(random.choices(characters2, k=10))
|
||||
characters3 = string.ascii_letters + string.digits
|
||||
random_string3 = ''.join(random.choices(characters3, k=10))
|
||||
|
||||
while True:
|
||||
up_value = random.uniform(1, 1.5)
|
||||
|
||||
if input_pressure > 10:
|
||||
input_pressure_state = -1
|
||||
elif input_pressure < 1:
|
||||
input_pressure_state = 1
|
||||
|
||||
if input_flow > 10:
|
||||
input_flow_state = -1
|
||||
elif input_flow < 1:
|
||||
input_flow_state = 1
|
||||
|
||||
if output_pressure > 6:
|
||||
output_pressure_state = -1
|
||||
elif output_pressure < 1:
|
||||
output_pressure_state = 1
|
||||
|
||||
if output_flow > 10:
|
||||
output_flow_state = -1
|
||||
elif output_flow < 1:
|
||||
output_flow_state = 1
|
||||
|
||||
if cpu_temperature > 90:
|
||||
cpu_temperature_state = -1
|
||||
elif cpu_temperature < 50:
|
||||
cpu_temperature_state = 1
|
||||
|
||||
if fan1_rpm > 3600:
|
||||
fan1_rpm_state = -1
|
||||
elif fan1_rpm < 500:
|
||||
fan1_rpm_state = 1
|
||||
|
||||
if fan2_rpm > 3600:
|
||||
fan2_rpm_state = -1
|
||||
elif fan2_rpm < 500:
|
||||
fan2_rpm_state = 1
|
||||
|
||||
|
||||
#characters1 = string.ascii_letters + string.digits
|
||||
#random_string1 = ''.join(random.choices(characters1, k=10))
|
||||
#characters2 = string.ascii_letters + string.digits
|
||||
#random_string2 = ''.join(random.choices(characters2, k=10))
|
||||
#characters3 = string.ascii_letters + string.digits
|
||||
#random_string3 = ''.join(random.choices(characters3, k=10))
|
||||
|
||||
input_pressure = input_pressure + input_pressure_state * up_value # 1~10
|
||||
input_flow = input_flow + input_flow_state * up_value # 1~10
|
||||
output_pressure = output_pressure + output_pressure_state * up_value / 2 # 1~6
|
||||
output_flow = output_flow + output_flow_state * up_value # 1~10
|
||||
cpu_temperature = cpu_temperature + cpu_temperature_state * up_value * 4 # 50~90
|
||||
fan1_rpm = fan1_rpm + fan1_rpm_state * up_value * 300 # 500~3600
|
||||
fan2_rpm = fan2_rpm + fan2_rpm_state * up_value * 300 # 500~3600
|
||||
|
||||
|
||||
msg = {
|
||||
"input_pressure" : 1,
|
||||
"input_flow" : 1,
|
||||
"output_pressure" : 1,
|
||||
"output_flow" : 1,
|
||||
"input_pressure" : input_pressure, # 1~10
|
||||
"input_flow" : input_flow, # 1~10
|
||||
"output_pressure" : output_pressure, # 1~6
|
||||
"output_flow" : output_flow, # 1~10
|
||||
"Util_value":{
|
||||
"cpu_temperature" : 70,
|
||||
"fan1_rpm" : 2000,
|
||||
"fan2_rpm" : 2000
|
||||
"cpu_temperature" : cpu_temperature, # 50~90
|
||||
"fan1_rpm" : fan1_rpm, # 500~3600
|
||||
"fan2_rpm" : fan2_rpm # 500~3600
|
||||
},
|
||||
"user_set_value":{
|
||||
"input1_str" : "stage1",
|
||||
"input2_str" : "stage2",
|
||||
"input3_str" : "stage3"
|
||||
"input1_str" : characters1, # (10)string
|
||||
"input2_str" : characters2, # (10)string
|
||||
"input3_str" : characters3 # (10)string
|
||||
}
|
||||
}
|
||||
sdtcloud.pubMessage(msg)
|
||||
#sdtcloud.pubMessage(msg)
|
||||
print(msg)
|
||||
time.sleep(2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue