Good morning, When you put the option sequence in a source with the generateasbatch option, the source only create once the parts of the batch and then it doesn do nothing for infinite time. Well, I would like to know how to order the source to generate another batch when a variable comes true, in other words, to generate a second batch when i want but without using generatecyclicaly.
Solved! Go to Solution.
To date, the Source is assumed to create MUs as an independent process. This does make sense, because we mostly need at least one external trigger to start a production process.
But I get your case and have come across it several times as well. Currently, you need to program it yourself. There is no command for the Source to push in the next "batch" of MUs. You can create an observer method to initiate the triggering of your MU creation method, say "CreateMUsOnTrigger". Then you need a table, which is basically the same as your sequence table, and a row counter.
Here is a suggestion:
for i:=1 to SequenceTable["Number",RowCounter] loop .MUs.Entity.create(Buffer)--or: SequenceTable["MU",RowCounter].create(Buffer) next RowCounter+=1
BTW, I think it would be a good enhancement of the Source, to make it create MUs on demand.
As to provide another way to use the source to do what you want.
Recently I have been using an attribute within the source to count out the MU's, subtracting 1 from it in the exit control, when it reaches 0 then I lock the exit of the source so no more MU's can leave. Then to get out a new batch I set the number to how many MU's I want to create and then unlock the exit.
-- Exit Control of Source
self.~.Count -= 1 if self.~.Count = 0 self.~.ExitLocked := true end
-- Code to generate next batch Source.Count := 50 -- 50 MU's to be created Source.ExitLocked := false
You can place the code to realise the next batch where you like and can trigger it from code and not just from the signal produced by the generator. I would also recomend setting it in the init method as well if you want it to be produced when you first hit start.