/// <summary> /// Method to run the program and returns the action message. /// </summary> /// <returns> The action message / status. </returns> private string StartCommand() { // Check the mode of the controller if (_controller.OperatingMode != ControllerOperatingMode.Auto) { return("Controller not set in automatic."); } // Check if the motors are enabled if (_controller.State != ControllerState.MotorsOn) { return("Motors not on."); } // Execute the program using (Mastership master = Mastership.Request(_controller)) { _controller.Rapid.Start(RegainMode.Continue, ExecutionMode.Continuous, ExecutionCycle.Once, StartCheck.CallChain); // Give back the mastership master.Release(); } // Return status message return("Program started."); }
public bool Read_Bool(string BoolName) { ABB_Data_Read Read = new ABB_Data_Read(); bool bValue = false; try { tasks = controller.Rapid.GetTasks(); using (Mastership m = Mastership.Request(this.controller.Rapid)) { //Check if the user has the rights to execute RAPID program if (uas.CheckDemandGrant(Grant.ModifyRapidDataValue)) { //Modify the rapid value bValue = Read.Read_ABB_Bool("mMain", "T_MAIN", controller, BoolName); return(bValue); } else { return(bValue); } } } catch (System.InvalidOperationException ex) { //return _infomessage = "Mastership is held by another client." + ex.Message; return(false); } catch (System.Exception ex) { //return _infomessage = "Unexpected error occurred: " + ex.Message; return(false); } }
public void StopRapidProgram() { try { if (controller.OperatingMode == ControllerOperatingMode.Auto) { using (Mastership m = Mastership.Request(controller.Rapid)) { controller.Rapid.Stop(); } } else { MessageBox.Show("Automatic mode is required to start execution from a remote client."); } } catch (System.InvalidOperationException ex) { MessageBox.Show("Mastership is held by another client." + ex.Message); } catch (System.Exception ex) { MessageBox.Show("Unexpected error occurred: " + ex.Message); } }
public string Set_Reset_Bool(string BoolName, Boolean BoolValue) { ABB_Data_Write Write = new ABB_Data_Write(); string _infomessage = ""; try { tasks = controller.Rapid.GetTasks(); using (Mastership m = Mastership.Request(this.controller.Rapid)) { //Check if the user has the rights to execute RAPID program if (uas.CheckDemandGrant(Grant.ModifyRapidDataValue)) { //Modify the rapid value Write.Write_ABB_Boolean(BoolName, "mMain", "T_MAIN", controller, BoolValue); return(_infomessage); } else { return(_infomessage); } } } catch (System.InvalidOperationException ex) { return(_infomessage = "Mastership is held by another client." + ex.Message); } catch (System.Exception ex) { return(_infomessage = "Unexpected error occurred: " + ex.Message); } }
public void StartProcess() { using (Mastership m = Mastership.Request(controller.Rapid)) { rd_begin.Value = processFlag; } }
/// <summary> /// Resets the program pointer in the controller to the main entry point. Needs to be called /// before starting execution of a program, otherwise the controller will throw an error. /// </summary> internal bool ResetProgramPointers() { if (controller == null) { logger.Debug("Cannot reset pointer: not connected to controller"); return(false); } if (tMainTask == null) { logger.Debug("Cannot reset pointer: mainTask not present"); return(false); } try { using (Mastership.Request(controller.Rapid)) { tMainTask.ResetProgramPointer(); if (tMonitorTask != null) { tMonitorTask.ResetProgramPointer(); } return(true); } } catch (Exception ex) { logger.Debug("Cannot reset pointer..."); logger.Debug(ex); } return(false); }
public string Program_Stop() { string _infomessage = ""; try { tasks = this.controller.Rapid.GetTasks(); using (Mastership m = Mastership.Request(this.controller.Rapid)) { //Check if the user has the rights to execute RAPID program if (uas.CheckDemandGrant(Grant.ExecuteRapid)) { this.controller.Rapid.Stop(StopMode.Cycle); _infomessage = "The program has been stopped"; return(_infomessage); } else { _infomessage = "You do not have the grant to execute RAPID programs"; } return(_infomessage); } } catch (System.InvalidOperationException ex) { _infomessage = "Mastership is held by another client." + ex.Message; return(_infomessage); } catch (System.Exception ex) { _infomessage = "Unexpected error occurred: " + ex.Message; return(_infomessage); } }
public static Dictionary <string, List <string[]> > readProgramData(bool run, string[] controllerData) { List <string[]> progData = new List <string[]> { }; ///List<string[]> currData = new List<string[]> { }; if (run == true) { Guid systemId = new Guid(controllerData[1]); Controller controller = new Controller(systemId); controller.Logon(UserInfo.DefaultUser); Task newTask = controller.Rapid.GetTask("T_ROB1"); using (Mastership.Request(controller.Rapid)) { RapidSymbolSearchProperties sProp = RapidSymbolSearchProperties.CreateDefault(); sProp.Types = SymbolTypes.Data; RapidSymbol[] progDatas = newTask.GetModule("MainModule").SearchRapidSymbol(sProp); foreach (RapidSymbol rs in progDatas) { RapidData rd = controller.Rapid.GetTask("T_ROB1").GetModule("MainModule").GetRapidData(rs); if ((rd.Value is ToolData) | (rd.Value is WobjData)) { string[] eachProg = new string[3] { rd.RapidType, rd.Name, rd.Value.ToString() }; progData.Add(eachProg); } } /* * RapidSymbol[] currDatas = newTask.GetModule("MainModule").SearchRapidSymbol(sProp); * foreach (RapidSymbol rs in currDatas) * { * RapidData rd = controller.Rapid.GetTask("T_ROB1").GetModule("MainModule").GetRapidData(rs); * if ((rd.Value is ToolData) | (rd.Value is WobjData)) * { * string[] eachCurr = new string[3] * { * rd.RapidType, * rd.Name, * rd.Value.ToString() * }; * currData.Add(eachCurr); * } * } */ } } return(new Dictionary <string, List <string[]> > { { "programData", progData } /*,{"currentData", currData}*/ }); }
/// <summary> /// Pings the controller's Rapid resource with a bogus request to check if it is available for /// Mastership, or it is held by someone else. /// </summary> /// <returns></returns> private bool TestMastershipRapid() { if (controller != null) { try { using (Mastership.Request(controller.Rapid)) { // Gets the current execution cycle from the RAPID module and sets it back to the same value (just a stupid test) ExecutionCycle mode = controller.Rapid.Cycle; controller.Rapid.Cycle = mode; logger.Debug("Mastership test OK"); return(true); } } catch (Exception ex) { logger.Debug("Rapid Mastership not available"); logger.Debug(ex); } } else { logger.Debug("Cannot test Rapid Mastership, no controller available"); } return(false); }
private void StartProduction() { try { if (controller.OperatingMode == ControllerOperatingMode.Auto) { using (Mastership m = Mastership.Request(controller.Rapid)) { this.controller.Rapid.Start(); label3.Text = "Production started"; } } else { MessageBox.Show("Automatic mode is required to start execution from a remote client."); } } catch (System.InvalidOperationException ex) { MessageBox.Show("Mastership is held by another client. " + ex.Message); } catch (System.Exception ex) { MessageBox.Show("Unexpected error occurred: " + ex.Message); } }
public static Dictionary <string, string> getCurrentPosition(bool run, string[] controllerData) { string robotTarget = ""; string jointTarget = ""; if (run == true) { Guid systemId = new Guid(controllerData[1]); Controller controller = new Controller(systemId); controller.Logon(UserInfo.DefaultUser); Task newTask = controller.Rapid.GetTask("T_ROB1"); using (Mastership.Request(controller.Rapid)) { robotTarget = newTask.GetRobTarget().ToString(); jointTarget = newTask.GetJointTarget().ToString(); } } return(new Dictionary <string, string> { { "robotTarget", robotTarget }, { "jointTarget", jointTarget } }); }
private void StopProduction() { try { if (controller.OperatingMode == ControllerOperatingMode.Auto) { using (Mastership m = Mastership.Request(controller.Rapid)) { this.controller.Rapid.Stop(StopMode.Immediate); label3.Text = "Production stopped!"; } } else { MessageBox.Show("Controller is not running"); } } catch (System.InvalidOperationException ex) { MessageBox.Show("Mastership is held by another client. " + ex.Message); } catch (System.Exception ex) { MessageBox.Show("Unexpected error occurred: " + ex.Message); } }
private void btnHome_Click(object sender, EventArgs e) { // JointTarget jCurPos = this.controller.MotionSystem.ActiveMechanicalUnit.GetPosition(); JointTarget jCurPos = new JointTarget(); jCurPos.FillFromString2("[[0,0,0,0,90,0],[9E9,9E9,9E9,9E9,9E9,9E9]]"); try { using (this.master = Mastership.Request(controller.Rapid)) { RapidData rd = controller.Rapid.GetRapidData("T_ROB1", "Module1", "jTarget"); controller.Rapid.GetTask("T_ROB1").SetProgramPointer("Module1", "moveJoint"); rd.Value = jCurPos; controller.Rapid.Start(); } if (this.controller.Rapid.ExecutionStatus != ExecutionStatus.Running) { master.Release(); } } catch (System.InvalidOperationException ex) { MessageBox.Show("Mastership is held by another client." + ex.Message); master.Release(); master = Mastership.Request(controller); } catch (System.Exception ex) { MessageBox.Show("Unexpected error occurred: " + ex.Message); } }
public void SetPath(List <BrushStatus> nativTargets, ProgressBar pb) { if (nativTargets.Count > maxLength) { targetsNum = maxLength; } else { targetsNum = nativTargets.Count; } rd_tgNumValue.FillFromString2(targetsNum.ToString()); using (Mastership m = Mastership.Request(controller.Rapid)) { rd_targetsNum.Value = rd_tgNumValue; } Pos rt; for (int i = 0; i < targetsNum; i++) { rt = new Pos(); rt.FillFromString2("[" + nativTargets[i].X + "," + nativTargets[i].Y + "," + nativTargets[i].Z + "]"); Debug.WriteLine(rt.ToString()); using (Mastership m = Mastership.Request(controller.Rapid)) { rd_targets.WriteItem(rt, i); } pb.Increment(1); } pb.Value = 0; }
public string Read_Record_FromArray(int Individual_Index) { ABB_Data_Read Read_DataRecord = new ABB_Data_Read(); string Individual_Time = ""; try { using (Mastership m = Mastership.Request(controller.Rapid)) { //Check if the user has the rights to execute RAPID program if (uas.CheckDemandGrant(Grant.ModifyRapidDataValue)) { Individual_Time = Read_DataRecord.Read_ABB_DataRecord("RawIndividual", "mMain", "T_MAIN", controller, Individual_Index); return(Individual_Time); } else { return(Individual_Time); } } } catch (System.NullReferenceException ex) { return(Individual_Time); } }
/// <summary> /// //重置Task程序指针 /// </summary> /// <param name="controller">控制器</param> /// <param name="taskname">任务名称</param> /// <returns>返回值</returns> private int RAPID_ProgramReset(Controller controller, string taskname) { controller.Logon(ABB.Robotics.Controllers.UserInfo.DefaultUser); //登录 if (controller.OperatingMode != ControllerOperatingMode.Auto) //自动模式 { return(-1); } if (!controller.AuthenticationSystem.CheckDemandGrant(Grant.ExecuteRapid))//可执行 { controller.AuthenticationSystem.DemandGrant(Grant.ExecuteRapid); } try { using (Mastership m = Mastership.Request(controller.Rapid)) //写权限 { controller.Rapid.GetTask(taskname).ResetProgramPointer(); //复位程序指针 m.Release(); } } catch (Exception) { } return(0); }
/// <summary> /// Resets the program pointer in the controller to the main entry point. Needs to be called /// before starting execution of a program, otherwise the controller will throw an error. /// </summary> internal bool ResetProgramPointer() { if (controller == null) { Console.WriteLine("Cannot reset pointer: not connected to controller"); return(false); } if (tRob1Task == null) { Console.WriteLine("Cannot reset pointer: mainTask not present"); return(false); } try { using (Mastership.Request(controller.Rapid)) { tRob1Task.ResetProgramPointer(); return(true); } } catch (Exception ex) { Console.WriteLine("Cannot reset pointer..."); Console.WriteLine(ex); } return(false); }
private void labelExecStatus_Click(object sender, EventArgs e) { try { if (ctl.OperatingMode == ControllerOperatingMode.Auto && ctl.State == ControllerState.MotorsOn) { Mastership mc = Mastership.Request(this.ctl.Rapid); if (labelExecStatus.Text == ExecutionStatus.Running.ToString()) { //Perform operation tasks[0].Stop(); } else { StartResult a; tasks[0].ResetProgramPointer(); a = tasks[0].Start(); } mc.Dispose(); } else { MessageBox.Show("Please turn to Auto mode and motor on"); } } catch (System.InvalidOperationException ex) { MessageBox.Show("Mastership is held by another client." + ex.Message); } catch (System.Exception ex) { MessageBox.Show("Unexpected error occurred: " + ex.Message); } }
public void StartRapidProgram() { try { if (controller.OperatingMode == ControllerOperatingMode.Auto) { using (Mastership m = Mastership.Request(controller.Rapid)) { //Perform operation Debug.WriteLine("Exec status of the controller ::: " + controller.Rapid.ExecutionStatus); Debug.WriteLine("Controller State ::: " + controller.State); controller.Rapid.Start(true); } } else { MessageBox.Show("Automatic mode is required to start execution from a remote client."); } } catch (System.InvalidOperationException ex) { MessageBox.Show("Mastership is held by another client." + ex.Message); } catch (System.Exception ex) { MessageBox.Show("Unexpected error occurred: " + ex.Message); } }
string UploadCommand(Program program) { try { // task.Stop(StopMode.Instruction); string tempPath = Path.Combine(Util.LibraryPath, "temp"); if (Directory.Exists(tempPath)) { Directory.Delete(tempPath, true); } Directory.CreateDirectory(tempPath); program.Save(tempPath); string localFolder = Path.Combine(tempPath, program.Name); string robotFolder = $@"{_controller.FileSystem.RemoteDirectory}\{program.Name}"; string filePath = string.Empty; if (!_controller.IsVirtual) { _controller.AuthenticationSystem.DemandGrant(Grant.WriteFtp); _controller.FileSystem.PutDirectory(localFolder, program.Name, true); filePath = $@"{robotFolder}\{program.Name}_T_ROB1.pgf"; } else { filePath = $@"{localFolder}\{program.Name}_T_ROB1.pgf"; } using (Mastership master = Mastership.Request(_controller.Rapid)) { var task = _controller.Rapid.GetTasks().First(); task.DeleteProgram(); int count = 0; while (count++ < 100) { System.Threading.Thread.Sleep(100); try { _controller.AuthenticationSystem.DemandGrant(Grant.LoadRapidProgram); if (task.LoadProgramFromFile(filePath, RapidLoadMode.Replace)) { return($"Program {program.Name} uploaded to {_controller.Name}."); } } catch (Exception) { } } // task.ResetProgramPointer(); } } catch (Exception e) { return($"Error uploading: {e}"); } return("Unknown error"); }
/// <summary> /// PP移至main /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ptm_Btn_Click(object sender, EventArgs e) { using (Mastership mr = Mastership.Request(this.abbcontroller.Rapid)) { this.abbtask.ResetProgramPointer(); //重置程序指针至Main } }
public void CtrlRestart(Controller ctrl) { ctrl.Logon(UserInfo.DefaultUser); try { if (ctrl.OperatingMode == ControllerOperatingMode.Auto) { using (Mastership.Request(ctrl)) { ctrl.Restart(ControllerStartMode.Warm); } } else { MessageBox.Show("需要打开自动模式"); } } catch (InvalidOperationException ex) { MessageBox.Show("Mastership problem." + ex.Message); } catch (Exception ex) { MessageBox.Show("Unexpected error occurred: " + ex.Message); } ctrl.Logoff();//should be unecessary since we get kicked out at restart. }
private void excStartBtn_Click(object sender, EventArgs e) { using (Mastership mr = Mastership.Request(this.abbcontroller.Rapid)) { this.abbcontroller.Rapid.Start(); } }
private void stopLaterBtn_Click(object sender, EventArgs e) { using (Mastership mr = Mastership.Request(abbcontroller.Rapid)) { abbcontroller.Rapid.Stop(StopMode.Cycle); //执行完当前循环后停止 } }
/// <summary> /// Rapid程序立刻停止 /// </summary> private void stopRightBtn_Click(object sender, EventArgs e) { using (Mastership mr = Mastership.Request(abbcontroller.Rapid)) { abbcontroller.Rapid.Stop(StopMode.Immediate); //立刻停止 } }
/// <summary> /// 开始程序 /// </summary> /// <param name="controller">控制器</param> /// <returns></returns> public int RAPID_ProgramStart(Controller controller) { controller.Logon(ABB.Robotics.Controllers.UserInfo.DefaultUser); //登录 if (controller.OperatingMode != ControllerOperatingMode.Auto) //自动模式 { return(-1); } if (controller.State != ControllerState.MotorsOn)//已经上电 { return(-1); } if (!controller.AuthenticationSystem.CheckDemandGrant(Grant.ExecuteRapid))//可执行 { controller.AuthenticationSystem.DemandGrant(Grant.ExecuteRapid); } try { using (Mastership m = Mastership.Request(controller.Rapid)) //写权限 { controller.Rapid.Start(RegainMode.Continue, ExecutionMode.Continuous); //开始继续运行 m.Release(); } } catch (Exception ex) { return(-1); } return(0); }
public void StartProcess() { processFlag.FillFromString2(TO_PAINT.ToString()); using (Mastership m = Mastership.Request(controller.Rapid)) { rd_start.Value = processFlag; } }
/// <summary> /// 单点传输 /// </summary> /// <param name="pq"></param> internal void writePosQuat(Pose pq) { using (Mastership m = Mastership.Request(AbbCtrl.Rapid)) { abbController.DstPosQuat.Value = pq; m.Release(); } }
public void SetDrawingSpeed(int level) { speedLevel.FillFromString2(level.ToString()); using (Mastership m = Mastership.Request(controller.Rapid)) { rd_speedLevel.Value = speedLevel; } }
public void StopProcess() { // fillfromstring2 allows us to pass a varable to rapid data processFlag.FillFromString2(SHUT_DOWN.ToString()); using (Mastership m = Mastership.Request(controller.Rapid)) { rd_start.Value = processFlag; } }
private void BeginControl() { Controller.Logon(UserInfo.DefaultUser); Mastership = Mastership.Request(Controller.Rapid); Task = Controller.Rapid.GetTask("T_ROB1"); Controller.FileSystem.RemoteDirectory = "(HOME)$"; }