|
|
Rank: Newbie Groups: Member
Joined: 8/11/2010 Posts: 6 Location: Calgary, Canada
|
Hello!
I am a new PI user and am not very familiar with Processbook or VBA but I think my problem is very simple. I just need to change the data in a processbook trend (basically a unit conversion). After reading these forums it seems that I'll need to manipulate the dataset with VBA but I was just wondering if there's an easier way to do this?
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Hello, Welcome to the forum. The easiest way for unit conversions would be to use the AF dataset in ProcessBook but this is no good if you don't have AF. You can perform the conversion within a Dataset or create a performance equation tag to store the converted values. It depends if you would need the converted value elsewhere in different displays, spreadsheet etc then use a PE tag otherwise a dataset will do the job. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 8/11/2010 Posts: 6 Location: Calgary, Canada
|
I am trying to go the Dataset route but I keep getting errors in my code. Code: Sub test()
Dim MyDataset As PIExpressionDataset
Set MyDataset = MyDatasets.Add("ConvertedValues", Nothing, True, 1, True, pbDatasetPIExpression)
Set MyDataset = MyDatasets.GetDataset("ConvertedValues") MyDataset.ServerName = "scpitest" MyDataset.Expression = ThisDisplay.Datasets.Expression * 1000 MyDataset.RefreshInterval = 3600 MyDataset.ColumnName = "Value" MyDataset.Interval = "10m" ThisDisplay.Datasets.SetDataset MyDataset
End Sub
I am just trying a test for now but it keeps telling me that an object is required.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
It looks like this line in your code is incorrect: Code: MyDataset.Expression = ThisDisplay.Datasets.Expression * 1000
ThisDisplay.DataSets is a collection thus doesn't have an expression property. Maybe you meant to refer to a specific Dataset from the collection or a PI Point? Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 8/12/2010 Posts: 1 Location: Texas, USA
|
Forget about VBA there's a much easier way of doing this. Click on the hammer, then double click the trend. Then click the down arrow next to the Tag Search... button. If you see an option called PI Calculation click on that. Then hit the New button in the top left corner. Now in the Definition section choose your server from the drop down menu and then where it says Tag or Expression enter your tag and the formula for the unit conversion so for example you'd put 'MY_TAG'*1.8+36 or something like that. Then choose an interval and click okay and you're done! Just make sure your column label is set to Value. You'll now have two trend lines, your original units and the converted units. Hope this helps!
|
|
|
Rank: Newbie Groups: Member
Joined: 8/11/2010 Posts: 6 Location: Calgary, Canada
|
Thanks for the suggestions. I am afraid that your method vic3151 won't work for me since I need to be able to change the data dynamicaly depending on which display is shown. I was able to fix up my code though and it now runs fine and I can create the new dataset. I just need a way now of showing the data in my trend. I tried Trend1.AddTrend but that only lets you add a string and not a dataset. Any ideas?
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
You just need to form the string as "DatasetName.Column", e.g. "MyDataset.Value" or "MyDataset.Average", so: Code:MyTrend.AddTrace "MyDataset.Value" Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 8/11/2010 Posts: 6 Location: Calgary, Canada
|
Got it working. Thanks for all your help!
|
|
|
|
Guest
|