Further to my recent post (pipt_findpoint does not seem to accept tags greater than 13 characters) I am attempting to scale (Float32) values in PI using VBA with Excel. The main part of my VBA is below and uses RecordedValues to gather values which are then scaled and finally written back to PI with UpdateValues.
Set pi_vals = srce_tag_pt.Data.RecordedValues(start_time, end_time, btInside) 'returns PIVALUES array hopefully time/value pairs.
pi_vals.ReadOnly = False
For Each pi_val In pi_vals
'SCALE THE ARCHIVE VALUE
pi_val.Value = pi_val.Value * f_scaling_factor
'WRITE TO PI
Set pi_ret_status = dest_tag_pt.Data.UpdateValues(pi_vals, dmReplaceDuplicates)
It seems to work well apart from the scaling! Inspecting each pi_val.Value both BEFORE and AFTER scaling shows that the value is indeed updated within the VBA. However, when the write takes place the ORIGINAL (unscaled) values are restored to pi_vals and written to the destination tag instead of the modified values.
Am I doing something wrong? is there a better direction I can take to achieve this?