Coder Social home page Coder Social logo

Extracting PI Point Tag about piconnect HOT 9 CLOSED

hugovdberg avatar hugovdberg commented on August 12, 2024
Extracting PI Point Tag

from piconnect.

Comments (9)

Hugovdberg avatar Hugovdberg commented on August 12, 2024 1

Note that the documentation contains a section API Reference that shows what methods and attributes the different kinds of objects have. The attributes should all have at least some description, if you're missing something please let me know!

I was going to suggest the following, but I noticed the mock API for the tests breaks the automatic detection of the right location:
If you find yourself lost in the API Reference because you don't know in which section a certain object lives, than it might help to navigate there from the tutorials. If you click on the bold class names in the tutorials they link to the exact location in the reference.

Finally, if you know/feel some attribute of an object is stored in the PI Server but it isn't currently available in PIconnect, then please let me know. If it is readily available in the PI AF SDK I can add it pretty quickly usually.

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024 1

@jbshiau235 you can install the package from the feature branch using pip install git+https://github.com/Hugovdberg/PIconnect@feature/feature/extract_single_historic_value. Due to the coronacrisis I don't think I'll get around to merging it into the main branch and publishing a new version soon. Both PIPoint and PIAFAttribute have an attribute recorded_time and interpolated_time, that query the data for a single time. The documentation needs work, but hopefully this helps you get started!

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

That's an interesting question. Yes, PIPoint , PIAFElement and PIAFAttribute objects all have a name attribute that contains the name of the item. For PIPoint objects this contains the tag name.
So something like this should work, hope that helps:

import re
import PIconnect as PI

pattern = re.compile(r"FQI?[TS]?\d{3}")
with PI.PIServer() as server:
    points = [point 
              for point in server.search("*")
              if pattern.match(point.name)] # or pattern.match(point.tag)

from piconnect.

jbshiau235 avatar jbshiau235 commented on August 12, 2024

Perfect, that works for me. I was mainly struggling to find documentation regarding what kinds of attributes a PIPoint has that I can extract. Doing "point.tag" works for me as well as "point.current_value" to extract what value it has. I appreciate your help on this!

from piconnect.

jbshiau235 avatar jbshiau235 commented on August 12, 2024

What attributes can I pull from a PISeries data type? I looked at the API Reference, but it only tells me what parameters to put into a PISeries object. I'm looking to extract recorded values of PIPoint objects into a dictionary or list to put into a table with columns: Tag Name (string), Time Stamp (date/time), Value (either string or number). I can get the tag name from PISeries.tag, and value from PISeries[index] (after guessing around), but I can't seem to get the time stamp to come out. Is there a property I can use to pull that information?

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

The PISeries objects itself are not very informative, they are essentially a pandas.Series with very little additional info. They have an attribute PISeries.tag with the tag name, and PISeries.uom with the units of measurement, and the timestamps are used as the PISeries.index but more info is available from the PIPoint objects.

The PIPoint has the following attributes:

  • current_value & last_update: latest recorded value and the corresponding time stamp
  • name: the tag name
  • description: the description of the PI Point
  • units_of_measurement: the units of measurement of the values
  • raw_attributes: the raw attributes as reported by the PI SDK

But to get a table like you suggest there you could use something like the following snippet:

with PI.PIServer() as server:
    point = server.search("*")[0]
    data = point.recorded_values("-1d", "*")
data.reset_index().rename(columns={"index": "Time Stamp"}).melt(
    id_vars="Time Stamp", var_name="Tag Name", value_name="Value"
)

from piconnect.

jbshiau235 avatar jbshiau235 commented on August 12, 2024

Additional question regarding data extraction. Is it possible to pull an interpolated value for a PI Tag for a given single point in time? I know the reference shows you how to pull interpolated values over a time range, but I would like to know what the value was at a specific time stamp. I tried doing:

point.interpolated_values(start_time=some_time, end_time=some_time, interval='0s')

However, this didn't work since I believe this function only takes ranges with specified intervals. Ideally something like the current_value attribute would be nice, but for some time in the past history of the data.

from piconnect.

Hugovdberg avatar Hugovdberg commented on August 12, 2024

from piconnect.

jbshiau235 avatar jbshiau235 commented on August 12, 2024

Perfect, thank you very much. Stay healthy!

from piconnect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.