Array as RapidData
Software support has received many questions when it comes to Arrays. There are some missing features when it comes to arrays both in FP SDK 5.06 and PC SDK 5.06. The array support will be improved in coming releases. You will be able to try it out in RAB/PC SDK 5.07.
Example 1 - PC SDK & and FP SDK
1. You need a Controller instance, _ctrl
2. Task 1 needs a loaded module named TestArrays
3. TestArrays is an array with 10 element long
==>In? (I 5.06 there is unfortunately no way to check the length of an array.)
public void LoopRobTarget_5_06__5_07()
{
RapidData data = _ctrl.Rapid.GetRapidData( "T_ROB1", "TestArrays", "VRobTD" );
for( int i=0; i<10; i++ )
{
RobTarget target = (RobTarget)data.ReadItem( i );
Console.WriteLine( target.ToString() );
}
}
Example 2: PC SDK 5.06 - PC SDK User's guide/Sample Applications/...RapidDomain/C# ReadItem & WriteItem example.
The following example might be easier to understand compared to the User's guide's C# ReadItem & WriteItem example:
public void TouchTargets( Controller controller )
{
// get the data, modify and update
using( RapidData data = controller.Rapid.GetData ( "T_ROB1", "BasicExercise", "robtarget_array" ) )
using( Mastership.Request( controller.Rapid ) )
{
for( int i=0; i<6; i++ ) // hardcoded length
{
RobTarget target = (RobTarget)data.ReadItem(i);
// do some modifications...
target.Trans.X++;
target.Trans.Y++;
// update data in controller
data.WriteItem( target, i );
}
}
}
Notes.
1 pC SDK-RapidData-Arrays start at index 0. FP-SDK-RapidData-Arrays start at index 1
2 If possible work with arrays element by element. ->Don't copy the complete array by default. ->From the product point of view we will focus on high performance for element based operations of arrays.
3. Use using(....) -> You get simpler code (easier to read and understand)
4. If you have to add Dispose (in some cases in FP SDK) make sure you always enter the Dispose also if your code ends up in an exception. We recommend you to use the Try & Finally concept.
5. Only use try & catch if you can do something about the problem. Otherwise the code becomes hard to read and understand. In most cases you can probably use Try & Finally instead.
//Pernilla
pernillastake38686,6205787037Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings