New Route WIP

Page 2 of 4 Previous  1, 2, 3, 4  Next

View previous topic View next topic Go down

Re: New Route WIP

Post by leezer3 on Sun Sep 13, 2015 10:36 pm

The way to get your level crossing working as you want is to use a dummy station.
So:
Code:
.sta Crossing;S;;0;0;1, .stop 0
This simple little bit of code will create a station that only your train should stop at, with a forced red signal.

Next, you require a custom .animated file setup in your signal section, like so:
Code:
Signal(99).Load Route\Signals\LevelCrossing.animated
Place this in your route like this somewhere after your station:
Code:
.Section 0;2;4,.SigF 99;0;0;0
Your animated file then looks like this:
Code:
[Object]
States = LevelCrossing.b3d

[Object]
States = Barrier.b3d
RotateZFunction = [section != 0] * 0.355398163
RotateZDamping = 10, 0.5

That's a very simple animated function, which rotates the barrier if the associated section is not zero (Red)
Twiddle with the damping value to get the barrier rotation speed you require.

Add an appropriate $Rnd directive to the routefile to randomly add these stops at crossings Smile

Your only problem is that these will IIRC show in the auto-generated timetable, but that's no big deal.

Edit:
I've been thinking about your prototypical flashing lights problem.
I don't think it's solvable (At least sensibly anyway)- The best I think you can do is to stop the lights flashing when you're sure the train is well past the crossing.

Your problem is that there's no way to store a value in an animated file, except as the result of the previous itineration of a function.
Whilst we can set a time-period for a barrier to rise easily enough with a simple greater than statement (I.E. If the function result is greater than 5s, apply rotation using the appropriate damping settings), a flash requires resetting the value each time the state toggles.

Headache Razz
I'll keep thinking about it, but I can't see a way round it at the moment.

Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Mon Sep 14, 2015 5:19 am

Thanks for this but I just have clarify some of the details. I currently have a departure signal (with a forced red signal) at the first station with a level crossing about 75 metres after the stop point at the platform. Do I place the dummy station with an associated signal somewhere after the station like at the crossing. However I don't want my train to stop at the crossing just pass through.

I tried your code but does not work with the animation file I have made. I did remove one of the distances to try the section code and that worked but only when I was near the dummy crossing. What I did was add the dummy station at the crossing with a signal and add your animation code to one of boom gates of the animation file I have made. But with a forced red signal doesn't the train need to be in the station stopping area for signal to clear. The gate stays down when I am at the station. Instead it should be up and then go down just before departure time but before the signals clears. Not relevant for the crossing I am talking about but for a crossing after a signal wouldn't this not work as the gates would go down after the signal clears. Is it possible that if the signal is clear the gates get triggered at x distance (eg 400m, 600 m or whatever) and lifts after the train clears the crossing and if the signal is red it does not trigger but triggers before the signal clears.
And with the animation of the crossing I have uses this code before I tried your code:

Code:
[Object]
Position = 25.58,1.82,-2.41
States = red_1_side_one_side.csv,red_2_side_one_side.csv,off.csv
StateFunction = if[trackDistance<=600 & trackdistance[-1]>(-75), mod[value + 1, 2], 2]
RefreshRate = 0.5

[Object]
Position = 20,0.7,-0.8
States = boom_gate_FG1b.csv
RotateXFunction = if[trackDistance <=600 & trackdistance[-1]>(-25), 0, (abs[trackdistance] > 50) * (-1.5)]
RotateXDamping = 1, 1.1


How would I make the crossing be affected by the signal (only if it is red) "and" also the gates to go up after the distance in the code I have currently in use?

Should the custom signal just be a invisible signal? The signal at the station is a modified NWM signal:


Code:
[Object]
Position = 0, -0.25, 0
States = signalLed3_R.csv, signalLed3_y.csv, signalLed3_g.csv
statefunction = section / 2
[Object]
Position = 0, -0.35, 0
States = featherL_unlit_Led.csv, featherL_lit_Led.csv
statefunction = if[section != 0, 1, 0]


And with the flashing lights problem thanks for trying, it would be nice if you can think of something but if you can't I can live without it. Wink
Thanks for helping.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by leezer3 on Mon Sep 14, 2015 1:41 pm

Right, I'm confusing myself, but still; I'm assuming you know what I'm thinking, and have read all the documentation Razz

You need to combine a little more code-
I think what you're forgetting is that the visible object position, and the position of the .SigF & .Section commands can differ.

This is basically what you're after:
Code:
;;Level Crossing Signal
[Object]
States= Signals\LevelCrossing_Red.b3d, Signals\LevelCrossing_Green.b3d
Statefunction = if[section==0, 0, min[value + 0.5*delta/DELAY, 1]]
Position = 0,0,-50

;;Level Crossing Barrier
[Object]
States = LevelCrossing_Barrier.b3d
RotateZFunction = [section != 0] * -1.5
RotateZDamping = 1,1.1
Position = 0,0,-25
Set the DELAY value to an appropriate value in seconds for the barrier to lower.

To position this, the .SigF and .Section commands must be at the place where you wish the barrier to start lowering & adjust the two offsets in the Position commands appropriately.
When the train passes this command, the signal section will revert to 0 (Red), and the barrier will rise.
Triggering the lights requires will require what you've basically already got, with the positions adjusted appropriately.

A little explanation:
Consider this short example:
Code:
1000,  .SigF 0;1;-4;6.39, .Section 0; 2
In this case, using a simple non-offset file our visible signal and it's section are in the same place will be triggered when the train passes position 1000m.

Now, let's try a slightly more advanced animated file referring to the above section as per above:
Code:
[Object]
States= Signals\Red.b3d, Signals\Green.b3d
Statefunction = if[section != 0, 1, 0]
Position = 0,0,-100
This will place our signal object at a -100m offset to the placement of the .animated file in the route.
Thus, when we place our .animated file at 1000m, our visible signal object will actually be placed at 900m.
Any trackdistance statements will always refer to the underlying position of the .animated file (1000m), not that of the visible object.

What is the effect of this?
800m- Before both the visible signal and the .section- Signal remains green.
900m- We pass the visible signal, but *not* the .section command- Signal remains green.
1000m- We pass the section command- The section returned for this signal is now 0, and the visible signal turns red Smile


Signals can be literally anything you want- It makes no difference. It's a little unfortunate that we have to resort to hacks like this, but 90% of the time there will be a way around an issue, even if it's a little circular.

Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Tue Sep 15, 2015 7:12 am

Thanks for this but I am a bit unsure. Of course I know all the documentation off my heart and exactly what you are thinking Smile . I understand with placing the signal object before the signal command and what that does, it was something I didn't think of. But then the signal returning to red after the train passes the signal would take longer to happen which is not prototypical.

Is the code with the delay added to the signal object because the code in your example uses signal objects but the delay is used to lower the barrier?

I confused with the positioning of the signal commands as I not sure what you mean by "where you wish the barrier to start lowering" and you "adjust the two offsets in the Position commands appropriately". I understand the idea with the section command affecting the barrier but wouldn't I place it at the point I want the barrier to go up after the train clears the crossing. Some more information would be helpful.

Now I not sure if your code will work in way I want it but what I want is to stand at the first station waiting for departure time, with the barrier raised and lights not flashing. Then about 30 seconds before departure time the red lights flash and the barriers lower and with the signal (which is a  3 aspect signal, with red, yellow and green) clearing before departure time. 

Not relevant for this crossing but there will be some crossings straight after a signal. Here you may get held at red but not every time. So is there is a way to trigger the barrier at a set distance but if the signal is red the barrier will not be triggered and so they stay up. But then when it's clear but before the signal clears the barrier lowers and the signal clears.

I know this not ideal but thanks for helping. You know more about this than me. Very Happy

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by MattD6R on Wed Sep 23, 2015 9:33 am

If you wouldn't mind could you please answer my questions in my previous post. I don't know enough about the animation format to work this out.

I have added pedestrian crossings on either side of the level crossing. I did manage to work out the animation for the gates which rotate horizontally. Very Happy





MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by leezer3 on Wed Sep 23, 2015 3:51 pm

Sorry, my fault, missed those Smile

When the *first* car of your train passes the .section command, the section will change to red.
We are using the red signal section as a trigger to raise and lower our barriers-
Thus, placing your level crossing at position 0,0,0 in the .animated file means that your gates will start rising when your train is approximately halfway across your crossing. (I'm assuming that you're centering your .b3d / .csv files on 0,0,0)
In order to get the crossing barriers to rise when the whole train has cleared the crossing, we therefore need to offset our physical object (The .b3d file) within our animated file.
Using the Position statement within the .animated file allows us to move the displayed world object relative to the positioning of the .animated file, rather than being affected by the track blocks- An easy way to demonstrate this, is to use an .animated file with a large offset on a very tight curve; You'll notice that the offset moves in a straight line from the position of the .animated file, rather than following the curve of the trackwork.

Moving back to your more specific problems:
Unfortunately, there is no way to easily check the state of two different animations, and this means we need to improvise a little.
Going back to my code:
Code:
;;Level Crossing Barrier
[Object]
States = LevelCrossing_Barrier.b3d
RotateZFunction = [section != 0] * -1.5
RotateZDamping = 1,1.1
Position = 0,0,-25

This should be relatively simple- Our signal section has cleared, and so the barrier rotates.
Code:
;;Level Crossing Signal
[Object]
States= Signals\LevelCrossing_Red.b3d, Signals\LevelCrossing_Green.b3d
Statefunction = if[section==0, 0, min[value + 0.5*delta/DELAY, 1]]
Position = 0,0,-50

The DELAY value in this command is actually rather important- Why?
Without using a delay, when the section clears, our barrier will start to lower, and our signal will clear at exactly the same time Smile
Obviously, this isn't what we're after, as this could potentially mean that our train enters the crossing whilst the barrier is still in motion.
Thus, we need to add a delay to allow our barrier time to lower, before the signal object is changed to green.

Now, go back to my first point Cool
At the moment, if we place our .sigf & .section commands at 2500m, the visible signal will actually be at 2450m, and the barriers are placed at 2475. When the front car of our train reaches 2500m, the barriers will start to rise, and the physical signal object will change back to red. Thus, the offset should be adjusted so that when the .sigf & .section commands are passed, the train has comfortably cleared the crossing.
I suspect you'll probably want distances in the region of -150m for the signal and -100m for the barrier (4 car train plus a small amount of fudge factor)

This is a slightly better piece of code for a three aspect signal (Lifted straight from the documentation!) :
Code:
Statefunction = if[trackDistance>OFFSET | section==0, 0, if[value<0.5, value + 0.5*value/DELAY, section]]

Change OFFSET to the offset you are using in the .animated file (Otherwise it won't return to red after passing the signal), and DELAY to the time taken for the barriers to fall.


It's not much work to adapt this for a crossing without a station:
Code:
;;Level Crossing Barrier
[Object]
States = LevelCrossing_Barrier.b3d
RotateZFunction = if[section != 0, if[trackdistance < APPROACH DISTANCE, -1.5,0],0]
RotateZDamping = 1,1.1
Position = 0,0,-25

All that wants is a couple of slight changes in our conditionals to check both the section and the approach distance in the crossing barrier rotation/ lights.
The conditional is very simple, and works like this:
If the section is not equal to 0 (Green or Y), then check if our trackdistance is less than the approach distance.
If we are within the approach distance, rotate the barrier Smile
On the other hand, if the section is red, then the barrier will not move until it clears, *and* we are within the approach distance.

Using the same signal code will work just fine:
The timer will start counting as soon as the signal turns green, and so if the section is always green, it'll work perfectly.

Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Thu Sep 24, 2015 6:40 am

Thanks for helping Chris. Smile What I have done is shifted the section and Sigf commands to about 175m after the crossing (for a 6 car train). I added the offset to the signal object both to the position command and the statefunction. And I changed the one of boom gate to use section code you provided to test this out.

Am I right that I need to have the animated crossing file at the same track distance as the section and sigf commands and adjust the postion command  in the animated crossing file to place it the correct place? I wondering about this because the signal and the crossing are in different files so I not sure if the crossing is needed to done the same way as the signal object or whether I just leave in its original position.

After doing this the barrier does not rotate at all. I do get the error of: "the function  is not supported in [Unequal[section,0]] in RotateXFunction at line 54 in file C:\openbve\openbve Route and Train Content\Railway\Object\BRN\Crossings\Crossing_Ferny_Grove_1.animated"

This is the new code which came up with the error:
Code:
[Object]
Position = -4,0.7,21.1
States = boom_gate_FG1a.csv
RotateXFunction = [section != 0] * -1.5
RotateXDamping = 1,1.1


I have not adjusted the the position commands to place the barriers at the correct position yet which I not sure if that would stop it from working properly.

I do like the last part of your post as that will be good to simulate when delays are present due to network issues and unrelibity. Laughing I was wondering if was actually possible to get held up at a signal and not every time but it is good that it is possible, though I haven't tried the code yet. Thanks.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by leezer3 on Thu Sep 24, 2015 2:46 pm

You've placed it as a .freeobj
If you use the section keyword in an animated file, it must be placed using the .SigF command Smile

Keep the whole of the level crossing (Signal, barriers, object) in one giant .animated file.

Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Fri Sep 25, 2015 5:19 am

Thanks for that. I added the code from the animated crossing file to the signal file.

I do have an issue with referencing textures and objects because not all the objects and textures referenced in the animation file are located in the same folder or sub folder. These are located in other folders at the same level as the folder that contained this combined animation file in the object directory. So is it possible to step back a directory because in csv object files it can be like this:
Code:
../Crossings/barrier.csv

or do I have to place all the object and texture files in the same folder or sub folder as this animated file. Thanks for helping.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by graymac on Fri Sep 25, 2015 10:18 am

Just prefix another ..\ for every level you want to go back. It's part of good route design to simplify your folder structure to the best you can, as it makes it easier to produce your structures list. I agree, it can sometimes gets a bit messier describing the paths when using .animated files

graymac

Posts : 1708
Join date : 2011-08-28
Location : Co Mayo, Eire

http://www.celtictrainsim.com

Back to top Go down

Re: New Route WIP

Post by MattD6R on Fri Sep 25, 2015 11:59 am

Thanks. I got the paths right and working but not the flashing lights which are in the same folder and the uses exactly the same ../../ path to reference the correct folder. I can't seem to work that one out.
 
I do see simple folder structure as important (I like to keep things simple Very Happy) which I am trying to with Stations, Signals, Track, Rail_Corridor, Common, Signs etc folders with related subfolders.

One thing I was wondering with indexing objects I am having been indexing in the order I using them as I need then. But should I order them in a particular way as its hard to know how the order and number of objects will end up?

And Chris I have all the code in the animated signal file and this:

Code:
[Object]
Position = -4,0.7,21.1
States = ..\..\Crossings\boom_gate_FG1a.csv
RotateXFunction = [section != 0] * -1.5
RotateXDamping = 1,1.1


gives an error of the "the function  is not supported in [Unequal[section,0]] in RotateXFunction at line 69 in file C:\openbve\openbve Route and Train Content\Railway\Object\BRN\Signals\QldSigs_open\3AspectLed_FeatherL.animated"

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by leezer3 on Fri Sep 25, 2015 12:05 pm

Blast, try with curled brackets, not straight brackets Rolling Eyes
Code:
RotateXFunction = (section != 0) * -1.5


Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Fri Sep 25, 2015 12:12 pm

Nope, I get this error

An empty argument is invalid in Times in Times[Unequal[section,0],] in RotateXFunction at line 69 in file C:\openbve\openbve Route and Train Content\Railway\Object\BRN\Signals\QldSigs_open\3AspectLed_FeatherL.animated

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by MattD6R on Fri Sep 25, 2015 12:51 pm

Don't worry about my previous post with that code working when I added brackets around the -1.5. Therefore,
Code:
RotateXFunction = (section != 0) * (-1.5)


MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by MattD6R on Sat Sep 26, 2015 7:37 am

Ok I made some adjustments to the code with placing of the crossing and the correct rotation of the barriers but not in the correct places yet. The barrier stays up and only lowers when the train reaches the position of the sigf command. Then when the train clears the following signal the barrier goes up. Strangely when I removed the brackets I had added I get no error.

Thus:
Code:
[Object]
Position = -2.83,-3.83,-209.3
States = ..\..\Crossings\boom_gate_FG1b.csv
RotateXFunction = (section != 0) * -1.5
RotateXDamping = 1, 1.1


When the signal clears the signal object stays on red and when I pass over the AWS magnet I get the bing as you do with a green signal. When I change the statefunction of the signal back to section/2 it clears to green at departure time so I have the correct signal objects referenced.

The code with the issue is this:
Code:
[Object]
Position = 11.4, 0.7, -237.2
States = signalLed3_R.csv, signalLed3_Y.csv, signalLed3_G.csv
StateFunction = if[trackDistance>-237.2 | section==0, 0, if[value<0.5, value + 0.5*value/15, section]]

[Object]
Position = 11.4, 0.6, -237.2
States = featherL_unlit_Led.csv, featherL_lit_Led.csv
statefunction =  if[trackDistance>-237.2 | section==0, 0, if[value<0.5, value + 0.5*value/15, section]]
;z offset -237.2m, delay 15 sec,


I can't seem to work even though the paths are right that some flashing lights are visible and other are not. I am still using the old code, I am not sure how this would work like the barrier.

The code for the flashing lights was:
Code:
[Object]
Position = -4.4,1.85,21.1
States = ..\..\Crossings\red_1.csv,red_2.csv,off.csv
StateFunction = if[trackDistance<=600 & trackdistance[-1]>(-75), mod[value + 1, 2], 2]
RefreshRate = 0.5


Red_2.csv and off.csv come ups with file not found in States at line...  But Red_1.csv is displayed. Both are in the same folder two folders back, so if Red_1.csv is visible so the other ones should.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by leezer3 on Sat Sep 26, 2015 12:16 pm

You require the ..\ for all files Smile

Code:
States = ..\..\Crossings\red_1.csv,..\..\Crossings\red_2.csv,..\..\Crossings\off.csv

Remember that you're dealing with a very literal parser here- Each comma provides a completely separate path.

Signals not working-
You're not within the distance (My offset explanation wasn't perfect Sad ). Let me try to explain:
If your physical signal is at -237.2m, and you stop at 15m distance from the signal, then the front axle of your train is actually at -253.2m
Increase your distance in the statefunction command by 50m  (But *not* the position) and you'll be good Smile

AWS bings are more problematic-
The animation is somewhat of a bodge job to get around the delay problem, as there's nothing in the signalling code that allows for delays.
I'd kludge it slightly by using permenant magnets:
Code:
.Beacon 44001;0
This .beacon command will always produce an AWS warning, regardless of the state of the signal. I'd call this relatively reasonable behavior for level crossings, although not prototypical Smile

I suppose an additional beacon could be added to the standards to handle delayed approach signals (It's relatively simple logic), but as I'm the only currently active plugin developer, this isn't going to help current trains Razz

Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Sat Sep 26, 2015 1:06 pm

The Flashing lights are now displayed properly, but not affected by the section command which I not sure about how to do that.

I shifted the statefunction of the signal back by 50m (the stop position is 40m behind the signal) but the signal object is still stuck on red at departure. What I want is a bing from the AWS and a green signal at departure time.

The barriers are also not working correctly as I had mentioned which are built in the down position. Thanks.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by MattD6R on Sun Sep 27, 2015 11:05 am

The barrier are working correctly after I changed it to:
Code:
RotateXFunction = (section == 0) * (-1.5)

I can't seem to get the signal to clear from red at departure even after I shifted the statefunction back by 50m. I have the feather displaying correctly when the signal clears but the signal does not clear.
This is the code used with .SigF 1;1;2.8;4.8,.Section 0;2;4,
Code:
[Object]
Position = 11.4, 0.7, -237.2
States = signalLed3_R.csv, signalLed3_Y.csv, signalLed3_G.csv
Statefunction = if[trackDistance-287.2 | section==0, 0, if[value<0.5, value +
0.5*value/10, section]]
[Object]
Position = 11.4, 0.6, -237.2
States = featherL_unlit_Led.csv, featherL_lit_Led.csv
Statefunction = if[section==0, 0, min[value + 0.5*delta/2, 1]]
;signal x offset -237.2, delay 15 sec,

And with code I am using for the flashing lights they are flashing. I tried changing a few parts of it but not working as I would like it. What I did replace the triggering distance with section but I can't seem to make them stop flashing at a later distance so that it does not stop flashing before the barrier goes up.
This is what I have at the moment.

Code:
[Object]
Position = 16.77,-1.99,-210.2
States = ..\..\Crossings\red_1.csv,..\..\Crossings\red_2.csv,..\..\Crossings
\off.csv
StateFunction = if[section > 0 & trackdistance[-1]>(-50), mod[value + 1, 2], 2]
RefreshRate = 0.5

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by thehoviskid on Sun Sep 27, 2015 11:57 am

MattD6R wrote:What I want is a bing from the AWS and a green signal at departure time.
You won't get a bing from the AWS if the signal changes once you're passed the magnet- you'll keep the sunflower until you next pass a clear signal

thehoviskid

Posts : 128
Join date : 2011-07-09
Age : 39
Location : Heysham

Back to top Go down

Re: New Route WIP

Post by MattD6R on Sun Sep 27, 2015 12:10 pm

I am aware of that. I want the signal to clear to green at departure and so when I pass over the magnet I would get the bing. This magnet and signal is just after the end of the platform and before the level crossing.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by MattD6R on Sat Oct 03, 2015 11:25 pm

Chris, help with this would be appreciated, if possible. Smile As I have mentioned in a previous reply the signal does not clear and I am having trouble getting the flashing lights to stop flashing at a later distance.

I did post code for the signal with a mistake in it but correcting that did not sort out the problem. The code I have is:
Code:
Position = 11.4, 0.7, -237.2
States = signalLed3_R.csv, signalLed3_Y.csv, signalLed3_G.csv
Statefunction = if[trackDistance>-287.2 | section==0, 0, if[value<0.5, value + 0.5*value/10, section]]

Also currently I am working on the car park on the other side of the station.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by leezer3 on Sun Oct 04, 2015 8:36 pm

Sorry, been meaning to sort this out...

Your main problem is somewhat of a confusion with the distances. That's mostly my fault for just posting OFFSET Rolling Eyes
To quote the documentation for trackDistance (It's atrociously worded, but I didn't write it...):
Is positive when the train is in front of the object, negative when behind, and zero when the object lies between the ends of the train.
An example:
Object placed at 2000m
Train is at 1800m- trackDistance value is 200
Train is at 2000m- trackDistance value is 0
Train is at 2200m- trackDistance value is -200

In other words, your current offset code will only trigger when the train is 287.2m past your object.
Code:
StateFunction = if[trackDistance>287.2 | section==0, 0, if[value<0.5, value + 0.5*value/10, section]]

That appears to work as you're after Smile
Small note:
This assumes your section command looks like this:
.Section 0;1;2
If your section command looks like this (BRSigs_Open 3-aspect):
.Section 0;2;4
The code you require looks like this:
Code:
StateFunction = if[trackDistance>287.2 | section==0, 0, if[value<0.5, value + 0.5*value/10, (section /2)]]


Flashing lights:
Code:
StateFunction= if[trackDistance > 287.2 | trackDistance < 250,0  ,if[section!=0, 2,mod[value +1, 2]]]

Same basic difference, this triggers the flashing when you're between 287.2 and 250m from the position of the .sigF command, and the section is not zero.
(I've assumed 3 states for the flashing lights- Totally off, on, and flash off)

Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Mon Oct 05, 2015 2:58 am

After using the new code the signal object does not clear. I have .SigF 1;1;2.8;4.8,.Section 0;2;4, at a distance of 850 and the stop point: .Stop ;;;6, at a distance of 570. That is within the 287.2 in the signal code but I don't know much about the animation format and I am relying on what you are saying. Wink

As for the flashing lights it not working correctly. I am using 3 states with 2 red lights: red light on one side flashes, red light on other side flashes and both lights off. With your code it flashes before the departure time, then stop flashing when the signal should clear and then one of the red lights stays on when the train approaches the crossing and this continues after the train clears the crossing.

So the code added for the flashing lights is :
Code:
States = ..\..\Crossings\red_1.csv,..\..\Crossings\red_2.csv,..\..\Crossings\off.csv
StateFunction= if[trackDistance > 287.2 | trackDistance < 250,0  ,if[section!=0, 2,mod[value +1, 2]]]
RefreshRate = 0.5

When I change it to:
Code:
States = ..\..\Crossings\off.csv,..\..\Crossings\red_1.csv,..\..\Crossings\red_2.csv,
It also goes not work with one light flashing before departure and then this changes to the other light staying on when the signal should clear and then both off when the train approaches the crossing.

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by leezer3 on Mon Oct 05, 2015 2:53 pm

This is what comes of copying and pasting too much Rolling Eyes
The problem is I've been editing a copy of my posts, not the direct code from my animated file. Copy that with an error in the official documentation, and we're in a muddle Smile
Signal:
Code:
StateFunction = if[trackDistance>287.2 | section==0, 0, if[value<0.5, value + 0.5*delta/10, (section /2)]]

The third instance of value should of course be delta.

A slightly amended version of the flashing lights function:
Code:
StateFunction = if[trackDistance > 287 | trackDistance < 0,2  ,if[section==0, 2,mod[value +1, 2]]]

Expected states are:
Flashing state 1, flashing state 2 and off Smile

For good measure, my full .animated test file:
Code:
;;Signal
[Object]
Position = -3, -1.65, 0
States = ..\..\BRSigs_Open\Signal3_r.csv,..\..\BRSigs_Open\Signal3_y.csv,..\..\BRSigs_Open\Signal3_g.csv
StateFunction = if[trackDistance>287.2 | section==0, 0, if[value<0.5, value + 0.5 * delta/5, section/2]]
RefreshRate = 1


;;Flashing Lights
[Object]
Position = -3, 3.65, 0
States = ..\..\BRSigs_Open\Signal3_r.csv,..\..\BRSigs_Open\Signal3_y.csv,..\..\BRSigs_Open\Signal4_g.csv
StateFunction = if[trackDistance > 287 | trackDistance < 250,2  ,if[section==0, 2,mod[value +1, 2]]]
RefreshRate = 1

(The positions of the physical objects aren't offset so I could watch what was going on easily)

Cheers

Chris Lees

http://www.bvecornwall.co.uk

leezer3

Posts : 750
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Re: New Route WIP

Post by MattD6R on Tue Oct 06, 2015 6:48 am

With the signal it works, its so nice to see a green signal at departure instead of red every time. Very Happy

And the flashing lights also works properly. However I tried changing the second distance to -200 so that the lights stop flashing after the barriers reach the vertical. But that does not work and I am not sure how to get that working. Actually the same thing happens before the barrier drop with the warning with the flashing lights that the barriers are going to lower, but that might not be possible.

The offsets in my animation file does need to be repositioned in the proper places as the crossing was build at the position of where the crossing is be displayed. The road surface will need to be dropped (but not the whole object as one side ended up going thorough the track ballast when I tried that!) as a different gradient is used at SigF track position compared to the crossing track position. Pity I can't just split this up the animation file into two files.

Thanks for your efforts, I wouldn't know how to do this myself. Smile

MattD6R

Posts : 214
Join date : 2013-06-16
Location : Brisbane, Australia

Back to top Go down

Re: New Route WIP

Post by Sponsored content Today at 10:26 pm


Sponsored content


Back to top Go down

Page 2 of 4 Previous  1, 2, 3, 4  Next

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum