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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2012
George Serhan George Serhan is offline
Flexsim User
 
Join Date: Oct 2011
Posts: 49
Downloads: 10
Uploads: 0
Thanks: 59
Thanked 0 Times in 0 Posts
Rep Power: 101
George Serhan is on a distinguished road
Default Display flowitem lablenumber

Hi,

What I'm trying to get out of the model is to be able to display the flowitem number as it leaves the source. Two things that I noticed were not functioning as expected. First in Source the custom code under OnExit trigger, when I set the label number using setlabelnum "setlabelnum(item,"nrofcopies",duniform(1,1000 ))" the value parameter does not get evaluated, which I don't understand why!!
The other issue is that I want to display the output of the "nrofcopies" on a visual tool, but I can't no matter what I tried.
Attached Files
File Type: fsm example2.fsm (96.4 KB, 84 views)
Reply With Quote
  #2  
Old 02-05-2012
dalin cai dalin cai is offline
Flexsim User
 
Join Date: Aug 2010
Location: Wollongong, NSW, Australia
Posts: 9
Downloads: 19
Uploads: 0
Thanks: 11
Thanked 3 Times in 2 Posts
Rep Power: 0
dalin cai is on a distinguished road
Default

1, the source doesn't have a lable named "nrofcopies";

2, on exits trigger:
setlabelnum(item,"nrofcopies",duniform(1,1000));
should be:
setlabelnum(current,"nrofcopies",duniform(1,1000));
Reply With Quote
The Following 2 Users Say Thank You to dalin cai For This Useful Post:
George Serhan (02-06-2012), Jörg Vogel (02-06-2012)
  #3  
Old 02-06-2012
George Serhan George Serhan is offline
Flexsim User
 
Join Date: Oct 2011
Posts: 49
Downloads: 10
Uploads: 0
Thanks: 59
Thanked 0 Times in 0 Posts
Rep Power: 101
George Serhan is on a distinguished road
Default

Thanks Dalin, I don't think it is processing the "duniform" part of the command. The itemflow going through the processor look to have the same speed. The other thing is how do I display the value of the label on a visual tool
Thanks
George
Reply With Quote
  #4  
Old 02-06-2012
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 313
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

I think the way you try to show the value of a label is correct. Seems to be as if the label, you are looking for, doesn´t exist. So create label on Source or on Item (Flowitembin). Write value through it and your visual tool should work ;-)
__________________
Hemmi
Reply With Quote
The Following User Says Thank You to Sebastian Hemmann For This Useful Post:
George Serhan (02-07-2012)
  #5  
Old 02-06-2012
dalin cai dalin cai is offline
Flexsim User
 
Join Date: Aug 2010
Location: Wollongong, NSW, Australia
Posts: 9
Downloads: 19
Uploads: 0
Thanks: 11
Thanked 3 Times in 2 Posts
Rep Power: 0
dalin cai is on a distinguished road
Default

1,The code "treenode involved = /**/centerobject(current,1)/**/" in visual tool refers to Source. However, the source in your model doesn't have "nrofcopies" label. One way to solve this is to create a lable named "nrofcopies" for the source, and set it's value onexit trigger.

2, the flowitem in your model doesn't have "nrofcopies" label. So, on process time "getlabelnum(item,"nrofcopies")" always returns 0. To solve this, oncreation trigger of source (onexit trigger is fine as well), Create and Initialize Label for the item.

3, if you want to display the lable value of the flow item, you can center connect visual tool with processor. in visual tool text: treenode involved = /**/first(centerobject(current,1))/**. here involved refers to the first treenode in the processor, which also means the flow item in the processor as there is only one flow item each time.
Reply With Quote
The Following User Says Thank You to dalin cai For This Useful Post:
George Serhan (02-07-2012)
  #6  
Old 02-07-2012
George Serhan George Serhan is offline
Flexsim User
 
Join Date: Oct 2011
Posts: 49
Downloads: 10
Uploads: 0
Thanks: 59
Thanked 0 Times in 0 Posts
Rep Power: 101
George Serhan is on a distinguished road
Default

Thanks for the reply Dalin,

The code below is written in the OnExit trigger, which is supposed to set the label number if the itemtype = 2 and its value duniform(1,1000).

Source1 - OnExit

treenode item = parnode(1);
treenode current = ownerobject(c);
int rownumber = parval(2); //row number of the schedule/sequence table

/** Custom Code: Set item type */
setitemtype(item,bernoulli(60,1,2));
// Set the label number
if(getitemtype(item)==/**/ 2/**/)
setlabelnum(current,"nrofcopies",duniform(1,1000)) ;
//msg("Copies",numtostring(getlabelnum(current,"nrof copies")));
if(getitemtype(item)==2)
colorred(item);

Thanks
Reply With Quote
  #7  
Old 02-07-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: 636
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 George,

the whole question is on how to think about the command setlabelnum(obj,str/num label,num value)
setlabelnum changes the value of a label. The command does not create a label. To create a label use the methods dalin or Sebastian have mentioned.
There is a command, which is used in the described methods.
addlabel(obj,Str-name of the label,Datatype); // Datatype of the label (1 = Numbers, 2 = String further datatypes you will find in the maintree exec constants)
addlabel(item,"nrofcopies",1); // here is a label created in the object item, if the pointer (treenode) to item exists, with the string-name "nrofcopies", and its Datatype is of numbers.

Some of the users here expect that all members have an idea how to build code in a programming language e.g. basic, pascal, fortran, C and so on.
If someone hasn't any idea how to build a code, then it would be nice to tell us otherwise. The standard is for building variables in flexscript: first to declare the variable - set the datatype and the name, then to initialize the variable with a value. The procedure is the the same with labels. labels are a special construct in flexscript, which is similar to variables in other programming languages. Therefore you have to build or declare the label first. In some triggers you will find a template to assist you. Then you can change or set, read or get the value of the label.

Jörg
Reply With Quote
The Following 2 Users Say Thank You to Jörg Vogel For This Useful Post:
George Serhan (02-07-2012), Sebastian Hemmann (02-07-2012)
  #8  
Old 02-07-2012
George Serhan George Serhan is offline
Flexsim User
 
Join Date: Oct 2011
Posts: 49
Downloads: 10
Uploads: 0
Thanks: 59
Thanked 0 Times in 0 Posts
Rep Power: 101
George Serhan is on a distinguished road
Default

Now I understand what the previous posts meant. You're right Jörg, I should've mentioned that I'm not a programmer, so it takes a bit more to follow the logic. I'm learning the language though, and I know it is frustrating for some to explain the obvious to them.
Thanks for the clarification.
George.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
data display Alex Christensen User Development 3 10-06-2011 12:25 AM
Task Sequence Display jspeece Q&A 4 09-15-2009 09:03 AM
Scanning from Display Nico Zahn Q&A 0 01-08-2009 08:49 AM
Object display went haywired with flowitem bin opened up David Chan Gripes and Goodies 2 09-18-2008 09:44 AM
Customizing Flowitem Attributes - a quest for the flowitem with the fewest attributes Cliff King Tips and Tricks 0 11-22-2007 12:22 PM


All times are GMT -6. The time now is 06:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.