Wednesday, February 26, 2014

PI-OPC API Interface




1.    PI-OPC API Interface

9.1.PI Interface detailed design


The main functions of these Interfaces are:

       To provide an OPC communications custom interface between the OPC Server (TRF and Al AIN) and the OSISoft Plant Information (PI) system.
      To provide buffering capability to prevent data loss in case the PI server failed to archive data due to unavailability or loss of communication.
      PI OPC Interface needs to be installed and configured on all OPC interface machine. PI OPC interface failover will be configured as per OSIsoft standard through a shared file.
      The Interface configuration utility is used to configure the PI OPC Interface & its failover. Screenshots attached in this section are the sample screens. PI OPC interface installation will be placed in installation document.
Here are the steps of configuring PI OPC Interface using PI ICU:-
a.    Open ICU - > Go to Interface - > New Windows Interface Instance from Exe… as shown in below screenshot.
The following Window will appear:
b.    Browse to Interface executable OPCInt.exe from
 “…\PIPC\Interfaces\OPCInt folder”
Select PI Server, specify name of Interface instance, Point Source, Interface ID as shown below
Click on “Add”. Interface instance will get added in PI ICU, add Scan classes as shown
c.    Go to OPCInt tab, Enter OPC Server node name and click on List Available Servers, then select the OPC Server name from the dropdown list.
d.    Go to Health Points tab, Create following UniInt Interface Monitoring points
-       Heartbeat
-       Device Status
-       IO Rate
Right click the row for a particular Health Point to bring up the context menu then Click Create to create the Health Point for that particular row.
Go to IO Rate tab, Create IO Rate tag for the Interface.
e.    Go to Service tab, Create PI OPC Interface Service, save the configuration.
f.     Now Go to Tools - > Buffering, Enable buffering with PI Buffer Subsystem as shown in below screenshot.
g.    Go to Buffering Settings, Specify Event queue path as per the below screenshot. This is the path where buffer files will be saved.
 




h.    Go to Buffered Servers, select both primary and secondary server
 
i.      Set Startup type of PI Buffer Subsystem Service as Auto, Click Apply - > OK. Now buffer configuration is completed.
j.     Now Start PI OPC Interface service.


k.    Check PIPC log file. Interface should start successfully and collecting date.

9.2.   PI OPC interface Failover Configuration


9.2.1.           Failover configuration on Interface Node -1


Step 1: Verify non-failover interface operation. Check the data in PI Server. Data should start archiving through PI OPC interface. Now stop the interface through PI ICU.

Step 2: Configure the Shared File

·         The shared file will reside on the OPC Interface Node system.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
·         Setup a file share and make sure to assign the permissions so that both Primary and Backup interfaces have read/write access to the file.
·         Shared file is “OPCInt_0_1.dat” shall be stored on one of the existing OPC Interface machines.

Step 3: Configuring UniInt Failover Startup Parameters with PI ICU. 

Use the Failover section of the Interface Configuration Utility (ICU) to enable UniInt failover and select Phase 2 Failover as marked in Red in below screenshot.

Once you enable UniInt failover, PI OPC Interface instance configured on that Interface node (i.e. Node - 1) will automatically populated with Failover ID # 1 as marked in Blue in above screenshot.

Click on browse as shown in below screenshot to select the other PI OPC Interface instance to configure in failover with Failover ID # 2.




Once clicked on browse which will show the list of all available interface instances with current interface instance, select PI OPC Interface instance configured on Interface node 2

Click OK. PI OPC Interface instance configured on Interface node (i.e. Node - 2) will be populated with Failover ID # 2 as shown in below screenshot.



Select type of failover i.e. UFO Type as “HOT”, Click on browse and select the synchronization file path (For example: \\aafrtdb2gw\E$\Shared File\OPCInt_O_1.dat) to use for Failover configuration.


Step 4: Creating the UniInt Failover Control and Failover State Tags.
Configure five PI tags for the interface: the Active ID, Heartbeat 1, Heartbeat2, Device Status 1 and Device Status 2. You can also configure two state tags for monitoring the status of the interfaces.

The ICU can be used to create the UniInt Failover Control and State Tags.  To use the ICU Failover page to create these tags simply right click any of the failover tags in the tag list and select the “Create all points (UFO Phase 2)” menu item as shown in below screen.


Once clicked on “Create all points (UFO Phase 2)” menu item following screen will appear, click on Yes.

This will successfully create Digital Set ‘UFO_State’ on PI Server as shown in below screenshot. Click OK.


Once the failover control and failover state tags have been created the Failover page of the ICU should look similar to the illustration below.




9.2.2.           Failover configuration on Interface Node -2

Step 1: Verify non-failover interface operation. Check the data in PI Server. Data should start archiving through PI OPC interface. Now stop the interface through PI ICU.

Step 2: Configure the Shared File

·         Shared file is “.dat” file. For e.g. in this scenario file server used is “GHOCPIMSAPP1”, having shared folder as “Shared File” in E: drive. So Synchronization file path for Failover configuration will be as follows:-
“\\aafrtdb2gw\E$\Shared File\OPCInt_O_1.dat” Where “OPCInt_O_1.dat” is the shared .dat file.

      Step 3: Configuring UniInt Failover Startup Parameters with PI ICU. 

·         Use the Failover section of the Interface Configuration Utility (ICU) to enable UniInt failover and select Phase 2 Failover as marked in Red, Also this interface instance must define it’s failover ID as 2 , (/UFO_ID=2) and the other interface Failover ID as 1 (/UFO_OtherID=1) in its ICU failover configuration screen as shown below.



·         Click on browse as shown in below screenshot to select the other PI OPC Interface instance to configure in failover.

·         Once clicked on browse, will get the list of all available interface instances with current interface instance, select PI OPC Interface instance configured on Interface node 1. Click OK.

·         Following screen will appear, Click OK.


·         PI OPC Interface instance configured on Interface node (i.e. Node - 1) will be populated as shown in below screenshot.


·         Select type of failover, and select the synchronization file path and file to use for Failover configuration as shown in below screenshot.


Note:
·         SDK member on backup interface node will be pointing to the Secondary server
·         As UniInt Failover Control and Failover State tags are already created in PI Server while configuring failover on Interface node - 1, you will see status as “Created” in Failover page of the ICU on Interface node - 2.

How to Restore your PI Server



How to Restore your PI Server
Restoring your PI Server is the process of getting your PI Server software, configuration, and operations data from your backup files.
In order to restore your PI Server, you needed to have:
  1. Had a running PI Server
  2. Created Backup files (see How to Backup your PI Server)
If you have the backup files on a remote directory or on a USB drive, you are in a good position to use this article.
Contents
[hide]
Backup Files
Your backup files ought to (should) look like the PIHOME (e.g. C:\PI) directory. There are the following folders:
  • adm (administrative scripts)
  • bin (binaries)
  • dat (server configuration)
  • log (log files)
  • arc (archive of historical data)
Restoring to Existing PI Server
Before you begin, your PI server ought to be stopped. To stop PI:
 c:\pi\adm\pisrvstop
You also need to know which archive is the primary archive.
Determine Primary Archive
To do this, execute the following statement from the command line: c:\pi\adm\pidiag -ahd <path of archive>
For example:
 c:\pi\adm\pidiag.exe -ahd c:\pi\arc\piarch.006
The response ought to be some gibberish. You are looking for the EndTime to be "Current Time".
 PIarcfilehead[$Workfile: piarfile.cxx $ $Revision: 115 $]::
   Version: 7 Path: piarch.006
   State: 3 Type: 0 (fixed) Write Flag: 1 Shift Flag: 1
   Record Size: 1024 Count: 131072  Add Rate/Hour: 6.8
   Offsets: Primary: 26753/65536 Overflow: 81813/131072
   Annotations: 16015/65535  Annotation File Size: 4666812
        Start Time: 5-Jun-11 10:30:41
          End Time: Current Time
       Backup Time: 13-Sep-11 03:16:15
     Last Modified: 14-Sep-11 03:15:11
The archive whose End Time is "Current Time" and has the most recent Start Time is the primary archive.
Copy Backup Files to PIHOME
Copy the PI Backup files to the PI folder. For my server, the backup files are located at d:\backups\pi.
To copy those files, over, I execute the xcopy /s /y command:
 xcopy /s /y d:\backups\pi c:\pi
This command will copy all files from d:\backups\pi to c:\pi. This command will copy all subdirectories (/s) and overwrite file collisions (conflict) (/y). You are essentially replacing the existing files with files from the backup.
Note: Not all PI server files are backed up (various .bat files and binaries). Which is why you need a working PI server to accomplish this restoration.
Register the Primary Archive
What you see after running pidiag -ar
Register the primary archive with the command c:\pi\adm\pidiag -ar
 c:\pi\adm\pidiag.exe -ar
You will be presented with a dialog:
Enter the full name of the primary file (including directory structure). For example:
 c:\pi\piarch.006
Once completed, your PI server can be started. However, the history has yet to be restored.
Restoring Remaining Archive Files
Archive files are registered with the piartool -ar command. To register the remaining archives, execute that command against every archive you wish to register.
 c:\pi\adm\piartool -ar c:\pi\arc\piarch.001
 c:\pi\adm\piartool -ar c:\pi\arc\piarch.002
 c:\pi\adm\piartool -ar c:\pi\arc\piarch.003
 c:\pi\adm\piartool -ar c:\pi\arc\piarch.004
 c:\pi\adm\piartool -ar c:\pi\arc\piarch.005
If your archives have a nomenclature that can be described with a wildcard, and you have a lot of archives to register, try the for command:
 for %f in (piarch.???) do c:\pi\adm\piartool.exe -ar %f
This command executes c:\pi\adm\piartool.exe -ar against every file of the form piarch.???.