question

Vaibhav R3 avatar image
0 Likes"
Vaibhav R3 asked Vaibhav R3 commented

What is the flexscript code to assign distributions to Down Time and Up Time?

I have very many Processors with different down times and up times. It will be great if you could provide a demo model with couple of Processors and their up time and down time getting updated during the reset. Thanks.

FlexSim 22.1.2
breakdown
· 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.

Felix Möhlmann avatar image Felix Möhlmann commented ·

Could you provide some more information?

What do you mean by "Up Time" and "Down Time"? A time table, MTBF/MTTR or something else?

And in what way do you want to update those settings? Switch between different preset distributions, set which processor is assigned to which schedule, etc...?

0 Likes 0 ·
Vaibhav R3 avatar image Vaibhav R3 Felix Möhlmann commented ·

I need to assign MTBF MTTR distributions from excel to Processors.

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Vaibhav R3 commented

Rather than update the entries in the MTBF/MTTR directly, it will likely be better to link those to values that can be updated more easily.

Set up an excel import to copy the distributions from excel into a global table (or copy/paste them manually).

1659349361697.png

The import will always set the columns to contain string data (text). Change that to FlexScript after the import.

1659349514187.png

You can then reference the table cell and use the distributions in them in the MTBF/MTTR. In the table format I chose above, each row would supply the values for one MTBF/MTTR.

1659349589134.png


If the distribution type always stays the same and only the numbers change, you can also just import those and read them from the table without having to run the cells as FlexScript.

1659349820008.png


1659349361697.png (3.3 KiB)
1659349514187.png (23.7 KiB)
1659349589134.png (15.9 KiB)
1659349820008.png (28.2 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.

Vaibhav R3 avatar image Vaibhav R3 commented ·
Thanks for the answer. I am aware of the approach provided by you. But, I was looking for a compact loop where in I could set those properties during the reset. Thanks anyways.
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Vaibhav R3 commented ·

The time functions are present as FlexScript nodes in the MTBF/MTTR tree. You can overwrite the treenode's code with a custom string.

treenode mtbf = Model.find("/Tools/MTBFMTTR/MTBFMTTR1>variables/mtbf");
string codeString = "Object current = ownerobject(c);\nObject involved = param(1);\nreturn exponential(0, 1000, getstream(current));";
mtbf.value = codeString;

1659353632772.png

If you type "excel" into the command helper window you will find the needed commands to open an excel workbook, navigate within and read data from it.

1659353522690.png

You could write a for-loop over all subnodes of the MTBFMTTR tools-node and generate the code strings by adding data from excel to a base string.

0 Likes 0 ·
1659353522690.png (9.5 KiB)
1659353632772.png (17.9 KiB)
Vaibhav R3 avatar image Vaibhav R3 Felix Möhlmann commented ·

Thanks. Cheers!

0 Likes 0 ·