Tag Archives: piserver

Read and Write A Tag Value From PI-Server Using PI-SDK Through VBA (Visual Basic)

13 Mar

Reading a tag value from PI-Server

Private Function TargetValue()
Dim valueRet As String
Dim srv As Server
Dim dt As New PITimeFormat
Dim pt As PIPoint

Dim MYPIServer As PISDK.Servers
Set srv = PISDK.Servers.DefaultServer

TargetValue = srv.PIPoints(“Target”).Data.Snapshot

‘ Target is the tag name here.
End Function

Writing a tag value to PI-Server

‘***************************Writing into Target Tag****************************
Private Sub WriteTargetInstructionPI()
Dim srv As Server
Dim dt As New PITimeFormat
Dim pt As PIPoint

Dim MYPIServer As PISDK.Servers
Set srv = PISDK.Servers.DefaultServer

TagName = “Target”
Set pt = srv.PIPoints(TagName) ‘ it’s your PI point

dt.InputString = “*”        ‘it’s data. InputString – Converting String in PIdata format

pt.Data.UpdateValue TextBoxTarget.Text, dt, dmReplaceDuplicates ‘function for Update (reed help)

End Sub


Note: I have used Sub for writing the tag value and Function for reading tag value for my own business logic. You can use either Function or Sub according to your own requirements.


What is PI Server?

2 Nov

Much of this information is copied from OSI Soft

Business Challenge: Where PI Server is used?

Process-focused manufacturing companies produce copious amounts of data from a wide variety of sources throughout their operations. Usually data of plants like you have installed boilers, chillers etc. Plant managers and business executives need to have access to this information, in a meaningful and practical format, so they can direct operations toward best profitability and
productivity, and conduct effective business planning. Information aggregation from a multitude of sources manually or through custom programming can be costly and slow to deliver business value. E.g previously this process was manual. Plant manger manually collect the reading and then process. Important thing here is that process was manual i,e done by the humans.

Companies need to find a way to unify the streams of information from many sources into a single, comprehensive system that lets them accomplish their business goals as they manage their operation to achieve the highest levels of performance
and productivity.

PI Server: What it is?

The PI Server™ is the real-time data collection, archiving and distribution engine that powers the PI System™. The PI Server brings all relevant data from your many disparate sources into a single system, secures it so appropriate access is given to individuals based on their roles and delivers it to users at all levels of the company in a uniform and consistent manner. The PI Server optimizes data storage to provide needed fidelity while delivering data instantly. As a result, users have a comprehensive real-time and historical
view into operational, IT infrastructure and business activities enabling them to make timely and profitable decisions.

How to find PI SDK/Server Documentation (Programming Guide)?

17 Oct

When I started PI Server Programming the first problem I got, was to find the programming guide/documentation of PI SDK. So I Googled it but unable to find the documentation. Yesterday I was desperate to find the PI Server Documentation so I tried random. Finally I was very happy when I was successful. Actually it was very easy.

So I decided to write about it.

Here is a step by step process

Connection with PI Server C#

16 Oct

First of all you should include the PISDK reference (DLL Files) in your project.

using PISDK;
Server _piserver; /// Make
string strConnectionString = null;
strConnectionString = “UID=pidemo”;
_piserver = myPISDK.Servers[“testsrvr4”]; // You should specify your own parameters

DateTime startTime = DateTime.Now.AddSeconds(-1);
DateTime endTime = DateTime.Now;
TimeSpan span = new TimeSpan(0, 5, 0);

List values = GetValuesOfPointAsStrings(“MahtabPoint”, startTime, endTime, span); //”MahtabPoint” is my own specified point. You will have to insert it your own in order to get its value.

public List GetValuesOfPoint(string pointName, DateTime startTime, DateTime endTime, TimeSpan span)
List values = new List();
PIPoint point = _piserver.PIPoints[pointName];
DateTime tmpTime = startTime;

while (tmpTime < endTime)
values.Add(point.Data.ArcValue(tmpTime, RetrievalTypeConstants.rtAtOrBefore));
tmpTime += span;

//lbl_test.Text += point.Name.ToString();
return values;

public List GetValuesOfPointAsStrings(string pointName, DateTime startTime, DateTime endTime, TimeSpan span)
List stringValues = new List();

List values = GetValuesOfPoint(pointName, startTime, endTime, span);

foreach (PIValue value in values)
if (value.Value.GetType().IsCOMObject)
stringValues.Add((value.Value as DigitalState).Name.ToString());

return stringValues;