57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
from src.variables.service import get_variable, set_variable
|
|
from src.modules.RTD8.service import read_temp
|
|
from src.modules.IndustrialAutomation.service_analog import read_0_10_out, set_0_10_out
|
|
|
|
fans = [
|
|
{
|
|
"inputs": [
|
|
{
|
|
"stack": 1,
|
|
"channel": 1
|
|
},
|
|
{
|
|
"stack": 1,
|
|
"channel": 2
|
|
}
|
|
],
|
|
"temp_min": 40, #minimum temp for fan_min
|
|
"temp_max": 70, #maximum temp for fan_max
|
|
"fan_min": 0, #fan minimum 0-10V set
|
|
"fan_max": 10, #fan maximum 0-10V set
|
|
"output_stack": 0, #stack card
|
|
"output_channel": 2 #card channel
|
|
}
|
|
]
|
|
|
|
|
|
def max_temp(channels: list) -> float:
|
|
temp: float = 0
|
|
for channel in channels:
|
|
temp_ch = read_temp(stack=channel["stack"], channel=channel["channel"])
|
|
if temp < temp_ch:
|
|
temp = temp_ch
|
|
|
|
return temp
|
|
|
|
|
|
def fan_control():
|
|
for fan in fans:
|
|
temp = max_temp(fan["inputs"])
|
|
|
|
if temp > fan["temp_max"]:
|
|
set_0_10_out(stack=fan["output_stack"], channel=fan["output_channel"], value=10)
|
|
elif temp < fan["temp_min"]:
|
|
set_0_10_out(stack=fan["output_stack"], channel=fan["output_channel"], value=0)
|
|
else:
|
|
temp_calc = temp - fan["temp_min"]
|
|
temp_max_calc = fan["temp_max"] - fan["temp_min"]
|
|
calc_out = round(temp_calc / temp_max_calc, 4) * 10
|
|
set_0_10_out(stack=fan["output_stack"], channel=fan["output_channel"], value=calc_out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|