-
Notifications
You must be signed in to change notification settings - Fork 0
/
waterlevelcode.py
65 lines (51 loc) · 1.33 KB
/
waterlevelcode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 29 22:18:18 2024
@author: laura
"""
from cap import ncdt6500_get_data, ncdt6500_decode
import ne1000
import socket
from typing import List
import time
from time import sleep
TCP_ADDRESS = '169.254.168.150'
#x is the procentage shown at the ue cap controller at the optimal water level ener x manually at callabration
x = 64
y = x * 0.1
ue = y + 0.5
ut = y - 0.5
print(ue)
print(ut)
PORT = 'COM5'
ADDRESS = 1
DIA = 38
# 1ml werden nchgefullt 2 ist 1 ml
dev = ne1000.Ne1000Serial(PORT)
volume = ne1000.Ne1000Volume(2, 'ml')
rate = ne1000.Ne1000Rate(10, 'MM')
pump = ne1000.Ne1000(dev, ADDRESS)
pump.diameter_mm(DIA)
pump.volume(volume)
pump.rate(rate)
pump.direction_infuse()
waterlevel_low = False
#was_in_cutting_window = False
while not waterlevel_low:
for channel, raw_data in enumerate(ncdt6500_get_data()):
print(f"channel #{channel}: {ncdt6500_decode(raw_data):.4g} V")
waterlevel = ncdt6500_decode(raw_data)
if waterlevel > ue:
pump.run()
time.sleep(2)
# if waterlevel < ut:
# pump = ne1000.Ne1000(dev, ADDRESS)
# pump.diameter_mm(DIA)
# pump.volume(volume)
# pump.rate(rate)
# pump.direction_withdraw()
# pump.run()
# time.sleep(10)
elif waterlevel <= ue:
#continue
time.sleep(0.1)