OSISoft PI Setup Guide for Productive Maintenance | MuleSoft Documentation
# OSISoft PI Setup Guide for Productive Maintenance
This section explain how to configure several components of OSI PI in order to connect to PI servers to retrieve time series data from PI data server.
## Configuration Steps
  1. PI Data Server Connection
  2. PI Web API Configuration
  3. Web API System Configuration
  4. Configure PI Randomizer Interface
  5. Configure PI Points
  6. Use PI Web API to Retrieve Attributes and Values of PI Points
  7. PI Point Configuration for this Use Case


## PI Data Server Connection
The PI data server hosts configuration of PI points, stores values of the PI points and allows PI Web API connect to it and retrieve data from the clients. Make sure your machine can connect to the running instance of the PI data server.
  1. Go to the Windows menu items or location of PI system typically located at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PI System.
  2. Run PI system explorer and select Servers menu.
  3. If you see Data Server (and Asset Server) are connected no further configuration is required. Otherwise select Tools > Options menu.
  4. Check PI Trust, uncheck Windows Security and check Allow login prompt. Then when you try to connect to data server it will prompt you with Windows authentication and your windows credentials.


## PI Web API Configuration
The PI Web API needs to be configured to retrieve PI points attributes and values using REST.
  1. Go to the Windows menu items or location of PI system typically located at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PI System.
  2. Run PI Web API Admin Utility and connects to the PI Asset Server instance.
  3. Select HTTPS port 443 and Firewall exception.
  4. Select Bypass Advanced Certification Check.
  5. Select account type and account name.
  6. Select AF server and database, and data server.
  7. Follow the screens to continue configuration and note down the PI Web API url.


## Web API System Configuration
This section talks about configuration items which are supported but not configured by default. Follow these steps to configure Web API system:
  1. Open PI System Explorer
  2. Click on Database and select Configuration
  3. Expand Elements / OSISoft / PI Web API / PI_Server_Host / System Configuration, and then click on 'Attributes' tab
  4. Configure the following items:


Item | Details | Comments  
---|---|---  
Basic Auth config | * Select AuthenticationMethods * Value field click on String Array * Type Basic in value and click on Add * Click on Check-In button | Needed to authenticate and connect client to Web API.  
Bulk Request config | * If you see IgnoreCacheControlForBulkRequests make sure it is set to True * Otherwise Click on New Attribute button on top and set the value to IgnoreCacheControlForBulkRequests, type to Boolean and value to True * Click on Check-In button | Needed for value set URL to get data for multiple points  
POST Request config | * Set EnableCSRFDefense to false | Needed for POST to work to avoid 403 suite access denied error  
## Configure PI Randomizer Interface
Follow these steps to configure the random interface and install it as a Windows service.
  1. Run PI Interface Configuration Utility
  2. Select Interface > New Windows interface instance from a bat file or from an exe file and browse to Random interface installation directory typically C:\Program Files\PIPC\Interfaces\Random containing random.exe or random.bat file
  3. Select Host PI data server and click on add
  4. In the general section make sure the point source is R and in the scan frequency, you specify the frequency at which random interface will simulate PI points. You can specify multiple frequencies
  5. In the Service section make sure tcp/ip is selected as a dependency


## Configure PI Points
PI Interface for Random Simulator Data is installed and configured with PI Data Archive, is an excellent source of test data. You can configure points to generate various types of randomized data. The default point source for this interface is R.
Point builder will allow you to configure PI points. Run PI System Management Tools and select Points > Point Builder . Click on 'New' and provide point details as described in the following sections.
### General Tab
  * Name: it must be a unique name across all points, for example, FlowLevel-M23
  * Descriptor: can be used to store some important info such as machine or location where the point is attached
  * Stored Value: how value is stored in data server, select Real-time data
  * Point Source: source of value, for Random interface select R
  * Point Class: select Classic
  * Point Type: data type of the point such as int, float, string, timestamp, blob or digital
  * Digital Set: if the data type is Digital, select the set of value defined in the Digital Set
  * Eng Units: engineering unit of the point being measured, for example, PSI for flow, F for temperature


### Archive Tab
  * Typical Value: typical value of the point, for example, 50
  * Zero: minimum value of the point, for example, 10
  * Span: maximum value of the point, for example, 100
  * Make sure the Scan and Archiving are selected On


### Classic Tab
The values in the Location 1 to 5, depends on the Data Type, Scan Class of the random interface being used, desired amount of change between each value, and number of value to change before midpoint resets to current value. Note that not all location values are required for each point. For example:
Field | Value | Description  
---|---|---  
Location2 | If the span is 100, it will allow to change value by 1 in each scan (10*(100/1000)) = 1  
Location3 | After 25 random value it will reset to current value  
Location4 | Scan class of PI point. Look at random.bat or Random interface configuration. This says the PI point will be changed as per line 1, so if that is 30 sec, the PI point value will change every 30 seconds.  
Location5 | Number from 0 to 5 depending on point data type  
**Digital States configuration**
When point data type is selected as Digital, its value can be one of those specified in a Digital State.
  1. Select Points > Digital States and click on Add icon.
  2. Name the set and set of state values with state name.


The result should be a Digital State for a Maintenance Status, which can be `0=Active` and `1=Broken`.
## Use PI Web API to Retrieve Attributes and Values of PI Points
Once PI servers, data server, Web API, random interface and PI points are configured you can use PI Web API to retrieve and update point attributes and values from PI server. The Web API provides REST interface to interact with PI server over the web.
The following table describes some of the common endpoints to retrieve PI point information. Note that each points and assets in PI server is identified using a unique webId.
Description | Web API URL  
---|---  
PI Web API home page |   
Get attributes of all PI points | `https://host:port/piwebapi/dataservers/DataServer_webId/points`  
Get attributes of multiple specified PI points | `https://host:port/piwebapi/points/multiple?webId=Point1_WebId_&webId=Point2_WebId`  
Get value of a specific PI point | `https://host:port/piwebapi/streams/Point_webId/value`  
Get values of multiple specified PI points | `https://host:port/piwebapi/streamsets/value?webId=Point1_webId_&webId=Point2_webId`  
Get attributes of multiple specified PI points using POST method | POST: `Body:{ "1" : { "Method": "GET", "Resource": "https://host:port/piwebapi/points/multiple?webId=Point1_webId& webId=Point2webId" } }`  
Get data values of multiple specified PI points using POST method | POST: `Body:{ "1" : { "Method": "GET", "Resource": "https://host:port/piwebapi/streamsets/value?webId=Point1_webId&webId=Point2_webId" } }`  
## PI Point Configuration for this Use Case
This use case measures vibration delta, temperature, oil level, noise level, and maintenance status of several machines. The following table describes the configuration of these PI points for one machine.
Attribute | Point1 | Point2 | Point3 | Point4 | Point5  
---|---|---|---|---|---  
Vibration Delta | Temperature | Oil Level | Noise Level | Maintenance Status  
Descriptor | Machine1 | Machine1 | Machine1 | Machine1 | Machine1  
Stored Values | Real-time data | Real-time data | Real-time data | Real-time data | Real-time data  
Point Source  
Point Class  
Point Type  
Digital Set | MachineStatus  
Eng Units | Percentage | Decibels  
Typical Value  
Archiving  
Location3  
Data Type | Station Data | Station Data | Station Data | Station Data | Random Data  
## See Also
  *   * MuleSoft Accelerator for Manufacturing