Commit message
This commit is contained in:
parent
f235a588f0
commit
8d082b28d9
24
config.json
24
config.json
|
@ -1,10 +1,24 @@
|
|||
{
|
||||
"get_data_interval": 10,
|
||||
"set_zero_temperature": "y",
|
||||
"set_zero_temperature": "n",
|
||||
"ref_zero_point": {
|
||||
"oilInFlowRate": 4016,
|
||||
"oilOutFlowRate": 3995,
|
||||
"waterInFlowRate": 3984,
|
||||
"waterOutFlowRate": 3995
|
||||
"oilInFlowRate": 6143,
|
||||
"oilOutFlowRate": 5998,
|
||||
"waterInFlowRate": 5778,
|
||||
"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 입니다.)
|
||||
runtime: python3.9
|
||||
stackbase:
|
||||
tagName: v1.0.4 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
tagName: v1.0.5 # Stackbase(gitea)에 릴리즈 태그명 입니다.
|
||||
repoName: aquarack-sensor-collector # Satackbase(gitea)에 저장될 저장소 이릅니다.
|
||||
|
|
38
main.py
38
main.py
|
@ -11,20 +11,27 @@ sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string
|
|||
def get_point_temperature(serial_obj):
|
||||
global t_col
|
||||
# CWT-TM-320s
|
||||
res_dict = {
|
||||
"topLeftTemperature": 999.99,
|
||||
"topRightTemperature": 999.99,
|
||||
"bottomLeftTemperature": 999.99,
|
||||
"bottomRightTemperature": 999.99
|
||||
}
|
||||
points = [1, 3, 7, 9]
|
||||
res_dict = {}
|
||||
points = []
|
||||
ch_list = [f'ch_{num}' for num in range(1, 13)]
|
||||
|
||||
with open('config.json', 'r') as f:
|
||||
info = json.load(f)
|
||||
|
||||
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:
|
||||
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
|
||||
except Exception as e:
|
||||
print(f'error: {e}')
|
||||
pass
|
||||
|
||||
return res_dict
|
||||
|
@ -84,13 +91,17 @@ def init_zero_detection(serial_obj, config_dict):
|
|||
return True
|
||||
|
||||
def init_data_dict():
|
||||
col = ["topLeftTemperature", "topRightTemperature", "bottomLeftTemperature", "bottomRightTemperature",
|
||||
"oilInFlowRate", "oilInTemperature", "oilOutFlowRate", "oilOutTemperature",
|
||||
"waterInFlowRate", "waterInTemperature", "waterOutFlowRate", "waterOutTemperature"]
|
||||
global k_col, t_col
|
||||
# col = ["topLeftTemperature", "topRightTemperature", "bottomLeftTemperature", "bottomRightTemperature",
|
||||
# "oilInFlowRate", "oilInTemperature", "oilOutFlowRate", "oilOutTemperature",
|
||||
# "waterInFlowRate", "waterInTemperature", "waterOutFlowRate", "waterOutTemperature"]
|
||||
col = k_col + t_col
|
||||
|
||||
return {key: 0.0 for key in col}
|
||||
|
||||
def runAction():
|
||||
sum_data = init_data_dict()
|
||||
# sum_data = {}
|
||||
cnt, cnt_limit = 0, 0
|
||||
|
||||
while True:
|
||||
|
@ -114,7 +125,10 @@ def runAction():
|
|||
}
|
||||
|
||||
for key, value in pub_data.items():
|
||||
try:
|
||||
sum_data[key] += value
|
||||
except:
|
||||
sum_data[key] = value
|
||||
|
||||
end = int(time.time() * 1000)
|
||||
diff = end - start
|
||||
|
@ -139,6 +153,6 @@ if __name__ == "__main__":
|
|||
g_zero_point = [0] * 4
|
||||
k_col = ["oilInFlowRate","oilInTemperature","oilOutFlowRate","oilOutTemperature",
|
||||
"waterInFlowRate","waterInTemperature","waterOutFlowRate","waterOutTemperature"]
|
||||
t_col = ["topLeftTemperature", "topRightTemperature", "bottomLeftTemperature", "bottomRightTemperature"]
|
||||
t_col = []
|
||||
|
||||
runAction()
|
Loading…
Reference in New Issue