TaskSearchRapidSymbol Method |
Namespace: ABB.Robotics.Controllers.RapidDomain
public override RapidSymbol[] SearchRapidSymbol( RapidSymbolSearchProperties sProps, string stDataType, string stRegex )
Exception | Condition |
---|---|
GeneralException | A General Exception has occurred. |
NOTE! RAPID data declared in a -Shared -Hidden module cannot be accessed.
private void btnSearch_Click(object sender,EventArgs e) { try { // Create Task if not done if (tT_Rob1 == null) tT_Rob1 = ctrl.Rapid.GetTask("T_ROB1"); RapidSymbolSearchProperties sProp = RapidSymbolSearchProperties.CreateDefault(); sProp.SymbolType = SymbolTypes.Function | SymbolTypes.RapidData; sProp.IsInUse = false; sProp.SearchMethod = SymbolSearchMethod.Block; RapidSymbol[] datas = tT_Rob1.SearchRapidSymbol(sProp,"num",string.Empty); foreach (RapidSymbol rs in datas) { ListViewItem li = new ListViewItem(rs.Name); // [<TASK>,<MODULE>,...] li.SubItems.Add(rs.Scope[1]); // Add item listView1.Items.Add(li); } } catch (System.Exception ee) { // Handle any error here } }
This example shows a simple search method that find declared data of type defined by parameter sDataType. Parameter bSystem determines the scope to search. The search is made from task T_ROB1.
private RapidSymbol[] GetSymbols(string stDataType, bool bSystem) { RapidSymbol[] result = new RapidSymbol[0]; Task tRob1 = null; try { // Create temporary controller object to get task using (Controller c = new Controller()) { tRob1 = c.Rapid.GetTask("T_ROB1"); if (tRob1 != null) { RapidSymbolSearchProperties sProps = RapidSymbolSearchProperties.CreateDefault(); // Setup sProps according to parameter bSystem if (bSystem == true) { // Search data that the task can se in System scope, e.g. Shared data sProps.GlobalRapidSymbol = true; sProps.IsInUse = false; sProps.LocalRapidSymbol = false; sProps.Recursive = false; sProps.SearchMethod = SymbolSearchMethod.Scope; sProps.SymbolType = SymbolTypes.RapidData; } else { // Search Task scope sProps.SymbolType = SymbolTypes.RapidData; sProps.IsInUse = false; sProps.SearchMethod = SymbolSearchMethod.Block; } // Perform the search result = tRob1.SearchRapidSymbol(sProps, stDataType, string.Empty); } else { // No task to search from } } } catch (GeneralException ge) { // TODO: Add error handling } catch (System.Exception se) { // TODO: Add error handling } finally { // Release temporary resources if (tRob1 != null) { tRob1.Dispose(); tRob1 = null; } } return result; }