question

asb.p avatar image
0 Likes"
asb.p asked Matt Long answered

How to get the name of time table assigned to a resource?

Hello,

In my model,I have assigned only one time table to a each resource.

I am trying to prepare a simple GUI which helps the users to change shift of the resources. For setting current item of the combo box when the GUI is open I am trying to read the shift assigned to perticular object but i could not able to get the value of the timetable node. Below is the code snippet I have written for this purpose. @Ben Wilson @Matthew Gillespie @Brenton King @Arun KR @Jacob Gillespie

Please let me know how to get the time table assigned to a object.

treenode timetablenode = mem.find(">variables/timetables");
treenode timetable = timetablenode.subnodes[1];
string text = timetable.value; //this line code is coming as null
Array Str = text.split(">");
string text1 = Str[1];
Array Str1 = text1.split("/");
String timetableName = Str1[3];
		
FlexSim 17.0.12
flexscriptcomand
capture.jpg (30.3 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.

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

The subnodes under the timetables variable have coupling data, not string data. The .value property on a node with coupling data will return the node it's point at. However, this node is a node inside the members variable on the timetable. You then need to use the ownerobject command to get the actual timetable node.

treenode timetableVar = getvarnode(mem, "timetables");
treenode varSubnode = timetablenode.subnodes[1];
treenode timetableSubnode = timetable.value;
treenode timetable = ownerobject(timetableSubnode);
string name = timetable.name;
5 |100000

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

Matt Long avatar image
2 Likes"
Matt Long answered

It's a bit simpler than that @Arun KR, you don't need to do all the extra getting of the path/string manipulation.

treenode tableNode = model().find("Processor1>variables/timetables/1").value;
string tableName = ownerobject(tableNode).name;

The /1 at the end of the find() command gets the first subnode of the timetables variable (regardless of the name).

Since the object is coupled to a subnode of the Time Table, you can get the ownerobject of that subnode (the Time Table) using the ownerobject() command.

5 |100000

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