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.
// 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);
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.
public class RapidProgramInfo {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidProgramInfo" data-throw-if-not-resolved="false"></xref> classpublic RapidProgramInfo()// Routine the program pointer moves to when it is reset, null when the controller did not report itpublic string EntryPoint { get; set; }// Name of the program, null when the controller did not report itpublic string Name { get; set; }// Returns a string representation of this programpublic override string ToString()}
public enum RapidProgramLoadMode {// Keep the modules already loaded and add the ones of the programAdd = 0// Replace everything the task holds with the programReplace = 1}
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.
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");
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
// 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);}
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.
public class RapidModuleItem {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidModuleItem" data-throw-if-not-resolved="false"></xref> classpublic RapidModuleItem()// Name of the module, for example "MainModule"public string Name { get; set; }// Returns a string representation of this modulepublic override string ToString()// Whether the module belongs to the program or to the systempublic RapidModuleType Type { get; set; }}
public class RapidModuleInfo : RapidModuleItem {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidModuleInfo" data-throw-if-not-resolved="false"></xref> classpublic RapidModuleInfo()// Number of properties declared on the modulepublic int AttributeCount { get; }// Properties declared on the module, empty when it declares nonepublic RapidModuleAttribute[] Attributes { get; set; }// Name of the file the module was loaded from, for example "MainModule.mod"public string FileName { get; set; }}
public class RapidModuleText {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidModuleText" data-throw-if-not-resolved="false"></xref> classpublic RapidModuleText()// Counter the controller increments whenever the module changes, null when it did not report itpublic int? ChangeCount { get; set; }// Length the controller declares for the module, null when it did not report it.//// <p>This is the size the controller reserves for the module and not the length of// <xref href="UnderAutomation.ABB.Rws.Data.RapidModuleText.Text" data-throw-if-not-resolved="false"></xref>, so the two normally differ.</p>public int? DeclaredLength { get; set; }// Source of the modulepublic string Text { get; set; }// Returns a string representation of this module sourcepublic override string ToString()}
public class RapidModuleExtension {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidModuleExtension" data-throw-if-not-resolved="false"></xref> classpublic RapidModuleExtension()// Counter the controller increments whenever the module changes, null when it did not report itpublic int? ChangeCount { get; set; }// Number of lines the module holds, null when the controller did not report itpublic int? LineCount { get; set; }// Length of the longest line of the module, null when the controller did not report itpublic int? MaxColumnCount { get; set; }// Returns a string representation of this extensionpublic override string ToString()}
public class RapidSetTextRangeResult {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidSetTextRangeResult" data-throw-if-not-resolved="false"></xref> classpublic RapidSetTextRangeResult()// Counter the controller incremented for the change, null when it did not report itpublic int? ChangeCount { get; set; }// Whether the change renamed the modulepublic bool ModuleRenamed { get; set; }// Name the module now has, empty when the change did not rename itpublic string NewModuleName { get; set; }// Returns a string representation of this resultpublic override string ToString()}
public class RapidTextPosition {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidTextPosition" data-throw-if-not-resolved="false"></xref> classpublic RapidTextPosition()// Column of the position, 0 when the search found nothingpublic int Column { get; set; }// Whether the position points at something, which it does not when a search found nothingpublic bool Found { get; }// Line of the position, 0 when the search found nothingpublic int Row { get; set; }// Returns a string representation of this positionpublic override string ToString()}
public enum RapidModuleType {// A module of the program, saved and loaded with itProgramModule = 1// A module of the system, which survives loading another programSystemModule = 2// The controller reported a type this library does not knowUnknown = 0}
public enum RapidModuleAttribute {// The source of the module is encoded and cannot be read backEncoded = 2// Execution may not step into the routines of the moduleNoStepIn = 4// The source of the module may not be displayedNoView = 3// The module may not be changedReadOnly = 6// The module belongs to the system rather than to the programSystemModule = 1// The controller reported an attribute this library does not knowUnknown = 0// The source may be displayed but not changedViewOnly = 5}
public enum RapidTextReplaceMode {// Insert the new text after the range, leaving it in placeAfter = 0// Insert the new text before the range, leaving it in placeBefore = 1// Replace the range with the new textReplace = 2}
public enum RapidTextQueryMode {// Apply the change even when it invalidates the program pointerForce = 0// Apply the change only when the program pointer survives itTry = 1}
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.
// 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);
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.
public class RapidBuildError {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidBuildError" data-throw-if-not-resolved="false"></xref> classpublic RapidBuildError()// Column the error was found at, null when the controller did not report itpublic int? Column { get; set; }// Description of the error as the controller worded itpublic string Error { get; set; }// Numeric identifier of the error, null when the controller did not report itpublic int? ErrorNumber { get; set; }// Name of the module the error was found inpublic string ModuleName { get; set; }// Line the error was found at, null when the controller did not report itpublic int? Row { get; set; }// Returns a string representation of this build errorpublic override string ToString()}
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.
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);
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.
public class RapidBreakpoint {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidBreakpoint" data-throw-if-not-resolved="false"></xref> classpublic RapidBreakpoint()// Column the breakpoint ends at, null when the controller did not report itpublic int? EndColumn { get; set; }// Line the breakpoint ends at, null when the controller did not report itpublic int? EndRow { get; set; }// Name of the module the breakpoint sits in, null when the controller did not report itpublic string ModuleName { get; set; }// Column the breakpoint starts at, null when the controller did not report itpublic int? StartColumn { get; set; }// Line the breakpoint starts at, null when the controller did not report itpublic int? StartRow { get; set; }// Returns a string representation of this breakpointpublic override string ToString()}
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.
// 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);}
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.
public class RapidModifiablePositions {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidModifiablePositions" data-throw-if-not-resolved="false"></xref> classpublic RapidModifiablePositions()// Column the modifiable range ends at, null when the controller did not report itpublic int? EndColumn { get; set; }// Line the modifiable range ends at, null when the controller did not report itpublic int? EndRow { get; set; }// Number of motion instructions of the range whose position can be rewrittenpublic int ModifiableLineCount { get; set; }// Column the modifiable range starts at, null when the controller did not report itpublic int? StartColumn { get; set; }// Line the modifiable range starts at, null when the controller did not report itpublic int? StartRow { get; set; }// Returns a string representation of this resultpublic override string ToString()}
public class RapidModifiablePositionItem {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidModifiablePositionItem" data-throw-if-not-resolved="false"></xref> classpublic RapidModifiablePositionItem()// Column the instruction ends at, null when the controller did not report itpublic int? EndColumn { get; set; }// Line the instruction ends at, null when the controller did not report itpublic int? EndRow { get; set; }// Name of the module holding the instructionpublic string ModuleName { get; set; }// Column the instruction starts at, null when the controller did not report itpublic int? StartColumn { get; set; }// Line the instruction starts at, null when the controller did not report itpublic int? StartRow { get; set; }// Name of the task holding the modulepublic string TaskName { get; set; }// Returns a string representation of this instructionpublic override string ToString()}
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.
// 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);
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.
// 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 + ")");}
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.
public class RapidModuleSymbol {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidModuleSymbol" data-throw-if-not-resolved="false"></xref> classpublic RapidModuleSymbol()// Name of the type of the symbol, for example "robtarget"public string DataType { get; set; }// Number of array dimensions of the symbol, null when the controller did not report itpublic int? Dimensions { get; set; }// Whether the symbol is allocated on the heap, null when the controller did not report itpublic bool? Heap { get; set; }// Whether the declaration is complete, null when the controller did not report itpublic bool? Linked { get; set; }// Whether the symbol is local to its module, null when the controller did not report itpublic bool? Local { get; set; }// Name of the declared symbolpublic string Name { get; set; }// How many times the symbol is referred to, null when the controller did not report itpublic int? ReferenceCount { get; set; }// How the controller stores the symbol, null when it did not report itpublic int? Storage { get; set; }// What kind of symbol was declaredpublic RapidSymbolType SymbolType { get; set; }// Path of the symbol, which the symbol resources takepublic string SymbolUrl { get; set; }// Returns a string representation of this declarationpublic override string ToString()// Path of the type of the symbolpublic string TypeUrl { get; set; }// Version the controller stamps on the declarationpublic string Version { get; set; }}
public class RapidRoutineInfo {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidRoutineInfo" data-throw-if-not-resolved="false"></xref> classpublic RapidRoutineInfo()// Whether the routine is local to its module, null when the controller did not report itpublic bool? Local { get; set; }// Name of the routinepublic string Name { get; set; }// Whether the routine is named, null when the controller did not report itpublic bool? Named { get; set; }// Number of parameters the routine takes, null when the controller did not report it.//// <p>The controller reports -1 when the parameter list is not linked yet.</p>public int? ParameterCount { get; set; }// Whether the routine is a procedure, a function or a trappublic RapidSymbolType SymbolType { get; set; }// Path of the routine, which the program pointer resources takepublic string SymbolUrl { get; set; }// Returns a string representation of this routinepublic override string ToString()}
public class RapidRoutineArgument {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidRoutineArgument" data-throw-if-not-resolved="false"></xref> classpublic RapidRoutineArgument()// Which alternative of the parameter this argument fills, null when the controller did not report itpublic int? AlternateArgument { get; set; }// Type of the argument, for example "num"public string DataType { get; set; }// Column the argument ends at, null when the controller did not report itpublic int? EndColumn { get; set; }// Line the argument ends at, null when the controller did not report itpublic int? EndRow { get; set; }// Length of the argument list, null when the controller did not report itpublic int? ListLength { get; set; }// Position of the argument in the argument list, null when the controller did not report itpublic int? ListNumber { get; set; }// What the argument is, for example a required argument or a name referencepublic string ObjectType { get; set; }// Position of the argument in the call, counted from 0public int? ParameterNumber { get; set; }// Column the argument starts at, null when the controller did not report itpublic int? StartColumn { get; set; }// Line the argument starts at, null when the controller did not report itpublic int? StartRow { get; set; }// Returns a string representation of this argumentpublic override string ToString()}
public class RapidInstructionTemplate {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidInstructionTemplate" data-throw-if-not-resolved="false"></xref> classpublic RapidInstructionTemplate()// Number of arguments the controller reported, null when it did not report itpublic int? ArgumentCount { get; set; }// The suggested argumentspublic RapidInstructionTemplateArgument[] Arguments { get; set; }// Whether every argument has been reported, null when the controller did not report itpublic bool? Complete { get; set; }// Index the controller started reporting from, null when it did not report itpublic int? Mark { get; set; }// Argument the controller suggests selecting first, null when it did not report itpublic int? SelectedParameter { get; set; }// Returns a string representation of this templatepublic override string ToString()// Version the controller stamps on the templatepublic string Version { get; set; }}
public class RapidInstructionTemplateArgument {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidInstructionTemplateArgument" data-throw-if-not-resolved="false"></xref> classpublic RapidInstructionTemplateArgument()// Position of the argument, null when the controller did not report itpublic int? ArgumentNumber { get; set; }// Type of the argument, for example "robtarget"public string DataType { get; set; }// Whether inserting the instruction also needs a declaration to be created for this argument,// null when the controller did not report itpublic bool? DeclarationNeeded { get; set; }// Number of array dimensions of the argument, null when the controller did not report itpublic int? Dimensions { get; set; }// Whether the suggested symbol is local to its module, null when the controller did not report itpublic bool? Local { get; set; }// Name of the argument, for example "ToPoint"public string Name { get; set; }// How the suggested symbol is declared, for example "CONST" or "TASK PERS"public string ObjectType { get; set; }// Whether the argument has to be given, null when the controller did not report itpublic bool? Required { get; set; }// Name of the symbol the argument refers to, empty when the argument is written as a literalpublic string Symbol { get; set; }// Returns a string representation of this argumentpublic override string ToString()// Value the argument is suggested with, written the way RAPID writes itpublic string Value { get; set; }}
public class RapidObjectChild {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidObjectChild" data-throw-if-not-resolved="false"></xref> classpublic RapidObjectChild()// Returns the span of one part by its name, null when the controller did not report itpublic RapidTextRange GetRange(string name)// What the object is, for example "module"public string ObjectType { get; set; }// Number of parts the controller reportedpublic int RangeCount { get; }// The parts of the object, including the ones it does not hold, whose span is then emptypublic RapidObjectChildRange[] Ranges { get; set; }// Returns a string representation of this objectpublic override string ToString()}
public class RapidObjectChildRange {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidObjectChildRange" data-throw-if-not-resolved="false"></xref> classpublic RapidObjectChildRange()// Whether the controller reported a real span for the part, which it does not when the object// does not hold itpublic bool IsPresent { get; }// Name of the part as the controller worded it, for example "data-decl" or "endmod"public string Name { get; set; }// Where the part sits in the sourcepublic RapidTextRange Range { get; set; }// Returns a string representation of this partpublic override string ToString()}
public class RapidObjectListExtension {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidObjectListExtension" data-throw-if-not-resolved="false"></xref> classpublic RapidObjectListExtension()// Span of the first element of the listpublic RapidTextRange First { get; set; }// Span of the last element of the listpublic RapidTextRange Last { get; set; }// Span of the whole listpublic RapidTextRange List { get; set; }// Returns a string representation of this extensionpublic override string ToString()}
public enum RapidObjectListType {// The attributes it declaresAttributes = 8// The statements of its BACKWARD handlerBackwardStatements = 1// The data declarations it holdsDataDeclarations = 5// The statements of its ERROR handlerErrorStatements = 2// The parameter declarations it holdsParameterDeclarations = 6// The routine declarations it holdsRoutineDeclarations = 7// The statements of the objectStatements = 0// The type declarations it holdsTypeDeclarations = 4// The statements of its UNDO handlerUndoStatements = 3}
public class RapidPalletHeadItem {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidPalletHeadItem" data-throw-if-not-resolved="false"></xref> classpublic RapidPalletHeadItem()// Name of the category, for example "Motion&Proc."public string Name { get; set; }// Number identifying the category, null when the controller did not report itpublic int? Number { get; set; }// Returns a string representation of this categorypublic override string ToString()}
public class RapidPalletItem {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidPalletItem" data-throw-if-not-resolved="false"></xref> classpublic RapidPalletItem()// Alternative of the parameter the entry preselects, null when the controller did not report itpublic int? Alternative { get; set; }// Instruction the entry insertspublic string Instruction { get; set; }// Whether the entry is a language keyword rather than an instruction, null when the controller// did not report itpublic int? Keyword { get; set; }// Name shown for the entry, for example "MoveJ"public string Name { get; set; }// Parameter the entry preselects, null when the controller did not report itpublic int? Parameter { get; set; }// Returns a string representation of this entrypublic override string ToString()}
public class RapidPreferredDataTypeItem {// Initializes a new instance of the <xref href="UnderAutomation.ABB.Rws.Data.RapidPreferredDataTypeItem" data-throw-if-not-resolved="false"></xref> classpublic RapidPreferredDataTypeItem()// Data type of the suggestionpublic string DataType { get; set; }// Name of the suggestion, for example "signaldi"public string Name { get; set; }// Returns a string representation of this suggestionpublic override string ToString()}
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.