|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
Hello,
My company uses a very old pi (3?) and I don't have access to pisdk and I want to do this in a pi book
Basically, how the bogging can I get a pi tag value from pi, play with it and then return it back to my pi book display?
Eg Server = server1.work.net
Tag 1 = blnd1.pv Tag 2 = flow.pv
So basically if I do tag1/tag2 I have a value in minutes. This I want to add to my current time ( I can use now() for that) and then return it to my pi display say as 01/jan 15:34
Whilst I can properly figure out the the time calc I can't get either tag value from pi and I don't know how to make my pi display constant update the value of it finishing
Any help would be appreciated!!!!
Thanks
James
|
|
|
|
|
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: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
Arrggg this is really hurting my Brian, anyone got a clue?
James
|
|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
Okay, after downloading the VB book from obisoft (very helpful!) I have got this far: Code: Sub test()
Dim vrDate As Variant Dim vrStatus As Variant Dim MyValue As Variant Dim MyValue1 As Variant Dim MyValue2 As Variant Dim y As String Dim yy As String Dim tt As String
value.SetTagName ("\\work\taga.PV") Value1.SetName ("\\work\tagb.TV") Value2.SetName ("\\work\tagc.PV")
MyValue = value.GetValue(vrDate, vrStatus)
MyValue1 = Value1.GetValue(vrDate, vrStatus) MyValue2 = Value2.GetValue(vrDate, vrStatus)
MsgBox "You have blended: " + CStr(MyValue) + " cubes" MsgBox "Target Volume: " + CStr(MyValue1) + " cubes" MsgBox "Blend Rate of: " + CStr(MyValue2) + " cubes a minute"
y = ((MyValue1 - MyValue) / MyValue2) yy = Now() tt = DateAdd("n", y, yy)
MsgBox "Finish Time: " + tt End Sub
Question is now, how do I write the value TT back to the pi display? Thank you
|
|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
Right, so i have figured out how to replace text, using this: Code: Dim MyTagName As String 'Tagname
MyTagName = Text.Contents
Text.Contents = tt
End Sub
But how do I make it re-write every minute, it would seem that application.ontime is not supported? Any ideas on how to run a macro in a display every minute? Ta J
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/28/2009 Posts: 75 Location: Cheshire, UK
|
J, Datasets may possibly provide a solution for this. They can of course be used in Value as well as Trend controls. This would give a constntly updated value though which you may not want. Miles MilesUK ProcessBook v3.0.15.3
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
I'm with Miles, you could do this in a dataset and set it to refresh once per minute. When you say you have an old version of PI, what is your version of ProcessBook? In relation to your latest post, to run your code once per minute you could use the "Display_DataUpdate" event that typically fires once every 5 seconds (it is configurable). Just put the following as your first line: Code: Private Sub Display_DataUpdate() ' Event should fire within the first 5 seconds of a minute If Second(Now()) <= 5 Then ' Call your routine here End If End Sub
Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
Hello, RJKsolutions - PI v2.16 Your code works but it gives me the only small error that i have with my version below, it means i cant do things like select a value to make a multistate. Stop the routine and its okay. Any ideas how to get around this? At present i have this, but it means that I cant do some things in pi: Code: Sub timingrun()
'updates my pi display to let me know its still running Dim MyTagName5 As String 'Tagname MyTagName5 = Text5.Contents MyTagName5 = MyTagName5 + 1 Text5.Contents = MyTagName5
Dim PauseTime, start, finish, TotalTime
PauseTime = 60 ' Set duration. start = Timer ' Set start time. Do While Timer < start + PauseTime DoEvents ' Yield to other processes. Loop finish = Timer ' Set end time.
'Calls my subroutines here
Call timingrun
End Sub
The code above in previous posts calculates how much I have made, how much is still to make and then works out how many minutes are left. I then add this to the VBA time and write it back to the pidisplay. Now i dont think i can make it do that in a dataset? Ta J
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Wow, Processbook v2.16, you guys need to upgrade! Your code there would never release the process back to Processbook so nothing else will run. It is quite easy to do without so much code but I need to make sure what I tell you will work in such an old version of Processbook...I'll get something to you asap. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Member Groups: Member
Joined: 4/12/2011 Posts: 10 Location: Uk
|
Actually your suggestion above works well, now that i have removed the timer. this here: Code: Private Sub Display_DataUpdate() ' Event should fire within the first 5 seconds of a minute If Second(Now()) <= 5 Then ' Call your routine here Dim MyTagName5 As String 'Tagname MyTagName5 = Text5.Contents MyTagName5 = MyTagName5 + 1 Text5.Contents = MyTagName5 Call Msblender Call Goblender3 Call Goblender4 End If End Sub
Only halts the process for about 2 secs, so that is just fine! (Unless you want to strech your brain a bit more!) Just need to try and solve this one: http://www.rjksolutionsl...ltistate-questions.aspx
Ta
|
|
|
|
Guest
|