ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 03-12-2012
Jens Mühlheimer Jens Mühlheimer is offline
Flexsim User
 
Join Date: Jul 2008
Location: Stuttgart, Germany
Posts: 140
Downloads: 8
Uploads: 0
Thanks: 40
Thanked 35 Times in 27 Posts
Rep Power: 174
Jens Mühlheimer will become famous soon enoughJens Mühlheimer will become famous soon enough
Default Search for cell and value

Hello everybody,

is it possible to search for a specific cell value depending on the itemtype of a flowitem?

I have multiple itemtypes (aprox. 30) and depending on the itemtype the Flowitems should be processed on different processors (A1, A2, B1, B2).

I.e.: Itemtype 12 is processed on A1, then on B1 / Itemtype 13 on A1, then on B2.



I want to set the outputport of my processors depending on the itemtype. Since I have quite a few itemtypes and different processors I want to use a GlobalTable for it.
My itemtypes equal the real part numbers, so I cannot get the value for the cell row using getitemtype(item).
I don't want the table to be static and say like "ItemType 12 is always in row 3", because I might have to include new itemtypes in the table. This is why I want to "search" my table for the corresponding row.

Thank you in advance!
Jens
  #2  
Old 03-12-2012
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

Hello Jens,

you can search your global table with a for loop

Code:
/**By Global Table Lookup*/
/** \nTable: */
string tablename = /**/"GlobalTable3"/**/; 
/** \nRow: */
int row = /**/1/**/; 
for(row;row <= gettablerows(tablename);row++)
{
    if(comparetext(gettablestr("GlobalTable3",row,1),getlabelstr(item,1))) // compare the string of the first label in the item
    break; // look for the right row and break out from the for loop
}
/** \nColumn: */
int col = /**/2/**/; // column of the Output port from the globaltable
return gettablenum(tablename,row,col)
;

instead of the break in if-statement you can use the command return, which is a bit shorter.

Jörg
The Following User Says Thank You to Jörg Vogel For This Useful Post:
Eleni Liosi (02-16-2014)
  #3  
Old 03-12-2012
Jens Mühlheimer Jens Mühlheimer is offline
Flexsim User
 
Join Date: Jul 2008
Location: Stuttgart, Germany
Posts: 140
Downloads: 8
Uploads: 0
Thanks: 40
Thanked 35 Times in 27 Posts
Rep Power: 174
Jens Mühlheimer will become famous soon enoughJens Mühlheimer will become famous soon enough
Default

Hi Jörg,

first of all thanks a lot. I used your code, but can't get it running.

Code:
treenode item = parnode(1);
treenode current = ownerobject(c);
/**By Global Table Lookup*/
/** \nTable: */
string tablename = /**/"test"/**/; 
/** \nRow: */
int row = /**/1/**/; 
for(row;row <= gettablerows(tablename);row++)
{
   if(comparetext(gettablestr(tablename,row,1),numtostring(getitemtype(item)))) // compare the string of the first label in the item
   colorrandom(current);
   break; // look for the right row and break out from the for loop
}
/** \nColumn: */
int col = /**/2/**/; // column of the Output port from the globaltable
return gettablenum(tablename,row,col);
Somehow the for-loop doesn't break because of the if-statement but the limited for-statement and I can't figure out why.

I would be grateful if you might have a look at my test model.

Thank you,
Jens

// Tried something else and it worked, because I only use integers and no strings I can compare the data mathematically.
Still, I don't find the real error in the code above!

Anyways! Thanks a lot, Jörg!

Code:
treenode item = parnode(1);
treenode current = ownerobject(c);
/**By Global Table Lookup*/
/** \nTable: */
string tablename = /**/"test"/**/; 
/** \nRow: */
int row = /**/1/**/; 
for(row;row <= gettablerows(tablename);row++)
{
   if(gettablenum(tablename,row,1) == getitemtype(item))
  {break;}
}
/** \nColumn: */
int col = /**/2/**/; // column of the Output port from the globaltable
return gettablenum(tablename,row,col);
Attached Files
File Type: fsm search table.fsm (63.3 KB, 84 views)
  #4  
Old 03-12-2012
Carsten Seehafer's Avatar
Carsten Seehafer Carsten Seehafer is offline
FlexSim Geek
 
Join Date: Oct 2008
Location: Ritterhude, Deutschland
Posts: 230
Downloads: 45
Uploads: 1
Thanks: 474
Thanked 320 Times in 143 Posts
Rep Power: 379
Carsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud of
Default

Code:

  if(comparetext(gettablestr(tablename,row,1),numtostring(getitemtype(item)))) // compare the string of the first label in the item
{
    colorrandom(current);
    break; // look for the right row and break out from the for loop
}
;-)
The Following User Says Thank You to Carsten Seehafer For This Useful Post:
Jens Mühlheimer (03-13-2012)
  #5  
Old 03-12-2012
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 232
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default

Hello,

Isn't this just as the example from the basic training?..

you use a table and a label. on the table each row is a itemtype, and each column is a step, on each cell you have the output port for that step.

then on the exit trigger of the processors(or the entry trigger of the queue) you set the set label to +1. On the send to port from the queue you just read from the table entering the itemtype and step of the process for the row and column.

not sure if i'm right but this sounds a lot like that...

regards

Pablo
  #6  
Old 03-13-2012
Jens Mühlheimer Jens Mühlheimer is offline
Flexsim User
 
Join Date: Jul 2008
Location: Stuttgart, Germany
Posts: 140
Downloads: 8
Uploads: 0
Thanks: 40
Thanked 35 Times in 27 Posts
Rep Power: 174
Jens Mühlheimer will become famous soon enoughJens Mühlheimer will become famous soon enough
Default

Quote:
Originally Posted by Carsten Seehafer View Post
Code:
 if(comparetext(gettablestr(tablename,row,1),numtostring(getitemtype(item)))) // compare the string of the first label in the item
{
   colorrandom(current);
   break; // look for the right row and break out from the for loop
}
;-)
Hi Carsten,

I also used this code but it didn't do the trick. I don't know why ..
  #7  
Old 03-13-2012
Carsten Seehafer's Avatar
Carsten Seehafer Carsten Seehafer is offline
FlexSim Geek
 
Join Date: Oct 2008
Location: Ritterhude, Deutschland
Posts: 230
Downloads: 45
Uploads: 1
Thanks: 474
Thanked 320 Times in 143 Posts
Rep Power: 379
Carsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud of
Default

I haven't tested Jörgs code, but the missing brackets jumped into my eyes. Please have a look into Flexsim Users Manual. There is a chapter "Writing Logic in Flexsim" in "Flexsim Coding". It's a good overview about the syntax.

If you set a break point in your code you can see what happen in every line in your code (also in User Manual, Modeling Tools > Flexscript Step Debugging).

Greetings

Carsten
The Following User Says Thank You to Carsten Seehafer For This Useful Post:
Jörg Vogel (03-13-2012)
  #8  
Old 03-13-2012
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

Hello Jens,

I compare two strings: one item label and stringvalue in a global table.
Because there is only one statement after the if-statement, I have not used the brackets.

I attach a small model, which works well for me.

Jörg

port from a global table.fsm

Edit: The code is in the flow tab of each processor.

Last edited by Jörg Vogel; 12-03-2014 at 03:31 AM.
The Following User Says Thank You to Jörg Vogel For This Useful Post:
Jens Mühlheimer (03-13-2012)
  #9  
Old 03-13-2012
Jens Mühlheimer Jens Mühlheimer is offline
Flexsim User
 
Join Date: Jul 2008
Location: Stuttgart, Germany
Posts: 140
Downloads: 8
Uploads: 0
Thanks: 40
Thanked 35 Times in 27 Posts
Rep Power: 174
Jens Mühlheimer will become famous soon enoughJens Mühlheimer will become famous soon enough
Default

Thank you for the great help.

I also got it running now. I added another search function (for-loop) to go through the columns and check them for the machine numbers which I get from a string label of a processor. Using this I can use one table to assigne the processors (with alternatives) for all part numbers.


Thread Thread Starter Forum Replies Last Post
Search function Nico Zahn Q&A 2 10-23-2010 02:04 AM
Cell Control in a Rack Gavin Douglas Q&A 2 10-22-2008 09:16 AM
Search box in Time Tables etc. Nico Zahn Gripes and Goodies 9 06-16-2008 09:57 AM
Search and replace Nico Zahn Gripes and Goodies 0 05-19-2008 01:54 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.