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 first and last recorded value of a series #85

Open
Hugovdberg opened this issue May 2, 2018 · 0 comments
Open

Comments

@Hugovdberg
Copy link
Owner

To export interpolated values only over the time range for which values were actually recorded some helper attributes would be useful:

  • PIPoint.first_recorded_value
  • PIPoint.first_recorded_timestamp
  • PIPoint.last_recorded_value
  • PIPoint.last_recorded_timestamp

A workaround is available in the meantime:

import PIconnect as PI

start_date = PI.AFSDK.AF.Time.AFTime('01-01-1970')
end_date = PI.AFSDK.AF.Time.AFTime('*')

at_or_after_date = PI.AFSDK.AF.Data.AFRetrievalMode.AtOrAfter
at_or_before_date = PI.AFSDK.AF.Data.AFRetrievalMode.AtOrBefore

with PI.PIServer() as server:
    tags = server.search('*')
    for tag in tags:
        first_val = tag.pi_point.RecordedValue(start_date, at_or_after_date)
        last_val = tag.pi_point.RecordedValue(end_date, at_or_before_date)
        first_recorded_timestamp = first_val.Timestamp
        first_recorded_value = first_val.Value
        last_recorded_timestamp = last_val.Timestamp
        last_recorded_value = last_val.Value
        print tag.name, first_recorded_timestamp, first_recorded_value, last_recorded_timestamp, last_recorded_value

The values from this example are not cleaned up into python objects yet, but can be useful already.

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

1 participant