Cancel
Showing results for 
Search instead for 
Did you mean: 

Insert data from one table into another table depending on the time

Experimenter
Experimenter

Hi,

 

I am currently working with the software Plant Simulation. I am still not very familiar with the software, that is why I need your help.

 

I am simulating a goods elevator which transports pallets from one level to another in a specific time. All in all the elevator approaches nine levels (basement, ground floor, level 1 to 7). Each level "produces" an amount of pallets which need to go to different levels. The amounts shall change every day. My simulation works fine if I simulate a single day, but now I want that the simulation runs several days and that the amounts of pallets change automatically. 

 

I distribute the pallets by using a "creationTable" which is inserted into the source of each level that produces the pallets. The distribution occurs percental. This is recorded in the creationTable (see two attached document "CreationTable"). The column attribute refers to another table with contains the information about the destination level (integer). Now these percental data shall change each day.

 

Therefore I inserted an extra table in plant simulation (see attached document "Amounts") which already has all the information needed. Each column represents one day (Column caption contains the date). The rows contain the percental data for each level. How can I connect these two tables, so that with every new day the data changes in the creationTable?

 

I also would like to change the total amount of pallets that leave the level (e.g. day 1: level 1 produces 120 pallets and on day 2: level 1 produces 90 pallets). This information is saved in the row in which the current level is saved. The following rows underneath are the percental data in which the total amount of pallets is split.

 

I hope you understand my problem and can help me to solve it. Thanks in advance for your effort. :-)

 

Kristen

4 REPLIES

Re: Insert data from one table into another table depending on the time

Legend
Legend

Kristen:

 

You could copy the data from one table to another in a method that executes once per day in your simulation.

 

First, create a Init method in your model if one does not yet exist. Then in Init, add the line of code:

 

ref(UpdateTable).methCall(86400);

 

This will cause the the UpdateTable method to first be executed 24 hours into your simulation run.

 

In the UpdateTable method, you'll want to determine the day # (or column to reference in Amounts), copy the data to the creationTable, and then schedule the next execution of UpdateTable.

 

-- UpdateTable method

 

is

     dayNumber : integer;

do

 

     -- get current day number

     dayNumber := ceil(time_to_num(EventController.SimTime)/86400);

 

     -- use dayNumber as column # in Amounts and copy data as needed

 

     -- schedule next update

     self.methCall(86400);

end;

 

Re: Insert data from one table into another table depending on the time

Experimenter
Experimenter

Hi RobertG,

 

thank you so much it works!!

 

One little question left. I simulate in a timeframe from march till the end of june 2015. If I run the simulation at once  how can I get a report for each day that shows me how many palettes arrived in one level (see the attached example). Otherwise the simulations gives me one report at the end of the simulation with all palettes moved in these four months.

 

Thanks in advance!

Kristen

 

 

Re: Insert data from one table into another table depending on the time

Legend
Legend

Glad to hear it worked.

 

To report daily arrivals, you could do something similar and execute a method every 24 hours to update a table with the number of deliveries.

 

In the Init method, schedule first update of daily report:

 

ref(UpdateReport).methCall(86400);


In UpdateReport, record the number of arrivals in the past day by subtracting the sum of the previously recorded arrivals from the current overall total deliveries.

 

-- UpdateReport method

 

is

     dayNumber : integer;
     nextRow : integer;

do

 

     -- get current day number

     dayNumber := ceil(time_to_num(EventController.SimTime)/86400);

 

     -- column 1 is day number
     -- column 2 is number of deliveries for the day

 

     nextRow := DeliveryReport.YDim + 1;
     DeliveryReport[1,nextRow] := dayNumber;
     DeliveryReport[2,nextRow] := TotalDeliveries - DeliveryReport.sum({2,1}..{2,nextRow-1});


     -- schedule next update

     self.methCall(86400);

end;

 

You'll also need to delete all the entries in DeliveryReport between runs by adding DeliveryReport.delete to your Init or Reset method.

Re: Insert data from one table into another table depending on the time

Experimenter
Experimenter

Great! Thank you so much, you helped a lot. :-)

 

Everything works fine.

 

Greetings,

 

Kristen