hello guys, y need your help n.n
I have one tag that brings me my instant value.
now I want through Vba, create a pi calculation which bring, for example, the average of the week, or month, etc.
create this configuration but through vba
Try this post as it has VBA code to create a dataset. No that easy to come up with on my own but using a few examples it becomes pretty straightforward. There are several other good posts and you can find them by searching for "VBA dataset". Let us know if you have questions.
if already seen several examples, but they are bringing predefined functions excel, I'm working on ProcessBook and saw that you can create a dataset, but not like adding an average for this dataset.
Please see PI SDK help (PIPC\HELP\pisdk.chm) for detailed information about Summary function used in this example:
Dim sTime As New PITimeFormat 'StartTime of Interval
Dim eTime As New PITimeFormat 'EndTime of Interval
Dim pt As PIPoint
Set Srv = Servers("LM-PI02")
Dim pv As PIValue
Dim nv As NamedValues
Dim async As PIAsynchStatus
sTime.InputString = "*-1d"
eTime.InputString = "*"
Set pt = Srv.PIPoints("sinusoid")
Set pv = pt.Data.Summary(sTime, eTime, astAverage, cbTimeWeighted)
If this is not what you are looking for, can you please clarify what you are looking to accomplish?
Ho this is very good.
if you do not mind, how i can display this average in a value ?
Are you asking how to store this value in a PI Tag? Can you please elaborate with what you want?
Use a textbox symbol and enable scripting. Then use
Text1.Contents = pv.Value
where Text1 is the name of the textbox.
thi is true, jej, thanks.
Retrieving data ...