private void InitVariables() { // Add local variables that are linked to corresponding variables on the physical RC8 controller // Add a variable linked to the robot connected to the RC8 controller Robot = RC8Controller.AddRobot("Arm"); // Add robot variables RobotBusyStatus = Robot.AddVariable("@BUSY_STATUS"); // Add a variable linked to the robot's busy status RobotState = Robot.AddVariable("@State"); // Add a variable which contains the current state of the robot RobotExternalSpeed = Robot.AddVariable("@Extspeed"); // Add a variable linked to the external (teach pendant) speed RobotCurrentPosition = Robot.AddVariable("@CURRENT_POSITION"); // Add a variable which contains the current robot position RobotCurrentAngle = Robot.AddVariable("@CURRENT_ANGLE"); // Add a variable which contains the current robot angle // Add variables that are linked to the current error code and description CurrentErrorCode = RC8Controller.AddVariable("@ERROR_CODE"); CurrentErrorDescription = RC8Controller.AddVariable("@ERROR_DESCRIPTION"); // Register to handle new message events from the controller // Every time the controller has a new message, the ShowMessage function will be called RC8Controller.OnMessage += new _ICaoControllerEvents_OnMessageEventHandler(ShowMessage); // Add a variable linked to string variable S10 RC8variable_S10 = RC8Controller.AddVariable("S10"); timer_InterfaceUpdate.Start(); // Start the GUI timer }
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 }
public DensoRobot(CaoRobot r) { robot = r; OnLogEvent("Robot: robot add variable..."); foreach (var s in RobotVarStrings) { RobCaoVars.Add(s, robot.AddVariable(s, "")); } }
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; }