leezer3 / OpenBVE

OpenBVE- A free train simulator
http://www.openbve-project.net
275 stars 52 forks source link

[Bug] The delay of electric brake #737

Closed enjoysoftware closed 2 years ago

enjoysoftware commented 2 years ago

Description

In BVE2,4, there is an item in train.dat that allows you to set the delay time of the electric brake as shown in the image below. In this setting item, you can set the time from when the brake is applied until the electric brake is activated. However, OpenBVE completely ignores this item. With OpenBVE, the electric brake will start immediately after the brake is applied, resulting in unnatural operation. Screenshot from 2022-02-04 20-52-28 In the example in this image, the electric brake is activated 0.5 seconds after the brake is applied. Documentation in BVE Trainsim Official Website scr Can OpenBVE do this?

Route

--

Train

Any trains made for BVE Trainsim

Logs

--

Related information

Any platforms

leezer3 commented 2 years ago

That sounds like a bug will take poke.

enjoysoftware commented 2 years ago

I didn't know it was a bug. I'm sorry to write it in an incomprehensible way. Therefore, I change the title.

leezer3 commented 2 years ago

Now that's really interesting....

OpenBVE never seems to have implemented these. This is from 2016- https://github.com/leezer3/OpenBVE/blob/0d929f4042cfc566c405e0829cd1ddaf67f8b348/openBVE/OpenBve/OldParsers/TrainDatParser.cs#L200 The parser only goes up to the 4th parameter, and ignores everything beyond that. Presumably an oversight from Michelle etc. originally.

When the independant LocoBrake was introduced (not widely used), these two parameter numbers were used to control the loco brake delay. Should be able to sort something out, but it might be a little messy :/

leezer3 commented 2 years ago

See what you think with today's build.

For the minute, I haven't added this to the hold brake, only manually activated brake applications (as otherwise it wouldn't work at all well IMHO), but open to suggestions if you think it should work differently.

enjoysoftware commented 2 years ago

https://user-images.githubusercontent.com/47489953/152627341-1d451e1c-34e5-4658-a65a-11f095e5119b.mp4

I checked if the electric brake delay works properly on the Keisei Chiba Line on the official website of BVE Trainsim 4. According to train.dat of this train data, the electric brake should be activated 1 second after the brake is activated, but it still did not work properly with OpenBVE.

leezer3 commented 2 years ago

Hmm...

Reworked the approach slightly, please give it another try.

I've also added a small tweak so that it displays a readme file (if present) when the train.txt isn't missing, which makes the Keisei train look a little better.

enjoysoftware commented 2 years ago

The electric brake now works properly! thank you. When I tested, there were still a few bugs in the brakes.

enjoysoftware commented 2 years ago

https://user-images.githubusercontent.com/47489953/152641449-42d3fd49-19cb-4f56-b287-90595c414ed7.mp4

leezer3 commented 2 years ago

Delay: Ah, I think you're expecting it to keep the previous deceleration when the notch changes for the value of the delay period. Might need a little more twiddling to work in this way..... Probably ought to see what BVE4 does in this regard too.

Air brake: This hasn't been touched (and this code can't affect it as far as I can see). Is this the handle delay in action?

enjoysoftware commented 2 years ago

This hasn't been touched

In BVE Trainsim,the air brake operates from the time the handle delay time has elapsed until the electric brake starts operating. I'm sorry for the expressions that are difficult to understand. I am not good at English, so I have to study it harder :) If you thought it difficult to understand what I say , feel free to let me know. In that case, we will send you a comparison video with BVE4.

leezer3 commented 2 years ago

It's no problem, that's what I thought.

I think we might have a wider issue here, which probably would explain things: Looking a little closer at Mackoy's documentation, it suggests that the delay section should be structured in this order:

  1. PowerUp
  2. PowerDown
  3. ElectricBrakeUp
  4. ElectricBrakeDown
  5. BrakeUp
  6. BrakeDown

On the other hand, OpenBVE has always had this order: https://openbve-project.net/documentation_hugo/en/trains/train_dat.html#delay

  1. PowerUp
  2. PowerDown
  3. BrakeUp
  4. BrakeDown

Essentially, I think we've always been reading the electric brake delay values into brake delay. This is something I'm not necessarily happy with changing, as most trains designed for OpenBVE are likely to have been written with this bug in mind. A possibility might be to detect the BVE2 / BVE4 header & flip these two values in only this circumstance, but there are plenty of trains with an OpenBVE exterior and an older train.dat version. The other thing is that in most (all?) cases, these values are likely to be very similar, and hence changing them isn't likely to have much effect??

enjoysoftware commented 2 years ago

Certainly Mackoy documentation says:

  1. PowerUp
  2. PowerDown
  3. ElectricBrakeUp
  4. ElectricBrakeDown
  5. BrakeUp
  6. BrakeDown

This is the order of the User Interface of BVE Trainsim's Train Editor items, not the order of the train.dat entries. I edited train.dat in the Train Editor for BVE Trainsim and found that entries in train.dat was written like following:

PowerUp PowerDown BrakeUp BrakeDown ElectricBrakeUp ElectricBrakeDown Therefore, it seems to have little impact on other old train data.

leezer3 commented 2 years ago

Thanks- I'm glad that's not the case :) (This sort of mess is one of the major reasons I'd like to fully complete the XML formats- At least these are 100% clear on what you're editing)

Have sorted the delay when changing up brake notch, but done nothing to the air brake at the minute. Needs more investigation on that one.....

enjoysoftware commented 2 years ago

When I tested it again at Keisei Chiba Line, the delay of electric brake worked fine!

enjoysoftware commented 2 years ago

Sorry for the late reply. Thank you for setting the electric brake delay in the train editor as well. We will close this issue because it has been resolved. I will open the issue of air brake if needed. I'm really thankful to you.