I have the following nested loops:
For every UNIT (user-defined in input table)
- Get all batches within the user-defined start/end time window using PIUnitBatchSearch
- For every BATCH
-- Get the start/end time of the current batch
--- For every TAG (user-defined in input table)
--- Get the PIValues for the start/end batch time using PIPoint.Data.RecordedValues
---- For every PIValue
---- Write every value in a spreadsheet
This isn't really an optimal design as it is very slow. Is there any way I can pull all the batches along with their data from Pi in one go giving it a unit, tag, start/end date list?
I was thinking of pulling the batch list for a user-defined time window and the pivalues for that same window separately (two huge PI pulls instead of a lot of small pulls) and then joining them together (is there a specific PI function for this join?)
I've written this pseudocode in VBA, it would be great if you could include a VBA snippet supporting your answer.
Thanks in advance!