Access vast amounts of technical know-how and pro tips from our community of Geo SCADA experts.
Search in
Link copied. Please paste this link to share this article on your social media post.
Originally published on Geo SCADA Knowledge Base by Anonymous user | June 09, 2021 11:56 PM
📖 Home Back
Editing the content of a mimic, trend or logic program can be done through the use of the ViewX automation interface. This interface allows an application to connect to ViewX rather than the database server.
The program below, written in Visual Basic, uses the standard automation interface to both connect to the server, create a logic program, then connect to ViewX and configure the code for that program.
'constants
Dim SYSTEM_NAME As String
Dim USER_NAME As String
Dim SYSTEM_PASSWORD As String
Sub Logic()
'declare these constants!!
SYSTEM_NAME = ""
USER_NAME = ""
SYSTEM_PASSWORD = ""
' Connect to Server
Dim objServer As New ScxV6Server
objServer.Connect SYSTEM_NAME, USER_NAME, SYSTEM_PASSWORD
' Create ST Program object and rename it
Dim prog As ScxV6ObjectSet
prog = objServer.CreateObject("CLogicSTProgram", "$Root")
prog.Rename "Example Logic"
'Attach to ViewX
Dim v As ViewX.Application
Set v = New ViewX.Application
v.Visible = True
'Open ST Program document
Dim STProg As ViewXLogic.LogicSTProgram
Set STProg = ViewX.Documents("CLogicSTProgram").OpenFromServer(False, SYSTEM_NAME, "Example Logic")
' write text to program
Dim text As String
text = "PROGRAM ExampleLogic" + vbCrLf
text = text + "code here;" + vbCrLf
text = text + "END_PROGRAM"
STProg.SetProgramAndSave (text)
' Close window
STProg.Close
objServer.Disconnect
Set objServer = Nothing
End Sub
Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.