///////////////////////////////////////////////////////////////////////////////
// Skrypty dla sygnalizacji w¹skotorowej TomSka & Brood_K.
// 16-06-2015 dodany semafor 4K_A i znacznik SZ (TomSka)


//////// ksztaltowe niemieckie

SCRIPT WT_1R_B

// Semafor wyjazdowy ksztaltowy B 1 ramienny

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;



if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED || block_state() ==# BLOCK_JN_OBSTRUCTED  )

	{
state = SIGASP_STOP;
 }
else
{ if (  sig_feature( SIGFEAT_USER1 )  )

{ state = SIGASP_CLEAR_1; }
else
{ state = SIGASP_APPROACH_1; }
}
draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////

SCRIPT WT_2R_A

// Semafor wjazdowy ksztaltowy A 2 ramienny

// deklaracja zmiennych

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	extern float	next_sig_lr ();
		  float	nast_sem;
     
	nast_sem = next_sig_lr ( SIGFN_NORMAL );

// skrypt

if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED )    					

	{ 
state = SIGASP_STOP;													
 }
else														
{
if (  sig_feature( SIGFEAT_USER1 ) && route_set () && nast_sem == SIGASP_CLEAR_1 )
{
 state = SIGASP_CLEAR_1;
}
else
{
state = SIGASP_APPROACH_1;
}
}
draw_state = def_draw_state ( state );

///////////////////////////////////////////////////////////////////////////////


SCRIPT WT_2R_A_SZ

// Semafor wjazdowy ksztaltowy A 2 ramienny z sygn zastepczym

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	extern float	next_sig_lr ();
		  float	nast_sem;
     
	nast_sem = next_sig_lr ( SIGFN_NORMAL );

// skrypt

if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED )    					

	{ 
state = SIGASP_STOP;													
 }
else														
{
if (  sig_feature( SIGFEAT_USER1 ) && route_set () && nast_sem == SIGASP_CLEAR_1 )
{
 state = SIGASP_CLEAR_1;
}
else
{
state = SIGASP_APPROACH_1;
}
}
if ( nast_sem == SIGASP_APPROACH_2 )
{
state = SIGASP_RESTRICTING;
}


draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////



// Semafory swietlneTomSkalski


SCRIPT WT_4K_A

// Semafor wjazdowy A 4-komorowy

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	extern float	next_sig_lr ();
		  float	nast_sem;
     
	nast_sem = next_sig_lr ( SIGFN_NORMAL );

// skrypt

if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED )    					

	{ 
state = SIGASP_STOP;													
 }
else														
{
if (  sig_feature( SIGFEAT_USER1 ) && route_set () && nast_sem == SIGASP_CLEAR_1 )
{
 state = SIGASP_CLEAR_1;
}
else
{
state = SIGASP_APPROACH_1;
}
}
if ( nast_sem == SIGASP_APPROACH_2 )
{
state = SIGASP_RESTRICTING;
}


draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
SCRIPT SZ_zn
//skrypt znacznika sygnalu zastepczego

	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;

	state = SIGASP_APPROACH_2;
	draw_state = def_draw_state (state);
	return;

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

// Semafory swietlneTomSkalski


SCRIPT WT_3K_A

// Semafor wjazdowy A 3-komorowy

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	extern float	next_sig_lr ();
		  float	nast_sem;
     
	nast_sem = next_sig_lr ( SIGFN_NORMAL );

// skrypt

if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED )    					

	{ 
state = SIGASP_STOP;													
 }
else														
{
if (  sig_feature( SIGFEAT_USER1 ) && route_set () && nast_sem == SIGASP_CLEAR_1 )
{
 state = SIGASP_CLEAR_1;
}
else
{
state = SIGASP_APPROACH_1;
}
}
draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

SCRIPT WT_2K_B1a

// Semafor wyjazdowy swietlny B 2-komorowy

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	


if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED || block_state() ==# BLOCK_JN_OBSTRUCTED  )

	{ 
state = SIGASP_STOP;
 }
else
{

if (  sig_feature( SIGFEAT_USER1 )  )
 
{

 state = SIGASP_CLEAR_1; 		
			
		
}

else

{

state = SIGASP_APPROACH_1;

}
}

draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

SCRIPT WT_3K_B

// Semafor wyjazdowy swietlny B 3-komorowy

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	


if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED || block_state() ==# BLOCK_JN_OBSTRUCTED  )

	{ 
state = SIGASP_STOP;
 }
else

{

if (  sig_feature( SIGFEAT_USER1 )  )

{ state = SIGASP_CLEAR_1; }

else


{ state = SIGASP_APPROACH_1; }

}

draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

SCRIPT WT_sem_W4

// Wskaznik W4

	extern float	sig_feature ();
	extern float	block_state ();
	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	


if ( (!enabled) || block_state() ==# BLOCK_OCCUPIED || block_state() ==# BLOCK_JN_OBSTRUCTED  )

	{ 
state = SIGASP_STOP;
 }
else
{

if (  sig_feature( SIGFEAT_USER1 )  )
 
{

 state = SIGASP_CLEAR_1; 		
			
		
}

else
{
state = SIGASP_APPROACH_1;
}
}

draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////

SCRIPT WW1
//skrypt wskaznika WW1

	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;

	state = SIGASP_STOP_AND_PROCEED;
	draw_state = def_draw_state (state);
	return;
	
	
///////////////////////////////////////////////////////////////////////////////
SCRIPT SZast
//skrypt stalego sygnalu zastepczego

	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;

	state = SIGASP_RESTRICTING;
	draw_state = def_draw_state (state);
	return;

///////////////////////////////////////////////////////////////////////////////

//Wykolejnice
SCRIPT VYKOL

	extern float	block_state ();
	extern float	draw_state;

	if ( block_state () ==# 2 )
	draw_state = 0;
	else draw_state = 1;


SCRIPT VYKNAV

	extern float	block_state ();
	extern float	draw_state;

	if ( block_state () ==# 2 )
	draw_state = 0;
	else draw_state = 1;
///////////////////////////////////////////////////////////////////////////////

//Zwrotnice
SCRIPT WNX

	extern float	route_set ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;

	state = 7;
	draw_state = 0;

	if ( route_set() )
	{
		draw_state = 1;
		return;
	}

	return;
	

///////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////

SCRIPT RESET

//Skrypt wskaznika w5

	extern float	block_state ();
	//extern float	route_set ();
	extern float	next_sig_mr ();
	extern float	def_draw_state ();
	extern float	sig_feature ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	float			next_state;
	//float			czy_na_bok;


if ( !enabled || block_state() ==# BLOCK_OCCUPIED ) 
	{ state = SIGASP_CLEAR_1; }
else
	{	
		if ( sig_feature ( SIGFEAT_USER1 ) )
			{ 
			next_state = next_sig_mr ( SIGFN_NORMAL ); 
			if ( next_state ==# SIGASP_STOP ) 
				{ state = SIGASP_STOP_AND_PROCEED; }
			else
				{ state = next_state; }
			}
		else
			{ state = SIGASP_CLEAR_2; }
	}

draw_state = def_draw_state ( state );


///////////////////////////////////////////////////////////////////////////////

// End of File
