Sepasoft MES Module Suite
system.mes.getEquipmentStateOptions
A function to return equipment state options under the provided parent. This function is built for performance and is not intended to provide all possible states in a tree structure of equipment states, only one level of equipment states at a time.
|
Syntax
system.mes.getEquipmentStateOptions(equipmentPath, parentUUID, stateTypeFilter)
String equipmentPath - The path of equipment to return the states for. String parentUUID - The UUID of the parent equipment state class for the state options being searched for. If "" is passed in, the equipment state class assigned to the equipment will be used. String stateTypeFilter - The equipment state type filter.
MESObjectList - A MESObjectList object containing MESEquipmentState or MESEquipmentStateClass objects.
All
|
State Type FilterValid options for the State filter parameter are...
'Unknown'
'Unplanned Downtime' 'Planned Downtime' 'Blocked' 'Starved' 'Running' 'Idle' 'Disabled'
Multiple entries can be passed to the stateTypeFilter parameter as a comma separated string. There should be no spaces between names.
Example stateTypeFilter = 'Unplanned Downtime,Planned Downtime'
|
Code Examples
While the function is built for a single level of equipment states, often users would like to traverse a tree of equipment states. The following script examples provides such.
|
Code Snippet
|
Output
|
Python |
# or another way # add this code to your Shared Script # def get_all_members(obj, obj_list=[]): # getting all children of the passed object child_objs = [child.getMESObject() for child in obj.getChildCollection().getList()] for child in child_objs: obj_dict = {} # creating a dictionary for each child of the passed object obj_dict['obj'] = child # adding the object at the 'obj' key obj_dict['name'] = child.getName() # adding the name at the 'name' key parent_dict = filter(lambda item: item['obj'] == obj, obj_list) # checking to see if the original list already contains the parent of the object if parent_dict: obj_dict['path'] = "%s/%s" % (parent_dict[0]['path'], child.getName()) # if it exists, append the name of the current object to its parent's path else: obj_dict['path'] = "%s/%s" % (obj.getName(), child.getName()) # otherwise the path is parent name/child name obj_list.append(obj_dict) # tack it onto the list if child.getChildCollection().getList(): get_all_members(child, obj_list) # check it for children return obj_list def get_all_available_equipment_states(line_path): states = system.mes.getEquipmentStateOptions(line_path, '', '') state_list = [] for state in states: if state.getChildCollection(): dict_list = get_all_members(state) state_list.extend([obj['obj'] for obj in dict_list]) else: state_list.append(state) filtered_list = filter(lambda x: x.getMESObjectTypeName() == 'EquipmentState' and not x.getChildCollection(), state_list) return list(set(filtered_list)) |
Code |
|
Sepasoft MES Module Suite