Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Get values from multiple tags at the same time. #74

Open
Killian-Ryan opened this issue Apr 15, 2018 · 14 comments
Open

Comments

@Killian-Ryan
Copy link

Hugo thanks for sharing your code. I have a feature request;

Description

tags is a list of PIPoint objects. The following code works for me;
my_single_data = PIconnect.PIData.PISeriesContainer.interpolated_values(tags[0],"2018-03-19 20:00:00","2018-03-19 20:02:00","00:00:30")

It would be nice if the function could take a list of PIPoints and return an array of data.
my_data_table = PIconnect.PIData.PISeriesContainer.interpolated_values(tags,"2018-03-19 20:00:00","2018-03-19 20:02:00","00:00:30")

@Hugovdberg
Copy link
Owner

I'll have to look into this type of call, especially in detecting whether the function was called as a method or statically.

The recommended call is as follows:

import PIconnect as PI
import pandas as pd

with PI.PIServer() as server:
    tags = server.search(query)
    pd.concat([tag.interpolated_values(start, end, interval) for tag in tags], axis = 1)

The main advantage is that the context manager (called by the with statement) also handles connecting and disconnecting from the server. Do you have a case where your call has advantages over this construction?

@Killian-Ryan
Copy link
Author

Yes, I do use the context manager in either case, so I should clarify the intent of my question...
Instead of iterating over the tags in Python and making a call each time to OSI-PI, could we send a list of tags to OSI-PI in a single call? The reason I am asking, is because I wonder if it would return the data faster in the case of many tags.

@Hugovdberg
Copy link
Owner

Ah now I see what your pointing at. That would actually be nice if some performance could be gained there. Looking at the AF SDK documentation it seems there is the concept of a PIPointList which has methods to get both interpolated and recorded values. I will dive into this to see if I can make PIPoint.search return a list like object instead of a plain Python list which supports the PIPointList methods.

@mactone
Copy link

mactone commented Aug 24, 2020

I'll have to look into this type of call, especially in detecting whether the function was called as a method or statically.

The recommended call is as follows:

import PIconnect as PI
import pandas as pd

with PI.PIServer() as server:
    tags = server.search(query)
    pd.concat([tag.interpolated_values(start, end, interval) for tag in tags], axis = 1)

The main advantage is that the context manager (called by the with statement) also handles connecting and disconnecting from the server. Do you have a case where your call has advantages over this construction?

Hugo,
I've tried to use PI tags as query. It fails.
I used the code as below trying to get the recorded_values of two tags.
No error also NO RESULTS came back.

I am struggling to use it due to my poor python.
could you show me a more detailed example on how to define the query?

import PIconnect as PI
import pandas as pd

start='2016/06/01 00:00:00'
end='2016/06/05 00:00:00'

query=['W13_AI-DR08.PV','W13_TI-DR06.PV']

with PI.PIServer() as server:
    tags = server.search(query)
    pd.concat([tag.recorded_values(start, end) for tag in tags], axis = `1)

@Hugovdberg
Copy link
Owner

Backreference from #526: Requesting data for multiple points in a single query should use the same timestamps for all underlying tags.

@Hugovdberg
Copy link
Owner

Backreference from #502: Possibly provide an option to simplify the returned value to a single point if only one point is requested.

@niltecedu
Copy link

Hiya,

So we have a working version of this using PIPointList and a wrapper built by us which returns search using PIPointList and its 3-4x faster for around 35 pitags.

@Hugovdberg

If needed I can share the code with you so you can integrate it?

@Hugovdberg
Copy link
Owner

@niltecedu I was actually just implementing a PIPointList wrapper as well, but please share your version so we can take the best features of both implementations!

@niltecedu
Copy link

niltecedu commented Feb 8, 2023

Hi @Hugovdberg sorry for the late reply.

I have uploaded our implementation to the repo here: (dead)
Censored our server names. You can change it to your while testing.

We call the load_pidata file to load our data into a dataframe.

New_pireader contains all of the functions to retrieve the data, you might see loads of hacky code to make it work however I found that was the only way.

there's a new function in PI.py name search_list which returns a pipointlist. This is used in new_pireader to call the retrieve functions.

This was all updated to use pythonnet 3 so there might be change in other places in our piconnect. I updated the older version, this all happened in november last year when the project wasn't updated for a while :P

I don't think there is a way to call that search like yours. However we got a speed from 3x-10x while pulling the data, so it's definitely a very good addition.

(sorry had to take down the repo for sensitive data reasons)

@Hugovdberg
Copy link
Owner

Thanks for sharing, I was working on a wrapper around the PIPointList class that would allow it to be a drop in replacement for the list that's currently returned by search. That way you could either use it the old way, or call the download methods directly on the list.

@niltecedu
Copy link

@Hugovdberg

So we tried to do that however the functions called by PIPointlist are different in comparision to PIPoint, that's why we decided to have a separate wrapper for it.

@KojoBaiden
Copy link

KojoBaiden commented Mar 21, 2023

Is there any way to loop through a list of Pi Points (over 300 in my case) from a Pi Server to determine which ones are stale or bad without having to pull their data individually and trending them?

@RafieeAshkan
Copy link

Hi
I was wondering if there has been any update on PIPointList wrapper? This would be great feature to have
Thanks

@dcoe-jkpaper
Copy link

Hi, Any update on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants