- Код: Выделить всё
logfile:write( "RETURN_V0 "..RETURN_V0 )
logfile:write( "RETURN_V0 "..RETURN_V0 )
function OnControlValueChange ( name, index, value )
if Call( "*:ControlExists", name, index ) then
if (name == "t_Battery") then -- проверка состояния батареи.
Call( "*:SetControlValue", name, index, value );
if (value == 1) then
Call ("*:SetControlValue", "Battery", 0, 1);
SysCall("ScenarioManager:ShowAlertMessageExt", "System alert!", "Battery is ON", 5, 1);
elseif (Call ("*:GetControlValue", "Startup", 0) == -1) and (value < 1) then
Call ("*:SetControlValue", "Battery", 0, 0);
SysCall("ScenarioManager:ShowAlertMessageExt", "System alert!", "Battery is OFF", 5, 1);
end
elseif (name == "Battery") then -- Состояние батареи
Call( "*:SetControlValue", name, index, value );
SysCall("ScenarioManager:ShowAlertMessageExt", "System alert!", "BATTERY BATTERY", 5, 1);
if ( value < 1) then
-- здесь добавляются НА ВЫКЛЮЧЕНИЕ все питающиеся от батареи потребители
Call ("*:SetControlValue", "OnControl", 0, 0);
SysCall("ScenarioManager:ShowAlertMessageExt", "System alert!", "CONTROL is OFF", 5, 1);
end
elseif (name == "t_Main switch") then -- "Управление общее"
Call( "*:SetControlValue", name, index, value );
if ( value == 1) and (Call ("*:GetControlValue", "Battery", 0) == 1) then
Call ("*:SetControlValue", "OnControl", 0, 1);
SysCall("ScenarioManager:ShowAlertMessageExt", "System alert!", "CONTROL is ON", 5, 1);
elseif ( value == 0) then
Call ("*:SetControlValue", "OnControl", 0, 0);
SysCall("ScenarioManager:ShowAlertMessageExt", "System alert!", "CONTROL is OFF", 5, 1);
end
else
Call( "*:SetControlValue", name, index, value );
end -- end "name =="
end
end
if ( name == "ButtonForward" ) then
if ( value == 1 ) then
Call( "*:SetControlValue", "Reverser", 0, 1 );
end
elseif ( name == "ButtonBackward" ) then
if ( value == 1 ) then
Call( "*:SetControlValue", "Reverser", 0, -1 );
end
end
... ... ...
end -- end "name =="
end
if (Call ("*:GetControlValue", "Battery",0) == 0 ) then
Call ("*:SetControlValue", "OnControl", 0, 0);
elseif (Call ("*:GetControlValue", "Battery",0) == 1 ) and (Call ("*:GetControlValue", "t_Main switch",0) == 1 ) then
Call ("*:SetControlValue", "OnControl", 0, 1);
end
end -- end of OnControlValueChange
проверить состояние всех контролов пульта и обновить их.
Вернуться в [RW] Другие вопросы
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 5