//---------------------------------------------------------------------------
/*
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 Engine_Information_ThreadH
#define Engine_Information_ThreadH
//---------------------------------------------------------------------------
#include <Classes.hpp>
//---------------------------------------------------------------------------
class TEngineInfoThread : public TThread
{
private:
    unsigned char EngineNo, TIUNo, RemoteNo;
    bool bRepeat;
    DWORD DelayValue;
    TEngineInfo * CallingOpScreen; 	// this pointer must be local to each Thread
    HWND ParentHandle;				// for messages back to the Parent
    int TestValue;

	byte DODbyteResp[CMDMAX]; 	// Array for decoded binary response
    int iDODCount;
	byte DTObyteResp[CMDMAX]; 	// Array for decoded binary response
    int iDTOCount;
	byte FactorResp[CMDMAX]; 	// Array for decoded binary response
    int iFactorCount;
    byte DTVbyteResp[CMDMAX]; 	// Array for decoded binary response
    int iDTVCount;
	byte DCHbyteResp[CMDMAX]; 	// Array for decoded binary response
    int iDCHCount;
	byte QbyteResp[CMDMAX]; 	// Array for response
    int iQCount;

	bool DODUpdate;
	bool DTOUpdate;
	bool DTVUpdate;
	bool DCHUpdate;

    float fSF;					// Scaling Factor

    String PrintLine;
    TColor PrintColor;

   	__fastcall TEngineInfoThread(bool CreateSuspended);
    DWORD ThreadID;

protected:
	void __fastcall Execute();
    void __fastcall EI();
    void __fastcall CleanUp();
    void __fastcall Initialize();
    void __fastcall RunOnTerminate(TObject * Sender);
    void __fastcall CheckUpdateFlags(void);
    bool __fastcall Query(char * CommandString, byte * QBuf, int Engine, int TIU, int Remote);
    void __fastcall PrintItem();


public:
    __fastcall TEngineInfoThread(bool CreateSuspended, TEngineInfo * CallingOp, HWND Parent,
		int Eng, int TIU, int Remote, DWORD delay, bool RepeatParameter);
    __fastcall ~TEngineInfoThread();

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