Elvas Tower: MEP - F4 window crashes OR. - Elvas Tower

Jump to content

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

MEP - F4 window crashes OR. Rate Topic: -----

#11 User is offline   dennisat 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 474
  • Joined: 16-February 13
  • Gender:Male
  • Simulator:Open Rails & MSTS
  • Country:

Posted 03 March 2014 - 02:19 PM

 roeter, on 03 March 2014 - 12:49 PM, said:

Can you tell me which method etc. you have put this patch?
Perhaps I can look a bit deeper and put you on the road to the root of the problem.

Regards,
Rob Roeterdink

The method is "splitSection" in "signals.cs". I added a test (float.isNaN) to the existing tests for very small numbers. The lists being scanned to calculate the distance of the train from a track object must be ultimately derived from TDB data. I haven't dug any further yet.

I'm still at the stage where I have to check the C# manuals to understand how a lot of the code works as well as work out how the TDB is arranged.

Dennis

#12 User is offline   roeter 

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

Posted 03 March 2014 - 04:19 PM

 copperpen, on 03 March 2014 - 01:27 PM, said:

I am not sure my crash has the same cause. GetTrainInfo seems to be failing in this instance, possibly because OR cannot place train 23 and so fails on the total train count. The activity will run without the F4 window but without that, speed limits are invisible and signal aspects are not that easy to see.


I can assure you that the problem with train 23 has nothing to do with this, train 23 simply never becomes a real 'train'. There is also no such thing as a 'total train count'. The crash in F4 occurs when it attempts to sort the information on distance - an invalid distance value in one of the items in this list would cause this to crash.

 dennisat, on 03 March 2014 - 02:19 PM, said:

The method is "splitSection" in "signals.cs". I added a test (float.isNaN) to the existing tests for very small numbers. The lists being scanned to calculate the distance of the train from a track object must be ultimately derived from TDB data. I haven't dug any further yet.


If you throw an exception when an invalid value is found [ using throw new InvalidDataException("...") ], the program will crash but it will generate a call dump, which will tell where the method was called. This will indicate if the invalid position comes from a signal or a cross-over, as the method is called in the processing of both these items.
When it is known where the method was called when an invalid number occurs, trace statements can be added at that location which dump the ident of the item being processed to the log-file. The last item before the crash is the one which is probably causing the problems.

Regards,
Rob Roeterdink

#13 User is offline   dennisat 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 474
  • Joined: 16-February 13
  • Gender:Male
  • Simulator:Open Rails & MSTS
  • Country:

Posted 04 March 2014 - 12:22 AM

 roeter, on 03 March 2014 - 04:19 PM, said:

If you throw an exception when an invalid value is found [ using throw new InvalidDataException("...") ], the program will crash but it will generate a call dump..


Thanks, I'll give it a try today.

Dennis

#14 User is offline   dennisat 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 474
  • Joined: 16-February 13
  • Gender:Male
  • Simulator:Open Rails & MSTS
  • Country:

Posted 04 March 2014 - 12:27 AM

 copperpen, on 03 March 2014 - 02:15 PM, said:

Maybe, but this is right at the start of the activity, or any time after.

You'll find quite a few of these in MEP, many of them with AI that just shuffles up and down a platform. Presumably this is to give more activity at locations you pass or stop at. I've found that you can adjust the path slightly so that OR will accept it and it will still work in MSTS. It's a bit fiddly. However, because OR doesn't use the same algorithms as MSTS to time AI, you'll usually find the train has gone when you pass the point you're meant to see it.

Dennis

#15 User is offline   dennisat 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 474
  • Joined: 16-February 13
  • Gender:Male
  • Simulator:Open Rails & MSTS
  • Country:

Posted 04 March 2014 - 09:31 AM

 roeter, on 03 March 2014 - 04:19 PM, said:

If you throw an exception when an invalid value is found [ using throw new InvalidDataException("...") ], the program will crash but it will generate a call dump...
Rob Roeterdink


What a tedious day.

However I have now tracked back to method TryTrackSectionCurved in signals.cs. I am working from X2060.
In this method is a calculation var radiansAlongCurve = (float)Math.Asin(l.Z / trackSection.SectionCurve.Radius); which returns a non float number in the instance I'm trying to track because l.Z = 196.3618 and trackSection.SectionCurve.Radius = 196.28 which yields a value of 1.000416... which of course is too big to be a sine so radiansAlongCurve is left null.
This affects the subsequent calculations and tests and finally allows a TrackNodeCandidate to be passed back with a null parameter lon.
This ultimately crashes the Track Monitor and may cause other problems that I've not noticed yet.

The question is now how do I locate the relevant TDB entries and/or the Track piece causing this problem from this point.

I have to do some chores now for a couple of hours - it'll be a nice rest.

Dennis

#16 User is offline   roeter 

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

Posted 04 March 2014 - 11:57 AM

Welcome to the world of bug chasing - it is often a tedious and slow affair and can really leave you completely dazzeld :party: .
Anyway - you're almost there. If you stop in TryTrackSectionCurved (which is in traveller.cs, by the way), take a look at the variable trackVectorSection - this is a class, which holds all information on the related track section : the section type, shape, the tile in which it is located, the tile UiD and it's position.
Interesting to find out what's going wrong here :derisive: .

Regards,
Rob Roeterdink

#17 User is offline   gpz 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,772
  • Joined: 27-October 12
  • Gender:Male
  • Location:Budapest
  • Simulator:OpenRails
  • Country:

Posted 04 March 2014 - 12:14 PM

Based on Dennis' finding, it looks like the "if" test before the line Dennis mentioned is principally wrong:
// Compute distance along curve (ensure we are in the top right quadrant, otherwise our math goes wrong).
if (l.Z < -InitErrorMargin || l.X > trackSection.SectionCurve.Radius + InitErrorMargin || l.Z > trackSection.SectionCurve.Radius + InitErrorMargin)
    return null;
var radiansAlongCurve = (float)Math.Asin(l.Z / trackSection.SectionCurve.Radius);


The last part is: || l.Z > trackSection.SectionCurve.Radius + InitErrorMargin
With this condition the asin function can really fail. It should be just simply: || l.Z > trackSection.SectionCurve.Radius

#18 User is offline   copperpen 

  • Executive Vice President
  • Group: Status: Elite Member
  • Posts: 3,144
  • Joined: 08-August 05
  • Gender:Male
  • Simulator:MSTS & OR
  • Country:

Posted 04 March 2014 - 12:43 PM

Removing the + InitErrorMargin as suggested has allowed the activity to run with the F4 window open. Thank you Dennis for ploughing through the code.

Next thing is to edit this activity and see why two consists are not appearing in OR.

#19 User is offline   James Ross 

  • Open Rails Developer
  • Group: Status: Elite Member
  • Posts: 5,492
  • Joined: 30-June 10
  • Gender:Not Telling
  • Simulator:Open Rails
  • Country:

Posted 04 March 2014 - 01:00 PM

 gpz, on 04 March 2014 - 12:14 PM, said:

Based on Dennis' finding, it looks like the "if" test before the line Dennis mentioned is principally wrong:
// Compute distance along curve (ensure we are in the top right quadrant, otherwise our math goes wrong).
if (l.Z < -InitErrorMargin || l.X > trackSection.SectionCurve.Radius + InitErrorMargin || l.Z > trackSection.SectionCurve.Radius + InitErrorMargin)
    return null;
var radiansAlongCurve = (float)Math.Asin(l.Z / trackSection.SectionCurve.Radius);


The last part is: || l.Z > trackSection.SectionCurve.Radius + InitErrorMargin
With this condition the asin function can really fail. It should be just simply: || l.Z > trackSection.SectionCurve.Radius


AFAICT, removing that means there's no acceptable error margin any more on that edge, which makes the code much worse. If we need to clamp the values for the Asin calculation, that's fine, but do that instead of messing with the actual "are we on this curve" test, please.

#20 User is offline   gpz 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,772
  • Joined: 27-October 12
  • Gender:Male
  • Location:Budapest
  • Simulator:OpenRails
  • Country:

Posted 04 March 2014 - 01:28 PM

Then modify it like this:
            if (l.Z < -InitErrorMargin || l.X > trackSection.SectionCurve.Radius + InitErrorMargin || l.Z > trackSection.SectionCurve.Radius + InitErrorMargin)
                return null;
            float radiansAlongCurve;
            if (l.Z > trackSection.SectionCurve.Radius)
                radiansAlongCurve = MathHelper.PiOver2;
            else
                radiansAlongCurve = (float)Math.Asin(l.Z / trackSection.SectionCurve.Radius);


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