question

Mustafa L avatar image
0 Likes"
Mustafa L asked Matthew Gillespie commented

Create MTBF MTTR using flexscript

How do I create a MTBF object via flexscript?

FlexSim 18.1.2
flexscriptmtbf mttr
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

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

To add a new MTBF object to the toolbox you can use this line of FlexScript

treenode table = applicationcommand("addmtbfmttr");

If you want to configure the tool at all it gets a little more tricky. We don't currently have a nice API for configuring the MTBF, although we are hoping to add one down the road. You can still do everything through FlexScript, but nothings documented or very discoverable at the moment.

If you want to add new members to the tool you would use code like this:

treenode obj = model().find("Processor1");
treenode members = getvarnode(table, "members");
treenode timetables = getvarnode(obj,"timetables");

createcoupling(members, timetables);
members.last.name = obj.name;
timetables.last.name = table.name;

If there are any other things you want to configure through code we can help you find the needed code.

· 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.

Mustafa L avatar image Mustafa L commented ·

Thanks,

A follow up question :

treenode table = applicationcommand("addmtbfmttr");

opens up the pop up window. How do I close it using flex script?

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Mustafa L commented ·

Add a 1 as a second parameter if you don't want the properties window to open:

applicationcommand("addmtbfmttr", 1)
1 Like 1 ·
Mustafa L avatar image Mustafa L Matthew Gillespie ♦♦ commented ·

The code to add the coupling gives me an error on the last two lines

exception: FlexScript exception: Property "last" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code

exception: FlexScript exception: Property "last" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code

exception: FlexScript exception: Property "last" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code

exception: FlexScript exception: Property "name" accessed on invalid node. at MODEL:/Tools/UserCommands/addBreakDowns/code

how do I resolve this?

0 Likes 0 ·
Show more comments