Skip to content

Instantly share code, notes, and snippets.

@clope031
Last active May 14, 2020 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clope031/c194693a1e457e3a4024009aa01dc3fb to your computer and use it in GitHub Desktop.
Save clope031/c194693a1e457e3a4024009aa01dc3fb to your computer and use it in GitHub Desktop.
CAO_RC8PRovider_VB-NET_Variable
Imports ORiN2.interop.CAO
Public Class Variable
Dim g_eng As CaoEngine
Dim g_ctrl As CaoController
Dim g_val As CaoVariable
Private Sub Command1_Click(sender As System.Object, e As System.EventArgs) Handles Command1.Click
Text1.Text = g_val.Value 'Read Variable
End Sub
Private Sub Command2_Click(sender As System.Object, e As System.EventArgs) Handles Command2.Click
g_val.Value = Convert.ToBoolean(Text2.Text) 'Write Variable
End Sub
Private Sub Variable_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
g_eng = New CaoEngine
'Connect RC: IP setting depends on your RC setting.
g_ctrl = g_eng.Workspaces.Item(0).AddController("RC8", "CaoProv.DENSO.RC8", "localhost", "Server=192.168.0.1")
'Variable name "IO150"
g_val = g_ctrl.AddVariable("IO150", "")
End Sub
Private Sub Variable_FormClosed(sender As System.Object, e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
'Delete variable object
g_ctrl.Variables.Clear()
System.Runtime.InteropServices.Marshal.ReleaseComObject(g_val)
g_val = Nothing
'Delete controller object
g_eng.Workspaces.Item(0).Controllers.Remove(g_ctrl.Index)
System.Runtime.InteropServices.Marshal.ReleaseComObject(g_ctrl)
g_ctrl = Nothing
'Delete engine object
System.Runtime.InteropServices.Marshal.ReleaseComObject(g_eng)
g_eng = Nothing
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment