Skip to end of metadata
Go to start of metadata

Existential questions about how to use MES Schedule View showEditor() hideEditor() extension functions ?


no more, try this:


 

Step-by-step guide

  1. in this example showEditor() will work like this 
    showEditor() will not let you save if you selected a specific workday (from the dropdown)

    	# Force schedules to always start at the current time regardless of where was clicked
    	import datetime
    	dateTime.setTime(system.date.now().getTime())
    	
    	# Don't let scheduled be created from work orders
    	if workOrderLink is not None:
    		return False
    	
    	# Don't let schedules be created when its Thursday
    	# Sun 6 Mon 0 Tue 1 Wed 2 Thu 3 Fri 4 Sat 5
    	import datetime
    	today = datetime.datetime.today()
    	allow = self.parent.getComponent('Dropdown').selectedValue
    	print "working with today [%s]/today.weekday [%d] and scrapped [%d]" % (today,today.weekday(), allow)
    	
    	if today.weekday() == allow:
    		return False
    	
    	return True
  2. and hideEditor() will not save if your Equipment Path ends with 'xxx' 


    	obj = scheduleItem.getMESEquipmentObject()
    	
    	# False can also be returned to prevent the window from being closed on saved
    	
    	if scheduleItem.getEquipmentPath().endswith('Some'):
    		print 'Cannot Schedule an operation on line %s' % scheduleItem.getEquipmentPath()
    		return False
    		
    	return True

    in this example xxx=Some .. caution, case this python thing is case sensitive!

    text = "Python is easy to learn."
    result = text.endswith('to learn')
    # returns False
    print(result)
    
    result = text.endswith('to learn.')
    # returns True
    print(result)
    
    result = text.endswith('Python is easy to learn.')
    # returns True
    print(result)

use this Window for Ignition 7.9.14 

hideEditor showEditor 7914.proj

MES Schedule View