ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
||||
|
||||
question about "freeoperators"
hi all ,
I got a litter problem when use the command "freeoperators",i build a very simple model which only contain one source and one sink. In the source's transport resource i add the below code to the Tasksequence example 1 right after the FRUNLOAD task, inserttask(ts,TASKTYPE_SENDMESSAGE,current,item,0, 0,0,10); inserttask(ts,TASKTYPE_UTILIZE,item,NULL,STATE_UTI LIZE); In the message trigger i use freeoperators(centerobject(current,1),msgsendingob ject()); to free the operator. But when i run the model it seems sometimes the operator can‘t be free correct. To find out what's wrong , i make some test. 1ã€i use a queue to replace the sink, it’s work fine 2ã€in the source exit trigger i use tonum(item) to record the item's num, then in the message trigger use freeoperators(centerobject(current,1),tonode(getla belnum(current,1))); it's work fine . Then i go back to the original model, i use arrive schedule to control the time the operator receive the tasksequence , i found that only when the operator in the utilizi state receive a new tasksequence the operator can't be free correct , also test for the up two method, work fine. if i missed something or make something wrong ? |
#2
|
|||
|
|||
Jay Chou,
The problem you are having has to do with the fact that you are using the item in reference to the TASKTYPE_UTILIZE, and the item is getting destroyed when it enters the sink. That is why it works when you use a queue instead of a sink, or tonum() to get a reference to the item, because the item either isn't destroyed, or the memory address is getting reallocated to another object/node and is actually pointing to something instead of nothing. If you change you code to be this in the "Use Transport" Code:
inserttask(ts,TASKTYPE_SENDMESSAGE,current,outobject(current,1),0, 0,0,10); inserttask(ts,TASKTYPE_UTILIZE,outobject(current,1),NULL,STATE_UTILIZE); Code:
freeoperators(centerobject(current,1),outobject(current,1)); |
The Following User Says Thank You to Cameron Pluim For This Useful Post: | ||
Jay Chou (04-18-2013) |
#3
|
||||
|
||||
Hi Cameron ,
Thank you for your reply , about why tonum() can work you explain, i found in the command reference :the second parameter of the freeoperators command should match the involved1 parameter of the utilize task ,if the memory address reallocated to another object/node, does the freeoperator() can still work correctly? another question in my post , when i use freeoperator(TE,item) in my original model, only when the operator in STATE_UTILIZE he receive a new sequence, he can't be freeed correctly.Not all of the situation. attach is my model, if you delete the "Arrival2" in Source 1, the operator will be freeed correctly. Is there something more i should pay attention? Thank you, Jay Chou |
Thread | Thread Starter | Forum | Replies | Last Post |
How can you have a visual tool that has a mixture of "protected" and "no select"? | thill | Q&A | 1 | 03-13-2012 12:44 AM |
Question regarding 2 "in-line" gate processes | Jamie Santa Ana | Container Terminal (CT) Library | 3 | 09-02-2009 07:45 PM |
simple question about "Separator" | Vic Li | Q&A | 5 | 01-14-2009 09:45 PM |
Is it possible one object comprised of the function of "combiner" and "separetor"? | Vic Li | Q&A | 1 | 08-19-2008 04:41 AM |
about "no select" and "show parameter window from side bar" | qin tian | Gripes and Goodies | 3 | 03-21-2008 08:10 AM |