Commit message
This commit is contained in:
parent
c66fa01799
commit
1951662064
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"get_data_interval": 1,
|
"get_data_interval": 10,
|
||||||
"set_zero_temperature": "n",
|
"set_zero_temperature": "n",
|
||||||
"ref_zero_point": {
|
"ref_zero_point": {
|
||||||
"oilInFlowRate": 3989,
|
"oilInFlowRate": 4016,
|
||||||
"oilOutFlowRate": 3978,
|
"oilOutFlowRate": 3995,
|
||||||
"waterInFlowRate": 3984,
|
"waterInFlowRate": 3984,
|
||||||
"waterOutFlowRate": 4000
|
"waterOutFlowRate": 3995
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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.2 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
tagName: v1.0.3 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||||
repoName: aquarack-sensor-collector # Satackbase(gitea)에 저장될 저장소 이릅니다.
|
repoName: aquarack-sensor-collector # Satackbase(gitea)에 저장될 저장소 이릅니다.
|
||||||
|
|
23
main.py
23
main.py
|
@ -47,16 +47,14 @@ def get_keyence_devices(serial_obj):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = serial_obj.read_holding_registers(address=50, count=8, slave=5)
|
res = serial_obj.read_holding_registers(address=50, count=8, slave=5)
|
||||||
|
print(f'k_col: {k_col} g_zero: {g_zero_point}')
|
||||||
for i, j in enumerate(k_col):
|
for i, j in enumerate(k_col):
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
res_dict[j] = ((res.registers[i] - g_zero_point[i // 2]) / 16000) * 300
|
res_dict[j] = ((res.registers[i] - g_zero_point[i // 2]) / 16000) * 300
|
||||||
# print(f'Flow_rate: {flow_rate:.6f}L')
|
print(f'[{j}] Flow_rate: {res_dict[j]:.6f}L')
|
||||||
else:
|
else:
|
||||||
res_dict[j] = ((res.registers[i] - 4000) / 16000) * 100
|
res_dict[j] = ((res.registers[i] - 4000) / 16000) * 100
|
||||||
# print(f'Temperature: {temperature:.6f} degree')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# print(f'Error: {e}')
|
|
||||||
pass
|
pass
|
||||||
return res_dict
|
return res_dict
|
||||||
|
|
||||||
|
@ -84,8 +82,14 @@ def init_zero_detection(serial_obj, config_dict):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def init_data_dict():
|
||||||
|
col = ["topLeftTemperature", "topRightTemperature", "bottomLeftTemperature", "bottomRightTemperature",
|
||||||
|
"oilInFlowRate", "oilInTemperature", "oilOutFlowRate", "oilOutTemperature",
|
||||||
|
"waterInFlowRate", "waterInTemperature", "waterOutFlowRate", "waterOutTemperature"]
|
||||||
|
return {key: 0.0 for key in col}
|
||||||
|
|
||||||
def runAction():
|
def runAction():
|
||||||
sum_data = {}
|
sum_data = init_data_dict()
|
||||||
cnt, cnt_limit = 0, 0
|
cnt, cnt_limit = 0, 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -107,18 +111,19 @@ def runAction():
|
||||||
pub_data = {
|
pub_data = {
|
||||||
**get_point_temperature(client1), **get_keyence_devices(client1)
|
**get_point_temperature(client1), **get_keyence_devices(client1)
|
||||||
}
|
}
|
||||||
print(int(time.time() * 1000), pub_data)
|
|
||||||
|
|
||||||
sum_data = Counter(sum_data) + Counter(pub_data)
|
for key, value in pub_data.items():
|
||||||
|
sum_data[key] += value
|
||||||
|
|
||||||
end = int(time.time() * 1000)
|
end = int(time.time() * 1000)
|
||||||
diff = end - start
|
diff = end - start
|
||||||
sleep_time = int(interval / cnt_limit) - (diff * 0.001)
|
sleep_time = int(interval / cnt_limit) - (diff * 0.001)
|
||||||
cnt += 1
|
cnt += 1
|
||||||
if cnt == cnt_limit:
|
if cnt == cnt_limit:
|
||||||
snd_data = {key: value / cnt_limit for key, value in sum_data.items()}
|
snd_data = {key: value / cnt_limit for key, value in sum_data.items() if value != 0.0}
|
||||||
sdtcloud.pubMessage(snd_data)
|
sdtcloud.pubMessage(snd_data)
|
||||||
cnt = 0
|
cnt = 0
|
||||||
sum_data = {}
|
sum_data = init_data_dict()
|
||||||
|
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue