--[[
---------------------------------------------------------------------------
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
title = "Test Sound & Switches"

require([[defines]]);
require([[functions]]);

-- These labels appear on each of the tabs for the Function Buttons
Tab01Label = "Sounds";
Tab02Label = "Noises";
Tab03Label = "---";

function setup(Engine, TIU)
	EngineStartUp(Engine, TIU);
	return true;
end
--[[---------------------------------------------------------------------------------------]]
function cleanup(Engine, TIU)
	-- this function is called once when the user presses the [STOP] button
	print("cleanup()");
	EngineShutdown(Engine, TIU);
	return true;		-- false=cleanup failed, true=cleanup succeeded
	end
--[[---------------------------------------------------------------------------------------]]

--[[---------------------------------------------------------------------------------------]]
function WhistleButton(Eng, TIU)
	print("Whistle Button()");
	PlaySound(41, 0, Eng, TIU); -- Short Toot
	return true;
end
Function01Name, Function01Label = WhistleButton, "Whistle";
--[[---------------------------------------------------------------------------------------]]
function SoundOffButton(Eng, TIU)
	print("Sound Off Button()");
	--SetVolume(MASTER_VOLUME, 0, 0, Eng, TIU);
	Sound(OFF, 0, Eng, TIU);
	return true;
end
Function04Name, Function04Label = SoundOffButton, "Sound Off";
--[[---------------------------------------------------------------------------------------]]
function SoundOnButton(Eng, TIU)
	print("Sound On Button()");
	--SetVolume(MASTER_VOLUME, 99, 0, Eng, TIU);
	Sound(ON, 0, Eng, TIU);
	return true;
end
Function05Name, Function05Label = SoundOnButton, "Sound On";

--[[---------------------------------------------------------------------------------------]]
--[[---------------------------------------------------------------------------------------]]
function SW12CloseButton(Eng, TIU)
	print("College East Close Button()");
	AIUNo = 1;
	Switch(STRAIGHT, 1, AIUNo, TIU, 0);  -- College East
	return true;
end
Function06Name, Function06Label = SW12CloseButton, "College East Close";
--[[---------------------------------------------------------------------------------------]]
function SW12OpenButton(Eng, TIU)
	print("College East Open Button()");
	AIUNo = 1;
	Switch(DIVERGE, 1, AIUNo, TIU, 0);  -- College East
	return true;
end
Function07Name, Function07Label = SW12OpenButton, "College East Open";
--[[---------------------------------------------------------------------------------------]]
--[[---------------------------------------------------------------------------------------]]
function SW11CloseButton(Eng, TIU)
	print("College West Close Button()");
	AIUNo = 1;
	Switch(STRAIGHT, 2, AIUNo, TIU, 0);  -- College West
	return true;
end
Function08Name, Function08Label = SW11CloseButton, "College West Close";
--[[---------------------------------------------------------------------------------------]]
function SW11OpenButton(Eng, TIU)
	print("College West Open Button()");
	AIUNo = 1;	
	Switch(DIVERGE, 2, AIUNo, TIU, 0);  -- College West
	return true;
end
Function09Name, Function09Label = SW11OpenButton, "College West Open";
--[[---------------------------------------------------------------------------------------]]
function Noise1Button(Eng, TIU)
	retv = Noise(RELAY_CLICK);
	print("Noise : Relay Click " .. tostring(retv));
	return true;
end
Function11Name, Function11Label = Noise1Button, "Relay Click";
--[[---------------------------------------------------------------------------------------]]
function Noise2Button(Eng, TIU)
	retv = Noise(TOY_WHISTLE);
	print("Noise : Toy Whistle " .. tostring(retv));
	return true;
end
Function12Name, Function12Label = Noise2Button, "Toy Whistle";
--[[---------------------------------------------------------------------------------------]]
function Noise3Button(Eng, TIU)
	retv = Noise(MOUSE_CLICK);
	print("Noise : Mouse CLick " .. tostring(retv));
	return true;
end
Function13Name, Function13Label = Noise3Button, "Mouse CLick";
--[[---------------------------------------------------------------------------------------]]
function Noise4Button(Eng, TIU)
	retv = Noise(N_O_SQUARE);
	print("Noise : Disneyland New Orleans Square " .. tostring(retv));
	return true;
end
Function14Name, Function14Label = Noise4Button, "Disneyland";
--[[---------------------------------------------------------------------------------------]]
function Noise5Button(Eng, TIU)
	retv = Noise(AIR_HOSE);
	print("Noise : Air Hose Disconnect " .. tostring(retv));
	return true;
end
Function15Name, Function15Label = Noise5Button, "Air Hose";
--[[---------------------------------------------------------------------------------------]]