0
votes

I would like to release an amount of pallets to certain times loaded from my databases with a dynamic event. So for example at 6 am 50 pallets should leave my pallet rack. At 8 am another 20 pallets should leave the PR. I get the following function but I don't know how I use it in connection with a dynamic event and the parameters which determine the quantities of the pallets. So where can I insert the parameter? In this function below or should I create a dynamic event where I use the pallets in "action". I read a lot about dynamic events but don't understand it in connection with a database.

List< Date > dates=selectFrom(database).list(database.dates);
for(Date date : dates ) {
    Date today=date();
    long diff = date.getTime() - today.getTime();
    create_MyDynamicEvent(diff,MILLISECOND);
}

database

1
can you show your database structure in which you hold the dates and the quantities? - Felipe
@Felipe I did it. I also tried it with parameters with the different amounts - JackSock

1 Answers

0
votes

the dynamic events can take arguments... when you create it with arguments... Like this:

dynamic event with arguments

then you can generate the event with the argument that defines the quantity that you need to use: create_MyDynamicEvent(diff,MILLISECOND, amount);

Then in your dynamic event you release the required pallets, however you do that.

Your code will be:

List< Tuple > amounts =selectFrom( my_db ).list();
for( Tuple tup : amounts ) {
    Date today=date();
    Date future=tup.get(my_db.dates);
    long diff = future.getTime() - today.getTime();
    int amount=tup.get(my_db.amount);
    create_MyDynamicEvent(diff,MILLISECOND,amount);
}