OSI PI Examples — pynexusic 2.4.0 documentation

# OSI PI Examples

Example 1: Get full list of points in the database

  1. Import `OSIPI_WebAPI`

     >     from pynexusic import OSIPI_WebAPI as OSIPI

  2. Initialize `OSIPI_WebAPI` class

     >     OSIPI_obj = OSIPI.OSIPI_WebAPI(piwebapi_uri, username, password)

     > an example for piwebapi_uri is https://[domain].com/piwebapi

  3. Execute required function

     >     result, result_status_code = OSIPI_obj.getPointsList(pageSize=20000)

     > Output:

     >     result = [{'ServerName': 'xxxxxxxxxxx',
     >                 'Points': [{'WebId': 'xxxxxxxxxx',
     >                             'Id': xxxxx,
     >                             ...}],
     >                 'ResponseStatus': 200
     >               }]
     >     result_status_code = None

Example 2: Get stream summary data

  1. Import `OSIPI_WebAPI`

     >     from pynexusic import OSIPI_WebAPI as OSIPI

  2. Initialize `OSIPI_WebAPI` class

     >     OSIPI_obj = OSIPI.OSIPI_WebAPI(piwebapi_uri, username, password)

     > an example for piwebapi_uri is https://[domain].com/piwebapi

  3. Execute required function

     >     result, result_status_code = OSIPI_obj.getStreamDataSummary(webID, startTime='*-2mo', endTime='*-1mo', summaryType='Average')

     where webID is the required stream webID, for more details see OSI PI documentation

     > Output:

     >     result = {'Links': {},
     >                 'Items': [{'Type': 'Average',
     >                             'Value': {'Timestamp': 'xxxxxxxx',
     >                                         'Value': xxxxxx,
     >                                         ...}
     >                             }]
     >               }
     >     result_status_code = 200