Commit message
This commit is contained in:
parent
f235a588f0
commit
8d082b28d9
26
config.json
26
config.json
|
@ -1,10 +1,24 @@
|
||||||
{
|
{
|
||||||
"get_data_interval": 10,
|
"get_data_interval": 10,
|
||||||
"set_zero_temperature": "y",
|
"set_zero_temperature": "n",
|
||||||
"ref_zero_point": {
|
"ref_zero_point": {
|
||||||
"oilInFlowRate": 4016,
|
"oilInFlowRate": 6143,
|
||||||
"oilOutFlowRate": 3995,
|
"oilOutFlowRate": 5998,
|
||||||
"waterInFlowRate": 3984,
|
"waterInFlowRate": 5778,
|
||||||
"waterOutFlowRate": 3995
|
"waterOutFlowRate": 5758
|
||||||
|
},
|
||||||
|
"temperature_point": {
|
||||||
|
"ch_1": ["n", "test_ch_1"],
|
||||||
|
"ch_2": ["n", "ch_2_name"],
|
||||||
|
"ch_3": ["n", "ch_3_name"],
|
||||||
|
"ch_4": ["n", "ch_4_name"],
|
||||||
|
"ch_5": ["n", "ch_5_name"],
|
||||||
|
"ch_6": ["n", "ch_6_name"],
|
||||||
|
"ch_7": ["n", "ch_7_name"],
|
||||||
|
"ch_8": ["n", "ch_8_name"],
|
||||||
|
"ch_9": ["n", "ch_2_name"],
|
||||||
|
"ch_10": ["n", "ch_10_name"],
|
||||||
|
"ch_11": ["n", "ch_11_name"],
|
||||||
|
"ch_12": ["n", "ch_12_name"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,5 @@ spec:
|
||||||
package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.)
|
package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.)
|
||||||
runtime: python3.9
|
runtime: python3.9
|
||||||
stackbase:
|
stackbase:
|
||||||
tagName: v1.0.4 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
tagName: v1.0.5 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||||
repoName: aquarack-sensor-collector # Satackbase(gitea)에 저장될 저장소 이릅니다.
|
repoName: aquarack-sensor-collector # Satackbase(gitea)에 저장될 저장소 이릅니다.
|
||||||
|
|
44
main.py
44
main.py
|
@ -11,20 +11,27 @@ sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string
|
||||||
def get_point_temperature(serial_obj):
|
def get_point_temperature(serial_obj):
|
||||||
global t_col
|
global t_col
|
||||||
# CWT-TM-320s
|
# CWT-TM-320s
|
||||||
res_dict = {
|
res_dict = {}
|
||||||
"topLeftTemperature": 999.99,
|
points = []
|
||||||
"topRightTemperature": 999.99,
|
ch_list = [f'ch_{num}' for num in range(1, 13)]
|
||||||
"bottomLeftTemperature": 999.99,
|
|
||||||
"bottomRightTemperature": 999.99
|
with open('config.json', 'r') as f:
|
||||||
}
|
info = json.load(f)
|
||||||
points = [1, 3, 7, 9]
|
|
||||||
|
t_col = []
|
||||||
|
for key, value in info['temperature_point'].items():
|
||||||
|
if value[0] == 'y':
|
||||||
|
t_col.append(value[1])
|
||||||
|
points.append(ch_list.index(key) + 1)
|
||||||
|
res_dict[value[1]] = 999.99
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = serial_obj.read_holding_registers(address=32, count=32, slave=2)
|
res = serial_obj.read_holding_registers(address=32, count=32, slave=2)
|
||||||
|
|
||||||
for i, j in zip(t_col, points):
|
for i, j in zip(res_dict.keys(), points):
|
||||||
res_dict[i] = res.registers[j - 1] * 0.1
|
res_dict[i] = res.registers[j - 1] * 0.1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(f'error: {e}')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return res_dict
|
return res_dict
|
||||||
|
@ -84,13 +91,17 @@ def init_zero_detection(serial_obj, config_dict):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def init_data_dict():
|
def init_data_dict():
|
||||||
col = ["topLeftTemperature", "topRightTemperature", "bottomLeftTemperature", "bottomRightTemperature",
|
global k_col, t_col
|
||||||
"oilInFlowRate", "oilInTemperature", "oilOutFlowRate", "oilOutTemperature",
|
# col = ["topLeftTemperature", "topRightTemperature", "bottomLeftTemperature", "bottomRightTemperature",
|
||||||
"waterInFlowRate", "waterInTemperature", "waterOutFlowRate", "waterOutTemperature"]
|
# "oilInFlowRate", "oilInTemperature", "oilOutFlowRate", "oilOutTemperature",
|
||||||
|
# "waterInFlowRate", "waterInTemperature", "waterOutFlowRate", "waterOutTemperature"]
|
||||||
|
col = k_col + t_col
|
||||||
|
|
||||||
return {key: 0.0 for key in col}
|
return {key: 0.0 for key in col}
|
||||||
|
|
||||||
def runAction():
|
def runAction():
|
||||||
sum_data = init_data_dict()
|
sum_data = init_data_dict()
|
||||||
|
# sum_data = {}
|
||||||
cnt, cnt_limit = 0, 0
|
cnt, cnt_limit = 0, 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -112,9 +123,12 @@ def runAction():
|
||||||
pub_data = {
|
pub_data = {
|
||||||
**get_point_temperature(client1), **get_keyence_devices(client1)
|
**get_point_temperature(client1), **get_keyence_devices(client1)
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value in pub_data.items():
|
for key, value in pub_data.items():
|
||||||
sum_data[key] += value
|
try:
|
||||||
|
sum_data[key] += value
|
||||||
|
except:
|
||||||
|
sum_data[key] = value
|
||||||
|
|
||||||
end = int(time.time() * 1000)
|
end = int(time.time() * 1000)
|
||||||
diff = end - start
|
diff = end - start
|
||||||
|
@ -125,7 +139,7 @@ def runAction():
|
||||||
sdtcloud.pubMessage(snd_data)
|
sdtcloud.pubMessage(snd_data)
|
||||||
cnt = 0
|
cnt = 0
|
||||||
sum_data = init_data_dict()
|
sum_data = init_data_dict()
|
||||||
|
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -139,6 +153,6 @@ if __name__ == "__main__":
|
||||||
g_zero_point = [0] * 4
|
g_zero_point = [0] * 4
|
||||||
k_col = ["oilInFlowRate","oilInTemperature","oilOutFlowRate","oilOutTemperature",
|
k_col = ["oilInFlowRate","oilInTemperature","oilOutFlowRate","oilOutTemperature",
|
||||||
"waterInFlowRate","waterInTemperature","waterOutFlowRate","waterOutTemperature"]
|
"waterInFlowRate","waterInTemperature","waterOutFlowRate","waterOutTemperature"]
|
||||||
t_col = ["topLeftTemperature", "topRightTemperature", "bottomLeftTemperature", "bottomRightTemperature"]
|
t_col = []
|
||||||
|
|
||||||
runAction()
|
runAction()
|
Loading…
Reference in New Issue