--[[
---------------------------------------------------------------------------
Remote Train Control Program for Windows

© Copyright 2025 by Mark DiVecchio

	This file is part of Remote Train Control.

	Remote Train Control is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Remote Train Control is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Remote Train Control.  If not, see <http://www.gnu.org/licenses/>.

 Home Page : http://www.silogic.com/trains/RTC_Running.html
---------------------------------------------------------------------------]]
-- Semicolons are not required in Lua code
title = "Route/Scene Test"
require([[defines]]);
require([[functions]]);

local RSNo;

--[[---------------------------------------------------------------------------------------]]
function setup(Engine, TIU)
	print("setup() Running");
	print("Route/Scene Number?")
	RSNo = InputLine(10.5);	-- parameter is Route/Scene number - timeout set to 10.5 seconds
	if (RSNo ~= nil) then
		print(string.format("User Entered Route/Scene : %s", RSNo));
		-- update button labels
		Function01Label = "Activate " .. RSNo;
		Function02Label = "Reset " .. RSNo;
		Function03Label = "All Sw NORMAL " .. RSNo;
		Function04Label = "All Accy ON " .. RSNo;
		Function05Label = "All Accy OFF " .. RSNo;
		Tab01Label = "Action"
		Counter02Label = "Action Count";
		SetUpLabels();	-- do the update 
		print("Label Update Complete");
		else
		return Stop("Terminated - no user input");
		end;
	return true;		-- false=setup failed, true=setup succeeded
	end
--[[---------------------------------------------------------------------------------------]]
function loop(Engine, TIU)
	-- Always call Sleep(X) at least once in this function if it returns true;
	--print("loop() Running");
	Sleep(0.1);
	--print("Almost Done...");
	return true;
	end
--[[---------------------------------------------------------------------------------------]]
function cleanup(Engine, TIU)
	-- this function is called once when the user presses the [STOP] button or the Stop() function is called
	print("cleanup() Running");
	return true;		-- false=cleanup failed, true=cleanup succeeded
	end
--[[---------------------------------------------------------------------------------------]]
function F1(Eng, TIU)
	print("Activate on RouteScene " .. RSNo);
	RSActivate(RSNo);
	BumpCounter(COUNTER02);
	return true;
end;
Function01Name, Function01Label = F1, "Activate";
--[[---------------------------------------------------------------------------------------]]
function F2(Eng, TIU)
	print("Reset on RouteScene " .. RSNo);
	RSReset(RSNo);
	BumpCounter(COUNTER02);
	return true;
end;
Function02Name, Function02Label = F2, "Reset";
--[[---------------------------------------------------------------------------------------]]
function F3(Eng, TIU)
	print("All Sw NORMAL on RouteScene " .. RSNo);
	RSAllSwitchesNormal(RSNo);
	BumpCounter(COUNTER02);
	return true;
end;
Function03Name, Function03Label = F3, "All Sw NORMAL";
--[[---------------------------------------------------------------------------------------]]
function F4(Eng, TIU)
	print("All Accy ON on RouteScene " .. RSNo);
	RSAllAccyOn(RSNo);
	BumpCounter(COUNTER02);
	return true;
end;
Function04Name, Function04Label = F4, "All Accy ON";
--[[---------------------------------------------------------------------------------------]]
function F5(Eng, TIU)
	print("All Accy OFF on RouteScene " .. RSNo);
	RSAllAccyOff(RSNo);
	BumpCounter(COUNTER02);
	return true;
end;
Function05Name, Function05Label = F5, "All Accy OFF";
--[[---------------------------------------------------------------------------------------]]