Click or drag to resize

TaskGetRapidData Method

Gets a RapidData object that references a RAPID data instance in the robot controller.

Namespace:  ABB.Robotics.Controllers.RapidDomain
Assembly:  ABB.Robotics.Controllers (in ABB.Robotics.Controllers.dll) Version: 6.5.129.0
Syntax
C#
public RapidData GetRapidData(
	params string[] rapidData
)

Parameters

rapidData
Type: SystemString
An array of strings, which specifies where in the RAPID domain the RAPID data is declared.

Return Value

Type: RapidData
A RapidData object. If the RAPID data doesn't exist null is returned.
Exceptions
ExceptionCondition
GeneralExceptionA General Exception has occurred.
ArgumentNullExceptionrapidData is null or length is less then 1
Remarks
NOTE:When the returned instance is no longer needed you must call its Dispose method.
Remarks
If the name of the declaring module is unknown SearchRapidSymbol(RapidSymbolSearchProperties, String, String) can be used.

To access RAPID data in a shared module use the name of the data as parameter, see the second example below.

NOTE! RAPID data declared in a -Shared -Hidden module cannot be accessed.

Examples
This example utilizes a function that returns the sum of all reg1 variables in the system. Variable reg1 is by default declared in RAPID module USER.
private int SumOfAllReg1(Controller c)
{
    int result = 0;
    try
    {
        // Get all tasks
        Task[] tasks = c.Rapid.GetTasks();

        foreach (Task t in tasks)
        {
            RapidData rdReg1 = t.GetRapidData("USER","reg1");

            result += int.Parse(rdReg1.Value.ToString());
        } 
    }
    catch (GeneralException ee)
    {
        // TODO: Add error handling
    }
    catch (System.Exception ee)
    {
        // TODO: Add error handling
    }
    finally
    {
        // Release resources
    }

    return result;
}

This example gets the shared RAPID data nMessageID seen from task T_ROB1.

private RapidData GetMessageID()
{
    RapidData rData = null;
    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)
            {
                // Only send one parameter to get shared data 
                rData = tRob1.GetRapidData("nMessageID");
            }
            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 rData;
}
See Also