1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#! /usr/bin/perl use warnings; use strict; use Win32::OLE; use Win32::OLE::Const; use Win32::OLE::Variant; my $PI = Win32::OLE->new('PISDK.PISDK') or die "PISDK Error: ",Win32::OLE->LastError(); my $piConst = Win32::OLE::Const->Load($PI); #print "PiConst: $_ \t= $piConst->{$_}\n" for (sort(keys(%$piConst))); # print all constants my $server = $PI->Servers->Item("Servername") or die "No PI server Objekt: ",Win32::OLE->LastError(),"\n"; my $status = $server->Open("UID=Username;PWD=Userpassword"); print_point ('PI-Tag_Name'); sub print_point { my $piTag = $_[0]; my $point = $server->PIPoints->item($piTag); print "\npiTag: $piTag Point: $point\n"; unless ($point) { print "piTag $piTag kann nicht gelesen werden\n"; return; } print "\t$_ = $point->{$_}\n" for(sort(keys(%$point))); # ok print "\tData: $_ = $point->Data->{$_}\n" for(sort(keys(%{$point->{Data}}))); # ok print "\tData-Snapshot: $_ = $point->Data->Snapshot->{$_}\n" for(sort(keys(%{$point->Data->{Snapshot}}))); # ok my $startTime = Variant(VT_DATE,'05.01.2015 12:00:00'); my $endTime = Variant(VT_DATE,'07.01.2015 23:45:00'); my $btFlag = Variant(VT_I4,$piConst->{btInside}); $Win32::OLE::Warn = 3; my $recValues = $point->Data->RecordedValues($startTime,$endTime,$btFlag); # error "Typkonflikt" at argument "BoundaryType" my $recValues = $point->Data->RecordedValues($startTime,$endTime,$piConst->{btInside}); # same error my $recValues = $point->Data->RecordedValues('05.01.2015 12:00:00','07.01.2015 12:00:00',0); # same error my $recValues = $point->Data->RecordedValues( {StartTime => "05.01.2015 12:00:00", # same error EndTime => "07.01.2015 12:00:00", BoundaryType => Variant(VT_I4,0)} ); # BoundaryType => 0} }
QuoteDie BoundaryTypeConstants kann man auslesen (my $piConst = Win32::OLE::Const->Load($PI);),
mögliche Werte sind 0,1,2,3 und sollten als .NET-Enumeration vom Typ int sein (4 Bytes).