question

shanice.c avatar image
0 Likes"
shanice.c asked shanice.c commented

How to push to list using code?

In my process flow, I have completed filling in the parameter of load and unload activity, and is now writing the conditional expressions in the beginning of token start. I query from the list and table firstly, then use if statement to determine which TaskType will AGV going to execute. I use token.agv.TaskType to record the task number agv gets. I assign the task agv is going to execute in Custom Code: Get Task activity. Now my AGV only do I/O to EQ(Input port to Processor), then it stops. However, it should chooese to execute I/O to Queue (TaskType2) next base on my if statement. Since the material from Inputport has two possible destination. I hope to push the material to 2 different lists in the Custom Code: Get Task line 39, 40, 53, 54, but fail to push material to list using code. The token is not successfully assigned the TaskType value it is going to execute later. For materials from I/O to Processor will be pushed to itemlist2; for materials from I/O to Queue will be pushed to itemlist4. I didn't use push to list activity to do this, because I don't have tokens in process flow that represent materials, otherwise perhaps it would be simpler to use activity.


The if statement part of my code is used to query if Processor/Queue is available. My script to query from list and table are at the left hand side custom code: Query, the conditional expressions are written in the middle below the Source: AGV token activity.

Also, the following error exception was from Process Flow in the activity called "custom code: Update EQ Table". The problem seemed to be coming from line 56 where I try to have "n/a" assigned to a number field. But I cannot understand why String cannot be written into the table.

time: 582.000000 exception: FlexScript exception: MODEL:/Tools/ProcessFlow/ProcessFlow_02/Custom Code: Update EQ Table>variables/codeNode

Thank you!

0813-agv-write-to-table.fsm

FlexSim 21.1.4
flexsim 21.1.4custom codepush to list
5 |100000

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

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered shanice.c commented

Here are some things that are going wrong in your model at the moment:

1. In "Get Task" you assume that there will always be an entry for the available EQ or Queues by assigning "Table("countAvailableResource2")[1][1]" as a variable. That table will not exist if no entry is on the list, leading to an error.

You don't actually need to clone the query result to a table first. Instead of using "COUNT" in the query I would simply have it select all fitting entries. The value you are looking for will then be the number of rows in the query result table, that you can assign to the "value" variable.

  1. // Example for one type only
  2. Table myTable = Table.query("SELECT resourceType FROM FRList_AvailableResource WHERE resourceType = 0 ")
  3. Variant value = myTable.numRows; //空的Queue


2. In the "Update X Table" activities you are trying to read labels on items that don't exist.

Using

  1. Table("QueueTable")[j][10]=groupmember("QueueGroup",j).first.labels.assert("Registered").value;

(or something similar) assumes that there is an item inside the respective object. At other points you check that this is the case by checking the state of the queue or processor. Towards the end of "Update Queue Table" there are three lines (as above) where such a check is not done, leading to an error.

In "Update EQ Table" there is also one case of this. For one condition you wrote

  1. if(groupmember("EQGroup",i).stats.state().value == 2 || 4)
  2. {
  3. Table("EQTable")[i][7]=groupmember("EQGroup",i).first.labels.assert("enterEQtime").value;
  4. }

The "4" is interpreted as "true", meaning the OR-statement will always return true.

I assume what you meant to write is

  1. if(groupmember("EQGroup",i).stats.state().value == 2 || (groupmember("EQGroup",i).stats.state().value == 4)


3. The processors push themselves to the wrong list in the Exit trigger (ItemList3 when it should be FRList_AvailableResource), if I'm not mistaken.


4. You always unload to "token.pulledavailableResource". For tasktype 3 this will still point the last used queue or processor as the label is not reassign to point to Queue5.

· 9
5 |100000

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