|
|
Rank: Newbie Groups: Member
Joined: 9/8/2008 Posts: 2 Location: Mississippi
|
I am trying to write some code in a VBA Macro for Excel to review data in my PI server and determine the number of run hours for a piece of equipment. I have no problems when the information is numerical. My program looks like this:
For i = 1 To lngTimeCount lngStatus = piar_value(ActiveCell.Value, lngPiTimes(10) + (i * 3600), 4, sngValues(11), istats(10)) If Cells(4, ActiveCell.Column).Value = ">" Then If sngValues(11) > Cells(5, ActiveCell.Column).Value Then lngTimer = lngTimer + 1 End If ElseIf Cells(4, ActiveCell.Column).Value = "<" Then If sngValues(11) < Cells(5, ActiveCell.Column).Value Then lngTimer = lngTimer + 1 End If ElseIf Cells(4, ActiveCell.Column).Value = "=" Then If sngValues(11) = Cells(5, ActiveCell.Column).Value Then lngTimer = lngTimer + 1 End If End If sngWinTime = ((lngPiTimes(10) + (i * 3600)) / 86400) + 25569 Next i
The problem I have is that I have some tags that are using named states "ONE" and "ZERO" to denote on and off respectively. What API call can I use to determine what the value is?
Thanks!
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 612 Location: Cheshire, United Kingdom.
|
Hi rburrell and welcome to the forum! Indeed there is, from PI-API you can use the following function: pipt_digcodefortag "This function retrieves the digital state associated with the passed string. Only those digital states within the range of the passed point are checked." Or pipt_digcode "This function retrieves the digital state code associated with the passed string. The first code matching the string is returned. The case of the strings is not significant." You could use PI-SDK also to retrive the digital states for a PIPoint. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 9/8/2008 Posts: 2 Location: Mississippi
|
Just to let everyone know, I found the solution. I am using pipt_digpointers and getting what the digital state number is to determine if the equipment is running. In this case the value of ONE is the second sate and dignumb is returning 1 in this case.
Thanks for the assistance.
rburrell
|
|
|
Rank: Newbie Groups: Member
Joined: 9/10/2008 Posts: 3 Location: San Francisco, CA
|
I know I'm late to the discussion, but if you are using the PI Enterprise Server (as opposed to the PI-Basic Server), you should have the BatchDB as well as PI-Batch-Generator.
Configure a PIUnit in your ModuleDB to represent your equipment. Then use the PIBaGen interface to populate the PIBatchDB with start/end-times according to your 'ActiveTag'... the one that goes "ZERO" to "ONE"
PI-Batch will tell you equipment utilization.
Do this once, and reap the benefits forever. Stick it in a spreadsheet using PI-API, and you may have to solve it again.
|
|
|
|
Guest
|