I’m struggling to figure out how to make the connection to the PI server to python

I’m struggling to figure out how to make the connection to the PI server to python,

Parents
  • hello sir , could you please help me on this

     

    below code power shell code

     

    folder

    $filePath = "C:\Users\VODDUSR1\Decrypt\Final_goldenbatches\334 - Singapore test script showcase\"

    $start = (Get-Date)

     

    and pull frequency (minutes)

    $my_variables = Import-Excel -path ($filePath + "01 - Data in\PSCODES_CRYO.xlsx") -EndColumn 4 -EndRow 57 -WorksheetName Data

    $my_tags = Import-Excel -path ($filePath + "01 - Data in\PSCODES_CRYO.xlsx") -EndColumn 14 -EndRow 3 -WorksheetName Tags

    #$my_recordConditions = Import-Excel -path ($filePath + "01 - Data in\PSCODES.xlsx") -EndColumn 3 -EndRow 6 -WorksheetName StartConditions

    $piServerName="PHSGBO-HISCOL"

    $minutes = 10

     

    # ___________________________________________________

    # local function

    # ___________________________________________________

    function Get-PIPoint($tagName){

    try{

    $pt = [OSIsoft.AF.PI.PIPoint]::FindPIPoint($global:piServer,[string]$tagName)

    ("TagName found: {0}" -f $tagName)

    }

    catch{

    Write-host("Not found: {0}" -f $tagName)

    }

    return $pt

    }

    # ___________________________________________________

    # data models

    # ___________________________________________________

    # add the data tags as columns

     

    $simca=[PSCustomObject]@{

    PIBatchId = ""

    Time = ""

    Unit = ""

    }

     

    Datatag array and pull column headers.

    $dataTags = @()

    $my_tags[1].PSObject.Properties | ForEach-Object {

    if($_.Name -ne "Line"){

    $dataTags += $_.Name

    }

    }

    $dataTags | foreach{

    $simca | Add-Member NoteProperty $_ ""

    }

     

    simcadata table for export data type

    $simcaList = @()

     

    # connect to PIServer using AFSDK (unlike that other connection used for AF data!)

    $AFSDKAssembly = [Reflection.Assembly]::LoadWithPartialName("OSIsoft.AFSDK")

    $piServers = New-Object OSIsoft.AF.PI.PIServers

    $piServer = $piServers[$piServerName]

    $span=New-Object OSIsoft.AF.Time.AFTimeSpan(New-TimeSpan -minutes $minutes)

     

    # check connection

    if(-not $piServer.ConnectionInfo.IsConnected){

    $piServer.Connect()

    }

     

    foreach($ef in $my_variables){

    write-host $ef

    $currentVessel= $ef.Line

    # get all events for the time period

    $batchRange = New-Object OSIsoft.AF.Time.AFTimeRange($ef.StartTime, $ef.EndTime)

    # set up a templist for the points

Reply
  • hello sir , could you please help me on this

     

    below code power shell code

     

    folder

    $filePath = "C:\Users\VODDUSR1\Decrypt\Final_goldenbatches\334 - Singapore test script showcase\"

    $start = (Get-Date)

     

    and pull frequency (minutes)

    $my_variables = Import-Excel -path ($filePath + "01 - Data in\PSCODES_CRYO.xlsx") -EndColumn 4 -EndRow 57 -WorksheetName Data

    $my_tags = Import-Excel -path ($filePath + "01 - Data in\PSCODES_CRYO.xlsx") -EndColumn 14 -EndRow 3 -WorksheetName Tags

    #$my_recordConditions = Import-Excel -path ($filePath + "01 - Data in\PSCODES.xlsx") -EndColumn 3 -EndRow 6 -WorksheetName StartConditions

    $piServerName="PHSGBO-HISCOL"

    $minutes = 10

     

    # ___________________________________________________

    # local function

    # ___________________________________________________

    function Get-PIPoint($tagName){

    try{

    $pt = [OSIsoft.AF.PI.PIPoint]::FindPIPoint($global:piServer,[string]$tagName)

    ("TagName found: {0}" -f $tagName)

    }

    catch{

    Write-host("Not found: {0}" -f $tagName)

    }

    return $pt

    }

    # ___________________________________________________

    # data models

    # ___________________________________________________

    # add the data tags as columns

     

    $simca=[PSCustomObject]@{

    PIBatchId = ""

    Time = ""

    Unit = ""

    }

     

    Datatag array and pull column headers.

    $dataTags = @()

    $my_tags[1].PSObject.Properties | ForEach-Object {

    if($_.Name -ne "Line"){

    $dataTags += $_.Name

    }

    }

    $dataTags | foreach{

    $simca | Add-Member NoteProperty $_ ""

    }

     

    simcadata table for export data type

    $simcaList = @()

     

    # connect to PIServer using AFSDK (unlike that other connection used for AF data!)

    $AFSDKAssembly = [Reflection.Assembly]::LoadWithPartialName("OSIsoft.AFSDK")

    $piServers = New-Object OSIsoft.AF.PI.PIServers

    $piServer = $piServers[$piServerName]

    $span=New-Object OSIsoft.AF.Time.AFTimeSpan(New-TimeSpan -minutes $minutes)

     

    # check connection

    if(-not $piServer.ConnectionInfo.IsConnected){

    $piServer.Connect()

    }

     

    foreach($ef in $my_variables){

    write-host $ef

    $currentVessel= $ef.Line

    # get all events for the time period

    $batchRange = New-Object OSIsoft.AF.Time.AFTimeRange($ef.StartTime, $ef.EndTime)

    # set up a templist for the points

Children
No Data