Last active
May 14, 2020 16:47
-
-
Save clope031/ae5f291311d23b81960da37aee244ee2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
using ORiN2.interop.CAO; | |
namespace RC8_with_ORiN_VS2010 | |
{ | |
public partial class Variable : Form | |
{ | |
private CaoEngine g_eng; //CaoEngine object variable | |
private CaoController g_ctrl; //CaoController object variable | |
private CaoVariable g_val; //CaoVariable object variable | |
public Variable() | |
{ | |
InitializeComponent(); | |
} | |
private void Command1_Click(object sender, EventArgs e) | |
{ | |
Text1.Text = Convert.ToString(g_val.Value); //Read Variable | |
} | |
private void Command2_Click(object sender, EventArgs e) | |
{ | |
g_val.Value = Convert.ToString(Text2.Text); | |
} | |
private void Variable_Load(object sender, EventArgs e) | |
{ | |
g_eng = new CaoEngine(); //CaoEngine object creation | |
//Connect RC: IP setting depends on your RC setting. | |
g_ctrl = g_eng.Workspaces.Item(0).AddController("RC8", "CaoProv.DENSO.RC8", "", "Server=192.168.0.1"); | |
//Variable name "S15" | |
g_val = g_ctrl.AddVariable("S15", ""); | |
} | |
private void Variable_FormClosed(object sender, FormClosedEventArgs e) | |
{ | |
//Delete variable object | |
g_ctrl.Variables.Clear(); | |
System.Runtime.InteropServices.Marshal.ReleaseComObject(g_val); | |
g_val = null; | |
//Delete controller object | |
g_eng.Workspaces.Item(0).Controllers.Remove(g_ctrl.Index); | |
System.Runtime.InteropServices.Marshal.ReleaseComObject(g_ctrl); | |
g_ctrl = null; | |
//Delete engine object | |
System.Runtime.InteropServices.Marshal.ReleaseComObject(g_eng); | |
g_eng = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment