News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Sequential loading vehicles during Gradual load/unload.

Started by hreintke, August 29, 2021, 12:40:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hreintke

Can be intended behaviour but I see differences in load/unload process with gradual procsess.

Unload : All vehicles in the convoi are processed in parallel.
Load   : Vehicles are loaded in sequence, no paralell processing.

It happens when multiple vehicles with the same goods are being loaded.


Within simconvoi::hat_gehalten :

Due to gradual loading, a vehicle only gets partially loaded.
Then is checked (line 3020)

if (v->get_total_cargo() < v->get_cargo_max()) {
// not full
cargo_type_prev = v->get_cargo_type();
}

Which then prevents (partial) loading of the other vehicles (line 3015)

if(cargo_type_prev==NULL  ||  !cargo_type_prev->is_interchangeable(v->get_cargo_type())) {
// load
amount += v->load_cargo(halt, destination_halts, max_amount-amount);
unloading_state &= amount==0;
}


I expected loading also being handled in paralel.


Edit :

In the load/unload process there is the check


wants_more |= (amount == max_amount)  &&  (v->get_total_cargo() < v->get_cargo_max());


-> stop loading when not all possible cargo is loaded this step.

But it can be that the incomplete loading is caused by the unloading speed of another convoi.

f.e.
Loading convoi max_amount = 20
Unloading convoi max_amount = 10

Unload step 1 -> available 10
Load   step 1 -> load 10 (less than max_amount) -> can leave
Unload step 2 -> another 10 available.

I think the loading should continue until the unload has completed.


wants_more |= ("loaded cargo amount" > 0)  &&  (v->get_total_cargo() < v->get_cargo_max());

prissi


hreintke

Did not do a complete test but two issues now.

1/ When to start loading


if(  max_amount > amount  &&  !no_load  &&  !next_depot  &&  v->get_total_cargo() < v->get_cargo_max()  ) {


You only try to load when a "under max" unload has been completed.
But loading is possible when vehicle is not full.


if( !no_load  &&  !next_depot  &&  v->get_total_cargo() < v->get_cargo_max()  ) {



2/ Check departure

Yous still check for departure when max is not loaded, but there can be a unload in process.


wants_more |= (amount == max_amount)  &&  (v->get_total_cargo() < v->get_cargo_max());



Log file

From hat_gehalten
CV 99 convoi loading
CV Prod convoi unloading


Message: HG : t = 86943138 (3) CV 99
Message: HG : 86943138 unload 0 max = 16
Message: HG : 86943138 load 0, max = 16
Message: HG : 86943138 unload 0 max = 16
Message: HG : 86943138 Check depart (3) CV 99
Message: HG : t = 86943331 (3) CV 99
Message: HG : 86943331 unload 0 max = 16
Message: HG : 86943331 load 0, max = 16
Message: HG : 86943331 unload 0 max = 16
Message: HG : 86943331 Check depart (3) CV 99
Message: HG : t = 86943331 (2) CV Prod
Message: HG : 86943331 unload 1 max = 1    <== Not trying to load
Message: HG : 86943331 unload 1 max = 1    <== Not trying to load
Message: HG : 86943331 unload 1 max = 1
Message: HG : 86943331 unload 1 max = 1
Message: HG : t = 86943528 (3) CV 99
Message: HG : 86943528 unload 0 max = 16
Message: HG : 86943528 load 4, max = 16
Message: HG : 86943528 unload 0 max = 16
Message: HG : 86943528 Check depart (3) CV 99  <== Check departure when load is coming in
Message: HG : t = 86943528 (2) CV Prod
Message: HG : 86943528 unload 9 max = 9    <== Not trying to load
Message: HG : 86943528 unload 9 max = 9    <== Not trying to load
Message: HG : 86943528 unload 9 max = 9
Message: HG : 86943528 unload 9 max = 9
Message: HG : t = 86943762 (3) CV 99


BTW :
The first unload if a convoi always has max = 1

uint16 max_amount = next_depot ? 32767 : (v->get_cargo_max() * loading_ms) / ((uint32)v->get_desc()->get_loading_time() + 1) + 1;


Because loading_ms will be 0 (zero) at that moment.
Is that intentional ?

Will continue testing.

prissi

1) only start loading after unloading the vehicle is intended. A full unload load cycle should take 2*loading time. Also it is not realistic to fill a tanker half with gasoline while it is still half full of oil. (I know, a car can still have partial load. But the intention was really first unload then load.

2) uint16 max_amount = next_depot ? 32767 : (v->get_cargo_max() * loading_ms) / ((uint32)v->get_desc()->get_loading_time() + 1) + 1; returns at least 1 should v->get_cargo_max() * loading_ms < ((uint32)v->get_desc()->get_loading_time() + 1) So a slow unloading should happen with one unit per step. (Actually, I tested this during development accidentally.)


prissi

But the premature departure when having still goods waiting to load has been fixed, I hope.

hreintke

Yes, that is fixed.
I will do some more testing but that will be next week.