question

Matheus Rosa avatar image
0 Likes"
Matheus Rosa asked Matheus Rosa commented

How to Setup the source by an input value

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?

FlexSim 16.0.1
sourcecodemodel inputuser input
· 1
5 |100000

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

Matheus Rosa avatar image Matheus Rosa commented ·

For example:


#include <stdio.h>

int main ()
{
  int l;

  printf ("Enter the length: ");
  scanf ("%d",&l);    
  return 0;
}
0 Likes 0 ·

1 Answer

Jeff Nordgren avatar image
3 Likes"
Jeff Nordgren answered Jeff Nordgren commented

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


gui-sample-fs1.fsm (20.3 KiB)
· 3
5 |100000

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

Matheus Rosa avatar image Matheus Rosa commented ·

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 0 ·
Ben Wilson avatar image Ben Wilson ♦♦ Matheus Rosa commented ·

@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 0 ·
Matheus Rosa avatar image Matheus Rosa commented ·

@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 0 ·