Cancel
Showing results for 
Search instead for 
Did you mean: 

OnStrategy - Maximum number of suspended methods has been exceeded

Valued Contributor
Valued Contributor

Hello,

 

I have a Exit Strategy method that I have been working on. I just got it working correctly today, but now it is exceeding the maximum number of suspended methods and causing that error. 

 

Here is my code:

Param EntranceNo: integer
var Snif1:integer := Snif_1.NumMU + PSTOP_LL_13.NumMU
var Snif2:integer := Snif_2.NumMU + PSTOP_LL_14.NumMU + LT_18.NumMU + PSTOP_LT_18.NumMU

If Snif1 >= 5 and Snif2 >= 7
	waituntil Snif_2.occupied = false or Snif_1.occupied = false prio 1
	self.newCallChain(EntranceNo)
	return
elseif Snif1 >= 5
	self.~.Exit := 1
elseif Snif2 > Snif1
	self.~.Exit := 0
elseif Snif1 > Snif2
	self.~.Exit := 1
else
	If self.~.Exit = 1
		self.~.Exit := 0
	elseif self.~.Exit = 0
		self.~.Exit := 1
	end
end


self.~.ExitForNextEnteringMU := Self.~.Exit

I know that the issue has something to do with the waituntil command in the If statement, however I am unsure why this is happening. I believe the way that this is programed the method should hit the waituntil and stop there until the conditions are met, at which time it will recall itself and return. Instead I find just shy of 2000 instances of the same method at the waituntil statement suspended.

 

I have read that waituntil does not work well with observers and situations where the method is called frequently, so maybe that is the issue. Can someone please suggest a different way to achieve what I am doing here, or suggest a way to keep the waituntil method from overflowing. 

 

Thank you!

2 REPLIES

Re: OnStrategy - Maximum number of suspended methods has been exceeded

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello mbuschur,

 

you can raise the maximum number of suspended methods in the Preferences dialog.

 

But if you think that you shouldn't have this big amount of suspended methods you have to find the reason why so many methods are waiting in the waituntil statement.

 

I'd recommend to set a breakpoint at the waituntil statement and see if there are calls which might have not expected.

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: OnStrategy - Maximum number of suspended methods has been exceeded

Valued Contributor
Valued Contributor

Ralf,

 

I tried the breakpoint, and found the problem. I didn't entirely understand the problem until I started talking it out in this post, but I'm now using a different condition that avoids the problem.

 

Basically, what was happening was an MU would arrive at the converter with the exit strategy. The exit strategy would activate the waituntil statment waiting for either of the SingleProcs called Snif_1 or Snif_2 to be unoccupied.

 

Then when Snif_1 would release its MU the exit strategy would recall itself and end (Self.newcallchain and return). The problem was, this newcallchain and return was happening fast enough that the singleproc wasn't considered to be occupied anymore, but the MU on it hadn't actually moved yet. This resulted in the

If Snif1 >= 5 and Snif2 >= 7

condition still being true as well. With the waituntil condition and the if statement both true at the same time the method went into an infinite loop.

 

I do not understand why this problem occurred with one SingleProc and not the other, but as I said at the beginning, I changed the waituntil condition and that avoided the problem.

 

Thank you for your troubleshooting suggestion!