YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Getting compressed data in array :/ Options · View
Boewie
#1 Posted : Thursday, July 08, 2010 2:51:21 PM
Rank: Newbie
Groups: Member

Joined: 7/8/2010
Posts: 2
Location: belgium
Hi all,

i would love to put the data from PICompDat in an 2dimensional array (VBA).

is this possible ? if so, can someone give me a start tip ?

thx in advance,

Kristof
Sponsor  
 

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.
RJK Solutions
#2 Posted : Friday, July 09, 2010 8:19:54 AM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Hello Kristof,

Welcome to the forum.

PICompDat is just a PI-Datalink wrapper method for the PISDK "PIData.RecordedValues" method. If you want some form of flexibility for the data you are returned then I would use PISDK directly. Do a search for "RecordedValues" and you will see some examples on this forum or check out the PISDK help file that also has some examples.

Cheers.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
Boewie
#3 Posted : Friday, July 09, 2010 9:56:45 AM
Rank: Newbie
Groups: Member

Joined: 7/8/2010
Posts: 2
Location: belgium
Hi, i think i have the solution.

Quote:

Function CompDataInschakeling(ByVal servernaam As String, ByVal tag As String, ByVal begindat As String, ByVal einddat As String, ByVal InUit As String)

'--------------------------------Declaraties---------------------------------------
Dim getallen(), ValueTeller, ArrayIndex, totaleU, totaleI As Integer
Dim Pnt As PIPoint
Dim srv As Server
Dim PntVal As PIValue
Dim PntVals As PIValues

'---------------------------------Errorhandling-------------------------------------
On Error GoTo ErrHandler:
'---------------------------------Setters------------------------------------
Set srv = Servers(servernaam)

Set Pnt = srv.PIPoints(tag)
'Set Pnt = PISDK.Servers.DefaultServer.PIPoints(tag) 'TestServer
Set PntVals = Pnt.Data.RecordedValues(begindat, einddat, btInside)
ValueTeller = 0
totaleI = 0
totaleU = 0

'----------------------------------Waardes in array pushen-----------------------
For Each PntVal In PntVals
ReDim Preserve getallen(ValueTeller)
getallen(ValueTeller) = PntVal.Value
ValueTeller = ValueTeller + 1
Next PntVal
Set PntVals = Nothing 'opruimen
Set Pnt = Nothing 'opruimen

'-----------------------------------Tellen I / U----------------------------------
For ArrayIndex = 0 To UBound(getallen) ' voor elke waarde in de array , nakijken.
If ArrayIndex > 1 And ArrayIndex < UBound(getallen) Then
If getallen(ArrayIndex) = 1 And getallen(ArrayIndex + 1) = 0 Then ' Gaan we van 1 naar 0 ... uitgang !
totaleU = totaleU + 1
ElseIf getallen(ArrayIndex) = 0 And getallen(ArrayIndex + 1) = 1 Then ' Gaan we van 0 naar 1 ... Ingang !
totaleI = totaleI + 1
ElseIf getallen(ArrayIndex) = "I/O Timeout" Or getallen(ArrayIndex) = "Intf Shut" Then ' I/O timeout of intf shut ... Ingang
totaleI = totaleI + 1
ElseIf getallen(ArrayIndex) = 0 And getallen(ArrayIndex - 1) = "I/O Timeout" Then 'Is de Volgende waarde I/O , en de huidige 0 Uitgang
totaleU = totaleU + 1
ElseIf getallen(ArrayIndex) = 0 And getallen(ArrayIndex - 1) = "Intf Shut" Then 'Is de Volgende intf shut , en de huidige 0 Uitgang
totaleU = totaleU + 1
Else
End If
End If
Next ArrayIndex



'-----------------------------------Meldingen (tests)-------------------------------

If InUit = 0 Then
CompDataInschakeling = totaleU
ElseIf InUit = "1" Then
CompDataInschakeling = totaleI

End If
'MsgBox "Volgens mijn bescheiden mening is " & tag & " " & totaleI & " keer ingeschakeld", vbQuestion, "Totale Inschakelingen"
'MsgBox "Volgens mijn bescheiden mening is " & tag & " " & totaleU & "keer uitgeschakeld", vbQuestion, "Totale Uitschakelingen"

'-----------------------------------Nog wat opruimen---------------------------------
'Set ArrayIndex = Nothing

'-----------------------------------Errorhandling oplossing---------------------------
ErrHandler:
If Err.Number = 0 Then
Exit Function
ElseIf Err.Number = 9 Then
MsgBox "Gelieve bij datums een datusm te geven", vbCritical, "mission failed !!!"
ElseIf Err.Number = -2147220305 Then
MsgBox "Er ging iets mis bij de verbinding naar de server." & vbCrLf & "Gelieve een servernaam en tag in te geven", vbCritical, "mission failed !!!"
ElseIf Err.Number = -2147220472 Then
MsgBox "Uw opgegeven server werd niet gevonden." & vbCrLf & "Gelieve een juiste server op te geven", vbCritical, "mission failed !!!"
ElseIf Err.Number = 13 Then
MsgBox "Gelieve een geldige eind- en begindatum in te geven", vbCritical, "mission failed !!!"
ElseIf Err.Number = 5 Then
MsgBox "Oei, er ging blijkbaar iets mis, bent u zeker dat u alles heb ingevuld?", vbCritical, "mission failed !!!"
Else
MsgBox "Errorrrrrrr"
End If
Exit Function

End Function


thanks for the advice !

sorry 4 dutch names Blushing
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.