Elvas Tower: CallOn - Elvas Tower

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

CallOn

#1 User is offline   jorgegonzalito 

  • Hostler
  • Group: Status: Active Member
  • Posts: 72
  • Joined: 13-May 13
  • Gender:Male
  • Simulator:MSTS
  • Country:

Posted 12 August 2021 - 11:27 AM

Hello, I am trying to implement the code necessary for a locomotive to enter a sector occupied by cars, to be able to fulfill its "#dispose >> $ attach etc".

I need to modify the following script, from what I was able to figure out:

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 ||
		block_state() !=# BLOCK_CLEAR ||
		!route_set())
	{
		state = SIGASP_STOP;
	}
	else
	{
		state = SIGASP_CLEAR_2;
	}

	draw_state = def_draw_state (state);


I tried to understand as much as I could, even though I don't know how to speak English, but in all the threads that I visited, there is talk of a code "to replace" that I can't find in any script of all the ones I have (not just the one exposed) . I am totally disoriented.

#2 User is offline   roeter 

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

Posted 12 August 2021 - 11:48 AM

It is the check on BLOCK_CLEAR which needs to be replaced.
In the script as shown, the signal will only clear if the block ahead is fully clear of trains, i.e. not occupied.
If callon is required, there must be a separate check on BLOCK_OCCUPIED.

The most simple form of the script would be :

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 ||
                block_state() ==# BLOCK_JN_OBSTRUCTED ||
                !route_set())
        {
        // route is not available
                state = SIGASP_STOP;
        }
        else if (block_state() ==# BLOCK_CLEAR)
        {
        // route is clear
                state = SIGASP_CLEAR_2;
        }
        else
        // block_state is now BLOCK_OCCUPIED, this is the call on situation
        {
                state = SIGASP_RESTRICTED;
        }

        draw_state = def_draw_state (state);


In the above script, any train will always proceed on block occupied.
That's probably not what you want, so an additional check must be inserted to ensure trains will only be allowed to pass if the block is occupied if they have a reason to do so, e.g. when attaching.
This check can be do with the function TrainHasCallOn().

The final 'else' would then be :

        else
        // block_state is now BLOCK_OCCUPIED, this is the callon situation
        {
            state = SIGASP_STOP;    // default state is stop
            if (TrainHasCallOn())   // if train has callon allowed, it may pass this signal
            {
                state = SIGASP_RESTRICTED;
            }
        } 


You can find full description of the TrainHasCallOn function in the manual.

Regards,
Rob Roeterdink

#3 User is offline   jorgegonzalito 

  • Hostler
  • Group: Status: Active Member
  • Posts: 72
  • Joined: 13-May 13
  • Gender:Male
  • Simulator:MSTS
  • Country:

Posted 12 August 2021 - 12:26 PM

Rob, thanks for your reply. The script now looked like this:

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 || block_state() ==# BLOCK_JN_OBSTRUCTED || !route_set())
	{
		state = SIGASP_STOP;
	}
	else if (block_state() ==# BLOCK_CLEAR)
	{
		state = SIGASP_CLEAR_2;
	}
	else
	// block_state is now BLOCK_OCCUPIED, this is the callon situation
	{
		state = SIGASP_STOP;
		if (TrainHasCallOn())
		{
			state = SIGASP_RESTRICTED;
		}
	}

	draw_state = def_draw_state (state);


But it didn't work for me. The locomotive continues to stay on the red signal.

#4 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 12 August 2021 - 03:01 PM

Try this:

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 || block_state() ==# BLOCK_JN_OBSTRUCTED || !route_set())
        {
                state = SIGASP_STOP;
                if (TrainHasCallOn())
                {
                        state = SIGASP_RESTRICTED;
                }
        }
        else if (block_state() ==# BLOCK_CLEAR)
        {
                state = SIGASP_CLEAR_2;
        }
        else

        draw_state = def_draw_state (state);


My standard for implementing call-on looks like so:

	if (!enabled)
	{
		state = SIGASP_STOP;
	}
	else if (block_state() ==# BLOCK_OCCUPIED)
	{
		if (TrainHasCallOn())
		{
			state = SIGASP_RESTRICTING;
		}
		else
		{
			state = SIGASP_STOP;
		}
	}


#5 User is offline   jorgegonzalito 

  • Hostler
  • Group: Status: Active Member
  • Posts: 72
  • Joined: 13-May 13
  • Gender:Male
  • Simulator:MSTS
  • Country:

Posted 12 August 2021 - 06:20 PM

View Postebnertra000, on 12 August 2021 - 03:01 PM, said:

Try this:

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 || block_state() ==# BLOCK_JN_OBSTRUCTED || !route_set())
        {
                state = SIGASP_STOP;
                if (TrainHasCallOn())
                {
                        state = SIGASP_RESTRICTED;
                }
        }
        else if (block_state() ==# BLOCK_CLEAR)
        {
                state = SIGASP_CLEAR_2;
        }
        else

        draw_state = def_draw_state (state);


My standard for implementing call-on looks like so:

	if (!enabled)
	{
		state = SIGASP_STOP;
	}
	else if (block_state() ==# BLOCK_OCCUPIED)
	{
		if (TrainHasCallOn())
		{
			state = SIGASP_RESTRICTING;
		}
		else
		{
			state = SIGASP_STOP;
		}
	}



Don't work :(

After much testing, this script works:

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 && route_set() )
		{
		if (block_state == #BLOCK_CLEAR)
		{
			state = #SIGASP_CLEAR_2;
		}
		else if (block_state == #BLOCK_OCCUPIED && TrainHasCallOn() )
		{
			state = #SIGASP_STOP_AND_PROCEED;
		}
		else
		{
			state = #SIGASP_STOP;
		}
	}

draw_state = def_draw_state (state);


At first the signs are red, as they should be. Afterwards, they turn green, It works fine with $attach, but when the train passed, it never turned red again and the train that came after have green signal when the first one still did not go away.

I can't believe this is so complicated. I have never had so much trouble with signals, as now, that I want to implement $attach and /runround. To top it all, there are no forums in Spanish where you can ask this. Spanish speakers only upload photos and talk about their routes, without getting into technicalities.

#6 User is offline   jorgegonzalito 

  • Hostler
  • Group: Status: Active Member
  • Posts: 72
  • Joined: 13-May 13
  • Gender:Male
  • Simulator:MSTS
  • Country:

Posted 13 August 2021 - 06:56 AM

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 && route_set() )
                {
                if (block_state == #BLOCK_CLEAR)
                {
                        state = #SIGASP_CLEAR_2;
                }
                else if (block_state == #BLOCK_OCCUPIED && TrainHasCallOn() )
                {
                        state = #SIGASP_STOP_AND_PROCEED;
                }
                else
                {
                        state = #SIGASP_STOP;
                }
        }

draw_state = def_draw_state (state);


What is missing from this script so that when the locomotive crossed, the signal turns red again?

Sorry for so many questions, I can't get the signal to work correctly in the different situations: when should it stay red, when should it change to green, when should it return to red, when should it allow $attach, $pickup or /runround.

Thanks.

#7 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 13 August 2021 - 08:16 AM

Unless Rob or someone else steps in, I'm going to do a couple tests when I get home tonight

#8 User is offline   roeter 

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

Posted 13 August 2021 - 11:41 AM

One item to look at, which was not mentioned yet - and my apologies for that - is what states are defined in the sigcfg.dat file for this signal.
Originally, the signal only used SIGASP_CLEAR_2 and SIGASP_STOP.
Now, it also uses SIGASP_STOP_AND_PROCEED or SIGASP_RESTRICTED. But are these states properly defined in the sigcfg.dat file? If not, it can cause all sorts of problems.

As for the script in post #6 : it's missing a SIGASP_STOP state if not enabled or the route is not set (first if).
Best option is to set a default state = SIGASP_STOP before the first if, that will ensure the signal returns to red after the train has passed.
The last else can then be deleted.

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;

        state = #SIGASP_STOP;

        if (enabled && route_set() )
                {
                if (block_state == #BLOCK_CLEAR)
                {
                        state = #SIGASP_CLEAR_2;
                }
                else if (block_state == #BLOCK_OCCUPIED && TrainHasCallOn() )
                {
                        state = #SIGASP_STOP_AND_PROCEED;
                }
        }

draw_state = def_draw_state (state);


If this does not work, and the signal always stays red, experiment with removing the "route_set()" option, or the "enabled" option.

Regards,
Rob Roeterdink

#9 User is offline   jorgegonzalito 

  • Hostler
  • Group: Status: Active Member
  • Posts: 72
  • Joined: 13-May 13
  • Gender:Male
  • Simulator:MSTS
  • Country:

Posted 14 August 2021 - 07:35 AM

I can no longer do any more tests, I need to continue with the Timetable that I am creating. At the entrance of the platform, I will place a new buried signal, with this script:

SCRIPT EverGreen
extern float state;
state = SIGASP_CLEAR_2;


CallOn don't work.

#10 User is offline   systema 

  • Fireman
  • Group: Status: Active Member
  • Posts: 107
  • Joined: 16-March 15
  • Gender:Male
  • Location:The Heart of Cheshire
  • Simulator:Open Rails
  • Country:

Posted 18 October 2021 - 02:56 PM

View Postroeter, on 13 August 2021 - 11:41 AM, said:

One item to look at, which was not mentioned yet - and my apologies for that - is what states are defined in the sigcfg.dat file for this signal.
Originally, the signal only used SIGASP_CLEAR_2 and SIGASP_STOP.
Now, it also uses SIGASP_STOP_AND_PROCEED or SIGASP_RESTRICTED. But are these states properly defined in the sigcfg.dat file? If not, it can cause all sorts of problems.

As for the script in post #6 : it's missing a SIGASP_STOP state if not enabled or the route is not set (first if).
Best option is to set a default state = SIGASP_STOP before the first if, that will ensure the signal returns to red after the train has passed.
The last else can then be deleted.

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;

        state = #SIGASP_STOP;

        if (enabled && route_set() )
                {
                if (block_state == #BLOCK_CLEAR)
                {
                        state = #SIGASP_CLEAR_2;
                }
                else if (block_state == #BLOCK_OCCUPIED && TrainHasCallOn() )
                {
                        state = #SIGASP_STOP_AND_PROCEED;
                }
        }

draw_state = def_draw_state (state);


If this does not work, and the signal always stays red, experiment with removing the "route_set()" option, or the "enabled" option.

Regards,
Rob Roeterdink


Does the additional state STOP_AND_PROCEED have to be added to the signal aspects in the configuration file for the signal type?

Mick Clarke
MEC

  • 2 Pages +
  • 1
  • 2
  • 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