AnsweredAssumed Answered

How to get the start time for the tag values [ Python - Piserver Connectivity ]

Question asked by Kathysan on Jun 14, 2017
Latest reply on Jun 15, 2017 by Kenji Hashimoto

I connect to the piserver from python and retrieve data from PI server using the following code.

 

    pisdk = Dispatch('PISDK.PISDK')
    myServer = pisdk.Servers('Servername')

     t0 = datetime.now()

    piTimeStart = Dispatch('PITimeServer.PITimeFormat')
    piTimeEnd = Dispatch('PITimeServer.PITimeFormat')
    piTimeStart.InputString = '01-01-2010 00:00:00'
    piTimeEnd.InputString = '12-31-2010 23:59:59'

 

    sampleAsynchStatus = Dispatch('PISDKCommon.PIAsynchStatus')

    samplePointUV = myServer.PIPoints['UV:IMP']

  

    sampleValuesUV = samplePointUV.Data.Summaries2(piTimeStart,piTimeEnd,timeinterval,5,0,sampleAsynchStatus)

 

      while True:
        try:
            valsumUV254 = sampleValuesUV("Average").Value # retrieve the value
         

            break  # it will get out of infinite loop when there is no error
        except:  # it failed because server needs more time
            td = datetime.now() - t0
            if td > tdMax:
                print( "It is taking so long to get PI data ! Exiting now ....")
                exit(1)
            time.sleep(3)

 

I successfully get all the values from the piserver corresponding to the tag UV:IMP . I want to get the date corresponding to each tag value. Any help would be appreciated.

Outcomes