question

Rykou avatar image
0 Likes"
Rykou asked Rykou commented

Autobuild adjustable model by code

I'm trying to use flexscript auto-build a model, but I'm confused about whether building a system with parallel processors is feasible or not. I mean, set the quantity of processors from 1 to 2 with code and it can auto-build from a system with one processor(video1) to a system with parallel processors(video2)。

I had used flexscript to auto-build the model. But I don't know if it is possible to auto-build the model by setting the number of processors with code or not. Please refer to the attached file.


flexscript autobulid.fsm



FlexSim 23.1.2
flexscriptusing codeautobuild
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

Kavika F avatar image
1 Like"
Kavika F answered Rykou commented

Hey @Rykou, I expanded on the code you wrote. All you have to do is add a variable that stores the number of processors you want. In the model I made, I decided to hook that up to a Parameter Table, but a simple local variable with a number in the code would work too.

Some highlights of the code I added/changed:

  1. int numProcessors = Model.parameters.NumProcessors;
  2. // int numProcessors = 2; // This can be any number you want

Either of these ways will set the numProcessors variable.

  1. Array processors = Array(numProcessors);
  2. for (int i = 1; i <= numProcessors; i++) {
  3. processors[i] = Object.create("Processor");
  4. }

This will create the number of processors you specified. Then you just have to modify your code to adjust the spacing and set the A-connections.

· 7
5 |100000

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