Maria B17 avatar image
Maria B17 asked Jason Lightfoot commented

Add new process in Multiprocessor with Flexscript

I'm setting up an automatic reading of a customized document with FlexScript, and part of the work involves assigning the numbers from a global table to the processors.

I have cases where a single station performs more than 2 processes and I would like to use the multiprocessor for this.

but I couldn't find anything that helps me add more than one process to the multi processor and assign their values via flexscript, could you help me?

FlexSim 24.0.0 beta
· 2
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

@Maria B17, please investigate a multiprocessor with one or a few processes and a multiprocessor with one more process in its model tree. Then you are able to replicate the mechanism to customize a multiprocessor by process flow or Flexscript.

0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Maria B17, was Matthew Gillespie's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Jason Lightfoot commented

There isn't a single function to do this yet, but you could use something like this:

treenode multiprocessor = Model.find("MultiProcessor1");
treenode optable = getvarnode(multiprocessor, "optable");

// Add new operation variable
treenode newOperation = optable.first.copy(optable);
int num = newOperation.rank;
string processName = "Process" + num; = processName;

// Add new state to the MultiProcessor state profile
treenode profile = applicationcommand("enumeratestatelist", multiprocessor, 1);
treenode newProfile = profile.subnodes.add();
newProfile.dataType = DATATYPE_NUMBER; = processName;
newProfile.rank = newOperation.rank;
applicationcommand("commitstatelist", multiprocessor, 1, profile);
· 2
5 |100000

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

Michael avatar image Michael commented ·
I used your code and it works well for my model. Just 1 thing that how can I change the process time of the process added in, and how can I delete a process that I just add in before.

One last thing, I don't really understand all your script so I want to ask if you have and document or course that kind of cover all the command or the concept of the script you gave.

thank you!

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Michael commented ·

In this case you can use the table functions to do what you want - eg:

Table optable=getvarnode(Model.find("MultiProcessor1"), "optable");

You might also benefit from looking a the documentation for tables and treenodes. If you need further assistance I'd recommend you create a new question.

0 Likes 0 ·