How to add or remove group from dashboard dynamically using code?

How to add or remove group from dashboard dynamically using code?

gilbert_jerald
Not applicable
137 Views
3 Replies
Message 1 of 4

How to add or remove group from dashboard dynamically using code?

gilbert_jerald
Not applicable

[ FlexSim 18.1.1 ]

Hi,

In my model, I have a group called "OperatorGroup" where 3 operators are been added to that group and it is been attached to the dashboard to collect the utilization stats.

In my case, if the number of object in the group is "zero" how to remove that group from the dashboard through code. and how to re-add if the number of object in the group is greater than "zero".

I am using legacy charts (state bar chart) to display group statistics.

Thanks

Accepted solutions (1)
138 Views
3 Replies
Replies (3)
Message 2 of 4

JordanLJohnson
Autodesk
Autodesk
Accepted solution

Instead of adding the toolbox group to the chart, I would use the legacy chart Group option. Instead of removing the group, you should remove everything from the chart on reset. Here is example code that belongs in the model's OnReset trigger:

string chartName = "State Bar"; // you may need to change the name here
treenode chart = model().find("Tools/Statistics/" + chartName); 

// Remove any objects from the chart
getvarnode(chart, "objects").subnodes.clear();

// Go through the groups, and add the correct objects
Array groupNames = ["Group1", "Group2"]; // put all group names you want in this array
for (int i = 1; i <= groupNames.length; i++) {
	string groupName = groupNames;
	Group group = Group(groupName);
	Array members = group.toFlatArray();
	for (int j = 1; j <= members.length; j++) {
		treenode member = members;
		treenode memberLink = function_s(chart, "addMember", member);
		memberLink.name = groupName;
	}
}
.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 3 of 4

albert_l
Not applicable

Hi Jordan, I looked up function_s on the command reference and found the following information:

"For developer use. Executes code associated with the node found in the object's eventfunctions group having the specified name. For a list of the pre-defined system level events in FlexSim refer to function_n() command documentation."

Where can I find the list of object eventfunctions? Appreciate the help.

0 Likes
Message 4 of 4

JordanLJohnson
Autodesk
Autodesk

The list of possibilities for the second parameter of function_s depend on what you pass as the first parameter. The first parameter should be an object. You can look in that object's eventfunctions node, or in the eventfunctions node of the class in the library. Once you find the list of functions, it is up to you to read the code and determine what needs to be passed in, or whether it will work to call that function at all.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes