PDA

View Full Version : Remove a tasksequence from a tasksequencequeue?


AlanZhang
08-08-2007, 05:54 PM
Is there any way to remove a tasksequence from a tasksequencequeue?

The commands gettasksequencequeue() and gettasksequence() can return the reference of a tasksequence. But I did not find a command to remove the tasksequence.


Thanks.

Alan

Jeff Nordgren
08-09-2007, 09:30 AM
Alan,

The short answer is yes. Care should be taken anytime you "delete" anything abnormally but with that said, all you need to do is make sure you reference the node that has the task you want to delete and do a destroyobject() on that node.

AlanZhang
08-09-2007, 01:24 PM
Alan,

The short answer is yes. Care should be taken anytime you "delete" anything abnormally but with that said, all you need to do is make sure you reference the node that has the task you want to delete and do a destroyobject() on that node.

Thanks, Jeff. I did try to use destroyobject() command to destroy treenode reference returned by gettasksequence command. But nothing seems happened.

Alan

Jeff Nordgren
08-09-2007, 01:40 PM
Alan,

It's probably just a matter of how you are referencing the node. The way you can "prove" to yourself that is does work is to pause your model when your task executer has task sequences. Open a tree view of the task executer and open up the tasksequencequeue node (cued up task sequences). Right click on the node icon of the task sequence you want to delete and designate it as the so() node. Then open a Script window and type in the command: destroyobject(so()); You should see that node disappear. So I'm guessing that it's just a matter of how you are referencing that node in your code.

AlanZhang
08-10-2007, 03:21 PM
Thanks, Jeff. I just tried your method. It works.

AlanZhang
08-14-2007, 05:26 PM
More questions...

If a dispatcher is used, there is no tasksequence nodes under tasksequencequeue treenode in either the dispatcher or connected operators. So where is the tasksequencequeue of the dispatcher? How do I know how many tasksequences is in the queue of the dispatcher? How to get the reference of these tasksequences?

Thanks.
Alan

Steven Hamoen
08-15-2007, 01:54 AM
Alan,

If you send a tasksequence to a dispatcher and the transporter/operator can execute it immidiately it will be placed in the node "activetasksequence" of the taskexecuter. That is the node where you find the tasksequences that are currently being executed. Because the dispatcher can't execute a tasksequence it doesn't has this node.

If you send more than 1 tasks you will see that they are queued up, either in the tasksequencequeue of the dispatcher or if you create a custom passto that sends them on immediately, you find them in the tasksequencequeue of the transporter.

Regards,
Steven

AlanZhang
08-15-2007, 03:27 PM
Steven,

You are right. I made a small model to see the tasksequencequeue for dispatchers and operators. And I saw tasksequence nodes under the tasksequencequeue treenode of both dispatcher and operator. And the number of task sequences in the queue is actually drawn beside these task executors with small dots. A small secret of Flexsim!

Thanks again!

Alan

Nico Zahn
10-17-2007, 06:02 AM
Hi,
I tried to solve a problem which is on my list for quite a long time, using the getutilzedOperator - command from Tom.
If you try to put up a modell where the processors have cycletimes exceeding the shiftmodell and you want the OPs also to work on other processes it is necessary to free the OPs before stopping the processor. This can be easily done with this very nice getutilizedoperator command.
While one group of processors is down the operators move over to the second group and start to be utilzed. When the first group of processors starts to work again, they will request operators.
If those Operators are not available and the processors need to go down again, there is still the tasksequence requested in the dispatcher. So I put up a user command to remove all task from the taskseuqence queue of the dispatcher for a certain object.
Works well so far. (please see attached modell).
But after a few cycles the processors stays in the state "Waiting for operator" while the operators get utilized... ??
Can some one explain to me what went wrong?? Thanks..
P.S.
(there are some debugging message in the output console)

AlanZhang
10-17-2007, 09:19 AM
Hi Nico,

Did you forgot attaching your model? Or you have uploaded to somewhere? It is a interesting discussion. A sample model would be very helpful.

Alan

Nico Zahn
10-18-2007, 12:36 AM
Sorry, somehow the upload didnīt work....:eek: The modell is now attached.

AlanZhang
10-19-2007, 03:50 PM
Hi Nico,

Your problem is really an interesting one. If I understand it correctly, the main problem is that the processor's state is not set correctly.

The reason is that when you resume the object, the object will go into whatever previous state when it is stopped (with matched id). The requestoperators() command will create a tasksequence which will pass to an operator. In that tasksequence, the following tasks will be created (see more details in the requestoperators command help):
1. put a preempt "bookmark" in the task sequence (TASKTYPE_MILESTONE)
2. travel to the station (TASKTYPE_TRAVEL)
3. resume the station (TASKTYPE_STOPREQUESTFINISH)
4. be utilized at the station (TASKTYPE_UTILIZE)

Since there is no task to set station's state, the state of station will not be changed (I guess, for a standard processor, it has its own logic to set the station's state and request operators). That's why you see the the processor is in the state of waiting_for_operator when the operator is utilized for that station.

In my attached model, in the Resume Function, I simply duplicate the requestoperator logic, but insert one more task to set the processor's state.

The main code in the Resume Function of your Timetable and Timetable2 is something like:


.......
// utilize OPs
//requestoperators(disp,downobject,item,1,0,0);

// instead of use requestoperators(), create our own task which will set processor state
treenode statenode = state_current(downobject);
stopobject(downobject, STATE_WAITING_FOR_OPERATOR, 100002); // need to go into STATE_WAITING_FOR_OPERATOR because unless operator arrives, the process cannot be really resumed
treenode newts = createemptytasksequence(disp,0,0);
inserttask(newts, TASKTYPE_MILESTONE,NULL,NULL,3);
inserttask(newts, TASKTYPE_TRAVEL, downobject, NULL, 0, 0);
inserttask(newts, TASKTYPE_STOPREQUESTFINISH, downobject, NULL, 0, 100002, 0, 0);
inserttask(newts, TASKTYPE_SETNODENUM, statenode, NULL, STATE_PROCESSING, 0); // set the processor state
inserttask(newts, TASKTYPE_UTILIZE, item, downobject,0);
dispatchtasksequence(newts);
.......
I hope I have addressed your question. Let me know if you find any thing wrong.

Have fun! ;)
Alan