question

Jason Merschat avatar image
0 Likes"
Jason Merschat asked Jason Merschat commented

profiling the task sequence Error

I am getting an error saying to try profiling the Task Sequence profiletasksequence(). I did a search on this command and find no reference in the index. Any idea what this is and how to use it?

flexsim-task-sequence-error.png

FlexSim 17.1.4
task sequence
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Kari Payton avatar image Kari Payton commented ·

Hi @Jason Merschat I asked a similar question before here.

1 Like 1 ·
Jason Merschat avatar image Jason Merschat Kari Payton commented ·

Thanks @Kari Payton seems like we are working through similar issues!

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ commented ·

You can find command documentation using the menu options Help > Commands or Help > Command Helper.

I'll add a case to the dev list to improve the User Manual's search so that you can find command documentation from there as well.

1 Like 1 ·

1 Answer

Phil BoBo avatar image
8 Likes"
Phil BoBo answered Jason Merschat commented

Attached is a sample model that I built with ProcessFlow to demonstrate how you can get these types of errors and how you can debug them.

If you open the attached model and run it, you will see exceptions in the System Console. This is the first debugging tool that FlexSim gives you to alert you that something bad happened in your model. The exceptions may look cryptic, but there is a lot of useful information printed in them that can help you debug what is wrong and give you a hint as to how to fix it.

For example, this model prints:

time: 67.325266 exception: Exception Caught in FixedResource::getItemInfo(treenode flowitem)
time: 67.325266 exception: Exception Caught in FixedResource::setItemState(treenode flowitem, int state)
time: 67.325266 exception: Exception Caught in FixedResource::releaseItem(treenode item) object: /Processor1
time: 67.325266 exception: Exception Caught in Processor::onTimerEvent(treenode involved, int code, char *datastr) object: /Processor1
time: 67.325266 exception: Exception Caught in ObjectFunction251__project_library_FlexSimObject_behaviour_eventfunctions_OnTimerEvent object: /Processor1 class: /Processor1

That exception print is a call stack. It has lots of interesting information in it:

  • The exception happened at the event at time 67.325266. If you re-run the model to that time, you can see what is happening at that time to get a flavor for what is going on your model.
  • The involved object is "object: /Processor1". The object Processor1 is where the exception happened. This narrows down the place in your model where you should look at time 67.325266. The problem is somehow related to that Processor.
  • The exception involved functions named "getItemInfo", "setItemState", "releaseItem", and "onTimerEvent". You probably won't know exactly what these functions are or do, but their names can give you a hint as to what is happening and what is going wrong. The Processor's onTimerEvent is at the bottom of the call stack, so the issue is somehow related to a timed event on the Processor. Next on the call stack is releaseItem, so the issue is probably related to releasing an item from the Processor. Next on the stack are setItemState and getItemInfo. Both of these are related to setting or getting information on the involved item.

When you take that information together, we can get a picture that at time 67.325266, Processor1 is trying to release an item, but it can't access that item's properties. The release could be happening due to a number of different things. If we set a stoptime of 67.32 and run to that time, we can look at the processor and see that it has no items in it. If we open Debug > Event List, we can see that the Processor has a Process Finish event at time 67.325266. When we step through that event, the exception fires.

So what happened to the item?

This is the point where knowledge of what you were just changing in your model is helpful. I built this model so I know that I just recently added a Process Flow that had task sequences that load partially finished items from Processor1 and unloads them to Processor2. As it turns out, the way I'm doing that is causing an exception when Processor1 tries to finish processing the item that I stole from it using ProcessFlow before it was finished processing. That item has subsequently finished processing at Processor2 and been dropped into a sink, destroying it. This then leaves an empty reference to the item when Processor1 tries to execute its event to finish processing that item, which throws an exception. So I should change the logic in my model to avoid this error. Perhaps I shouldn't be taking items out of a processor mid-process. Or if I do, I need to somehow tell the Processor to destroy the events it has pending for that item.

But what does this have to do with profiletasksequence()?

If we run the model longer, we will see this error message appear:

What is happening here, now?

Again, we have some clues to figure out what is going on:

  • A task executer is trying to execute a task sequence, but an invalid task has been encountered.
  • The involved task executer object is Operator1.
  • He is trying to do an Unload task, which is the 3rd task in his task sequence.
  • The involved objects are "Invalid Pointer" and "Processor2".

To get more information, we have a few options.

First, we could open Debug > Output Console and Debug > Script Console. In the Script window, we can execute the following code to profile Operator1's active task sequence:

profiletasksequence(gettasksequence(model().find("Operator1"),0));

This prints the following information in the Output Console:

Task Sequence:	Total number of tasks = 3,  Priority = 0,  Preempt = None
		Currently active task = 3,  Tasks left to finish = 1


Load            involved1: invalid pointer involved2: Processor1 var1: 0.00 var2: 0.00 var3: 0.00 var4: 0.00 
Travel            involved1: Processor2 involved2: NULL var1: 0.00 var2: 0.00 var3: 0.00 var4: 0.00 
ACTIVE >>> Unload            involved1: invalid pointer involved2: Processor2 var1: 0.00 var2: 0.00 var3: 0.00 var4: 0.00 

Second, we could go look at that same information directly in the tree. We can use the Tree view to look at Operator1's active task sequence:

This gives us the same information, but without using the script window to execute commands.

So what clues do we get here? Almost the same information as the error message with one key detail: we have the whole task sequence instead of just the erroneous task.

We can see that this task sequence is a Load > Travel > Unload task sequence, and that the Load is to Processor1 and the Unload is to Processor2.

This is the point where knowledge of what you were just changing in your model is helpful. If we go look at the process flow, we can see where we create a task sequence that looks like this. The involved1 as an "invalid pointer" is not what we want. We are trying to load an item. So what's wrong?

The same thing is wrong here that was wrong above, except now it is on the other end. We are trying to load and unload an item that was previously processed at Processor1 and then sent to the Sink. That item has been destroyed so the task is throwing an error message. We need to adjust the model's logic so that we're not trying to do things to items that might have already been destroyed.

This is just an example to help teach how to debug such error messages. Hopefully this is helpful to you and anyone else who may be struggling with how to debug such errors.

If you still can't figure out what is happening in your model by following similar steps to those I showed here, please post your model (or a small sample model showing the issue) and we can help you debug it. You can post it in a private question if it contains sensitive information.


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Merschat avatar image Jason Merschat commented ·

Thank you for the detailed explanation. Very helpful!

0 Likes 0 ·