Elvas Tower: New signalling functions - Elvas Tower

Jump to content

Posting Rules

All new threads will be started by members of the Open Rails team, Staff, and/or Admins. Existing threads started in other forums may get moved here when it makes sense to do so.

Once a thread is started any member may post replies to it.
  • 8 Pages +
  • « First
  • 4
  • 5
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

New signalling functions OR specific signalling functions added in version 2266 Rate Topic: -----

#51 User is offline   ebnertra000 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,234
  • Joined: 27-February 17
  • Gender:Male
  • Location:East-Central Minnesota
  • Simulator:OR/TSRE
  • Country:

Posted 07 April 2020 - 05:24 PM

A block_state() test can return one of three values:
CLEAR if nothing is in the block to the next signal,
OCCUPIED if a train is between this signal and the next (or end of track), or
JN_OBSTRUCTED if the block is impassible due to a switch being lined against the intended route.

Basically, call-on should only be necessary when the block ahead is occupied hence the typically required check if (block_state() ==# BLOCK_OCCUPIED)

#52 User is offline   LeoGarcia 

  • Hostler
  • Group: Status: Active Member
  • Posts: 50
  • Joined: 01-October 18
  • Gender:Male
  • Simulator:Open Rails
  • Country:

Posted 08 April 2020 - 06:41 AM

I was going through the files I attached to them earlier, and found that there were a lot of scripts repeated and even several unused ones in the route. So I did a debug. Finally, everything was left in a single script file, which I attach:

SCRIPT UKSemHome

	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 ||					// Not enabled/cleared to show natural state?
		block_state() !=# BLOCK_CLEAR ||	// Block ahead not clear?
		!route_set())				// Switch not set as per link?
	{ state = SIGASP_STOP; }
	else
	{ state = SIGASP_CLEAR_2; }
	draw_state = def_draw_state (state);		// Get draw state

SCRIPT UKSemDist

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

	if ( //!enabled ||				// Not enabled/cleared to show natural state?
		!route_set() ||				// Switch not set as per link?
		dist_multi_sig_mr (SIGFN_NORMAL, SIGFN_DISTANCE) ==# SIGASP_STOP)
	{ state = SIGASP_APPROACH_2; }
	else
	{ state = SIGASP_CLEAR_2; }
	draw_state = def_draw_state (state);		// Get draw state

SCRIPT ARSemLink

	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_CLEAR && route_set())
		state = SIGASP_CLEAR_2;
	else
		state = SIGASP_STOP;
	draw_state = def_draw_state(state);

SCRIPT ArSemDesvio

	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	opp_sig_mr();

	if (enabled && route_set() && opp_sig_mr(SIGFN_NORMAL) == SIGASP_STOP )							
	{ state = SIGASP_STOP_AND_PROCEED; }
	else
	{ state = SIGASP_STOP; }
	draw_state = def_draw_state (state);		// Get draw state

SCRIPT SenalEnCir
// Pantalla Principal (Home) 2 estados. válida para:	Salida de ramales. Salida de estación

	extern float	block_state ();
	extern float	route_set ();
	extern float	next_sig_lr ();
	extern float	def_draw_state ();
	extern float	state;
	extern float	draw_state;
	extern float	enabled;
	float		next_state;

	if (!enabled ||					// Not enabled/cleared to show natural state?
		block_state() !=# BLOCK_CLEAR ||	// Block ahead not clear?
		!route_set())				// Switch not set as per link?
	{ state = SIGASP_STOP; }
	else
	{ state = SIGASP_APPROACH_2; }
	draw_state = def_draw_state (state);		// Get draw state

SCRIPT ArSemAbsAAOM2

	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	opp_sig_mr();

	if (enabled &&
		(opp_sig_mr(SIGFN_NORMAL) == SIGASP_STOP ||
		block_state() ==# BLOCK_CLEAR))
	{
		if (opp_sig_mr(SIGFN_NORMAL) == SIGASP_STOP &&
			block_state() ==# BLOCK_CLEAR &&
			route_set()
		)
				state = SIGASP_CLEAR_2;
		else{
			if(route_set())
			{	state = SIGASP_STOP_AND_PROCEED; }
			else {	state = SIGASP_RESTRICTING; }
		}
	}
	else
				state = SIGASP_STOP;
	draw_state = def_draw_state(state);


However, I still can't understand where to put the new "call on" element, because there is not a use of the word "OCCUPIED" in the entire script, and I have a locomotive that is unable to finish the runround in a Timetable.

#53 User is offline   VicenteIR 

  • Fireman
  • Group: Status: Active Member
  • Posts: 149
  • Joined: 24-April 15
  • Gender:Male
  • Location:Dimona, Israel
  • Simulator:Open Rails
  • Country:

Posted 26 April 2020 - 02:30 PM

sigid = opp_sig_id(SIGFN_Type, <n>)
What does that mean <n>? Is it a typo error in the document of "Additional signal script functions "? Is there one more function of sigid = opp_Nsig_id(SIGFN_Type, <n>) exists?

I've a signal point with back-facing Signal Head. Is it correct to identificate those Signal Head with that sigid = opp_sig_id(SIGFN_Type, <n>) if I need to check an opposite aspect only?

Thanks.
Oleg

#54 User is offline   VicenteIR 

  • Fireman
  • Group: Status: Active Member
  • Posts: 149
  • Joined: 24-April 15
  • Gender:Male
  • Location:Dimona, Israel
  • Simulator:Open Rails
  • Country:

Posted 27 April 2020 - 02:02 AM

The service leaves by shunting the signal into the "station neck". Passes through the shunting and returns to the clear station line. Due to the fact that the service from the main track to the station with an exit signal at STOP should go the same way, I can not "isolate" separately the shunt aspect or the draw_state of shunting.
http://i.piccy.info/i9/d4c86327a7fff4e1d2189207f0f81609/1587980415/67461/1373151/RunActivityLAA_2020_04_27_12_32_44_17_800.jpghttp://i.piccy.info/a3/2020-04-27-09-40/i9-13776576/763x559-r/i.gif
To make it different, I need to “catch” the moment in picture 1, when opposite exit signal is at RESTRICTING state, transfer it to the shunting signal, distribute it to all “sub-heads” and remember.
[img][URL=http://piccy.info/view3/13777723/3aa5fe555ec9da1e49430f46fef5784d/orig/][IMG]http://i.piccy.info/i9/cf358e639c1698bb6c4c85c5e14444fd/1588021256/72234/1373151/RunActivityLAA_2020_04_27_12_34_10_98_800.jpg[/IMG][/URL]http://i.piccy.info/a3/2020-04-27-21-00/i9-13777723/763x559-r/i.gif[/img]
A script of the shunting signal (all sub-heads - the same):

Quote

extern float block_state ();
extern float route_set ();
extern float next_sig_lr ();
extern float this_sig_lr ();
extern float def_draw_state ();
extern float state;
extern float draw_state;
extern float enabled;
extern float sig_feature ();
extern float this_sig_lvar ();
extern float opp_sig_id ();
extern float ID_SIG_LR ();
extern float store_lvar();

float next_state;
float sigid;
float opp_state;
float shunt_mode;


sigid = opp_sig_id (SIGFN_NORMAL);
next_state = next_sig_lr (SIGFN_NORMAL);
opp_state = ID_SIG_LR (sigid);
shunt_mode = this_sig_lvar(1);
if (route_set () )
{
state = SIGASP_STOP;
if (!enabled && (opp_state ==# SIGASP_RESTRICTING))
{
store_lvar(1, 1);
}
if (!enabled && (block_state() ==# BLOCK_OCCUPIED))
{
store_lvar(1, 0);
}
if (enabled && (block_state() ==# BLOCK_CLEAR) && (shunt_mode ==# 1))
{
state = SIGASP_RESTRICTING;
}
if (enabled && (block_state() ==# BLOCK_CLEAR) && (shunt_mode ==# 0))
{
state = next_state;
}
draw_state = def_draw_state (state);
}
else
{
state = SIGASP_STOP; draw_state = 0;
if (this_sig_lr (SIGFN_NORMAL) ># SIGASP_STOP)
{
draw_state = 2;
}
}

What am I doing wrong?

#55 User is offline   roeter 

  • Vice President
  • Group: Status: Elite Member
  • Posts: 2,424
  • Joined: 25-October 11
  • Gender:Male
  • Country:

Posted 27 April 2020 - 03:52 AM

At the end, following 'else', I think you have a '}' at the wrong position.
It reads :

else
 {
[A] state = SIGASP_STOP; draw_state = 0;
[B] if (this_sig_lr (SIGFN_NORMAL) ># SIGASP_STOP)
 {
 draw_state = 2;
 }
 }


Take a look at lines [A] and [B]. In [A], 'state' is set to SIGASP_STOP. In [B], you check if the state is > SIGASP_STOP. Guess what - it never is.

I think it should be like this :

else
 {
 state = SIGASP_STOP; draw_state = 0;
 }
 if (this_sig_lr (SIGFN_NORMAL) ># SIGASP_STOP)
 {
 draw_state = 2;
 }


By the way, indentation helps a lot to catch such errors. It makes reading the script a lot easier.

Another note : you retreive the info for shunt_mode from the local variable (1), and later set the value of this variable.
That means that shunt_mode uses the previous value of this variable. Is that your intention?

Regards,
Rob Roeterdink

#56 User is offline   VicenteIR 

  • Fireman
  • Group: Status: Active Member
  • Posts: 149
  • Joined: 24-April 15
  • Gender:Male
  • Location:Dimona, Israel
  • Simulator:Open Rails
  • Country:

Posted 27 April 2020 - 02:24 PM

Rob, thank you for your attention and help!
Obviously, I do not quite understand the syntax of the new additions. Therefore, I ask for help in Developing Features - I have no found examples of their use on the network.
The signal is a multi-head linked signal based on one shape with two lights - white and blue. It is a part of historical signalization of USSR Railways. There are two modes of railway work in simulation: the "Mainline Mode" and the "Shunting Mode". At the "Mainline Mode" a signal's job - not to "disturb" - blue light is the danger aspect for shunting work only. In the "Mainline Mode" it has no danger value. Because of this reason - line "state = next_state;" in the script.
Each head of the signal has it's own link. If a head gets TRUE from route_set() - a first block of script is in operation, else - SIGASP is STOP. draw_state = 0; - blue. But if another head is operated, I need to repay it. So I looking for least restrictive aspect of all of heads with function this_sig_lr () and if so - draw_state = 2; - no lights.
I'll try your syntax, but it is a working script, it is in use few years and my expression is quite does it's job too.

 roeter, on 27 April 2020 - 03:52 AM, said:

Another note : you retreive the info for shunt_mode from the local variable (1), and later set the value of this variable.
That means that shunt_mode uses the previous value of this variable. Is that your intention?


I need to separate between the modes. As I said, a script is work properly exсept an act that I pictured: a path from the shunting signal to empty station line when exit signal from those line is at STOP. Because it is the same what a train from Main Line do... I must to let him to pass the signal at STOP_AND_PROCEED and in case of RESTRICTING on the shunting signal an entrance signal is at STOP - to let a shunting to complete if exist. Until now the shunting moves in those conditions with STOP_AND_PROCEED. It is not realistic, but I didn't found something better. So I hoping on new functions.
I've trying to program for shunting RESTRIGTING for this.
I set shunt_mode = this_sig_lvar(1); at the top similarly I getting other information from functions. Near next_state = next_sig_lr (SIGFN_NORMAL);, for example.
Is it uncorrect?
An intention was to set the values subject to the conditions. And to store them. "1" - for Shunting Mode and "0" to reset.
And then - to set aspect according to those values.

I didn't understand store_lvar well?

(Firstly I put conditions
if (!enabled && (opp_state ==# SIGASP_RESTRICTING))
{
store_lvar(1, 1);
}
if (!enabled && (block_state() ==# BLOCK_OCCUPIED))
{
store_lvar(1, 0);
}
were before if (route_set () ) - no result)

Thank you again and most regards
Oleg

#57 User is offline   VicenteIR 

  • Fireman
  • Group: Status: Active Member
  • Posts: 149
  • Joined: 24-April 15
  • Gender:Male
  • Location:Dimona, Israel
  • Simulator:Open Rails
  • Country:

Posted 28 April 2020 - 05:14 AM

I got the value "shunt_mode" 1 by using function "opp_sig_lr (SigFn_NORMAL) and also removing "!enabled" from the conditions (otherwise it was not work). It is only one change in the script.

#58 User is offline   eugenR 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 472
  • Joined: 15-April 13
  • Gender:Male
  • Simulator:MSTS
  • Country:

Posted 28 April 2020 - 08:41 AM

 VicenteIR, on 28 April 2020 - 05:14 AM, said:

I got the value "shunt_mode" 1 by using function "opp_sig_lr (SigFn_NORMAL) and also removing "!enabled" from the conditions (otherwise it was not work). It is only one change in the script.

Here:
http://www.elvastowe...-in-msts-vs-or/
in Post #7 you can find a definition for ENABLED.

#59 User is offline   VicenteIR 

  • Fireman
  • Group: Status: Active Member
  • Posts: 149
  • Joined: 24-April 15
  • Gender:Male
  • Location:Dimona, Israel
  • Simulator:Open Rails
  • Country:

Posted 29 April 2020 - 11:47 PM

After maybe one hundred times of reading I finally understanded what do you mean.
(How stupid I can to be...((()
Obviously, I can have some more questions than the subject. If so, I'll ask them in the topic that you've pointed. I think - this is not for Developing Futures.

One more question about the storing of variables please.
If this logic is correct?:
Conditions => store_lvar (key, value)
Another Conditions => store_lvar (same key, different value)
Function always checking for value that stored by key
If the value returned => get state
If returned another value => get different state.
?

Thanks
Oleg

#60 User is offline   roeter 

  • Vice President
  • Group: Status: Elite Member
  • Posts: 2,424
  • Joined: 25-October 11
  • Gender:Male
  • Country:

Posted 30 April 2020 - 12:48 AM

Basically, yes, that is correct.
One thing to remember, though: the variables are stored and set per signal, not per signal head.
So if a signal has multiple heads, these can access (both set and read) variables for other heads.
But if separate heads use variables in different ways, these must not use the same variables.

Regards,
Rob Roeterdink

  • 8 Pages +
  • « First
  • 4
  • 5
  • 6
  • 7
  • 8
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users