Elvas Tower: Container management - Elvas Tower

Jump to content

Posting Rules

All new threads will be started by members of the Open Rails team, Staff, and/or Admins. Existing threads started in other forums may get moved here when it makes sense to do so.

Once a thread is started any member may post replies to it.
  • 8 Pages +
  • « First
  • 2
  • 3
  • 4
  • 5
  • 6
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Container management Rate Topic: -----

#41 User is offline   cjakeman 

  • Executive Vice President
  • PipPipPipPipPipPipPipPipPip
  • Group: ET Admin Group
  • Posts: 3,031
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 02 May 2022 - 01:03 PM

View PostCsantucci, on 01 May 2022 - 07:08 AM, said:

Chris, I wanted to start with Json, but I've seen that there isn't the possibility to directly read a Vector3 (X, Y, Z), which is instead available for the StfReader, and which is quite useful for this function.
Also an item.AsBoolean(parameter) seems to be missing.
I am a zero in writing/expanding parsers, so I'd need help here if I have to use Json.

Sure. I'll take a look tomorrow and get back to you.

#42 User is offline   gpz 

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

Posted 03 May 2022 - 05:17 AM

View PostCsantucci, on 01 May 2022 - 07:08 AM, said:

Chris, I wanted to start with Json, but I've seen that there isn't the possibility to directly read a Vector3 (X, Y, Z), which is instead available for the StfReader, and which is quite useful for this function.

See an example here, how a vector3 can be defined in json:
https://github.com/K...TF/Box.gltf#L77
(This is a 3-element array.)

#43 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Posts: Elite Member
  • Posts: 7,445
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 03 May 2022 - 06:07 AM

Thanks Peter,
it's clear how to define it. The problem (only for me) is how to parse it.

#44 User is offline   gpz 

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

Posted 03 May 2022 - 06:30 AM

The Vector3 struct is defined in the MonoGame package, while the json parser in the NewtonSoft.Json package, so they don't know about each other. Json can be parsed into float[], and that can be written into Vector3, I think.

#45 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Posts: Elite Member
  • Posts: 7,445
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 03 May 2022 - 10:50 PM

Yes, that is a possible, indirect, solution. But in my ignorance I don't know how to read an array using Json parser calls...

#46 User is offline   gpz 

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

Posted 04 May 2022 - 12:54 AM

You may define the whole json structure as classes, like here:
https://github.com/p....cs#L1599-L1630

Then you can deserialize the string like this:
https://github.com/p...tfShape.cs#L338

It can be done in one pass for the whole complex object.

#47 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Posts: Elite Member
  • Posts: 7,445
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 04 May 2022 - 02:30 AM

Thanks Peter,
I'll study that.

#48 User is offline   cjakeman 

  • Executive Vice President
  • PipPipPipPipPipPipPipPipPip
  • Group: ET Admin Group
  • Posts: 3,031
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 04 May 2022 - 10:08 AM

Hi Carlo,

View Postcjakeman, on 02 May 2022 - 01:03 PM, said:

Sure. I'll take a look tomorrow and get back to you.

Still working on this.

I'm preparing a PR which extends Source\Orts.Parsers.OR\JsonReader.cs, but I was hoping to provide some parsing for you too.

Here is the test data I am using. Basically contains a list of objects each with Boolean, Vector3, free text, enum text and ints. Hope that will be a good starting point.

Attached Image: 2022-05-04 19_06_59-_C__dev_OR_cjakeman_openrails_Program_a.containers-or - Notepad++.jpg

#49 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Posts: Elite Member
  • Posts: 7,445
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 04 May 2022 - 11:35 PM

Hi Chris and Peter,
in the meantime I could solve my problems. By analogy I could add an AsBoolean and for the vectors I used this simple syntax
		"IntrinsicShapeOffset": [0,1.17,-6.118],

which I was able to parse.

Thank you for your time.

#50 User is offline   cjakeman 

  • Executive Vice President
  • PipPipPipPipPipPipPipPipPip
  • Group: ET Admin Group
  • Posts: 3,031
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 07 May 2022 - 10:49 AM

View PostCsantucci, on 01 May 2022 - 07:08 AM, said:

Chris, I wanted to start with Json, but I've seen that there isn't the possibility to directly read a Vector3 (X, Y, Z), which is instead available for the StfReader, and which is quite useful for this function.
Also an item.AsBoolean(parameter) seems to be missing.
I am a zero in writing/expanding parsers, so I'd need help here if I have to use Json.

If a JSON file is known to be valid then, using the JSON library, it can be read in a single statement (as it is currently in Updater, ActivityEditor and TrackViewer).

If it might be edited as a text file, then we can use OR's JsonReader class to parse data and report any issues in the log with the appropriate line number.
Aspects to consider include:

  • ensuring required properties are present
  • allowing optional properties to be present or absent
  • ignoring unexpected properties (if desired)

An example which reads valid data and invalid data, including Boolean and a Vector3, is now available at https://github.com/c...-container-file It also shows working with required, optional and unexpected properties.

I know Carlo already has a working solution, but this example shows how OR's JsonReader class is meant be used.


I've now submitted a PR which adds AsBoolean() and AsVector3() to OR's JsonReader class as used in this example. Credit to James for improving my attempt.

#51 User is offline   James Ross 

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

Posted 07 May 2022 - 12:34 PM

View Postcjakeman, on 07 May 2022 - 10:49 AM, said:

If a JSON file is known to be valid then, using the JSON library, it can be read in a single statement (as it is currently in Updater, ActivityEditor and TrackViewer).

If it might be edited as a text file, then we can use OR's JsonReader class to parse data and report any issues in the log with the appropriate line number.
Aspects to consider include:

All code should use "JsonReader" unless granted an exception. It provides a more familiar, more performant way to load JSON than the other options in all but exceptional cases.

View Postcjakeman, on 07 May 2022 - 10:49 AM, said:

I know Carlo already has a working solution, but this example shows how OR's JsonReader class is meant be used.

I've now submitted a PR which adds AsBoolean() and AsVector3() to OR's JsonReader class as used in this example. Credit to James for improving my attempt.

There are still some small outstanding issues with the code, so please bear that in mind when taking code out of the example to use.

#52 User is offline   Laci1959 

  • Superintendant
  • Group: Posts: Elite Member
  • Posts: 1,131
  • Joined: 01-March 15
  • Gender:Male
  • Simulator:Alföld
  • Country:

Posted 07 May 2022 - 10:48 PM

View PostJames Ross, on 07 May 2022 - 12:34 PM, said:

All code should use "JsonReader" unless granted an exception. It provides a more familiar, more performant way to load JSON than the other options in all but exceptional cases.


There are still some small outstanding issues with the code, so please bear that in mind when taking code out of the example to use.


Who will be better off using JSON?

For programmers who write the OR program?
For the average user because the program will load faster to run?
For the average user who has weaker hardware and is running win 7 for some outside reason?
Or for the user who is trying to build a track as a driver, a traffic person, or an absolute outsider? Since it is not supported by any graphical track editor, it will not be an easy thing with the animated container anyway, but at least it is / was in a familiar environment.

#53 User is online   superheatedsteam 

  • Engineer
  • Group: Posts: Contributing Member
  • Posts: 608
  • Joined: 28-June 08
  • Location:Perth, WA
  • Country:

Posted 07 May 2022 - 11:40 PM

View PostLaci1959, on 07 May 2022 - 10:48 PM, said:

Who will be better off using JSON?


I'm not a programmer, but from the examples of JSON I have just seen from a google search, it is not some cryptic format and to me is human readable. If it makes programming and data exchange easier for the programmers, then I'm all for it.

Average 'user' will not care or know about JSON.

Average 'content creator' has demonstrated ability to learn new skills, adding JSON to their skill set should be insignificant in comparison.

Cheers,

Marek.

#54 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Posts: Elite Member
  • Posts: 7,445
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 11 May 2022 - 04:46 AM

Thanks for the JsonReader additions!

#55 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Posts: Elite Member
  • Posts: 7,445
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 18 May 2022 - 07:11 AM

There weren't progress reports since some time, because I decided to allow for more flexibility in use of 20 and 40ft containers. So, where a 40ft container was present and then unloaded, one can load two 20ft containers. This seems quite a trivial issued, but required a rethinking and rewriting of the FreightAnimDiscrete design.
Now FreightAnimDiscretes are no more defined by the player at game startup, remaining immutable in number, position, length; instead, they are generated dynamically depending from the load that is present. To be more clear, suppose to have a single-stack wagon able to get up to 80ft of containers. It could e.g. be loaded (from rear to front) with a 20ft, then with a 40ft, the with a 20 ft container. The 40ft container could be unloaded, generating a "hole" of 40ft, that eventually can be filled with two 20ft containers. And so on.
Another feature now is that, as announced, the container list present in a wagon can be defined in the .con file. This way the same .wag file can be used to carry different container combinations.
The possibility to define in the .wag file the containers present is still available in a simplified way, because wagon developers could prefer it. The two load definition methods can co-exist in the same consist.
Here an example of an entry in the .con file(I have used Peter's suggestion):
		Wagon (
			WagonData ( DTTX_620040_A ATW.DTTX_620040 )
			LoadData ( 20cmacgm common.containerdata CenterFront)
			LoadData ( 20hamburgsud common.containerdata CenterRear)
			LoadData ( 40msc common.containerdata Above)			
			UiD ( 11 )
		)

So this doublestacker has two 20ft containers below and a 40ft container above. The three parameters for each LoadData entry are the name of the load (container) description file, its folder within Trainset, and the position of the container in the wagon. Possible positions are Rear, CenterRear, Center, CenterFront, Front, Above.
The load description file has a .loa extension and is a simple Json file. Here an example of file 20cmacgm.loa:
{
	"Container": 
	{
		"Name" : "cmacgm",
		"Shape" : "COMMON.FREIGHT_Sgns/Sgns_0-20-0-001.s",
		"ContainerType" : "C20ft",
		"IntrinsicShapeOffset": [0, 1.17, 0],
	}
}

The IntrinsicShapeOffset X, Y and Z are the coordinates (within the container's shape file) of the center of the bottom face of the container (the one that lays on the wagon). Unfortunately in many existing container shapes the coordinates of this point are not 0, 0, 0.

To the .wag file following lines must be added
		ORTSFreightAnims (
		MSTSFreightAnimEnabled ( 0 )
		WagonEmptyWeight( 12.575t )
		EmptyMaxBrakeForce ( 47kN )
		EmptyMaxHandbrakeForce ( 15kN )
		EmptyORTSDavis_A ( 465.8 )
		EmptyORTSDavis_B ( 3.2 )
		EmptyORTSDavis_C ( 0.9942 )
		EmptyCentreOfGravity_Y ( 2.02 )
		IsGondola ( 0 )
		UnloadingStartDelay ( 2 )
		LoadingEndDelay ( 2 )
		LoadingAreaLength ( 14.6 )
		AboveLoadingAreaLength ( 16.15 )
		DoubleStacker ()
		Offset( 0 0.34 0 )
		IntakePoint ( 0 6.0 Container)
		)

which are the general FreightAnimation parameters, independent from the specific container load present.
(The physical parameters up to EmptyCentreOfGravity_Y ( 2.02 ) might be fully wrong for this type of wagon).
LoadingAreaLength and AboveLoadingAreaLength are the length in meters of the area available for the container load.
DoubleStacker means that the wagon can carry stacked containers.
The Offset is the offset within the .s file of the center point of the loading area.
Offset.Z is always equal to the first parameter of IntakePoint.

Here instead an example of the part needed in a .wag file with "pre-loaded" containers:
	ORTSFreightAnims (
		MSTSFreightAnimEnabled ( 0 )
		WagonEmptyWeight( 21.5t )
		EmptyMaxBrakeForce ( 47kN )
		EmptyMaxHandbrakeForce ( 15kN )
		EmptyORTSDavis_A ( 465.8 )
		EmptyORTSDavis_B ( 3.2 )
		EmptyORTSDavis_C ( 0.9942 )
		EmptyCentreOfGravity_Y ( 2.02 )
		IsGondola ( 0 )
		UnloadingStartDelay ( 2 )
		LoadingEndDelay ( 2 )
		IntakePoint ( -0.15 6.0 Container)
		LoadingAreaLength ( 12.19 )
		Offset (0 1.215, -0.15)

		FreightAnimStatic (
            			SubType( Default )
			FreightWeight( 0.01t )
			Shape( "..\\COMMON_Container_3d\\FA-Sggrss_576\\CZ-MT-Sggrss_579_40FA-A.s" )
			Offset( 0.0, 0.0, 0.0 )
            			Flip ( 0 )
        			)
		LoadData ( 40HCmaersk common.containerdata Center)
		)


As can be seen, the general part has the same data as the first example, then there is a static freightanim (nothing has changed for them), and then there may be one or more LoadData entries, that have the same format as the ones in the .con file.

All this now seems to work here, and I'll provide to the small developer group of this feature a new Test environment.
By the way Laci's container gantry was integrated in the test route and is working too with this feature.

There is another design and coding area now that requires significant upgrading, which is the allocation logic within the Container handling areas (and which hasn't changed up to now). Now there is no check on container length, which is not an issue if only 40ft containers are managed (which is indeed the most common case), but if there is a mixture of lengths, one should avoid that a 40ft container is stacked over a 20ft container. Also movements between wagons and stacking areas should be at least partially optimized. Furthermore it should be possible to "pre-load" container stations with containers.

When this task will be finished (no idea about the time needed) the feature can go public.

  • 8 Pages +
  • « First
  • 2
  • 3
  • 4
  • 5
  • 6
  • Last »
  • 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