question

wooram-kim avatar image
0 Likes"
wooram-kim asked Phil BoBo edited

Problem on funtion memberremove()

I have two machines. The machines have the same name, but they are on different planes. They are members of an MTBFMTTR object. I want to remove the red machine from the object with “memberremove(Model.find("Plane2/Processor"), "MTBFMTTR1", 2)”. But the machine is not removed, and the green machine is removed instead. I attahced the file and chapter image. Please help me.

memberremove.fsm

화면-캡처-2024-11-13-150508.png

FlexSim 24.1.0
object namemtbfmttr interfacememberremove
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

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Phil BoBo edited

This is a bug with the memberremove() command. It is searching for the coupling node by the object's name. Because both of your objects are named "Processor", it isn't working properly.

I'll add a case to the development list.

In the meantime, you can work around the issue by finding the coupling by value. Attached is your model with a MemberRemove user command that does this.

treenode child = param(1);
string parentname = param(2);
int type = param(3);

treenode members;
if (type==1) {
    members = Model.find("/Tools/TimeTables/"+parentname+">variables/members");
} else if (type==2) {
    members = Model.find("/Tools/MTBFMTTR/"+parentname+">variables/members");
}
treenode childcoupling;
for (int r = 1; r <= members.subnodes.length; r++) {
    treenode membercoupling = members.subnodes[r];
    if (ownerobject(membercoupling.value) == child)
        childcoupling = membercoupling;
}
if (objectexists(childcoupling))
    destroyobject(childcoupling);

memberremove_1.fsm


memberremove-1.fsm (28.4 KiB)
5 |100000

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