А ПР какая?
Вид для печати
Вложение 81947
Код:function_block Rot
var_input
Air1Auto, Air1On, Air2Auto, Air2On, Air3Auto, Air3On : bool;
end_var
var_output
Q1, Q2, Q3 : bool;
end_var
var
TMR1, TMR2, TMR3 : SYS.TON; // Таймер для каждого кондиционера
AutoCount : udint; // Кол-во кондиционеров в режиме авто
end_var
// Если кондей включен, его таймер должен работать и наоборот
TMR1(I:=Q1, T:=T#10m); TMR2(I:=Q2, T:=T#10m); TMR3(I:=Q3, T:=T#10m);
// Если кондей был включен и надо его выключить и его таймер это позволяет, то - выключаем
if Q1 and Not Air1Auto and Not Air1On and TMR1.Q then Q1:=false; end_if
if Q2 and Not Air2Auto and Not Air2On and TMR2.Q then Q2:=false; end_if
if Q3 and Not Air2Auto and Not Air2On and TMR3.Q then Q3:=false; end_if
// Если кондей был выключен и его надо включить безусловно, то - включаем
if Not Q1 and Air1On then Q1:=true; end_if
if Not Q2 and Air2On then Q2:=true; end_if
if Not Q3 and Air3On then Q3:=true; end_if
// Определяем кол-во кондеев в режиме Auto
AutoCount := 0;
if Air1Auto then AutoCount := AutoCount + 1; end_if
if Air2Auto then AutoCount := AutoCount + 1; end_if
if Air3Auto then AutoCount := AutoCount + 1; end_if
case AutoCount of
1: // Найти кондей с режимом Auto и включить его безусловно
if Air1Auto then Q1:=true; end_if
if Air2Auto then Q2:=true; end_if
if Air3Auto then Q3:=true; end_if
2: // Найти кондей с режимом Auto и если он накопил 10мин - выключить, а другой - включить
// Если нет накопленных - включаем первого какой попадется
if Air1Auto and TMR1.Q then
Q1:=false;
if Air2Auto then Q2:=true; end_if
if Air3Auto then Q3:=true; end_if
elsif Air2Auto and TMR2.Q then
Q2:=false;
if Air3Auto then Q3:=true; end_if
if Air1Auto then Q1:=true; end_if
elsif Air3Auto and TMR3.Q then
Q3:=false;
if Air1Auto then Q1:=true; end_if
if Air2Auto then Q2:=true; end_if
elsif (Not Q1 and Not Q2 and Not Q3) then
if Air1Auto then Q1:=true;
elsif Air2Auto then Q2:=true;
elsif Air3Auto then Q3:=true;
end_if
end_if
3: // Найти кондей, который накопил 10мин - выключить, а 2 других - включить
// Если нет такого, то включаем одного из выключенных
if TMR1.Q then
Q1:=false; Q2:=true; Q3:=true;
elsif TMR2.Q then
Q2:=false; Q1:=true; Q3:=true;
elsif TMR3.Q then
Q3:=false; Q1:=true; Q2:=true;
elsif (Not Q1 and Not Q2) then
Q1:=true;
elsif (Not Q1 and Not Q3) then
Q3:=true;
elsif (Not Q2 and Not Q3) then
Q2:=true;
end_if
end_case
end_function_block
Чуть поправил
https://disk.yandex.ru/d/wJD3lSpoXalXJg