private void Disconnect() { // Properly shut down the local variables in reverse order of precedence so that the ORiN engine is not left hanging TurnOffMotors(); try { Robot.Execute("GiveArm"); // Release the arm } catch (Exception ex) { ShowError("GiveArm", ex); } Robot.Variables.Clear(); // Clear all robot-specific variables from the main robot variable (THIS DOES NOT AFFECT VALUES ON THE PHYSICAL RC8 CONTROLLER) RobotBusyStatus = null; // Set the individual robot-specific variable to null RobotState = null; RobotExternalSpeed = null; RobotCurrentPosition = null; RobotCurrentAngle = null; RC8Controller.Robots.Clear(); // Clear all local robot variables from the controller variable Robot = null; // Set the individual robot variable to null RC8Controller.Variables.Clear(); // Clear all local variables from the controller variable (THIS DOES NOT AFFECT VALUES ON THE PHYSICAL RC8 CONTROLLER) CurrentErrorCode = null; // Set the individual local variables to null CurrentErrorDescription = null; RC8variable_S10 = null; ORiN_Engine.Workspaces.Item(0).Controllers.Remove(RC8Controller.Index); // Remove the controller variable from the ORiN engine RC8Controller = null; // Set the individual controller variable to null ORiN_Engine = null; // Set the ORiN engine variable to null }
private void ConnectToController() { KillCaoExecutableIfItIsAlreadyRunning(); // This is required to prevent lockup in the event that this program is not properly shut down ORiN_Engine = new CaoEngine(); // This starts a separate program called "CAO.exe" which allows this program to talk with RC8 controllers // Create a link to the RC8 controller via the engine (CAO.exe) RC8Controller = ORiN_Engine.Workspaces.Item(0).AddController( "", // This is the name of the connection to the RC8 controller; Pass an empty string to have the controller auto-generate a name "CaoProv.DENSO.RC8", // This is the name of the DENSO ORiN provider for RC8; It must be exactly as shown "localhost", // This is the name of the machine executing the DENSO ORiN provider (usually the machine running this program) "Server=192.168.0.1"); // This is the IP address of the physical RC8 controller }
private void button_Close_Click(object sender, EventArgs e) { // Properly shut down the local variables in reverse order of precedence so that the ORiN engine is not left hanging RC8Controller.Variables.Clear(); // Clear all local variables from the controller variable (THIS DOES NOT AFFECT VALUES ON THE PHYSICAL RC8 CONTROLLER) RC8variable_S10 = null; // Set the individual local variables to null ORiN_Engine.Workspaces.Item(0).Controllers.Remove(RC8Controller.Index); // Remove the controller variable from the ORiN engine RC8Controller = null; // Set the individual controller variable to null ORiN_Engine = null; // Set the ORiN engine variable to null Close(); // Exit this C# program }
public Form1() { //This constructor for the graphical interface is called automatically upon program startup before the form is visible to the user InitializeComponent(); //Disable the buttons to prevent exceptions from the user clicking them out of order button_ReadVariable.Enabled = false; button_WriteVariable.Enabled = false; button_Close.Enabled = false; KillCaoExecutableIfItIsAlreadyRunning(); // This is required to prevent lockup in the event that this program is not properly shut down ORiN_Engine = new CaoEngine(); // This starts a separate program called "CAO.exe" which allows this program to talk with RC7 controllers }
public void Init() { if (IsInitialized) { return; } Kill(); // Create CaoEngine object caoEngine = new CaoEngine(); caoWorkspace = caoEngine.Workspaces.Item(0); //caoController = caoWorkspace.AddController("RC7", "CaoProv.DENSO.NetwoRC", "", "conn=eth:192.168.0.1"); caoController = caoWorkspace.AddController("RC8", "CaoProv.DENSO.RC8", null, "Server=192.168.0.1,@IfNotMember=True"); caoRobot = caoController.AddRobot("Arm", ""); Robot = new DensoRobot(caoRobot); Robot.LogEvent += OnLogEvent; Controller = new DensoController(caoController); Controller.LogEvent += OnLogEvent; Controller.ClearError(); if ((int)Controller.ControllerCaoVars["@MODE"].Value <= 2) { MessageBox.Show("Controller not in Auto Mode! Retry!"); Close(); Kill(); IsInitialized = false; return; } //Controller.PutAutoMode(); Controller.Initialize(); //RobslaveTask = new DensoTask(caoController.AddTask("robslave", null)); //RobslaveTask.LogEvent += OnLogEvent; //RobslaveTask.Stop(); //RobslaveTask.Start(); IsInitialized = true; }
public void Close() { // Release caoRobot object if (caoRobot != null) { caoRobot.Variables.Clear(); Marshal.ReleaseComObject(caoRobot); caoRobot = null; } // Release controller object if (caoController != null) { caoController.Variables.Clear(); caoController.Robots.Clear(); Marshal.ReleaseComObject(caoController); caoController = null; } if (caoWorkspace != null) { caoWorkspace.Controllers.Clear(); Marshal.ReleaseComObject(caoWorkspace); caoWorkspace = null; } if (caoEngine != null) { caoEngine.Workspaces.Clear(); Marshal.ReleaseComObject(caoEngine); caoEngine = null; } IsInitialized = false; }