Skip to end of metadata
Go to start of metadata

You want to use a script to find the Shift that have been configured for an Equipment ?

Step-by-step guide

  1. Use this function/code

    eqPath = system.mes.loadMESObjectByEquipmentPath('[global]\<Enterprise>\<Site>\<Area>\<Line>')

  2. if you wanted for example to find the Shift Available for a given Date/Time Window for a given Equipment, another option would be:

    begin =
    anotherBegin =, 4)
    end =, 5)
    print begin
    print anotherBegin
    print end
    analysis = system.mes.analysis.createMESAnalysisSettings('analysis')
    analysis.setDataPoints("Line Schedule Available,Scheduled Shift")
    analysis.setFilterExpression("Equipment Path = 'Nuts Unlimited\SiteOne\Cust\Generic'")
    analysis.setGroupBy("Scheduled Shift")
    analysis.setSettingValues("Include Future=True")
    # system.mes.analysis.executeAnalysis() returns an MES Analysis Results object
    # For documentation, see:
    results = system.mes.analysis.executeAnalysis(anotherBegin, end, analysis)
    if results.hasMessage():
        count = results.getMessageCount()
        message_list = [str(results.getMessage(index)) for index in range(count)]
    # getDataset() returns an Ignition Dataset
    # For documentation, see:
    dataset = results.getDataset()
    sep = ",\t"
    print sep.join(dataset.getColumnNames())
    for row in range(dataset.getRowCount()):
        print sep.join(map(str, dataset.getRow(row)))

    you can verify the logic of the script by building the (almost) same Impromptu Analysis  that would show if you indeed would 
    return a Shift for that date 

    (important to add the correct Settings: Include Future = True !!)