question

sanaz karamimoghaddam avatar image
1 Like"
sanaz karamimoghaddam asked ernesto daniel AG2 commented

How to read ItemType and ItemName in the source arrival schedule table from a global table?

I have a large number of specific flowitems (about 25 item types) that are created based on a specified schedule. I have used a code to read the arrival dates from a global table to the source triggers on reset. How can I read the ItemType and ItemName lable from the global table to the arrival schedule table of the source.

P.S. Are these values (ItemName and ItemType) that are shown in the arrival schedule table of the source, flow item lables and can they be used as lables?

FlexSim 16.2.0
global tableitemtypesource scheduleflowitem lables
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

·
Sam Stubbs avatar image
5 Likes"
Sam Stubbs answered ernesto daniel AG2 commented

So in the OnReset trigger of the Source I entered the following code:

/**Custom Code*/
treenode current = ownerobject(c);


treenode schedule = getvarnode(current, "schedule");


for (int column = 1; column <= gettablecols("Source Table"); column++)  {
	for (int row = 1; row <= gettablerows("Source Table"); row++)  {
		if (getdatatype(gettablecell("Source Table",row,column))==DATATYPE_NUMBER)  {
			settablenum(schedule,row,column,gettablenum("Source Table",row,column));
		}
		if (getdatatype(gettablecell("Source Table",row,column))==DATATYPE_STRING)  {
			settablestr(schedule,row,column,gettablestr("Source Table",row,column));
		}
	}
}

You basically have a for loop parse through the table of the Source's schedule, as well as the Global Table. I put a check in there as well to see if the table value is a String or Number, since the commands are gettablenum or gettablestr respectively.

To answer your other question, the Name value changes the name of the item, which by default on an inter arrival source is "Box". (This value can be retrieved using the getname() command.) The ItemType is in fact a label.

I've attached the example below.

schedulesourceexample.fsm


· 6
5 |100000

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

sanaz karamimoghaddam avatar image sanaz karamimoghaddam commented ·

Thank you very much. It worked great!

0 Likes 0 ·
ernesto daniel AG2 avatar image ernesto daniel AG2 sanaz karamimoghaddam commented ·

hi @Sam Stubbs, in that same example

Now, how could I color each item in the production plan from the global table?

this to be able to observe better how the table is fulfilled.

After that when they pass to the processor, at the end of the process, separate them by colors in different queues.

thanks!!

production-plan.fsm

0 Likes 0 ·
production-plan.fsm (17.8 KiB)
Sam Stubbs avatar image Sam Stubbs ♦ ernesto daniel AG2 commented ·

One way might be to assign a numeric value to each item from the table based on the row number. And then use the Color.byNumber(...) command, with the row number as the parameter. This would give a new unique color for each row number so you could see them through the model. Is this what you're asking about?

1 Like 1 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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