Quantcast
Channel: OSIsoft Users Community
Viewing all articles
Browse latest Browse all 1120

Some VBA information and maybe assitance

$
0
0

Hi all.
I am currently attempting to biuld a procbook page to have a record of the running hours of a gearbox since its last oil change.
 
I can do this quite easily in Excel using the following methodolgy
 
1. Take date of last oil change in thsi case 1/1/2014
2. Use =PIArcVal("PI_TAG","1/1/2014",1,"192.168.201.38","auto") to recover the running hour of the pump motor unit at that time
3. Use a Now() statement to get the current date and time e.g. 9/22/2014 10:49
4. Use PIArcVal("PI_TAG","9/22/2014 10:49",1,"192.168.201.38","auto")  to recover the current running hours
5. Subtract the two. 
6. This will give the running hours of the gearbox since the oil change.
Simple.
From this i can then go on to build a system that highlights when a change is due or even overdue, based on the hours.
 
But to make this really usefull and look more professional for the entire plant staff, it would be better displayed via procbook. This would also reduce the risk of it being "adapted" as excel spreadsheets seem to be.
 
But i am struggling to get procbook VBA to give an archive value from PI. I can get the snapshot value using
mydesiredvalue = valuex.getvalue (vrtime,vrstatus)
but cannot find a mthod to recover a value from the past
 
The times can be input from a textbox and using the now() statement in vba, the maths is not tough and i can display the result using
TextBox1.Text = mydesiredvalue on the Procbook page.
 
So now you are aware of my issue , can anyone help me to solve this. I hope there is some VBA code to help,. 
 
Ian F


Viewing all articles
Browse latest Browse all 1120

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>