Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: support for Train.xml to TrainEditor2 (WIP) #417

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

s520
Copy link
Contributor

@s520 s520 commented Jan 6, 2020

This PR change unlimited number of tracks for motor sounds. (#349)
This feature is not intended to be available in Train.dat. It will be available in Train.xml.

I have not tested more than three tracks yet.

Update: 2020/01/14

I change the purpose of this PR to add support for Train.xml to TrainEditor2.
Therefore, I want to determine the specifications of Train.xml.

@s520 s520 changed the base branch from MotorTrailer to master January 14, 2020 07:13
@s520 s520 changed the title Change: unlimited number of tracks for motor sounds (WIP) Add: support for Train.xml to TrainEditor2 (WIP) Jan 14, 2020
@s520
Copy link
Contributor Author

s520 commented Jan 17, 2020

Currently, I assume the following structure for Train.xml:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<openBVE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Train>
    <Handle>
      <HandleType>Separate</HandleType>
      <PowerNotches>8</PowerNotches>
      <BrakeNotches>8</BrakeNotches>
      <PowerNotchReduceSteps>0</PowerNotchReduceSteps>
      <EbHandleBehaviour>NoAction</EbHandleBehaviour>
      <LocoBrakeType>Combined</LocoBrakeType>
      <LocoBrakeNotches>0</LocoBrakeNotches>
      <DriverPowerNotches>8</DriverPowerNotches>
      <DriverBrakeNotches>8</DriverBrakeNotches>
    </Handle>
    <Cab>
      <Position>0, 0, 0</Position>
      <DriverCar>0</DriverCar>
    </Cab>
    <Device>
      <Ats>AtsSn</Ats>
      <Atc>None</Atc>
      <Eb>false</Eb>
      <ConstSpeed>false</ConstSpeed>
      <HoldBrake>false</HoldBrake>
      <ReAdhesionDevice>TypeA</ReAdhesionDevice>
      <LoadCompensatingDevice>0</LoadCompensatingDevice>
      <PassAlarm>None</PassAlarm>
      <DoorOpenMode>SemiAutomatic</DoorOpenMode>
      <DoorCloseMode>SemiAutomatic</DoorCloseMode>
    </Device>
    <Cars>
      <Car>
        <IsMotorCar>true</IsMotorCar>
        <Mass>40</Mass>
        <Length>20</Length>
        <Width>2.6</Width>
        <Height>3.2</Height>
        <CenterOfGravityHeight>1.5</CenterOfGravityHeight>
        <LeftDoorWidth>1000</LeftDoorWidth>
        <LeftDoorMaxTolerance>0</LeftDoorMaxTolerance>
        <RightDoorWidth>1000</RightDoorWidth>
        <RightDoorMaxTolerance>0</RightDoorMaxTolerance>
        <FrontAxle>8</FrontAxle>
        <RearAxle>-8</RearAxle>
        <FrontBogie>
          <FrontAxle>0</FrontAxle>
          <RearAxle>0</RearAxle>
          <Reversed>false</Reversed>
          <Object />
        </FrontBogie>
        <RearBogie>
          <FrontAxle>0</FrontAxle>
          <RearAxle>0</RearAxle>
          <Reversed>false</Reversed>
          <Object />
        </RearBogie>
        <ExposedFrontalArea>5</ExposedFrontalArea>
        <UnexposedFrontalArea>1.6</UnexposedFrontalArea>
        <Performance>
          <Deceleration>1</Deceleration>
          <CoefficientOfStaticFriction>0.35</CoefficientOfStaticFriction>
          <CoefficientOfRollingResistance>0.0025</CoefficientOfRollingResistance>
          <AerodynamicDragCoefficient>1.2</AerodynamicDragCoefficient>
        </Performance>
        <Delay>
          <DelayPower>
            <Up>0, 0, 0, 0, 0, 0, 0, 0</Up>
            <Down>0, 0, 0, 0, 0, 0, 0, 0</Down>
          </DelayPower>
          <DelayBrake>
            <Up>0, 0, 0, 0, 0, 0, 0, 0</Up>
            <Down>0, 0, 0, 0, 0, 0, 0, 0</Down>
          </DelayBrake>
          <DelayLocoBrake>
            <Up></Up>
            <Down />
          </DelayLocoBrake>
        </Delay>
        <Move>
          <JerkPowerUp>1000</JerkPowerUp>
          <JerkPowerDown>1000</JerkPowerDown>
          <JerkBrakeUp>1000</JerkBrakeUp>
          <JerkBrakeDown>1000</JerkBrakeDown>
          <BrakeCylinderUp>300</BrakeCylinderUp>
          <BrakeCylinderDown>200</BrakeCylinderDown>
        </Move>
        <Brake>
          <BrakeType>ElectromagneticStraightAirBrake</BrakeType>
          <LocoBrakeType>NotFitted</LocoBrakeType>
          <BrakeControlSystem>None</BrakeControlSystem>
          <BrakeControlSpeed>0</BrakeControlSpeed>
        </Brake>
        <Pressure>
          <BrakeCylinderServiceMaximumPressure>480</BrakeCylinderServiceMaximumPressure>
          <BrakeCylinderEmergencyMaximumPressure>480</BrakeCylinderEmergencyMaximumPressure>
          <MainReservoirMinimumPressure>690</MainReservoirMinimumPressure>
          <MainReservoirMaximumPressure>780</MainReservoirMaximumPressure>
          <BrakePipeNormalPressure>490</BrakePipeNormalPressure>
        </Pressure>
        <Acceleration>
          <Entry>1, 1, 25, 25, 1</Entry>
        </Acceleration>
        <Motor>
          <PowerTracks>
            <Track>
              <Pitch>
                <Vertex>0.0, 0.0</Vertex>
              </Pitch>
              <Volume>
                <Vertex>0.0, 0.0</Vertex>
              </Volume>
              <SoundIndex>
                <Vertex>0.0, 0.0</Vertex>
              </SoundIndex>
            </Track>
          </PowerTracks>
          <BrakeTracks>
            <Track>
              <Pitch>
                <Vertex>0.0, 0.0</Vertex>
              </Pitch>
              <Volume>
                <Vertex>0.0, 0.0</Vertex>
              </Volume>
              <SoundIndex>
                <Vertex>0.0, 0.0</Vertex>
              </SoundIndex>
            </Track>
          </BrakeTracks>
        </Motor>
        <Reversed>false</Reversed>
        <Object></Object>
        <LoadingSway>false</LoadingSway>
      </Car>
    </Cars>
    <Couplers>
      <Coupler>
        <Min>0.27</Min>
        <Max>0.33</Max>
        <Object></Object>
      </Coupler>
    </Couplers>
  </Train>
</openBVE>

Are there any missing items or improvements?
Please tell me your opinion.

@leezer3
Copy link
Owner

leezer3 commented Jan 17, 2020

Initial Thoughts:

  • Not sure the cab section is necessary. We've got the InteriorView avaiable in the Car section, so that could probably go. Just use DriverCar to specify the default starting interior car?
  • With the ATS etc, the device probably needs the type in a sub-node? This would then allow specific properties to be changed for each device. (OdaykufanATS is a development of the internal ATS systems, and a lot of the features could / should probably be pulled out by default)
  • Might want to think about renaming some properties? For example, we could probably loose the Delay from the front of all the delay related properties?

Secondary:

  • I think we need the ability to specify units for a number string in the XML (This is on my list of things to work on, as MSTS does this). Keep the current units as default, but it's something to think about.
  • Things like the power / sound curves should probably be separatable into single files. We can do this for cars already, but they're going to be common properties.

@s520
Copy link
Contributor Author

s520 commented Jan 17, 2020

  1. The Cab section.
<openBVE>
  <Train>
    <Cab>
      <Position>0, 0, 0</Position>
      <DriverCar>0</DriverCar>
    </Cab>
  </Train>
</openBVE>

Change as follows:

<openBVE>
  <Train>
    <InitialDriverCar>0</InitialDriverCar>
    <Cars>
      <Car>
        <Cab>
          <DriverPosition>0, 0, 0</DriverPosition>
          <Panel>panel.xml</Panel>
        </Cab>
      </Car>
    </Cars>
  </Train>
</openBVE>
  1. Please give a more specific explanation. I do not have enough understanding.

  2. Simplify the name of the "Delay" section.

<openBVE>
  <Train>
    <Cars>
      <Car>
        <Delay>
          <Power>
            <Up>0, 0, 0, 0, 0, 0, 0, 0</Up>
            <Down>0, 0, 0, 0, 0, 0, 0, 0</Down>
          </Power>
          <Brake>
            <Up>0, 0, 0, 0, 0, 0, 0, 0</Up>
            <Down>0, 0, 0, 0, 0, 0, 0, 0</Down>
          </Brake>
          <LocoBrake>
            <Up></Up>
            <Down />
          </LocoBrake>
        </Delay>
      </Car>
    </Cars>
  </Train>
</openBVE>
  1. I will consider setting units.

  2. It is a matter of how much the file is divided. In my opinion, the "Car" section itself and the sections it contains and the "Coupler" section should be splittable. Do you think splitting this far is overkill?

@leezer3
Copy link
Owner

leezer3 commented Jan 17, 2020

That's correct for the first, although we already have an existing InteriorView node.

The second:

<Device>
      <Ats>
            <Type>AtsSn</Type>
      </Ats>
</Device>

Opening a random OdaykufanATS equipped train (Chasanai 5000 series) has a whole bunch of changable parameters for the devices:

[ATS-Sx]
DurationOfAlarm = 5
DurationOfInitialization = 3
DurationOfSpeedCheck = 0.55

[ATS-P]
DurationOfInitialization = 3
DurationOfBrakeRelease = 0.0
DesignDeceleration = 2.445
BrakePatternDelay = 0.5
BrakePatternOffset = 0
BrakePatternTolerance = 0
WarningPatternDelay = 5.5
WarningPatternOffset = 50
WarningPatternTolerance = -5
ReleaseSpeed = 15
MaximumSpeed = 120

[ATC]
AutomaticSwitch = false
EmergencyOperation = 15

Whilst obviously, we don't support these at the minute, I think it makes sense to allow the format to be extended if required in the future.

The 5th I don't know on, it's something that can be done either way.
Having said that, most other simulators (MSTS, OpenRails, RailWorks) have the sound properties in a separate file.
It's easy enough to do later on though, so I wouldn't worry too much about it as a first step.

@s520
Copy link
Contributor Author

s520 commented Jan 17, 2020

Thank you for the detailed explanation.
I start working.

@s520
Copy link
Contributor Author

s520 commented Feb 18, 2020

I made TrainEditor2 read and write Train.xml.
Please check it.

Also, I want to put Up and Down in the Move section of Train.xml.

        <Move>
          <JerkPower>300, 580</JerkPower>
          <JerkBrake>300, 580</JerkBrake>
          <BrakeCylinder>300, 200</BrakeCylinder>
        </Move>

Are there any other sections I should summarize?

I make the Brake section refinement and ReAdhesionDevice configurable for each car.

@s520
Copy link
Contributor Author

s520 commented Feb 21, 2020

Train.xml format was updated again.
Are each item divided into appropriate sections?

@leezer3 - Please tell me your opinion.
And about the units, how do you define them?
I think it's better to use XML attributes for the description, but I'm struggling with defining units.
Whether the user is free to define units like Animated Script, or do we define some units?

I searched for the format of MSTS, but did not understand.
If you refer to the format of MSTS, please let me know the homepage that explains it.

@leezer3
Copy link
Owner

leezer3 commented Feb 21, 2020

Units:
This is a sample from a MSTS engine file:

Wagon ( 3DTS_45xx_BR
    Type ( Engine )
    WagonShape ( 3DTS_45xx_BR.s )
    Size  ( 2.861906m 3.989765m 10.7m )
    CentreOfGravity ( 0m 1.981387m 0m )
    Centre ( 0m 0m 0m )
    Mass       ( 62t )
    InertiaTensor ( Box(3.1m 3.9m 10m) )
    Coupling (
		Type ( Chain )
		Spring (
			Stiffness ( 1e3N/m 5e6N/m )
			Damping ( 1e6N/m 1e6N/m )
			Break ( 1.2e9N 1.2e9N )
			r0 ( 3cm 8cm )
		)
	Velocity ( 0.1m/s )
	)
	Buffers (
		Spring (
			Stiffness ( 1e6N/m 1e9N/m )
			Damping ( 1e6N/m/s 1e6N/m/s )
			r0 ( 5cm 10cm )
		)
		Centre ( 0.5 )
		Radius ( 1 )
		Angle ( 0.5deg )
	)

The required unit is entered as a textual string at the end of the number, and the parser internally then converts the string into what it uses inside.
If we take the size string, it supports meters centimeters etc.

I can see plenty of ways for this to go wrong, but it'd be helpful to have, as it makes building something from a prototype much easier when you can just enter the 'real' numbers rather than having to abstractly convert them into what the sim uses internally.
It also allows for a much better visual experience when editing the file by hand.

Nowhere near a request but rather a half-baked idea- Say if you think it's a bad one!


In general, this seems very reasonable (and TBQH the first version or two are likely to have a little trial and error involved).
Only real trouble is that the sheer size of the changes make it very hard to review :)

@s520
Copy link
Contributor Author

s520 commented Feb 25, 2020

Units have been implemented for some items.
Please look at the length and pressure of the Car setting 1&2 in TrainEditor2.

Ex)

<MinimumPressure Unit="Kilopascal">690</MinimumPressure>

The abbreviation kPa can also be used.

@leezer3
Copy link
Owner

leezer3 commented Feb 25, 2020

Now that is brilliant, hadn't thought of using an attribute but it makes perfect sense!

@s520
Copy link
Contributor Author

s520 commented Feb 25, 2020

Thanks! I will proceed as it is.

@s520
Copy link
Contributor Author

s520 commented Mar 3, 2020

I have completed adding units.
Next, I check the operation and create a parser for the main sim.

@s520
Copy link
Contributor Author

s520 commented Mar 4, 2020

As with other configuration files, I changed the internal path of the intermediate file to a relative path.
This change makes it easier for others to verify editor bugs that are reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants