Files
Multi-Sensor/POCloud/python-driver/test.py
Patrick McDonagh 529399e2f3 Initial python driver
converted parts from Multi-Pond
2018-07-03 11:25:12 -05:00

27 lines
1.0 KiB
Python

import json
import time
from Channel import read_tag, write_tag
PLC_IP_ADDRESS = "192.168.1.12"
def read_pond_calibration(pond_number):
"""Read all calibration values for a specific pond."""
last_read_height = -1.0
cal_values = []
cal_index = 1
while last_read_height != 0 and cal_index <=10:
cal_tag_height = "pond{}CalibrationHeight[{}]".format(pond_number, cal_index)
cal_tag_volume = "pond{}CalibrationVolume[{}]".format(pond_number, cal_index)
print(cal_tag_height, cal_tag_volume)
read_height = read_tag(PLC_IP_ADDRESS, cal_tag_height, plc_type="Micro800")
time.sleep(2)
read_volume = read_tag(PLC_IP_ADDRESS, cal_tag_volume, plc_type="Micro800")
time.sleep(2)
print(read_height, read_volume)
if read_height and read_volume:
if read_height[0] > 0.0:
cal_values.append({"height": read_height[0], "volume": read_volume[0]})
last_read_height = read_height[0]
cal_index += 1
return cal_values