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

© Copyright 2019 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
--[[
This test contains both a loop() function and a tag() function.
This is valid if the RFID system is enabled.

In Non-Debug mode, if the RFID system is not enabled, it is not valid to have a tag() function.
You should get the following error message:

Error : tag(), nametag(), response() and uidtag() functions requires that the RFID system be enabled and connected

In Debug mode, this test is bypassed and the script will run.
]]

title = "Function Validity Test"

require("defines");

--[[---------------------------------------------------------------------------------------]]
function setup(Engine, TIU)
--
print("setup : TIU " .. TIU .. " Engine " .. Engine .. " Debug " .. Debug());
return true;
end
--[[---------------------------------------------------------------------------------------]]
function loop(Engine, TIU)
--
if (GetCounter(ELAPSEDTIME) % 10 == 0) then
	print("loop : TIU " .. TIU .. " Engine " .. Engine .. " Debug " .. Debug());
	Sleep(1);
	end;
Sleep(0.1);
return true;	-- false=do not loop, true=continue to loop
end
--[[---------------------------------------------------------------------------------------]]
function tag(Detector, Reader, EngineNo, TagLocation, CarModel, Railroad, CarNumber, TagPacket)
--
Beep();	-- sound a tone
if (EngineNo > 0) then	-- its an engine
	print(string.format([[tag() : Detector %d Reader %d EngineNo %d TagLocation %d EngineModel %d]],
		Detector, Reader, EngineNo, TagLocation, CarModel));
	else	-- it's a car
	print(string.format([[tag() : Detector %d Reader %d CarModel %d]],
		Detector, Reader, CarModel));
	-- ignore non engine tags
	return true;	-- true=continue to process tags, false=stop processing tags
	end
return true;	-- true=continue to process tags, false=stop processing tags
end
--[[---------------------------------------------------------------------------------------]]
function cleanup(Engine, TIU)
--
print("cleanup : TIU " .. TIU .. " Engine " .. Engine .. " Debug " .. Debug());
return true;
end
--[[---------------------------------------------------------------------------------------]]
