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 }
private void button_Connect_Click(object sender, EventArgs e) { button_Connect.Enabled = false; // 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 // Add a local variable that is linked to string variable S10 on the physical RC8 controller RC8variable_S10 = RC8Controller.AddVariable("S10"); button_ReadVariable.Enabled = true; button_WriteVariable.Enabled = true; button_Close.Enabled = true; }
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 DensoController(CaoController c) { controller = c; c.OnMessage += OnMessageEvent; OnLogEvent("Controller: robot add variable..."); foreach (var s in ControllerVarStrings) { ControllerCaoVars.Add(s, controller.AddVariable(s, null)); } for (int i = 0; i < 100; i++) { ControllerPointsPVars.Add("P" + i, controller.AddVariable("P" + i, null)); } for (int i = 0; i < 100; i++) { ControllerPointsJVars.Add("J" + i, controller.AddVariable("J" + i, null)); } }
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; }
private void button_Connect_Click(object sender, EventArgs e) { button_Connect.Enabled = false; // Create a link to the RC7 controller via the engine (CAO.exe) RC7Controller = ORiN_Engine.Workspaces.Item(0).AddController( "Sample", // This is the name of the connection to the RC7 controller; Pass an empty string to have the controller auto-generate a name "CaoProv.DENSO.NetwoRC", // This is the name of the DENSO ORiN provider for RC7; It must be exactly as shown "", // This is the name of the machine executing the DENSO ORiN provider (usually the machine running this program) "Conn=eth:192.168.0.2"); // This is the IP address of the physical RC7 controller //In order to perform motion commands on the pc side you should start the RobSlave.pac program on the RC7 RC7Task_RobSlave = RC7Controller.AddTask("RobSlave", ""); RC7Task_RobSlave.Start(1, ""); // Add a local variable that is linked to string variable S10 on the physical RC7 controller RC7variable_S10 = RC7Controller.AddVariable("S10"); button_ReadVariable.Enabled = true; button_WriteVariable.Enabled = true; button_Close.Enabled = true; }