RAPID modules & program files
Load, save and unload RAPID programs, read and edit module source text, manage breakpoints, read build errors and modify taught positions.
A RAPID program is a set of modules, and a module is a text file the controller keeps in memory. robot.Rws.Rapid loads and saves these files, reads and rewrites their source, and reports what the controller refused when it linked them.
Everything on this page that writes needs the Rapid mastership. Editing the source of a task that is running is possible, but the controller can refuse a change that would invalidate the program pointer.
Program files
A program is a .pgf file naming the modules it holds. GetProgram returns the program of a task, null when the task holds none.
AbbController robot = new AbbController();robot.Connect("192.168.0.1");// The program the task holds, null when it holds noneRapidProgramInfo program = robot.Rws.Rapid.GetProgram("T_ROB1");if (program != null)Console.WriteLine(program.Name + ", entry point " + program.EntryPoint);robot.Rws.Mastership.Request(MastershipDomain.Rapid);try{// The program file has to be on the controller already.// Upload it first with robot.Rws.File.robot.Rws.Rapid.LoadProgram("T_ROB1", "$HOME/myprogram.pgf", RapidProgramLoadMode.Replace);// Write every module of the task into a directory of the controllerrobot.Rws.Rapid.SaveProgram("T_ROB1", "$HOME/myprograms");robot.Rws.Rapid.SetProgramName("T_ROB1", "myprogram");robot.Rws.Rapid.SetEntryPoint("T_ROB1", "main");robot.Rws.Rapid.UnloadProgram("T_ROB1");}finally{robot.Rws.Mastership.Release(MastershipDomain.Rapid);}// Loading returns before the controller has finished, so read what it refusedforeach (RapidBuildError error in robot.Rws.Rapid.GetBuildErrors("T_ROB1"))Console.WriteLine(error.ModuleName + " " + error.Row + "," + error.Column + ": " + error.Error);robot.Disconnect();}
RapidProgramLoadMode | What happens to the modules already loaded |
|---|---|
Add | They are kept, the modules of the program are added |
Replace | Everything the task holds is replaced by the program |
Points to know:
- The file has to be on the file system of the controller already. Upload it first with the file system service.
LoadProgramreturns before the controller has finished loading. Read the task state and the build errors afterwards, do not assume the program is ready.SaveProgramwrites the modules of the task into a directory of the controller, not on your PC. Download them afterwards.SetEntryPointsets the routineResetProgramPointergoes back to, usuallymain.- Loading one module instead of a whole program is done with
LoadModule, see RAPID tasks & program execution.
// Loads a program into a task (synchronous)void LoadProgram(string task, string programPath, RapidProgramLoadMode loadMode = RapidProgramLoadMode.Add);// Saves the program of a task to the file system of the controller (synchronous)void SaveProgram(string task, string path);// Sets the routine the program pointer moves to when it is reset (synchronous)void SetEntryPoint(string task, string routine);// Renames the program of a task (synchronous)void SetProgramName(string task, string name);// Unloads the program of a task (synchronous)void UnloadProgram(string task);
Every method also exists in an asynchronous version, with the same name followed by Async and an optional CancellationToken.
The program loaded into a task. Returned by RapidService.GetProgram(), which returns null when the task holds no program at all.
| Member | Type | Description |
|---|---|---|
RapidProgramInfo() Constructor | Initializes a new instance of the RapidProgramInfo class | |
EntryPoint Property | string | Routine the program pointer moves to when it is reset, null when the controller did not report it |
Name Property | string | Name of the program, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this program |
What happens to the modules already in a task when a program is loaded into it
| Name | Value | Description |
|---|---|---|
Add | 0 | Keep the modules already loaded and add the ones of the program |
Replace | 1 | Replace everything the task holds with the program |
Modules of a task
GetModules lists the modules a task holds. GetModule gives the file a module came from and the properties declared on it.
AbbController robot = new AbbController();robot.Connect("192.168.0.1");foreach (RapidModuleItem module in robot.Rws.Rapid.GetModules("T_ROB1")){Console.WriteLine(module.Name + " " + module.Type); // ProgramModule or SystemModule// The file the module came from and the properties declared on itRapidModuleInfo info = robot.Rws.Rapid.GetModule("T_ROB1", module.Name);Console.WriteLine(info.FileName);foreach (RapidModuleAttribute attribute in info.Attributes)Console.WriteLine(" " + attribute); // SystemModule, NoStepIn, ...// How big the source is, in lines and columnsRapidModuleExtension size = robot.Rws.Rapid.GetModuleExtension("T_ROB1", module.Name);Console.WriteLine(size.LineCount + " lines, " + size.MaxColumnCount + " columns");// A counter that only moves when the module changes, cheaper than reading it againConsole.WriteLine(robot.Rws.Rapid.GetModuleChangeCount("T_ROB1", module.Name));}// Which of these properties this module acceptsRapidModuleAttribute[] possible = robot.Rws.Rapid.GetPossibleModuleAttributes("T_ROB1", "MainModule", RapidModuleAttribute.NoStepIn, RapidModuleAttribute.ViewOnly);Console.WriteLine(possible.Length);// Write one module as a file of the controller, the extension is added by the controllerrobot.Rws.Rapid.SaveModule("T_ROB1", "MainModule", "MainModule", "$HOME");robot.Disconnect();}
RapidModuleAttribute | What the module declares |
|---|---|
SystemModule | The module belongs to the system, it is not saved with the program |
ReadOnly | The source cannot be changed |
ViewOnly | The source can be read but not changed |
NoView | The source cannot even be read |
NoStepIn | Stepping does not enter the routines of the module |
Encoded | The source is stored encoded |
GetModuleChangeCount returns a counter that only moves when the module changes. Comparing it with the previous reading is much cheaper than downloading the source again to find out that nothing moved. GetModuleExtension gives the number of lines and the longest line of the source.
Read and edit the source
AbbController robot = new AbbController();robot.Connect("192.168.0.1");// The whole source of the moduleRapidModuleText source = robot.Rws.Rapid.GetModuleText("T_ROB1", "MainModule");Console.WriteLine(source.Text);Console.WriteLine(source.ChangeCount);// Only a few lines. Rows and columns are counted from 1, and the controller clamps// the end of the range to what the module really holds.Console.WriteLine(robot.Rws.Rapid.GetModuleTextRange("T_ROB1", "MainModule", 1, 1, 10, 1));// Where a piece of text sits, Found is false when it is nowhereRapidTextPosition found = robot.Rws.Rapid.SearchModuleText("T_ROB1", "MainModule", "MoveJ");Console.WriteLine(found.Found + " " + found.Row + "," + found.Column);robot.Rws.Mastership.Request(MastershipDomain.Rapid);try{// Insert one line after a range, leaving the rest of the module aloneRapidSetTextRangeResult result = robot.Rws.Rapid.SetModuleTextRange("T_ROB1", "MainModule",RapidTextReplaceMode.After, RapidTextQueryMode.Try,5, 1, 5, 1," reg1 := 0;\r\n");// Rewriting the line that declares the module renames itConsole.WriteLine(result.ModuleRenamed + " " + result.NewModuleName);// Replace the whole sourcerobot.Rws.Rapid.SetModuleText("T_ROB1", "MainModule","MODULE MainModule\r\n PROC main()\r\n ENDPROC\r\nENDMODULE\r\n");}finally{robot.Rws.Mastership.Release(MastershipDomain.Rapid);}robot.Disconnect();}
Rows and columns are counted from 1, not from 0. The controller clamps the end of a range to what the module really holds, so a range running past the last line is not an error.
SetModuleTextRange writes into a range and returns what the controller did with the change.
RapidTextReplaceMode | Where the new text goes |
|---|---|
Replace | The range is replaced by the new text |
Before | The new text is inserted before the range, which stays |
After | The new text is inserted after the range, which stays |
RapidTextQueryMode | When the program pointer would become invalid |
|---|---|
Try | The controller refuses the change |
Force | The controller applies it anyway and drops the program pointer |
Rewriting the line that declares the module renames it. This is why the result carries ModuleRenamed and NewModuleName. Use the new name in the calls that follow, the old one no longer exists.
SearchModuleText reports row and column 0 when it finds nothing, it does not fail. Test Found rather than the row.
SaveModule writes one module as a file of the controller. The controller adds the extension itself, so pass MainModule and not MainModule.mod.
// Gets the file a module came from and the properties declared on it (synchronous)RapidModuleInfo GetModule(string task, string module);// Gets the counter the controller increments whenever a module changes (synchronous) Comparing it with what a previous reading gave is cheaper than fetching the source again to find out that nothing changed.int GetModuleChangeCount(string task, string module);// Gets how many lines and columns the source of a module holds (synchronous) This is what it takes to ask for the whole of it with Int32%2cSystem.Int32).RapidModuleExtension GetModuleExtension(string task, string module);// Gets the declaration the controller finds at a position of a module (synchronous)RapidModuleSymbol GetModuleSymbol(string task, string module, int row, int column);// Gets the source of a module (synchronous)RapidModuleText GetModuleText(string task, string module);// Gets a range of the source of a module (synchronous)string GetModuleTextRange(string task, string module, int startRow, int startColumn, int endRow, int endColumn);// Gets the modules loaded into a task (synchronous)RapidModuleItem[] GetModules(string task);// Gets which of the requested properties may be declared on a module (synchronous)RapidModuleAttribute[] GetPossibleModuleAttributes(string task, string module, params RapidModuleAttribute[] attributes);// Saves a module to the file system of the controller (synchronous)void SaveModule(string task, string module, string name, string path);// Finds where a piece of text sits in the source of a module (synchronous)RapidTextPosition SearchModuleText(string task, string module, string text, int startRow = 1, int startColumn = 1);// Replaces the whole source of a module (synchronous)void SetModuleText(string task, string module, string text);// Writes text into a range of the source of a module (synchronous)RapidSetTextRangeResult SetModuleTextRange(string task, string module, RapidTextReplaceMode replaceMode, RapidTextQueryMode queryMode, int startRow, int startColumn, int endRow, int endColumn, string text);
Every method also exists in an asynchronous version, with the same name followed by Async and an optional CancellationToken.
A module loaded into a task, as listed by RapidService.GetModules(). RapidService.GetModule() returns a RapidModuleInfo, which adds the file the module came from and the attributes declared on it.
| Member | Type | Description |
|---|---|---|
RapidModuleItem() Constructor | Initializes a new instance of the RapidModuleItem class | |
Name Property | string | Name of the module, for example "MainModule" |
Type Property | RapidModuleType | Whether the module belongs to the program or to the system |
ToString() Method | string | Returns a string representation of this module |
Everything the controller reports about one module. Returned by RapidService.GetModule(); the module lists only carry the properties of the RapidModuleItem base class.
| Member | Type | Description |
|---|---|---|
RapidModuleInfo() Constructor | Initializes a new instance of the RapidModuleInfo class | |
AttributeCount Property read only | int | Number of properties declared on the module |
Attributes Property | RapidModuleAttribute[] | Properties declared on the module, empty when it declares none |
FileName Property | string | Name of the file the module was loaded from, for example "MainModule.mod" |
The source of a module and the counters that go with it. Returned by RapidService.GetModuleText().
| Member | Type | Description |
|---|---|---|
RapidModuleText() Constructor | Initializes a new instance of the RapidModuleText class | |
ChangeCount Property | int? | Counter the controller increments whenever the module changes, null when it did not report it |
DeclaredLength Property | int? | Length the controller declares for the module, null when it did not report it. This is the size the controller reserves for the module and not the length of Text, so the two normally differ. |
Text Property | string | Source of the module |
ToString() Method | string | Returns a string representation of this module source |
How big the source of a module is, which is what it takes to ask for the whole of it as a range. Returned by RapidService.GetModuleExtension().
| Member | Type | Description |
|---|---|---|
RapidModuleExtension() Constructor | Initializes a new instance of the RapidModuleExtension class | |
ChangeCount Property | int? | Counter the controller increments whenever the module changes, null when it did not report it |
LineCount Property | int? | Number of lines the module holds, null when the controller did not report it |
MaxColumnCount Property | int? | Length of the longest line of the module, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this extension |
What the controller did with a change written into the source of a module. Returned by RapidService.SetModuleTextRange(). Rewriting the MODULE line renames the module, which is why the controller reports the name it ended up with.
| Member | Type | Description |
|---|---|---|
RapidSetTextRangeResult() Constructor | Initializes a new instance of the RapidSetTextRangeResult class | |
ChangeCount Property | int? | Counter the controller incremented for the change, null when it did not report it |
ModuleRenamed Property | bool | Whether the change renamed the module |
NewModuleName Property | string | Name the module now has, empty when the change did not rename it |
ToString() Method | string | Returns a string representation of this result |
A position in the source of a module, counted from 1. Returned by RapidService.SearchModuleText(), which reports row and column 0 when the text was not found rather than failing.
| Member | Type | Description |
|---|---|---|
RapidTextPosition() Constructor | Initializes a new instance of the RapidTextPosition class | |
Column Property | int | Column of the position, 0 when the search found nothing |
Found Property read only | bool | Whether the position points at something, which it does not when a search found nothing |
Row Property | int | Line of the position, 0 when the search found nothing |
ToString() Method | string | Returns a string representation of this position |
Whether a module belongs to the program or to the system
| Name | Value | Description |
|---|---|---|
ProgramModule | 1 | A module of the program, saved and loaded with it |
SystemModule | 2 | A module of the system, which survives loading another program |
Unknown | 0 | The controller reported a type this library does not know |
A property declared on a module, which restricts what may be done with it
| Name | Value | Description |
|---|---|---|
Encoded | 2 | The source of the module is encoded and cannot be read back |
NoStepIn | 4 | Execution may not step into the routines of the module |
NoView | 3 | The source of the module may not be displayed |
ReadOnly | 6 | The module may not be changed |
SystemModule | 1 | The module belongs to the system rather than to the program |
Unknown | 0 | The controller reported an attribute this library does not know |
ViewOnly | 5 | The source may be displayed but not changed |
Where new text is put relative to the range it is written against
| Name | Value | Description |
|---|---|---|
After | 0 | Insert the new text after the range, leaving it in place |
Before | 1 | Insert the new text before the range, leaving it in place |
Replace | 2 | Replace the range with the new text |
How hard the controller tries to apply a change to the source of a running task
| Name | Value | Description |
|---|---|---|
Force | 0 | Apply the change even when it invalidates the program pointer |
Try | 1 | Apply the change only when the program pointer survives it |
Build errors
Linking a program never fails the request itself. The controller accepts it, then reports what it refused. GetBuildErrors returns one entry per error, with the module, the position and the message.
AbbController robot = new AbbController();robot.Connect("192.168.0.1");// The controller answers at most thirty errors at a time, read the next ones by pagingint start = 0;RapidBuildError[] errors = robot.Rws.Rapid.GetBuildErrors("T_ROB1", start, 30);while (errors.Length > 0){foreach (RapidBuildError error in errors){Console.WriteLine(error.ModuleName + " " + error.Row + "," + error.Column);Console.WriteLine(" " + error.Error);}start += errors.Length;errors = robot.Rws.Rapid.GetBuildErrors("T_ROB1", start, 30);}// An empty answer and a task state of Linked mean the program is runnableConsole.WriteLine(robot.Rws.Rapid.GetTask("T_ROB1").TaskState);robot.Disconnect();}
The controller returns at most thirty errors at a time, whatever larger limit is asked for. Use start and limit to read the rest. An empty array means the program linked cleanly, and the task state then becomes Linked.
BuildTask itself is described in RAPID tasks & program execution.
// Gets the errors the controller found while linking the program of a task (synchronous)RapidBuildError[] GetBuildErrors(string task, int? start = null, int? limit = null);
Every method also exists in an asynchronous version, with the same name followed by Async and an optional CancellationToken.
An error the controller found while linking the program of a task. Returned by RapidService.GetBuildErrors().
| Member | Type | Description |
|---|---|---|
RapidBuildError() Constructor | Initializes a new instance of the RapidBuildError class | |
Column Property | int? | Column the error was found at, null when the controller did not report it |
Error Property | string | Description of the error as the controller worded it |
ErrorNumber Property | int? | Numeric identifier of the error, null when the controller did not report it |
ModuleName Property | string | Name of the module the error was found in |
Row Property | int? | Line the error was found at, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this build error |
Breakpoints
SetBreakpoint places a breakpoint at a position of a module. The controller snaps it to the whole instruction holding that position, so the range it answers is normally wider than what was asked for.
AbbController robot = new AbbController();robot.Connect("192.168.0.1");robot.Rws.Mastership.Request(MastershipDomain.Rapid);try{// The controller snaps the breakpoint to the whole instruction holding the// position, so the range it answers is normally wider than what was asked forRapidBreakpoint placed = robot.Rws.Rapid.SetBreakpoint("T_ROB1", "MainModule", 12, 1);Console.WriteLine(placed.StartRow + "," + placed.StartColumn + " -> " +placed.EndRow + "," + placed.EndColumn);}finally{robot.Rws.Mastership.Release(MastershipDomain.Rapid);}foreach (RapidBreakpoint breakpoint in robot.Rws.Rapid.GetBreakpoints("T_ROB1"))Console.WriteLine(breakpoint.ModuleName + " " + breakpoint.StartRow);// A breakpoint only stops the program when execution was started with stopAtBreakpointrobot.Rws.Rapid.Start(RapidRegainMode.Continue, RapidExecutionMode.Continue,RapidExecutionCycle.Forever, RapidStartCondition.None, true, false);robot.Disconnect();}
A breakpoint only stops the program when execution was started with stopAtBreakpoint set to true, see RAPID tasks & program execution. Editing the source moves the positions, so read the breakpoints again after a change.
// Gets the breakpoints set in the program of a task (synchronous)RapidBreakpoint[] GetBreakpoints(string task, int? start = null, int? limit = null);// Sets a breakpoint at a position of a module (synchronous)RapidBreakpoint SetBreakpoint(string task, string module, int row, int column);
Every method also exists in an asynchronous version, with the same name followed by Async and an optional CancellationToken.
A breakpoint set in the program of a task. Returned by RapidService.GetBreakpoints() and RapidService.SetBreakpoint(). The controller answers a write with the range it actually snapped the breakpoint to, which is the whole instruction containing the requested position rather than the position itself.
| Member | Type | Description |
|---|---|---|
RapidBreakpoint() Constructor | Initializes a new instance of the RapidBreakpoint class | |
EndColumn Property | int? | Column the breakpoint ends at, null when the controller did not report it |
EndRow Property | int? | Line the breakpoint ends at, null when the controller did not report it |
ModuleName Property | string | Name of the module the breakpoint sits in, null when the controller did not report it |
StartColumn Property | int? | Column the breakpoint starts at, null when the controller did not report it |
StartRow Property | int? | Line the breakpoint starts at, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this breakpoint |
Modify a taught position
This is the teaching gesture of the FlexPendant: jog the robot where it should go, then write that position back into the motion instruction of the program.
AbbController robot = new AbbController();robot.Connect("192.168.0.1");// How many motion instructions of this range can be rewrittenRapidModifiablePositions modifiable =robot.Rws.Rapid.GetModifiablePositions("T_ROB1", "MainModule", 1, 1, 40, 1);Console.WriteLine(modifiable.ModifiableLineCount);// Every one of them, in every task of the systemforeach (RapidModifiablePositionItem item in robot.Rws.Rapid.GetAllModifiablePositions())Console.WriteLine(item.TaskName + "/" + item.ModuleName + " line " + item.StartRow);// Jog the robot where it should go, then write that position into the programrobot.Rws.Mastership.Request(MastershipDomain.Rapid);try{robot.Rws.Rapid.ModifyPosition("T_ROB1", "MainModule", 12, 1, 12, 1, true, true, false);}finally{robot.Rws.Mastership.Release(MastershipDomain.Rapid);}robot.Disconnect();}
GetModifiablePositions says how many motion instructions of a range can be rewritten, GetAllModifiablePositions lists every one of them in every task of the system. Read one of the two before writing, so you know what is about to change.
checkLimitsmakes the controller refuse a position outside the working range.checkDeactivatedAxesmakes it refuse to rewrite an axis that is deactivated, andallowDeactivatedrewrites it anyway.ModifyAllPositionsrewrites everything at once. The controller only accepts it from a client it considers local.
Jogging the robot to the position is done with the motion system service, and it needs the Motion mastership, which is a different domain from Rapid.
// Gets every motion instruction of the system whose position can be rewritten to where the robot currently stands, wherever in whichever task it sits (synchronous)RapidModifiablePositionItem[] GetAllModifiablePositions();// Gets how many motion instructions of a range can have their position rewritten to where the robot currently stands (synchronous)RapidModifiablePositions GetModifiablePositions(string task, string module, int startRow, int startColumn, int endRow, int endColumn);// Rewrites the positions of every motion instruction of the system that can be rewritten, to where the robot currently stands (synchronous)void ModifyAllPositions(bool checkLimits = true, bool checkDeactivatedAxes = true);// Rewrites the positions of the motion instructions of a range to where the robot currently stands (synchronous) This is the teaching gesture: jog the robot where it should go, then write that position back into the program.void ModifyPosition(string task, string module, int startRow, int startColumn, int endRow, int endColumn, bool checkLimits = true, bool checkDeactivatedAxes = true, bool allowDeactivated = false);
Every method also exists in an asynchronous version, with the same name followed by Async and an optional CancellationToken.
How many motion instructions of a range can have their position rewritten to where the robot currently stands, and which range they cover. Returned by RapidService.GetModifiablePositions(). The controller leaves the range empty when it found nothing modifiable.
| Member | Type | Description |
|---|---|---|
RapidModifiablePositions() Constructor | Initializes a new instance of the RapidModifiablePositions class | |
EndColumn Property | int? | Column the modifiable range ends at, null when the controller did not report it |
EndRow Property | int? | Line the modifiable range ends at, null when the controller did not report it |
ModifiableLineCount Property | int | Number of motion instructions of the range whose position can be rewritten |
StartColumn Property | int? | Column the modifiable range starts at, null when the controller did not report it |
StartRow Property | int? | Line the modifiable range starts at, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this result |
One motion instruction of the system whose position can be rewritten to where the robot currently stands, wherever in whichever task it sits. Returned by RapidService.GetAllModifiablePositions().
| Member | Type | Description |
|---|---|---|
RapidModifiablePositionItem() Constructor | Initializes a new instance of the RapidModifiablePositionItem class | |
EndColumn Property | int? | Column the instruction ends at, null when the controller did not report it |
EndRow Property | int? | Line the instruction ends at, null when the controller did not report it |
ModuleName Property | string | Name of the module holding the instruction |
StartColumn Property | int? | Column the instruction starts at, null when the controller did not report it |
StartRow Property | int? | Line the instruction starts at, null when the controller did not report it |
TaskName Property | string | Name of the task holding the module |
ToString() Method | string | Returns a string representation of this instruction |
Write an editor
The last group of methods exists for the applications that edit RAPID, not for the ones that drive a robot. They give what an editor needs: what is declared at a position, the arguments of a call, a complete instruction ready to be written, and the palette an operator picks an instruction from.
AbbController robot = new AbbController();robot.Connect("192.168.0.1");// What is declared at this position of the source, null when nothing isRapidModuleSymbol symbol = robot.Rws.Rapid.GetModuleSymbol("T_ROB1", "MainModule", 12, 5);if (symbol != null)Console.WriteLine(symbol.Name + " " + symbol.SymbolType + " " + symbol.DataType);// The routine called at this position, and the arguments of that callRapidRoutineInfo routine = robot.Rws.Rapid.GetRoutine("T_ROB1", "MainModule", 12, 5);Console.WriteLine(routine.Name + " " + routine.ParameterCount);foreach (RapidRoutineArgument argument inrobot.Rws.Rapid.GetRoutineArguments("T_ROB1", "MainModule", 12, 5)){Console.WriteLine(argument.DataType + " at " + argument.StartRow + "," + argument.StartColumn);}// A complete instruction ready to be written, instead of a bare keywordRapidInstructionTemplate template = robot.Rws.Rapid.GetInstructionTemplate("T_ROB1", "MainModule", "MoveJ");foreach (RapidInstructionTemplateArgument argument in template.Arguments)Console.WriteLine(argument.Name + " = " + argument.Value + " (" + argument.DataType + ")");// Where the parts of an object begin and end, given the whole span of that objectRapidObjectChild children = robot.Rws.Rapid.GetObjectChildren("T_ROB1", "MainModule", 1, 1, 40, 1);foreach (RapidObjectChildRange range in children.Ranges)Console.WriteLine(range.Name + ": " + range.Range);// Where one of the lists an object holds sits, without reading the moduleRapidObjectListExtension list = robot.Rws.Rapid.GetObjectListExtension("RAPID/T_ROB1/MainModule", RapidObjectListType.RoutineDeclarations);Console.WriteLine(list.List + " first " + list.First + " last " + list.Last);robot.Disconnect();}
GetModuleSymbol returns the declaration found at a position, null when there is none. GetRoutine and GetRoutineArguments work on a position sitting on a routine call, and the controller refuses the request when it does not.
GetInstructionTemplate returns a complete instruction with the arguments the controller suggests, instead of a bare keyword. GetObjectChildren and GetObjectListExtension give where the parts of an object begin and end, which is how an editor jumps to the declarations of a module without reading the whole source.
AbbController robot = new AbbController();robot.Connect("192.168.0.1");// Categories of the instruction palette, the same ones an editor showsforeach (RapidPalletHeadItem head in robot.Rws.Rapid.GetPalletHeads("T_ROB1")){Console.WriteLine(head.Number + ": " + head.Name);// Instructions of that categoryforeach (RapidPalletItem item in robot.Rws.Rapid.GetPallet("T_ROB1", head.Number.Value))Console.WriteLine(" " + item.Name + " " + item.Instruction);}// Types the controller suggests for one argument of an instructionforeach (RapidPreferredDataTypeItem type inrobot.Rws.Rapid.GetPreferredDataTypes("T_ROB1", "AliasIO", "FromSignal")){Console.WriteLine(type.Name + " (" + type.DataType + ")");}robot.Disconnect();}
GetPalletHeads returns the categories of the instruction palette, GetPallet the instructions of one category, and GetPreferredDataTypes the types that fit one argument of an instruction.
// Gets the template the controller suggests for an instruction or a data type: the arguments to write and the values to write them with (synchronous) This is what an editor uses to insert a complete, valid instruction rather than a bare keyword.RapidInstructionTemplate GetInstructionTemplate(string task, string module, string name, bool isDataType = false, int? row = null, int? column = null, int? parameterNumber = null, int? alternativeNumber = null);// Gets the parts a RAPID object is made of and where each of them sits in the source (synchronous) Pass the whole span of the object to get its parts; an editor uses this to know where the name, the attributes and the declaration lists of a module begin and end.RapidObjectChild GetObjectChildren(string task, string module, int startLine, int startColumn, int endLine, int endColumn);// Gets where one of the lists a RAPID object holds sits in the source: the span of the whole list, and the spans of its first and last elements (synchronous) An editor uses this to jump to the beginning or the end of a list without reading the whole module.RapidObjectListExtension GetObjectListExtension(string symbolUrl, RapidObjectListType type = RapidObjectListType.Statements);// Gets the entries of one category of the instruction palette (synchronous)RapidPalletItem[] GetPallet(string task, int palletNumber, int? start = null, int? limit = null);// Gets the categories of the instruction palette an editor offers (synchronous)RapidPalletHeadItem[] GetPalletHeads(string task, int? start = null, int? limit = null);// Gets the data types the controller suggests for one argument of an instruction (synchronous) An editor uses this to offer only the types that fit where the operator is typing.RapidPreferredDataTypeItem[] GetPreferredDataTypes(string task, string instruction, string parameter);// Gets the routine the controller finds called at a position of a module (synchronous)RapidRoutineInfo GetRoutine(string task, string module, int row, int column);// Gets the arguments of the routine call found at a position of a module (synchronous)RapidRoutineArgument[] GetRoutineArguments(string task, string module, int row, int column, int? mark = null, int? limit = null);
Every method also exists in an asynchronous version, with the same name followed by Async and an optional CancellationToken.
The declaration the controller finds at a given position of a module. Returned by RapidService.GetModuleSymbol(), which returns null when there is no declaration at that position.
| Member | Type | Description |
|---|---|---|
RapidModuleSymbol() Constructor | Initializes a new instance of the RapidModuleSymbol class | |
DataType Property | string | Name of the type of the symbol, for example "robtarget" |
Dimensions Property | int? | Number of array dimensions of the symbol, null when the controller did not report it |
Heap Property | bool? | Whether the symbol is allocated on the heap, null when the controller did not report it |
Linked Property | bool? | Whether the declaration is complete, null when the controller did not report it |
Local Property | bool? | Whether the symbol is local to its module, null when the controller did not report it |
Name Property | string | Name of the declared symbol |
ReferenceCount Property | int? | How many times the symbol is referred to, null when the controller did not report it |
Storage Property | int? | How the controller stores the symbol, null when it did not report it |
SymbolType Property | RapidSymbolType | What kind of symbol was declared |
SymbolUrl Property | string | Path of the symbol, which the symbol resources take |
TypeUrl Property | string | Path of the type of the symbol |
Version Property | string | Version the controller stamps on the declaration |
ToString() Method | string | Returns a string representation of this declaration |
The routine the controller finds called at a given position of a module. Returned by RapidService.GetRoutine(). The controller refuses the request when the position does not sit on a routine call.
| Member | Type | Description |
|---|---|---|
RapidRoutineInfo() Constructor | Initializes a new instance of the RapidRoutineInfo class | |
Local Property | bool? | Whether the routine is local to its module, null when the controller did not report it |
Name Property | string | Name of the routine |
Named Property | bool? | Whether the routine is named, null when the controller did not report it |
ParameterCount Property | int? | Number of parameters the routine takes, null when the controller did not report it. The controller reports -1 when the parameter list is not linked yet. |
SymbolType Property | RapidSymbolType | Whether the routine is a procedure, a function or a trap |
SymbolUrl Property | string | Path of the routine, which the program pointer resources take |
ToString() Method | string | Returns a string representation of this routine |
One argument of the routine call found at a given position of a module, and where it sits in the source. Returned by RapidService.GetRoutineArguments().
| Member | Type | Description |
|---|---|---|
RapidRoutineArgument() Constructor | Initializes a new instance of the RapidRoutineArgument class | |
AlternateArgument Property | int? | Which alternative of the parameter this argument fills, null when the controller did not report it |
DataType Property | string | Type of the argument, for example "num" |
EndColumn Property | int? | Column the argument ends at, null when the controller did not report it |
EndRow Property | int? | Line the argument ends at, null when the controller did not report it |
ListLength Property | int? | Length of the argument list, null when the controller did not report it |
ListNumber Property | int? | Position of the argument in the argument list, null when the controller did not report it |
ObjectType Property | string | What the argument is, for example a required argument or a name reference |
ParameterNumber Property | int? | Position of the argument in the call, counted from 0 |
StartColumn Property | int? | Column the argument starts at, null when the controller did not report it |
StartRow Property | int? | Line the argument starts at, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this argument |
The template the controller suggests for an instruction or a data type: the arguments to write and the values to write them with. Returned by RapidService.GetInstructionTemplate(). An editor uses it to insert a complete, valid instruction rather than a bare keyword.
| Member | Type | Description |
|---|---|---|
RapidInstructionTemplate() Constructor | Initializes a new instance of the RapidInstructionTemplate class | |
ArgumentCount Property | int? | Number of arguments the controller reported, null when it did not report it |
Arguments Property | RapidInstructionTemplateArgument[] | The suggested arguments |
Complete Property | bool? | Whether every argument has been reported, null when the controller did not report it |
Mark Property | int? | Index the controller started reporting from, null when it did not report it |
SelectedParameter Property | int? | Argument the controller suggests selecting first, null when it did not report it |
Version Property | string | Version the controller stamps on the template |
ToString() Method | string | Returns a string representation of this template |
One argument of the template the controller suggests for an instruction or a data type. Carried by RapidInstructionTemplate.
| Member | Type | Description |
|---|---|---|
RapidInstructionTemplateArgument() Constructor | Initializes a new instance of the RapidInstructionTemplateArgument class | |
ArgumentNumber Property | int? | Position of the argument, null when the controller did not report it |
DataType Property | string | Type of the argument, for example "robtarget" |
DeclarationNeeded Property | bool? | Whether inserting the instruction also needs a declaration to be created for this argument, null when the controller did not report it |
Dimensions Property | int? | Number of array dimensions of the argument, null when the controller did not report it |
Local Property | bool? | Whether the suggested symbol is local to its module, null when the controller did not report it |
Name Property | string | Name of the argument, for example "ToPoint" |
ObjectType Property | string | How the suggested symbol is declared, for example "CONST" or "TASK PERS" |
Required Property | bool? | Whether the argument has to be given, null when the controller did not report it |
Symbol Property | string | Name of the symbol the argument refers to, empty when the argument is written as a literal |
Value Property | string | Value the argument is suggested with, written the way RAPID writes it |
ToString() Method | string | Returns a string representation of this argument |
The parts a RAPID object is made of, and where each of them sits in the source. Returned by RapidService.GetObjectChildren(). Which parts the controller reports depends entirely on what the object is: a module answers with its name, its attributes and its declaration lists, a routine with something else. They are therefore returned as a list of named spans rather than as fixed properties.
| Member | Type | Description |
|---|---|---|
RapidObjectChild() Constructor | Initializes a new instance of the RapidObjectChild class | |
ObjectType Property | string | What the object is, for example "module" |
RangeCount Property read only | int | Number of parts the controller reported |
Ranges Property | RapidObjectChildRange[] | The parts of the object, including the ones it does not hold, whose span is then empty |
GetRange(string) Method | RapidTextRange | Returns the span of one part by its name, null when the controller did not report it
|
ToString() Method | string | Returns a string representation of this object |
One named part of a RAPID object, and where it sits in the source. Carried by RapidObjectChild.
| Member | Type | Description |
|---|---|---|
RapidObjectChildRange() Constructor | Initializes a new instance of the RapidObjectChildRange class | |
IsPresent Property read only | bool | Whether the controller reported a real span for the part, which it does not when the object does not hold it |
Name Property | string | Name of the part as the controller worded it, for example "data-decl" or "endmod" |
Range Property | RapidTextRange | Where the part sits in the source |
ToString() Method | string | Returns a string representation of this part |
Where one of the lists of a RAPID object sits in the source: the span of the whole list, and the spans of its first and last elements. Returned by RapidService.GetObjectListExtension(). An editor uses it to jump to the beginning or the end of a list without reading the module. The controller reports an empty span when the object holds no such list.
| Member | Type | Description |
|---|---|---|
RapidObjectListExtension() Constructor | Initializes a new instance of the RapidObjectListExtension class | |
First Property | RapidTextRange | Span of the first element of the list |
Last Property | RapidTextRange | Span of the last element of the list |
List Property | RapidTextRange | Span of the whole list |
ToString() Method | string | Returns a string representation of this extension |
Which of the lists a RAPID object holds is being asked about
| Name | Value | Description |
|---|---|---|
Attributes | 8 | The attributes it declares |
BackwardStatements | 1 | The statements of its BACKWARD handler |
DataDeclarations | 5 | The data declarations it holds |
ErrorStatements | 2 | The statements of its ERROR handler |
ParameterDeclarations | 6 | The parameter declarations it holds |
RoutineDeclarations | 7 | The routine declarations it holds |
Statements | 0 | The statements of the object |
TypeDeclarations | 4 | The type declarations it holds |
UndoStatements | 3 | The statements of its UNDO handler |
One category of the instruction palette the FlexPendant editor offers, for example "Prog.Flow". Returned by RapidService.GetPalletHeads(); its Number is what RapidService.GetPallet() takes.
| Member | Type | Description |
|---|---|---|
RapidPalletHeadItem() Constructor | Initializes a new instance of the RapidPalletHeadItem class | |
Name Property | string | Name of the category, for example "Motion&Proc." |
Number Property | int? | Number identifying the category, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this category |
One entry of an instruction palette category, which an editor offers as something the operator can insert at the cursor. Returned by RapidService.GetPallet().
| Member | Type | Description |
|---|---|---|
RapidPalletItem() Constructor | Initializes a new instance of the RapidPalletItem class | |
Alternative Property | int? | Alternative of the parameter the entry preselects, null when the controller did not report it |
Instruction Property | string | Instruction the entry inserts |
Keyword Property | int? | Whether the entry is a language keyword rather than an instruction, null when the controller did not report it |
Name Property | string | Name shown for the entry, for example "MoveJ" |
Parameter Property | int? | Parameter the entry preselects, null when the controller did not report it |
ToString() Method | string | Returns a string representation of this entry |
A data type the controller suggests for one argument of an instruction, so that an editor can offer the operator the types that fit where the cursor stands. Returned by RapidService.GetPreferredDataTypes().
| Member | Type | Description |
|---|---|---|
RapidPreferredDataTypeItem() Constructor | Initializes a new instance of the RapidPreferredDataTypeItem class | |
DataType Property | string | Data type of the suggestion |
Name Property | string | Name of the suggestion, for example "signaldi" |
ToString() Method | string | Returns a string representation of this suggestion |
What is not on this page
The values the modules declare are read and written from RAPID variables & symbols. Starting the program, moving the program pointer and loading one module are on RAPID tasks & program execution. Uploading a module file to the controller, and downloading a saved one, are on File system.
Try it in the demo application
The RAPID (RWS) page of the demo application exercises these calls against a live controller, without writing any code. It is shown in RAPID tasks & program execution.