I am currently trying to get a line to hold entities until a certain number have built up. There is a little more going on, but that is basically what I want to do.
This is the section of code:
?.ExitLocked := true
waituntil LT.PackoutCap = 10 prio 1
LT.PackoutCap := 0
LT.PackoutOrd := "0"
?.Exitlocked := false
waituntil LT.PackoutEj = 10 prio 1
LT.PackoutEj := 16
It works fine as far as stopping the MUs, but the issue comes when it should release them. As I understand it from the help, MUs that try to exit while the exit is locked should try to exit again when the exit is locked. However, when the target number of MU's is present the exit unlocks, but the MUs just sit there. I tried adding the @.move, which works to get one of them to move, but that is it.
Solved! Go to Solution.
Try instead something like the following which will loop through all of the MUs on the Line and move them all.
for var MU := 1 to ?.ContentsList.YDim ?.ContentsList["Object", MU].Move next
Ok so I am getting an error. It is telling me that the index must be an integer value and highlighting the second line in the code you posted. I inserted your code exactly into mine, was anything in your code such as "Object" a place holder? Sorry I am still very new to loops, and don't quite understand them.
I also apologize for not just posting the model, but the model is very complex, and the issue I am having is related to a very specific circumstance that I am forcing to happen for testing purposes. Given this, I am hesitant to post the model and try to walk everyone through what is happening.
Sorry, I did not test my code at all to check that it will run or not.
If it is having issue with the "Object" then replace it with 1 and that should work.
What this is doing is reading the contents list for the Line object, and then using the value in the first column (called Object) which is the path to the MU on it. Also now I concider it, will be best to work backwards (as we move out the MU then it will be removed from this list meaning after we get half way through then we will reach a index out of range error)
New code will look like this (still not tested)
for var MU := ?.ContentsList.YDim downto 1 ?.ContentsList[1, MU].Move next
No problem at all, and that did fix that problem, but it introduced a new one. I don't know if you will be able to help with this, but just in case we will try.
So the code you just gave me is working on a line object (Line 1). The successor to that line is another line (Line 2). The way I have it set up right now line 1 has the code you just gave me, and holds entities until a certain number are present in this case 10, then it releases all 10 of them. Line 2 has code that increments a counter as each entity passes through it so that I can keep track of everything and reset everything once the counter has hit the certain number.
The new problem is the counter is counting way too many entities. I'm not sure what is happening, but with your code Line 2 is incrementing up to 24 entities, but in reality only 9 have passed through. This incrementing system was working fine before, I don't understand what happened with it, though I feel as though it has to be something with the loop.
I am not quite sure why this could be affecting that, but am willing to have a look into it if you do post your model.
All this code is doing is moving the MU's to the other line, and should only run as many times as you have MU's, so in your case if you have 10 MU's on Line1 at the time this code is ran then it will run 10 Move commands, one for every MU on the Line.
Ok. So as I said I am testing a very specific circumstance. I have set the model up in such a way that it will run with this circumstance when you open it and tell it to run. (Make sure to not have the run speed at max as you will miss everything.)
You need to look down at what I have labeled as Packout 0. As the model runs you will see entities fill this. The entities will have order number 51_1. There will only be 10 of these particular entities in the system, so when the counter hits 10 it should eject the 10 and count up what I have labeled as PackoutEj to the 10 entities that pass and then reset.
To try to orient you: PSTOP_PACKOUT0 is what I was refering to as Line1 and Line55 is Line2. Also the code we have been looking at is within PSTOP_PACKOUT0. It has changed somewhat. The code we are specifically looking at starts at line 26 and goes to line 36.
Thanks for your help!
Hello, I can now see why you were refraining from posting the project, it is quite large.
If you look in the method you have LT.PackoutEj := 16 which will set it to 16, this is done just after you have used the move statment on all of the MU's, but the move dose not take instant effect. What is happening if you step through the code is the Move statment starts and the value is incromented to 16, from there the rest of it then comes from the enterance control for Line55 when the parts enter it.
If you comment out this line of code then you will see it will result in the value being 9 instead of 24. As for it being 9 dispite you have 10 parts in all of this type, your code is being triggered from a eariler stage when there is only 9 MU's on the line, so only 9 MU's get told to carry onto the next stage.
Also I am not all to happy with how the MU are warping to the exit.... have tried a few farious different stuff to make it work better but cant seam to make it look nice..... Knowing how you have stopped the MU's in place might be useful as this could of affected how it works. Might be a good idea to look into the ExitLocked flag on the Line, you could possible try to lock the exit to keep them on that conveyor and then instead of using the for loop and the move command you can just unlock the exit by setting the flat to true.
Yeah I knew about the last entity not makeing it because of the code being initiated ahead of it getting there. I was planning on working on that later.
Your answer on the question regarding to the PackoutEj makes complete sense. Thank you, I didn't think about that, and that was actually a remnant of past code.
I tried the Exitlock flag before. I agree with you, I believe it would work quite a bit better. However, I couldn't get it to work. When I tried, I had it set up to lock the exit when the first mu got there. (In the code before the first waituntil statement I believe) then once the waituntil was satisfied it unlocked the exit.
When I did this though, the entities would never move. The exit would be unlocked, but they would just sit there.
Any ideas why they wouldn't move?