How do I pull data at 1 minute interval using piconfig?

I have a request to pull all data for a number of tags at 1 minute interval. This is 13 years of data. I gather that I will have to break this up into chunks of 4-5months at a time. I think I can live with this.

I have played with piconfig and a powershell script I found in another post. I have everything figured out except the 1 minute part. I can do this with Datalink, but Excel doesn't have nearly enough capacity for this much data.

 

Is there a way to do this 1m interval using piconfig or powershell?

 

Also, I'm open to ideas on how to get as much data as possible at a go so I can do with less effort.

  • Hello ​ ,

     

    With piconfig.exe you have access to snapshot data through table pisnap and to recorded values through piarc but I wouldn't know how to retrieve archived data at a specific sampling interval. With OSIsoft.PowerShell you could use GetPIValue and there appears to be the option to request for interpolated events but I have never tried this myself.

  • Gregor, I found a powershell script you wrote some 6 years ago that outputs a count of the data points. Can it be modified to output the datapoint themselves?

     

    #region defaults - apply changes here
        $PIDataArchiveHostName = "GB-PIDA1"
        $PIPointName = "CDT158"
        $StartTimeString = "1-Jan-2019"
        $EndTimeString = "1-Feb-2019"
        $tsYears = 0
        $tsMonths = 0
        $tsDays = 0
        $tsHours = 0
        $tsMinutes = 0
        $tsSeconds = 30
        $tsMillisends = 0;
    #endregion
    # Creating a Stopwatch to measure execution time
    $StopWatch = New-Object System.Diagnostics.Stopwatch
    $StopWatch.Start()
    # Load AF SDK
    [System.Reflection.Assembly]::Load("OSIsoft.AFSDK, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6238be57836698e6")
    # Instantiate the PIServer object
    $KnownServers = New-Object OSIsoft.AF.PI.PIServers
    $PIServer = $KnownServers[$PIDataArchiveHostName]
    # Load the PI Point
    $PIPoint = [OSIsoft.AF.PI.PIPoint]::FindPIPoint($PIServer, $PIPointName)
    # Define time boundaries and interval for interpolations
    $StartTime = [OSIsoft.AF.Time.AFTime]::Parse($StartTimeString)
    $EndTime = [OSIsoft.AF.Time.AFTime]::Parse($EndTimeString)
    $TimeRange = New-Object OSIsoft.AF.Time.AFTimeRange($StartTime, $EndTime)
    $TimeSpan = New-Object OSIsoft.AF.Time.AFTimeSpan($tsYears, $tsMonths, $tsDays, $tsHours, $tsMinutes, $tsSeconds, $tsMillisends)
    # Request Interpolated values
    $AFValues = $PIPoint.InterpolatedValues($TimeRange, $TimeSpan, "", $true)
    # Report amount of values returned and elapsed time
    $AFValues.Count
    $StopWatch.Elapsed.TotalSeconds

     

  • Hello ​ ,

     

    the script is not using OSIsoft.Powershell module but AF SDK through System.Reflection.

    PIPoint.InterpolatedValues returns AFValues. Yes, you should be able to adjust this script for your purposes.

  • Great. I don't have the know how to make this adjustment unfortunately, or much scripting skill for that matter. Can I please ask you to share the lines I need to make this change?

  • Hello ​ ,

    there is usually multiple ways of doing things plus options to tweak a solution to specific requirements like writing the output to a file instead of showing it at the prompt. We support custom application development but expect customers to assume ownership and to create, maintain and support their custom applications. Custom applications can easily become very complex and for this reason we cannot support them. You may understand that we avoid offering ready-to-use code samples.

    Please consider finding a developer in your organization who understands the samples, maybe when consulting with the AF SDK Reference, and who is able to adjust the samples to meet with your businesses requirements.

    If you for your purposes you could remove lines 32 and 33 and add the following:

    foreach ($AFValue in $AFValues)
    {
        if ($AFValue.IsGood) 
        {
            Write-host $AFValue.Value "; " $AFValue.Timestamp
        }
    }