Skip to content

Connect to PI AF

Hugo van den Berg edited this page Mar 28, 2018 · 2 revisions

Connecting to a PI AF database is simplest by using the context manager:

import PIconnect as PI

with PI.PIAFDatabase() as database:
    for child in database.children:
        print(child)

Selecting an element in the PI AF hierarchy can be done either through the children attribute of a PIAFElement, or by passing a path as a string to the descendant function:

import PIconnect as PI

with PI.PIAFDatabase() as database:
    element = database.children['root'].children['child1']
    # This is equal to the following:
    element = database.descendant(r'root\child1')
Clone this wiki locally