//---------------------------------------------------------------------------
/*
Remote Train Control Program for Windows

© Copyright 2015 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
//---------------------------------------------------------------------------
#ifndef Route_Scene_ThreadH
#define Route_Scene_ThreadH
//---------------------------------------------------------------------------
#include <Classes.hpp>

#define THCONTROL_COUNT 6

#define RSACTIVATE 0
#define RSRESET 1
#define SETALLSWNORMAL 2
#define SETALLACCYON 3
#define SETALLACCYOFF 4

#define AIU_DELAY 500       // uSeconds to wait after an Aa, Ab, Ae, Ag, Ah command

//---------------------------------------------------------------------------
class TRouteSceneThread : public TThread
{
private:
    String PrintLine;
    TColor PrintColor;

    TForm * CallingScreen; 	// this pointer must be local to each Thread
    String FileName;
	int EngineNo, RemoteNo, RSNo, TIUNo;
    // TODO : Artifical limit of 256?
    String SAString[256];
    DWORD ThreadID;
    int SACount;

   	__fastcall TRouteSceneThread(bool CreateSuspended);
    __fastcall TRouteSceneThread::~TRouteSceneThread();

protected:
	void __fastcall Execute();
	void __fastcall RS();
	void __fastcall CleanUp();
    void __fastcall Initialize();
    void __fastcall RunOnTerminate(TObject * Sender);

public:
    __fastcall TRouteSceneThread(bool CreateSuspended, TForm * Caller, HWND Parent, int Remote, String FileName,
		int RSNumber, int Parameter);
    HWND ParentHandle;	// accessed by Parent
    int iParameter;

    bool Finished;
};
//---------------------------------------------------------------------------
#endif
