How to Setup the source by an input value

How to Setup the source by an input value

matheus_rosa
Not applicable
40 Views
5 Replies
Message 1 of 6

How to Setup the source by an input value

matheus_rosa
Not applicable

[ FlexSim 16.0.1 ]

I would like to know if it is possible to setup the source for an input value determined when I hit the start button.

For example, when I run the model, it should ask me the length of the wood that are going through the process in a window, so I can type 6 inches or 4 inches. Is there a way to do it with a custom code?

0 Likes
Accepted solutions (1)
41 Views
5 Replies
Replies (5)
Message 2 of 6

matheus_rosa
Not applicable

For example:


#include <stdio.h>

int main ()
{
  int l;

  printf ("Enter the length: ");
  scanf ("%d",&l);    
  return 0;
}
0 Likes
Message 3 of 6

jeff_nordgren
Not applicable
Accepted solution

Matheus,

Attached is a sample model that could be used to enter a length before running the model.

The attached model is in feet. I created a global variable called "Length". In the Source2 object, in the OnExit trigger, I set the length of the item (x value) to Length/12 (because the model is in feet) and the y and x sizes to 1 (one foot each).

Then I created a Dashboard and used 3 Model Input objects (at the bottom of the library list) to create a simple way to change the global variable. You can check the "Edit Mode" checkbox and look at the 3 fields that were added.

To make the changed length work properly, after hitting Reset on the model and before Pressing the Run button, change the length and press the OK button.

If you have any questions or problems, please let us know.

gui-sample-fs1.fsm

Message 4 of 6

matheus_rosa
Not applicable

Jeff,

Thank you for the example, it helped a lot. Just one other thing, is it possible to create an interface that will appear automatically after I hit run asking me for the length of the wood or I'll have to change inside the source's properties , I mean, that is fine for me to change it on the source every time I run it but I would like to make a more elegant interface, unfortunately I'm a new user of Flexsim and I don't know much about the advanced features yet. Anyway, your explanation helped me a lot thanks.

0 Likes
Message 5 of 6

Ben_WilsonADSK
Community Manager
Community Manager

@Matheus Rosa, this forum works a little different than our old community forum in that each "Answer" is meant to be an actual answer to the question, not a reply to a previous post.

Post-reply conversations are meant to be done in the comments of each answer. This makes answer finding easier for people who are skimming, so I've converted your answer into the comment above.

0 Likes
Message 6 of 6

matheus_rosa
Not applicable

@jeff.nordgren

Nevermind I saw the dashboard now !!! My bad I closed the dashboard. Thank you so much !!!!

@Ben Wilson

Sorry about that!

0 Likes